blob: fe8eb6f19713159b5420b9a7ed77f1d63389c81e [file] [log] [blame]
Mathias Agopiane3c697f2013-02-14 17:11:02 -08001/*
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
Mathias Agopiane3c697f2013-02-14 17:11:02 -080030#include <gui/ISurfaceComposerClient.h>
31
32namespace android {
33
34// ---------------------------------------------------------------------------
35
36class IGraphicBufferProducer;
37class Surface;
38class SurfaceComposerClient;
39
40// ---------------------------------------------------------------------------
41
42class SurfaceControl : public RefBase
43{
44public:
45 static bool isValid(const sp<SurfaceControl>& surface) {
46 return (surface != 0) && surface->isValid();
47 }
Mathias Agopian4d9b8222013-03-12 17:11:48 -070048
Mathias Agopiane3c697f2013-02-14 17:11:02 -080049 bool isValid() {
Mathias Agopian4d9b8222013-03-12 17:11:48 -070050 return mHandle!=0 && mClient!=0;
Mathias Agopiane3c697f2013-02-14 17:11:02 -080051 }
Mathias Agopian4d9b8222013-03-12 17:11:48 -070052
Mathias Agopiane3c697f2013-02-14 17:11:02 -080053 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);
Dave Burkebbb57f32013-03-01 20:39:03 +000061 status_t setPosition(int32_t x, int32_t y);
Mathias Agopiane3c697f2013-02-14 17:11:02 -080062 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
76private:
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,
Mathias Agopian4d9b8222013-03-12 17:11:48 -070086 const sp<IBinder>& handle,
87 const sp<IGraphicBufferProducer>& gbp);
Mathias Agopiane3c697f2013-02-14 17:11:02 -080088
89 ~SurfaceControl();
90
91 status_t validate() const;
92 void destroy();
93
94 sp<SurfaceComposerClient> mClient;
Mathias Agopian4d9b8222013-03-12 17:11:48 -070095 sp<IBinder> mHandle;
Mathias Agopiane3c697f2013-02-14 17:11:02 -080096 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