blob: 6e13207a830ed967f9f236b09f0767800826ce75 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -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#define LOG_TAG "SurfaceComposerClient"
18
19#include <stdint.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080020#include <sys/types.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080021
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080022#include <utils/Errors.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080023#include <utils/Log.h>
Mathias Agopiand4784a32010-05-27 19:41:15 -070024#include <utils/Singleton.h>
Mathias Agopiana67932f2011-04-20 14:20:59 -070025#include <utils/SortedVector.h>
26#include <utils/String8.h>
27#include <utils/threads.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080028
Mathias Agopian9cce3252010-02-09 17:46:37 -080029#include <binder/IMemory.h>
Mathias Agopiana67932f2011-04-20 14:20:59 -070030#include <binder/IServiceManager.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080031
Mathias Agopian076b1cc2009-04-10 14:24:30 -070032#include <ui/DisplayInfo.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080033
Mathias Agopianabe815d2013-03-19 22:22:21 -070034#include <gui/CpuConsumer.h>
Mathias Agopiane3c697f2013-02-14 17:11:02 -080035#include <gui/IGraphicBufferProducer.h>
Mathias Agopian90ac7992012-02-25 18:48:35 -080036#include <gui/ISurfaceComposer.h>
37#include <gui/ISurfaceComposerClient.h>
38#include <gui/SurfaceComposerClient.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080039
Mathias Agopian41f673c2011-11-17 17:48:35 -080040#include <private/gui/ComposerService.h>
Mathias Agopian90ac7992012-02-25 18:48:35 -080041#include <private/gui/LayerState.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080042
43namespace android {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080044// ---------------------------------------------------------------------------
45
Mathias Agopian7e27f052010-05-28 14:22:23 -070046ANDROID_SINGLETON_STATIC_INSTANCE(ComposerService);
47
Mathias Agopianb7e930d2010-06-01 15:12:58 -070048ComposerService::ComposerService()
49: Singleton<ComposerService>() {
Andy McFadden6652b3e2012-09-06 18:45:56 -070050 Mutex::Autolock _l(mLock);
51 connectLocked();
52}
53
54void ComposerService::connectLocked() {
Mathias Agopianb7e930d2010-06-01 15:12:58 -070055 const String16 name("SurfaceFlinger");
56 while (getService(name, &mComposerService) != NO_ERROR) {
57 usleep(250000);
58 }
Andy McFadden6652b3e2012-09-06 18:45:56 -070059 assert(mComposerService != NULL);
60
61 // Create the death listener.
62 class DeathObserver : public IBinder::DeathRecipient {
63 ComposerService& mComposerService;
64 virtual void binderDied(const wp<IBinder>& who) {
65 ALOGW("ComposerService remote (surfaceflinger) died [%p]",
66 who.unsafe_get());
67 mComposerService.composerServiceDied();
68 }
69 public:
70 DeathObserver(ComposerService& mgr) : mComposerService(mgr) { }
71 };
72
73 mDeathObserver = new DeathObserver(*const_cast<ComposerService*>(this));
74 mComposerService->asBinder()->linkToDeath(mDeathObserver);
Mathias Agopianb7e930d2010-06-01 15:12:58 -070075}
76
Andy McFadden6652b3e2012-09-06 18:45:56 -070077/*static*/ sp<ISurfaceComposer> ComposerService::getComposerService() {
78 ComposerService& instance = ComposerService::getInstance();
79 Mutex::Autolock _l(instance.mLock);
80 if (instance.mComposerService == NULL) {
81 ComposerService::getInstance().connectLocked();
82 assert(instance.mComposerService != NULL);
83 ALOGD("ComposerService reconnected");
84 }
85 return instance.mComposerService;
86}
87
88void ComposerService::composerServiceDied()
89{
90 Mutex::Autolock _l(mLock);
91 mComposerService = NULL;
92 mDeathObserver = NULL;
Mathias Agopianb7e930d2010-06-01 15:12:58 -070093}
94
Mathias Agopian7e27f052010-05-28 14:22:23 -070095// ---------------------------------------------------------------------------
96
Mathias Agopian698c0872011-06-28 19:09:31 -070097static inline
Mathias Agopiane57f2922012-08-09 16:29:12 -070098int compare_type(const ComposerState& lhs, const ComposerState& rhs) {
Mathias Agopian698c0872011-06-28 19:09:31 -070099 if (lhs.client < rhs.client) return -1;
100 if (lhs.client > rhs.client) return 1;
101 if (lhs.state.surface < rhs.state.surface) return -1;
102 if (lhs.state.surface > rhs.state.surface) return 1;
103 return 0;
104}
105
Mathias Agopiane57f2922012-08-09 16:29:12 -0700106static inline
107int compare_type(const DisplayState& lhs, const DisplayState& rhs) {
108 return compare_type(lhs.token, rhs.token);
109}
110
Mathias Agopian7e27f052010-05-28 14:22:23 -0700111class Composer : public Singleton<Composer>
112{
Mathias Agopiand4784a32010-05-27 19:41:15 -0700113 friend class Singleton<Composer>;
114
Mathias Agopian698c0872011-06-28 19:09:31 -0700115 mutable Mutex mLock;
Mathias Agopiane57f2922012-08-09 16:29:12 -0700116 SortedVector<ComposerState> mComposerStates;
117 SortedVector<DisplayState > mDisplayStates;
Jamie Gennis28378392011-10-12 17:39:00 -0700118 uint32_t mForceSynchronous;
Jeff Brownf3f7db62012-08-31 02:18:38 -0700119 uint32_t mTransactionNestCount;
Jamie Gennis2d5e2302012-10-15 18:24:43 -0700120 bool mAnimation;
Mathias Agopian698c0872011-06-28 19:09:31 -0700121
Jamie Gennisb8d69a52011-10-10 15:48:06 -0700122 Composer() : Singleton<Composer>(),
Jeff Brownf3f7db62012-08-31 02:18:38 -0700123 mForceSynchronous(0), mTransactionNestCount(0),
Jamie Gennis2d5e2302012-10-15 18:24:43 -0700124 mAnimation(false)
Jamie Gennis28378392011-10-12 17:39:00 -0700125 { }
Mathias Agopian698c0872011-06-28 19:09:31 -0700126
Jeff Brownf3f7db62012-08-31 02:18:38 -0700127 void openGlobalTransactionImpl();
Jamie Gennis28378392011-10-12 17:39:00 -0700128 void closeGlobalTransactionImpl(bool synchronous);
Jamie Gennis2d5e2302012-10-15 18:24:43 -0700129 void setAnimationTransactionImpl();
Mathias Agopian698c0872011-06-28 19:09:31 -0700130
131 layer_state_t* getLayerStateLocked(
Mathias Agopianac9fa422013-02-11 16:40:36 -0800132 const sp<SurfaceComposerClient>& client, const sp<IBinder>& id);
Mathias Agopian698c0872011-06-28 19:09:31 -0700133
Mathias Agopiane57f2922012-08-09 16:29:12 -0700134 DisplayState& getDisplayStateLocked(const sp<IBinder>& token);
135
Mathias Agopiand4784a32010-05-27 19:41:15 -0700136public:
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700137 sp<IBinder> createDisplay(const String8& displayName, bool secure);
Jesse Hall6c913be2013-08-08 12:15:49 -0700138 void destroyDisplay(const sp<IBinder>& display);
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700139 sp<IBinder> getBuiltInDisplay(int32_t id);
Mathias Agopian698c0872011-06-28 19:09:31 -0700140
Mathias Agopianac9fa422013-02-11 16:40:36 -0800141 status_t setPosition(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
Mathias Agopian41b6aab2011-08-30 18:51:54 -0700142 float x, float y);
Mathias Agopianac9fa422013-02-11 16:40:36 -0800143 status_t setSize(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
Mathias Agopian698c0872011-06-28 19:09:31 -0700144 uint32_t w, uint32_t h);
Mathias Agopianac9fa422013-02-11 16:40:36 -0800145 status_t setLayer(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
Mathias Agopian698c0872011-06-28 19:09:31 -0700146 int32_t z);
Mathias Agopianac9fa422013-02-11 16:40:36 -0800147 status_t setFlags(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
Mathias Agopian698c0872011-06-28 19:09:31 -0700148 uint32_t flags, uint32_t mask);
149 status_t setTransparentRegionHint(
Mathias Agopianac9fa422013-02-11 16:40:36 -0800150 const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
Mathias Agopian698c0872011-06-28 19:09:31 -0700151 const Region& transparentRegion);
Mathias Agopianac9fa422013-02-11 16:40:36 -0800152 status_t setAlpha(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
Mathias Agopian698c0872011-06-28 19:09:31 -0700153 float alpha);
Mathias Agopianac9fa422013-02-11 16:40:36 -0800154 status_t setMatrix(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
Mathias Agopian698c0872011-06-28 19:09:31 -0700155 float dsdx, float dtdx, float dsdy, float dtdy);
Jamie Gennisb8d69a52011-10-10 15:48:06 -0700156 status_t setOrientation(int orientation);
Mathias Agopianac9fa422013-02-11 16:40:36 -0800157 status_t setCrop(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
Jamie Gennisf15a83f2012-05-10 20:43:55 -0700158 const Rect& crop);
Mathias Agopian87855782012-07-24 21:41:09 -0700159 status_t setLayerStack(const sp<SurfaceComposerClient>& client,
Mathias Agopianac9fa422013-02-11 16:40:36 -0800160 const sp<IBinder>& id, uint32_t layerStack);
Mathias Agopian698c0872011-06-28 19:09:31 -0700161
Andy McFadden2adaf042012-12-18 09:49:45 -0800162 void setDisplaySurface(const sp<IBinder>& token,
163 const sp<IGraphicBufferProducer>& bufferProducer);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700164 void setDisplayLayerStack(const sp<IBinder>& token, uint32_t layerStack);
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700165 void setDisplayProjection(const sp<IBinder>& token,
166 uint32_t orientation,
167 const Rect& layerStackRect,
168 const Rect& displayRect);
Michael Wright1f6078a2014-06-26 16:01:02 -0700169 void setDisplaySize(const sp<IBinder>& token, uint32_t width, uint32_t height);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700170
Jamie Gennis2d5e2302012-10-15 18:24:43 -0700171 static void setAnimationTransaction() {
172 Composer::getInstance().setAnimationTransactionImpl();
173 }
174
Jeff Brownf3f7db62012-08-31 02:18:38 -0700175 static void openGlobalTransaction() {
176 Composer::getInstance().openGlobalTransactionImpl();
177 }
178
Jamie Gennis28378392011-10-12 17:39:00 -0700179 static void closeGlobalTransaction(bool synchronous) {
180 Composer::getInstance().closeGlobalTransactionImpl(synchronous);
Mathias Agopiand4784a32010-05-27 19:41:15 -0700181 }
182};
183
184ANDROID_SINGLETON_STATIC_INSTANCE(Composer);
185
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800186// ---------------------------------------------------------------------------
187
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700188sp<IBinder> Composer::createDisplay(const String8& displayName, bool secure) {
189 return ComposerService::getComposerService()->createDisplay(displayName,
190 secure);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700191}
192
Jesse Hall6c913be2013-08-08 12:15:49 -0700193void Composer::destroyDisplay(const sp<IBinder>& display) {
194 return ComposerService::getComposerService()->destroyDisplay(display);
195}
196
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700197sp<IBinder> Composer::getBuiltInDisplay(int32_t id) {
198 return ComposerService::getComposerService()->getBuiltInDisplay(id);
199}
200
Jeff Brownf3f7db62012-08-31 02:18:38 -0700201void Composer::openGlobalTransactionImpl() {
202 { // scope for the lock
203 Mutex::Autolock _l(mLock);
204 mTransactionNestCount += 1;
205 }
206}
207
Jamie Gennis28378392011-10-12 17:39:00 -0700208void Composer::closeGlobalTransactionImpl(bool synchronous) {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700209 sp<ISurfaceComposer> sm(ComposerService::getComposerService());
Mathias Agopian698c0872011-06-28 19:09:31 -0700210
211 Vector<ComposerState> transaction;
Mathias Agopian8b33f032012-07-24 20:43:54 -0700212 Vector<DisplayState> displayTransaction;
Jamie Gennis28378392011-10-12 17:39:00 -0700213 uint32_t flags = 0;
Mathias Agopian698c0872011-06-28 19:09:31 -0700214
215 { // scope for the lock
216 Mutex::Autolock _l(mLock);
Jeff Brownf3f7db62012-08-31 02:18:38 -0700217 mForceSynchronous |= synchronous;
218 if (!mTransactionNestCount) {
219 ALOGW("At least one call to closeGlobalTransaction() was not matched by a prior "
220 "call to openGlobalTransaction().");
221 } else if (--mTransactionNestCount) {
222 return;
223 }
224
Mathias Agopiane57f2922012-08-09 16:29:12 -0700225 transaction = mComposerStates;
226 mComposerStates.clear();
Jamie Gennisb8d69a52011-10-10 15:48:06 -0700227
Mathias Agopiane57f2922012-08-09 16:29:12 -0700228 displayTransaction = mDisplayStates;
229 mDisplayStates.clear();
Jamie Gennis28378392011-10-12 17:39:00 -0700230
Jeff Brownf3f7db62012-08-31 02:18:38 -0700231 if (mForceSynchronous) {
Jamie Gennis28378392011-10-12 17:39:00 -0700232 flags |= ISurfaceComposer::eSynchronous;
233 }
Jamie Gennis2d5e2302012-10-15 18:24:43 -0700234 if (mAnimation) {
235 flags |= ISurfaceComposer::eAnimation;
236 }
237
Jamie Gennis28378392011-10-12 17:39:00 -0700238 mForceSynchronous = false;
Jamie Gennis2d5e2302012-10-15 18:24:43 -0700239 mAnimation = false;
Mathias Agopian698c0872011-06-28 19:09:31 -0700240 }
241
Mathias Agopian8b33f032012-07-24 20:43:54 -0700242 sm->setTransactionState(transaction, displayTransaction, flags);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800243}
244
Jamie Gennis2d5e2302012-10-15 18:24:43 -0700245void Composer::setAnimationTransactionImpl() {
246 Mutex::Autolock _l(mLock);
247 mAnimation = true;
248}
249
Mathias Agopian698c0872011-06-28 19:09:31 -0700250layer_state_t* Composer::getLayerStateLocked(
Mathias Agopianac9fa422013-02-11 16:40:36 -0800251 const sp<SurfaceComposerClient>& client, const sp<IBinder>& id) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700252
253 ComposerState s;
254 s.client = client->mClient;
255 s.state.surface = id;
256
Mathias Agopiane57f2922012-08-09 16:29:12 -0700257 ssize_t index = mComposerStates.indexOf(s);
Mathias Agopian698c0872011-06-28 19:09:31 -0700258 if (index < 0) {
259 // we don't have it, add an initialized layer_state to our list
Mathias Agopiane57f2922012-08-09 16:29:12 -0700260 index = mComposerStates.add(s);
Mathias Agopian698c0872011-06-28 19:09:31 -0700261 }
262
Mathias Agopiane57f2922012-08-09 16:29:12 -0700263 ComposerState* const out = mComposerStates.editArray();
Mathias Agopian698c0872011-06-28 19:09:31 -0700264 return &(out[index].state);
265}
266
267status_t Composer::setPosition(const sp<SurfaceComposerClient>& client,
Mathias Agopianac9fa422013-02-11 16:40:36 -0800268 const sp<IBinder>& id, float x, float y) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700269 Mutex::Autolock _l(mLock);
270 layer_state_t* s = getLayerStateLocked(client, id);
271 if (!s)
272 return BAD_INDEX;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700273 s->what |= layer_state_t::ePositionChanged;
Mathias Agopian698c0872011-06-28 19:09:31 -0700274 s->x = x;
275 s->y = y;
276 return NO_ERROR;
277}
278
279status_t Composer::setSize(const sp<SurfaceComposerClient>& client,
Mathias Agopianac9fa422013-02-11 16:40:36 -0800280 const sp<IBinder>& id, uint32_t w, uint32_t h) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700281 Mutex::Autolock _l(mLock);
282 layer_state_t* s = getLayerStateLocked(client, id);
283 if (!s)
284 return BAD_INDEX;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700285 s->what |= layer_state_t::eSizeChanged;
Mathias Agopian698c0872011-06-28 19:09:31 -0700286 s->w = w;
287 s->h = h;
Jamie Gennis28378392011-10-12 17:39:00 -0700288
289 // Resizing a surface makes the transaction synchronous.
290 mForceSynchronous = true;
291
Mathias Agopian698c0872011-06-28 19:09:31 -0700292 return NO_ERROR;
293}
294
295status_t Composer::setLayer(const sp<SurfaceComposerClient>& client,
Mathias Agopianac9fa422013-02-11 16:40:36 -0800296 const sp<IBinder>& id, int32_t z) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700297 Mutex::Autolock _l(mLock);
298 layer_state_t* s = getLayerStateLocked(client, id);
299 if (!s)
300 return BAD_INDEX;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700301 s->what |= layer_state_t::eLayerChanged;
Mathias Agopian698c0872011-06-28 19:09:31 -0700302 s->z = z;
303 return NO_ERROR;
304}
305
306status_t Composer::setFlags(const sp<SurfaceComposerClient>& client,
Mathias Agopianac9fa422013-02-11 16:40:36 -0800307 const sp<IBinder>& id, uint32_t flags,
Mathias Agopian698c0872011-06-28 19:09:31 -0700308 uint32_t mask) {
309 Mutex::Autolock _l(mLock);
310 layer_state_t* s = getLayerStateLocked(client, id);
311 if (!s)
312 return BAD_INDEX;
Andy McFadden4125a4f2014-01-29 17:17:11 -0800313 if (mask & layer_state_t::eLayerOpaque) {
314 s->what |= layer_state_t::eOpacityChanged;
315 }
316 if (mask & layer_state_t::eLayerHidden) {
317 s->what |= layer_state_t::eVisibilityChanged;
318 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700319 s->flags &= ~mask;
320 s->flags |= (flags & mask);
321 s->mask |= mask;
322 return NO_ERROR;
323}
324
325status_t Composer::setTransparentRegionHint(
Mathias Agopianac9fa422013-02-11 16:40:36 -0800326 const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
Mathias Agopian698c0872011-06-28 19:09:31 -0700327 const Region& transparentRegion) {
328 Mutex::Autolock _l(mLock);
329 layer_state_t* s = getLayerStateLocked(client, id);
330 if (!s)
331 return BAD_INDEX;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700332 s->what |= layer_state_t::eTransparentRegionChanged;
Mathias Agopian698c0872011-06-28 19:09:31 -0700333 s->transparentRegion = transparentRegion;
334 return NO_ERROR;
335}
336
337status_t Composer::setAlpha(const sp<SurfaceComposerClient>& client,
Mathias Agopianac9fa422013-02-11 16:40:36 -0800338 const sp<IBinder>& id, float alpha) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700339 Mutex::Autolock _l(mLock);
340 layer_state_t* s = getLayerStateLocked(client, id);
341 if (!s)
342 return BAD_INDEX;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700343 s->what |= layer_state_t::eAlphaChanged;
Mathias Agopian698c0872011-06-28 19:09:31 -0700344 s->alpha = alpha;
345 return NO_ERROR;
346}
347
Mathias Agopian87855782012-07-24 21:41:09 -0700348status_t Composer::setLayerStack(const sp<SurfaceComposerClient>& client,
Mathias Agopianac9fa422013-02-11 16:40:36 -0800349 const sp<IBinder>& id, uint32_t layerStack) {
Mathias Agopian87855782012-07-24 21:41:09 -0700350 Mutex::Autolock _l(mLock);
351 layer_state_t* s = getLayerStateLocked(client, id);
352 if (!s)
353 return BAD_INDEX;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700354 s->what |= layer_state_t::eLayerStackChanged;
Mathias Agopian87855782012-07-24 21:41:09 -0700355 s->layerStack = layerStack;
356 return NO_ERROR;
357}
358
Mathias Agopian698c0872011-06-28 19:09:31 -0700359status_t Composer::setMatrix(const sp<SurfaceComposerClient>& client,
Mathias Agopianac9fa422013-02-11 16:40:36 -0800360 const sp<IBinder>& id, float dsdx, float dtdx,
Mathias Agopian698c0872011-06-28 19:09:31 -0700361 float dsdy, float dtdy) {
362 Mutex::Autolock _l(mLock);
363 layer_state_t* s = getLayerStateLocked(client, id);
364 if (!s)
365 return BAD_INDEX;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700366 s->what |= layer_state_t::eMatrixChanged;
Mathias Agopian698c0872011-06-28 19:09:31 -0700367 layer_state_t::matrix22_t matrix;
368 matrix.dsdx = dsdx;
369 matrix.dtdx = dtdx;
370 matrix.dsdy = dsdy;
371 matrix.dtdy = dtdy;
372 s->matrix = matrix;
373 return NO_ERROR;
374}
375
Jamie Gennisf15a83f2012-05-10 20:43:55 -0700376status_t Composer::setCrop(const sp<SurfaceComposerClient>& client,
Mathias Agopianac9fa422013-02-11 16:40:36 -0800377 const sp<IBinder>& id, const Rect& crop) {
Jamie Gennisf15a83f2012-05-10 20:43:55 -0700378 Mutex::Autolock _l(mLock);
379 layer_state_t* s = getLayerStateLocked(client, id);
380 if (!s)
381 return BAD_INDEX;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700382 s->what |= layer_state_t::eCropChanged;
Jamie Gennisf15a83f2012-05-10 20:43:55 -0700383 s->crop = crop;
384 return NO_ERROR;
385}
386
Mathias Agopian698c0872011-06-28 19:09:31 -0700387// ---------------------------------------------------------------------------
388
Mathias Agopiane57f2922012-08-09 16:29:12 -0700389DisplayState& Composer::getDisplayStateLocked(const sp<IBinder>& token) {
390 DisplayState s;
391 s.token = token;
392 ssize_t index = mDisplayStates.indexOf(s);
393 if (index < 0) {
394 // we don't have it, add an initialized layer_state to our list
395 s.what = 0;
396 index = mDisplayStates.add(s);
397 }
398 return mDisplayStates.editItemAt(index);
399}
400
401void Composer::setDisplaySurface(const sp<IBinder>& token,
Andy McFadden2adaf042012-12-18 09:49:45 -0800402 const sp<IGraphicBufferProducer>& bufferProducer) {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700403 Mutex::Autolock _l(mLock);
404 DisplayState& s(getDisplayStateLocked(token));
Andy McFadden2adaf042012-12-18 09:49:45 -0800405 s.surface = bufferProducer;
Mathias Agopiane57f2922012-08-09 16:29:12 -0700406 s.what |= DisplayState::eSurfaceChanged;
407}
408
409void Composer::setDisplayLayerStack(const sp<IBinder>& token,
410 uint32_t layerStack) {
411 Mutex::Autolock _l(mLock);
412 DisplayState& s(getDisplayStateLocked(token));
413 s.layerStack = layerStack;
414 s.what |= DisplayState::eLayerStackChanged;
415}
416
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700417void Composer::setDisplayProjection(const sp<IBinder>& token,
418 uint32_t orientation,
419 const Rect& layerStackRect,
420 const Rect& displayRect) {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700421 Mutex::Autolock _l(mLock);
422 DisplayState& s(getDisplayStateLocked(token));
423 s.orientation = orientation;
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700424 s.viewport = layerStackRect;
425 s.frame = displayRect;
426 s.what |= DisplayState::eDisplayProjectionChanged;
Mathias Agopiane57f2922012-08-09 16:29:12 -0700427 mForceSynchronous = true; // TODO: do we actually still need this?
428}
429
Michael Wright1f6078a2014-06-26 16:01:02 -0700430void Composer::setDisplaySize(const sp<IBinder>& token, uint32_t width, uint32_t height) {
431 Mutex::Autolock _l(mLock);
432 DisplayState& s(getDisplayStateLocked(token));
433 s.width = width;
434 s.height = height;
435 s.what |= DisplayState::eDisplaySizeChanged;
436}
437
Mathias Agopiane57f2922012-08-09 16:29:12 -0700438// ---------------------------------------------------------------------------
439
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800440SurfaceComposerClient::SurfaceComposerClient()
Mathias Agopian698c0872011-06-28 19:09:31 -0700441 : mStatus(NO_INIT), mComposer(Composer::getInstance())
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800442{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800443}
444
Mathias Agopian698c0872011-06-28 19:09:31 -0700445void SurfaceComposerClient::onFirstRef() {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700446 sp<ISurfaceComposer> sm(ComposerService::getComposerService());
Mathias Agopiand4784a32010-05-27 19:41:15 -0700447 if (sm != 0) {
Mathias Agopian7e27f052010-05-28 14:22:23 -0700448 sp<ISurfaceComposerClient> conn = sm->createConnection();
Mathias Agopiand4784a32010-05-27 19:41:15 -0700449 if (conn != 0) {
450 mClient = conn;
Mathias Agopiand4784a32010-05-27 19:41:15 -0700451 mStatus = NO_ERROR;
452 }
453 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800454}
455
Mathias Agopian698c0872011-06-28 19:09:31 -0700456SurfaceComposerClient::~SurfaceComposerClient() {
Mathias Agopian631f3582010-05-25 17:51:34 -0700457 dispose();
458}
Mathias Agopiandd3423c2009-09-23 15:44:05 -0700459
Mathias Agopian698c0872011-06-28 19:09:31 -0700460status_t SurfaceComposerClient::initCheck() const {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800461 return mStatus;
462}
463
Mathias Agopian698c0872011-06-28 19:09:31 -0700464sp<IBinder> SurfaceComposerClient::connection() const {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800465 return (mClient != 0) ? mClient->asBinder() : 0;
466}
467
Mathias Agopiand4784a32010-05-27 19:41:15 -0700468status_t SurfaceComposerClient::linkToComposerDeath(
469 const sp<IBinder::DeathRecipient>& recipient,
Mathias Agopian698c0872011-06-28 19:09:31 -0700470 void* cookie, uint32_t flags) {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700471 sp<ISurfaceComposer> sm(ComposerService::getComposerService());
Mathias Agopiand4784a32010-05-27 19:41:15 -0700472 return sm->asBinder()->linkToDeath(recipient, cookie, flags);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800473}
474
Mathias Agopian698c0872011-06-28 19:09:31 -0700475void SurfaceComposerClient::dispose() {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800476 // this can be called more than once.
Mathias Agopian7e27f052010-05-28 14:22:23 -0700477 sp<ISurfaceComposerClient> client;
Mathias Agopiand4784a32010-05-27 19:41:15 -0700478 Mutex::Autolock _lm(mLock);
479 if (mClient != 0) {
Mathias Agopiand4784a32010-05-27 19:41:15 -0700480 client = mClient; // hold ref while lock is held
481 mClient.clear();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800482 }
Mathias Agopiand4784a32010-05-27 19:41:15 -0700483 mStatus = NO_INIT;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800484}
485
Mathias Agopian698c0872011-06-28 19:09:31 -0700486sp<SurfaceControl> SurfaceComposerClient::createSurface(
Mathias Agopian698c0872011-06-28 19:09:31 -0700487 const String8& name,
Mathias Agopian698c0872011-06-28 19:09:31 -0700488 uint32_t w,
489 uint32_t h,
490 PixelFormat format,
491 uint32_t flags)
492{
Mathias Agopian4d9b8222013-03-12 17:11:48 -0700493 sp<SurfaceControl> sur;
Mathias Agopian698c0872011-06-28 19:09:31 -0700494 if (mStatus == NO_ERROR) {
Mathias Agopian4d9b8222013-03-12 17:11:48 -0700495 sp<IBinder> handle;
496 sp<IGraphicBufferProducer> gbp;
497 status_t err = mClient->createSurface(name, w, h, format, flags,
498 &handle, &gbp);
499 ALOGE_IF(err, "SurfaceComposerClient::createSurface error %s", strerror(-err));
500 if (err == NO_ERROR) {
501 sur = new SurfaceControl(this, handle, gbp);
Mathias Agopian698c0872011-06-28 19:09:31 -0700502 }
503 }
Mathias Agopian4d9b8222013-03-12 17:11:48 -0700504 return sur;
Mathias Agopian698c0872011-06-28 19:09:31 -0700505}
506
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700507sp<IBinder> SurfaceComposerClient::createDisplay(const String8& displayName,
508 bool secure) {
509 return Composer::getInstance().createDisplay(displayName, secure);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700510}
511
Jesse Hall6c913be2013-08-08 12:15:49 -0700512void SurfaceComposerClient::destroyDisplay(const sp<IBinder>& display) {
513 Composer::getInstance().destroyDisplay(display);
514}
515
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700516sp<IBinder> SurfaceComposerClient::getBuiltInDisplay(int32_t id) {
517 return Composer::getInstance().getBuiltInDisplay(id);
518}
519
Mathias Agopianac9fa422013-02-11 16:40:36 -0800520status_t SurfaceComposerClient::destroySurface(const sp<IBinder>& sid) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700521 if (mStatus != NO_ERROR)
522 return mStatus;
523 status_t err = mClient->destroySurface(sid);
524 return err;
525}
526
Svetoslavd85084b2014-03-20 10:28:31 -0700527status_t SurfaceComposerClient::clearLayerFrameStats(const sp<IBinder>& token) const {
528 if (mStatus != NO_ERROR) {
529 return mStatus;
530 }
531 return mClient->clearLayerFrameStats(token);
532}
533
534status_t SurfaceComposerClient::getLayerFrameStats(const sp<IBinder>& token,
535 FrameStats* outStats) const {
536 if (mStatus != NO_ERROR) {
537 return mStatus;
538 }
539 return mClient->getLayerFrameStats(token, outStats);
540}
541
Mathias Agopian698c0872011-06-28 19:09:31 -0700542inline Composer& SurfaceComposerClient::getComposer() {
543 return mComposer;
544}
545
546// ----------------------------------------------------------------------------
547
548void SurfaceComposerClient::openGlobalTransaction() {
Jeff Brownf3f7db62012-08-31 02:18:38 -0700549 Composer::openGlobalTransaction();
Mathias Agopian698c0872011-06-28 19:09:31 -0700550}
551
Jamie Gennis28378392011-10-12 17:39:00 -0700552void SurfaceComposerClient::closeGlobalTransaction(bool synchronous) {
553 Composer::closeGlobalTransaction(synchronous);
Mathias Agopian698c0872011-06-28 19:09:31 -0700554}
555
Jamie Gennis2d5e2302012-10-15 18:24:43 -0700556void SurfaceComposerClient::setAnimationTransaction() {
557 Composer::setAnimationTransaction();
558}
559
Mathias Agopian698c0872011-06-28 19:09:31 -0700560// ----------------------------------------------------------------------------
561
Mathias Agopianac9fa422013-02-11 16:40:36 -0800562status_t SurfaceComposerClient::setCrop(const sp<IBinder>& id, const Rect& crop) {
Jamie Gennisf15a83f2012-05-10 20:43:55 -0700563 return getComposer().setCrop(this, id, crop);
564}
565
Mathias Agopianac9fa422013-02-11 16:40:36 -0800566status_t SurfaceComposerClient::setPosition(const sp<IBinder>& id, float x, float y) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700567 return getComposer().setPosition(this, id, x, y);
568}
569
Mathias Agopianac9fa422013-02-11 16:40:36 -0800570status_t SurfaceComposerClient::setSize(const sp<IBinder>& id, uint32_t w, uint32_t h) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700571 return getComposer().setSize(this, id, w, h);
572}
573
Mathias Agopianac9fa422013-02-11 16:40:36 -0800574status_t SurfaceComposerClient::setLayer(const sp<IBinder>& id, int32_t z) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700575 return getComposer().setLayer(this, id, z);
576}
577
Mathias Agopianac9fa422013-02-11 16:40:36 -0800578status_t SurfaceComposerClient::hide(const sp<IBinder>& id) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700579 return getComposer().setFlags(this, id,
Mathias Agopian3165cc22012-08-08 19:42:09 -0700580 layer_state_t::eLayerHidden,
581 layer_state_t::eLayerHidden);
Mathias Agopian698c0872011-06-28 19:09:31 -0700582}
583
Mathias Agopianac9fa422013-02-11 16:40:36 -0800584status_t SurfaceComposerClient::show(const sp<IBinder>& id) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700585 return getComposer().setFlags(this, id,
586 0,
Mathias Agopian3165cc22012-08-08 19:42:09 -0700587 layer_state_t::eLayerHidden);
Mathias Agopian698c0872011-06-28 19:09:31 -0700588}
589
Mathias Agopianac9fa422013-02-11 16:40:36 -0800590status_t SurfaceComposerClient::setFlags(const sp<IBinder>& id, uint32_t flags,
Mathias Agopian698c0872011-06-28 19:09:31 -0700591 uint32_t mask) {
592 return getComposer().setFlags(this, id, flags, mask);
593}
594
Mathias Agopianac9fa422013-02-11 16:40:36 -0800595status_t SurfaceComposerClient::setTransparentRegionHint(const sp<IBinder>& id,
Mathias Agopian698c0872011-06-28 19:09:31 -0700596 const Region& transparentRegion) {
597 return getComposer().setTransparentRegionHint(this, id, transparentRegion);
598}
599
Mathias Agopianac9fa422013-02-11 16:40:36 -0800600status_t SurfaceComposerClient::setAlpha(const sp<IBinder>& id, float alpha) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700601 return getComposer().setAlpha(this, id, alpha);
602}
603
Mathias Agopianac9fa422013-02-11 16:40:36 -0800604status_t SurfaceComposerClient::setLayerStack(const sp<IBinder>& id, uint32_t layerStack) {
Mathias Agopian87855782012-07-24 21:41:09 -0700605 return getComposer().setLayerStack(this, id, layerStack);
606}
607
Mathias Agopianac9fa422013-02-11 16:40:36 -0800608status_t SurfaceComposerClient::setMatrix(const sp<IBinder>& id, float dsdx, float dtdx,
Mathias Agopian698c0872011-06-28 19:09:31 -0700609 float dsdy, float dtdy) {
610 return getComposer().setMatrix(this, id, dsdx, dtdx, dsdy, dtdy);
611}
612
613// ----------------------------------------------------------------------------
614
Mathias Agopiane57f2922012-08-09 16:29:12 -0700615void SurfaceComposerClient::setDisplaySurface(const sp<IBinder>& token,
Andy McFadden2adaf042012-12-18 09:49:45 -0800616 const sp<IGraphicBufferProducer>& bufferProducer) {
617 Composer::getInstance().setDisplaySurface(token, bufferProducer);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700618}
619
620void SurfaceComposerClient::setDisplayLayerStack(const sp<IBinder>& token,
621 uint32_t layerStack) {
622 Composer::getInstance().setDisplayLayerStack(token, layerStack);
623}
624
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700625void SurfaceComposerClient::setDisplayProjection(const sp<IBinder>& token,
626 uint32_t orientation,
627 const Rect& layerStackRect,
628 const Rect& displayRect) {
629 Composer::getInstance().setDisplayProjection(token, orientation,
630 layerStackRect, displayRect);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700631}
632
Michael Wright1f6078a2014-06-26 16:01:02 -0700633void SurfaceComposerClient::setDisplaySize(const sp<IBinder>& token,
634 uint32_t width, uint32_t height) {
635 Composer::getInstance().setDisplaySize(token, width, height);
636}
637
Mathias Agopiane57f2922012-08-09 16:29:12 -0700638// ----------------------------------------------------------------------------
639
Dan Stoza7f7da322014-05-02 15:26:25 -0700640status_t SurfaceComposerClient::getDisplayConfigs(
641 const sp<IBinder>& display, Vector<DisplayInfo>* configs)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800642{
Dan Stoza7f7da322014-05-02 15:26:25 -0700643 return ComposerService::getComposerService()->getDisplayConfigs(display, configs);
644}
645
646status_t SurfaceComposerClient::getDisplayInfo(const sp<IBinder>& display,
647 DisplayInfo* info) {
648 Vector<DisplayInfo> configs;
649 status_t result = getDisplayConfigs(display, &configs);
650 if (result != NO_ERROR) {
651 return result;
652 }
653
654 int activeId = getActiveConfig(display);
655 if (activeId < 0) {
656 ALOGE("No active configuration found");
657 return NAME_NOT_FOUND;
658 }
659
660 *info = configs[activeId];
661 return NO_ERROR;
662}
663
664int SurfaceComposerClient::getActiveConfig(const sp<IBinder>& display) {
665 return ComposerService::getComposerService()->getActiveConfig(display);
666}
667
668status_t SurfaceComposerClient::setActiveConfig(const sp<IBinder>& display, int id) {
669 return ComposerService::getComposerService()->setActiveConfig(display, id);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800670}
671
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700672void SurfaceComposerClient::setDisplayPowerMode(const sp<IBinder>& token,
673 int mode) {
674 ComposerService::getComposerService()->setPowerMode(token, mode);
Jeff Brown2a09bb32012-10-08 19:13:57 -0700675}
676
Svetoslavd85084b2014-03-20 10:28:31 -0700677status_t SurfaceComposerClient::clearAnimationFrameStats() {
678 return ComposerService::getComposerService()->clearAnimationFrameStats();
679}
680
681status_t SurfaceComposerClient::getAnimationFrameStats(FrameStats* outStats) {
682 return ComposerService::getComposerService()->getAnimationFrameStats(outStats);
683}
684
Mathias Agopian698c0872011-06-28 19:09:31 -0700685// ----------------------------------------------------------------------------
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800686
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800687status_t ScreenshotClient::capture(
688 const sp<IBinder>& display,
689 const sp<IGraphicBufferProducer>& producer,
Dan Stozac1879002014-05-22 15:59:05 -0700690 Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
Dan Stozac7014012014-02-14 15:03:43 -0800691 uint32_t minLayerZ, uint32_t maxLayerZ, bool useIdentityTransform) {
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800692 sp<ISurfaceComposer> s(ComposerService::getComposerService());
693 if (s == NULL) return NO_INIT;
Dan Stozac1879002014-05-22 15:59:05 -0700694 return s->captureScreen(display, producer, sourceCrop,
Dan Stozac7014012014-02-14 15:03:43 -0800695 reqWidth, reqHeight, minLayerZ, maxLayerZ, useIdentityTransform);
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800696}
697
Mathias Agopian74c40c02010-09-29 13:02:36 -0700698ScreenshotClient::ScreenshotClient()
Mathias Agopianabe815d2013-03-19 22:22:21 -0700699 : mHaveBuffer(false) {
700 memset(&mBuffer, 0, sizeof(mBuffer));
Mathias Agopian74c40c02010-09-29 13:02:36 -0700701}
702
Mathias Agopian8000d062013-03-26 18:15:35 -0700703ScreenshotClient::~ScreenshotClient() {
704 ScreenshotClient::release();
705}
706
Mathias Agopianabe815d2013-03-19 22:22:21 -0700707sp<CpuConsumer> ScreenshotClient::getCpuConsumer() const {
708 if (mCpuConsumer == NULL) {
Dan Stoza6d5a7bb2014-03-13 11:39:09 -0700709 sp<IGraphicBufferConsumer> consumer;
710 BufferQueue::createBufferQueue(&mProducer, &consumer);
711 mCpuConsumer = new CpuConsumer(consumer, 1);
Mathias Agopianabe815d2013-03-19 22:22:21 -0700712 mCpuConsumer->setName(String8("ScreenshotClient"));
713 }
714 return mCpuConsumer;
Mathias Agopianbf2c6a62010-12-10 16:22:31 -0800715}
716
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700717status_t ScreenshotClient::update(const sp<IBinder>& display,
Dan Stozac1879002014-05-22 15:59:05 -0700718 Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
Dan Stozac7014012014-02-14 15:03:43 -0800719 uint32_t minLayerZ, uint32_t maxLayerZ,
720 bool useIdentityTransform) {
Mathias Agopianbf2c6a62010-12-10 16:22:31 -0800721 sp<ISurfaceComposer> s(ComposerService::getComposerService());
722 if (s == NULL) return NO_INIT;
Mathias Agopianabe815d2013-03-19 22:22:21 -0700723 sp<CpuConsumer> cpuConsumer = getCpuConsumer();
724
725 if (mHaveBuffer) {
726 mCpuConsumer->unlockBuffer(mBuffer);
727 memset(&mBuffer, 0, sizeof(mBuffer));
728 mHaveBuffer = false;
729 }
730
Dan Stozac1879002014-05-22 15:59:05 -0700731 status_t err = s->captureScreen(display, mProducer, sourceCrop,
Dan Stozac7014012014-02-14 15:03:43 -0800732 reqWidth, reqHeight, minLayerZ, maxLayerZ, useIdentityTransform);
Mathias Agopianabe815d2013-03-19 22:22:21 -0700733
734 if (err == NO_ERROR) {
735 err = mCpuConsumer->lockNextBuffer(&mBuffer);
736 if (err == NO_ERROR) {
737 mHaveBuffer = true;
738 }
739 }
740 return err;
741}
742
Dan Stozac1879002014-05-22 15:59:05 -0700743status_t ScreenshotClient::update(const sp<IBinder>& display, Rect sourceCrop,
Dan Stozac7014012014-02-14 15:03:43 -0800744 bool useIdentityTransform) {
Dan Stozac1879002014-05-22 15:59:05 -0700745 return ScreenshotClient::update(display, sourceCrop, 0, 0, 0, -1UL,
Dan Stozac7014012014-02-14 15:03:43 -0800746 useIdentityTransform);
Mathias Agopianabe815d2013-03-19 22:22:21 -0700747}
748
Dan Stozac1879002014-05-22 15:59:05 -0700749status_t ScreenshotClient::update(const sp<IBinder>& display, Rect sourceCrop,
Dan Stozac7014012014-02-14 15:03:43 -0800750 uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform) {
Dan Stozac1879002014-05-22 15:59:05 -0700751 return ScreenshotClient::update(display, sourceCrop, reqWidth, reqHeight,
752 0, -1UL, useIdentityTransform);
Mathias Agopian74c40c02010-09-29 13:02:36 -0700753}
754
755void ScreenshotClient::release() {
Mathias Agopianabe815d2013-03-19 22:22:21 -0700756 if (mHaveBuffer) {
757 mCpuConsumer->unlockBuffer(mBuffer);
758 memset(&mBuffer, 0, sizeof(mBuffer));
759 mHaveBuffer = false;
760 }
761 mCpuConsumer.clear();
Mathias Agopian74c40c02010-09-29 13:02:36 -0700762}
763
764void const* ScreenshotClient::getPixels() const {
Mathias Agopianabe815d2013-03-19 22:22:21 -0700765 return mBuffer.data;
Mathias Agopian74c40c02010-09-29 13:02:36 -0700766}
767
768uint32_t ScreenshotClient::getWidth() const {
Mathias Agopianabe815d2013-03-19 22:22:21 -0700769 return mBuffer.width;
Mathias Agopian74c40c02010-09-29 13:02:36 -0700770}
771
772uint32_t ScreenshotClient::getHeight() const {
Mathias Agopianabe815d2013-03-19 22:22:21 -0700773 return mBuffer.height;
Mathias Agopian74c40c02010-09-29 13:02:36 -0700774}
775
776PixelFormat ScreenshotClient::getFormat() const {
Mathias Agopianabe815d2013-03-19 22:22:21 -0700777 return mBuffer.format;
Mathias Agopian74c40c02010-09-29 13:02:36 -0700778}
779
780uint32_t ScreenshotClient::getStride() const {
Mathias Agopianabe815d2013-03-19 22:22:21 -0700781 return mBuffer.stride;
Mathias Agopian74c40c02010-09-29 13:02:36 -0700782}
783
784size_t ScreenshotClient::getSize() const {
Mathias Agopianabe815d2013-03-19 22:22:21 -0700785 return mBuffer.stride * mBuffer.height * bytesPerPixel(mBuffer.format);
Mathias Agopian74c40c02010-09-29 13:02:36 -0700786}
787
788// ----------------------------------------------------------------------------
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800789}; // namespace android