• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/ISurfaceComposerClient.h>
31 
32 namespace android {
33 
34 // ---------------------------------------------------------------------------
35 
36 class IGraphicBufferProducer;
37 class Surface;
38 class SurfaceComposerClient;
39 
40 // ---------------------------------------------------------------------------
41 
42 class SurfaceControl : public RefBase
43 {
44 public:
isValid(const sp<SurfaceControl> & surface)45     static bool isValid(const sp<SurfaceControl>& surface) {
46         return (surface != 0) && surface->isValid();
47     }
48 
isValid()49     bool isValid() {
50         return mHandle!=0 && mClient!=0;
51     }
52 
53     static bool isSameSurface(
54             const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs);
55 
56     // release surface data from java
57     void        clear();
58 
59     status_t    setLayerStack(int32_t layerStack);
60     status_t    setLayer(int32_t layer);
61     status_t    setPosition(float x, float y);
62     status_t    setSize(uint32_t w, uint32_t h);
63     status_t    hide();
64     status_t    show();
65     status_t    setFlags(uint32_t flags, uint32_t mask);
66     status_t    setTransparentRegionHint(const Region& transparent);
67     status_t    setAlpha(float alpha=1.0f);
68     status_t    setMatrix(float dsdx, float dtdx, float dsdy, float dtdy);
69     status_t    setCrop(const Rect& crop);
70 
71     static status_t writeSurfaceToParcel(
72             const sp<SurfaceControl>& control, Parcel* parcel);
73 
74     sp<Surface> getSurface() const;
75 
76 private:
77     // can't be copied
78     SurfaceControl& operator = (SurfaceControl& rhs);
79     SurfaceControl(const SurfaceControl& rhs);
80 
81     friend class SurfaceComposerClient;
82     friend class Surface;
83 
84     SurfaceControl(
85             const sp<SurfaceComposerClient>& client,
86             const sp<IBinder>& handle,
87             const sp<IGraphicBufferProducer>& gbp);
88 
89     ~SurfaceControl();
90 
91     status_t validate() const;
92     void destroy();
93 
94     sp<SurfaceComposerClient>   mClient;
95     sp<IBinder>                 mHandle;
96     sp<IGraphicBufferProducer>  mGraphicBufferProducer;
97     mutable Mutex               mLock;
98     mutable sp<Surface>         mSurfaceData;
99 };
100 
101 }; // namespace android
102 
103 #endif // ANDROID_GUI_SURFACE_CONTROL_H
104