SurfaceControl.h revision bbb57f3331c7182399ed82e9c4f93a965677dde3
1/* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef ANDROID_GUI_SURFACE_CONTROL_H 18#define ANDROID_GUI_SURFACE_CONTROL_H 19 20#include <stdint.h> 21#include <sys/types.h> 22 23#include <utils/KeyedVector.h> 24#include <utils/RefBase.h> 25#include <utils/threads.h> 26 27#include <ui/PixelFormat.h> 28#include <ui/Region.h> 29 30#include <gui/ISurface.h> 31#include <gui/ISurfaceComposerClient.h> 32 33namespace android { 34 35// --------------------------------------------------------------------------- 36 37class IGraphicBufferProducer; 38class Surface; 39class SurfaceComposerClient; 40 41// --------------------------------------------------------------------------- 42 43class SurfaceControl : public RefBase 44{ 45public: 46 static bool isValid(const sp<SurfaceControl>& surface) { 47 return (surface != 0) && surface->isValid(); 48 } 49 bool isValid() { 50 return mSurface!=0 && mClient!=0; 51 } 52 static bool isSameSurface( 53 const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs); 54 55 // release surface data from java 56 void clear(); 57 58 status_t setLayerStack(int32_t layerStack); 59 status_t setLayer(int32_t layer); 60 status_t setPosition(int32_t x, int32_t y); 61 status_t setSize(uint32_t w, uint32_t h); 62 status_t hide(); 63 status_t show(); 64 status_t setFlags(uint32_t flags, uint32_t mask); 65 status_t setTransparentRegionHint(const Region& transparent); 66 status_t setAlpha(float alpha=1.0f); 67 status_t setMatrix(float dsdx, float dtdx, float dsdy, float dtdy); 68 status_t setCrop(const Rect& crop); 69 70 static status_t writeSurfaceToParcel( 71 const sp<SurfaceControl>& control, Parcel* parcel); 72 73 sp<Surface> getSurface() const; 74 75private: 76 // can't be copied 77 SurfaceControl& operator = (SurfaceControl& rhs); 78 SurfaceControl(const SurfaceControl& rhs); 79 80 friend class SurfaceComposerClient; 81 friend class Surface; 82 83 SurfaceControl( 84 const sp<SurfaceComposerClient>& client, 85 const sp<ISurface>& surface); 86 87 ~SurfaceControl(); 88 89 status_t validate() const; 90 void destroy(); 91 92 sp<SurfaceComposerClient> mClient; 93 sp<IBinder> mSurface; 94 sp<IGraphicBufferProducer> mGraphicBufferProducer; 95 mutable Mutex mLock; 96 mutable sp<Surface> mSurfaceData; 97}; 98 99}; // namespace android 100 101#endif // ANDROID_GUI_SURFACE_CONTROL_H 102