blob: 8401cb69671e19ee76a6d24bf214da7117147e9e [file] [log] [blame]
The Android Open Source Project9066cfe2009-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>
20#include <unistd.h>
21#include <fcntl.h>
22#include <errno.h>
23#include <sys/types.h>
24#include <sys/stat.h>
25
26#include <cutils/memory.h>
27
28#include <utils/Atomic.h>
29#include <utils/Errors.h>
30#include <utils/threads.h>
31#include <utils/KeyedVector.h>
Mathias Agopian07952722009-05-19 19:08:10 -070032#include <binder/IServiceManager.h>
33#include <binder/IMemory.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034#include <utils/Log.h>
35
Mathias Agopian1473f462009-04-10 14:24:30 -070036#include <ui/DisplayInfo.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080037#include <ui/ISurfaceComposer.h>
38#include <ui/ISurfaceFlingerClient.h>
39#include <ui/ISurface.h>
40#include <ui/SurfaceComposerClient.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041#include <ui/Rect.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080042
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043#include <private/ui/LayerState.h>
Mathias Agopian9779b2212009-09-07 16:32:45 -070044#include <private/ui/SharedBufferStack.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045#include <private/ui/SurfaceFlingerSynchro.h>
46
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080047#define VERBOSE(...) ((void)0)
48//#define VERBOSE LOGD
49
50#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
51#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
52
53namespace android {
54
55// ---------------------------------------------------------------------------
56
57// Must not be holding SurfaceComposerClient::mLock when acquiring gLock here.
58static Mutex gLock;
59static sp<ISurfaceComposer> gSurfaceManager;
60static DefaultKeyedVector< sp<IBinder>, sp<SurfaceComposerClient> > gActiveConnections;
61static SortedVector<sp<SurfaceComposerClient> > gOpenTransactions;
Mathias Agopiand763b5d2009-07-02 18:11:53 -070062static sp<IMemoryHeap> gServerCblkMemory;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080063static volatile surface_flinger_cblk_t* gServerCblk;
64
65const sp<ISurfaceComposer>& _get_surface_manager()
66{
67 if (gSurfaceManager != 0) {
68 return gSurfaceManager;
69 }
70
71 sp<IBinder> binder;
72 sp<IServiceManager> sm = defaultServiceManager();
73 do {
74 binder = sm->getService(String16("SurfaceFlinger"));
75 if (binder == 0) {
76 LOGW("SurfaceFlinger not published, waiting...");
77 usleep(500000); // 0.5 s
78 }
79 } while(binder == 0);
80 sp<ISurfaceComposer> sc(interface_cast<ISurfaceComposer>(binder));
81
82 Mutex::Autolock _l(gLock);
83 if (gSurfaceManager == 0) {
84 gSurfaceManager = sc;
85 }
86 return gSurfaceManager;
87}
88
89static volatile surface_flinger_cblk_t const * get_cblk()
90{
91 if (gServerCblk == 0) {
92 const sp<ISurfaceComposer>& sm(_get_surface_manager());
93 Mutex::Autolock _l(gLock);
94 if (gServerCblk == 0) {
95 gServerCblkMemory = sm->getCblk();
96 LOGE_IF(gServerCblkMemory==0, "Can't get server control block");
Mathias Agopiand763b5d2009-07-02 18:11:53 -070097 gServerCblk = (surface_flinger_cblk_t *)gServerCblkMemory->getBase();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080098 LOGE_IF(gServerCblk==0, "Can't get server control block address");
99 }
100 }
101 return gServerCblk;
102}
103
104// ---------------------------------------------------------------------------
105
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106static inline int compare_type( const layer_state_t& lhs,
107 const layer_state_t& rhs) {
108 if (lhs.surface < rhs.surface) return -1;
109 if (lhs.surface > rhs.surface) return 1;
110 return 0;
111}
112
113SurfaceComposerClient::SurfaceComposerClient()
114{
115 const sp<ISurfaceComposer>& sm(_get_surface_manager());
116 if (sm == 0) {
117 _init(0, 0);
118 return;
119 }
120
121 _init(sm, sm->createConnection());
122
123 if (mClient != 0) {
124 Mutex::Autolock _l(gLock);
125 VERBOSE("Adding client %p to map", this);
126 gActiveConnections.add(mClient->asBinder(), this);
127 }
128}
129
130SurfaceComposerClient::SurfaceComposerClient(
131 const sp<ISurfaceComposer>& sm, const sp<IBinder>& conn)
132{
133 _init(sm, interface_cast<ISurfaceFlingerClient>(conn));
134}
135
136void SurfaceComposerClient::_init(
137 const sp<ISurfaceComposer>& sm, const sp<ISurfaceFlingerClient>& conn)
138{
139 VERBOSE("Creating client %p, conn %p", this, conn.get());
140
141 mSignalServer = 0;
142 mPrebuiltLayerState = 0;
143 mTransactionOpen = 0;
144 mStatus = NO_ERROR;
145 mControl = 0;
146
147 mClient = conn;
148 if (mClient == 0) {
149 mStatus = NO_INIT;
150 return;
151 }
152
Mathias Agopiand763b5d2009-07-02 18:11:53 -0700153 mControlMemory = mClient->getControlBlock();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800154 mSignalServer = new SurfaceFlingerSynchro(sm);
Mathias Agopian9779b2212009-09-07 16:32:45 -0700155 mControl = static_cast<SharedClient *>(mControlMemory->getBase());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800156}
157
158SurfaceComposerClient::~SurfaceComposerClient()
159{
160 VERBOSE("Destroying client %p, conn %p", this, mClient.get());
161 dispose();
162}
163
164status_t SurfaceComposerClient::initCheck() const
165{
166 return mStatus;
167}
168
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800169sp<IBinder> SurfaceComposerClient::connection() const
170{
171 return (mClient != 0) ? mClient->asBinder() : 0;
172}
173
174sp<SurfaceComposerClient>
175SurfaceComposerClient::clientForConnection(const sp<IBinder>& conn)
176{
177 sp<SurfaceComposerClient> client;
178
179 { // scope for lock
180 Mutex::Autolock _l(gLock);
181 client = gActiveConnections.valueFor(conn);
182 }
183
184 if (client == 0) {
185 // Need to make a new client.
186 const sp<ISurfaceComposer>& sm(_get_surface_manager());
187 client = new SurfaceComposerClient(sm, conn);
188 if (client != 0 && client->initCheck() == NO_ERROR) {
189 Mutex::Autolock _l(gLock);
190 gActiveConnections.add(conn, client);
191 //LOGD("we have %d connections", gActiveConnections.size());
192 } else {
193 client.clear();
194 }
195 }
196
197 return client;
198}
199
200void SurfaceComposerClient::dispose()
201{
202 // this can be called more than once.
203
Mathias Agopiand763b5d2009-07-02 18:11:53 -0700204 sp<IMemoryHeap> controlMemory;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800205 sp<ISurfaceFlingerClient> client;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800206
207 {
208 Mutex::Autolock _lg(gLock);
209 Mutex::Autolock _lm(mLock);
210
211 delete mSignalServer;
212 mSignalServer = 0;
213
214 if (mClient != 0) {
215 client = mClient;
216 mClient.clear();
217
218 ssize_t i = gActiveConnections.indexOfKey(client->asBinder());
219 if (i >= 0 && gActiveConnections.valueAt(i) == this) {
220 VERBOSE("Removing client %p from map at %d", this, int(i));
221 gActiveConnections.removeItemsAt(i);
222 }
223 }
224
225 delete mPrebuiltLayerState;
226 mPrebuiltLayerState = 0;
227 controlMemory = mControlMemory;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800228 mControlMemory.clear();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800229 mControl = 0;
230 mStatus = NO_INIT;
231 }
232}
233
234status_t SurfaceComposerClient::getDisplayInfo(
235 DisplayID dpy, DisplayInfo* info)
236{
237 if (uint32_t(dpy)>=NUM_DISPLAY_MAX)
238 return BAD_VALUE;
239
240 volatile surface_flinger_cblk_t const * cblk = get_cblk();
241 volatile display_cblk_t const * dcblk = cblk->displays + dpy;
242
243 info->w = dcblk->w;
244 info->h = dcblk->h;
245 info->orientation = dcblk->orientation;
246 info->xdpi = dcblk->xdpi;
247 info->ydpi = dcblk->ydpi;
248 info->fps = dcblk->fps;
249 info->density = dcblk->density;
250 return getPixelFormatInfo(dcblk->format, &(info->pixelFormatInfo));
251}
252
253ssize_t SurfaceComposerClient::getDisplayWidth(DisplayID dpy)
254{
255 if (uint32_t(dpy)>=NUM_DISPLAY_MAX)
256 return BAD_VALUE;
257 volatile surface_flinger_cblk_t const * cblk = get_cblk();
258 volatile display_cblk_t const * dcblk = cblk->displays + dpy;
259 return dcblk->w;
260}
261
262ssize_t SurfaceComposerClient::getDisplayHeight(DisplayID dpy)
263{
264 if (uint32_t(dpy)>=NUM_DISPLAY_MAX)
265 return BAD_VALUE;
266 volatile surface_flinger_cblk_t const * cblk = get_cblk();
267 volatile display_cblk_t const * dcblk = cblk->displays + dpy;
268 return dcblk->h;
269}
270
271ssize_t SurfaceComposerClient::getDisplayOrientation(DisplayID dpy)
272{
273 if (uint32_t(dpy)>=NUM_DISPLAY_MAX)
274 return BAD_VALUE;
275 volatile surface_flinger_cblk_t const * cblk = get_cblk();
276 volatile display_cblk_t const * dcblk = cblk->displays + dpy;
277 return dcblk->orientation;
278}
279
280ssize_t SurfaceComposerClient::getNumberOfDisplays()
281{
282 volatile surface_flinger_cblk_t const * cblk = get_cblk();
283 uint32_t connected = cblk->connected;
284 int n = 0;
285 while (connected) {
286 if (connected&1) n++;
287 connected >>= 1;
288 }
289 return n;
290}
291
Mathias Agopian1473f462009-04-10 14:24:30 -0700292
293void SurfaceComposerClient::signalServer()
294{
295 mSignalServer->signal();
296}
297
Mathias Agopian17f638b2009-04-16 20:04:08 -0700298sp<SurfaceControl> SurfaceComposerClient::createSurface(
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800299 int pid,
300 DisplayID display,
301 uint32_t w,
302 uint32_t h,
303 PixelFormat format,
304 uint32_t flags)
305{
Mathias Agopian17f638b2009-04-16 20:04:08 -0700306 sp<SurfaceControl> result;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800307 if (mStatus == NO_ERROR) {
308 ISurfaceFlingerClient::surface_data_t data;
309 sp<ISurface> surface = mClient->createSurface(&data, pid,
310 display, w, h, format, flags);
311 if (surface != 0) {
312 if (uint32_t(data.token) < NUM_LAYERS_MAX) {
Mathias Agopian17f638b2009-04-16 20:04:08 -0700313 result = new SurfaceControl(this, surface, data, w, h, format, flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800314 }
315 }
316 }
317 return result;
318}
319
320status_t SurfaceComposerClient::destroySurface(SurfaceID sid)
321{
322 if (mStatus != NO_ERROR)
323 return mStatus;
324
325 // it's okay to destroy a surface while a transaction is open,
326 // (transactions really are a client-side concept)
327 // however, this indicates probably a misuse of the API or a bug
328 // in the client code.
329 LOGW_IF(mTransactionOpen,
330 "Destroying surface while a transaction is open. "
331 "Client %p: destroying surface %d, mTransactionOpen=%d",
332 this, sid, mTransactionOpen);
333
334 status_t err = mClient->destroySurface(sid);
335 return err;
336}
337
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800338void SurfaceComposerClient::openGlobalTransaction()
339{
340 Mutex::Autolock _l(gLock);
341
342 if (gOpenTransactions.size()) {
343 LOGE("openGlobalTransaction() called more than once. skipping.");
344 return;
345 }
346
347 const size_t N = gActiveConnections.size();
348 VERBOSE("openGlobalTransaction (%ld clients)", N);
349 for (size_t i=0; i<N; i++) {
350 sp<SurfaceComposerClient> client(gActiveConnections.valueAt(i));
351 if (gOpenTransactions.indexOf(client) < 0) {
352 if (client->openTransaction() == NO_ERROR) {
353 if (gOpenTransactions.add(client) < 0) {
354 // Ooops!
355 LOGE( "Unable to add a SurfaceComposerClient "
356 "to the global transaction set (out of memory?)");
357 client->closeTransaction();
358 // let it go, it'll fail later when the user
359 // tries to do something with the transaction
360 }
361 } else {
362 LOGE("openTransaction on client %p failed", client.get());
363 // let it go, it'll fail later when the user
364 // tries to do something with the transaction
365 }
366 }
367 }
368}
369
370void SurfaceComposerClient::closeGlobalTransaction()
371{
372 gLock.lock();
373 SortedVector< sp<SurfaceComposerClient> > clients(gOpenTransactions);
374 gOpenTransactions.clear();
375 gLock.unlock();
376
377 const size_t N = clients.size();
378 VERBOSE("closeGlobalTransaction (%ld clients)", N);
Mathias Agopian9779b2212009-09-07 16:32:45 -0700379
380 const sp<ISurfaceComposer>& sm(_get_surface_manager());
381 sm->openGlobalTransaction();
382 for (size_t i=0; i<N; i++) {
383 clients[i]->closeTransaction();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800384 }
Mathias Agopian9779b2212009-09-07 16:32:45 -0700385 sm->closeGlobalTransaction();
386
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800387}
388
Mathias Agopian9779b2212009-09-07 16:32:45 -0700389
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800390status_t SurfaceComposerClient::freezeDisplay(DisplayID dpy, uint32_t flags)
391{
392 const sp<ISurfaceComposer>& sm(_get_surface_manager());
393 return sm->freezeDisplay(dpy, flags);
394}
395
396status_t SurfaceComposerClient::unfreezeDisplay(DisplayID dpy, uint32_t flags)
397{
398 const sp<ISurfaceComposer>& sm(_get_surface_manager());
399 return sm->unfreezeDisplay(dpy, flags);
400}
401
Mathias Agopianeb0c86e2009-03-27 18:11:38 -0700402int SurfaceComposerClient::setOrientation(DisplayID dpy,
403 int orientation, uint32_t flags)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800404{
405 const sp<ISurfaceComposer>& sm(_get_surface_manager());
Mathias Agopianeb0c86e2009-03-27 18:11:38 -0700406 return sm->setOrientation(dpy, orientation, flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800407}
408
409status_t SurfaceComposerClient::openTransaction()
410{
411 if (mStatus != NO_ERROR)
412 return mStatus;
413 Mutex::Autolock _l(mLock);
414 VERBOSE( "openTransaction (client %p, mTransactionOpen=%d)",
415 this, mTransactionOpen);
416 mTransactionOpen++;
417 if (mPrebuiltLayerState == 0) {
418 mPrebuiltLayerState = new layer_state_t;
419 }
420 return NO_ERROR;
421}
422
423
424status_t SurfaceComposerClient::closeTransaction()
425{
426 if (mStatus != NO_ERROR)
427 return mStatus;
428
429 Mutex::Autolock _l(mLock);
430
431 VERBOSE( "closeTransaction (client %p, mTransactionOpen=%d)",
432 this, mTransactionOpen);
433
434 if (mTransactionOpen <= 0) {
435 LOGE( "closeTransaction (client %p, mTransactionOpen=%d) "
436 "called more times than openTransaction()",
437 this, mTransactionOpen);
438 return INVALID_OPERATION;
439 }
440
441 if (mTransactionOpen >= 2) {
442 mTransactionOpen--;
443 return NO_ERROR;
444 }
445
446 mTransactionOpen = 0;
447 const ssize_t count = mStates.size();
448 if (count) {
449 mClient->setState(count, mStates.array());
450 mStates.clear();
451 }
452 return NO_ERROR;
453}
454
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700455layer_state_t* SurfaceComposerClient::_get_state_l(SurfaceID index)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800456{
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800457 // API usage error, do nothing.
458 if (mTransactionOpen<=0) {
459 LOGE("Not in transaction (client=%p, SurfaceID=%d, mTransactionOpen=%d",
460 this, int(index), mTransactionOpen);
461 return 0;
462 }
463
464 // use mPrebuiltLayerState just to find out if we already have it
465 layer_state_t& dummy = *mPrebuiltLayerState;
466 dummy.surface = index;
467 ssize_t i = mStates.indexOf(dummy);
468 if (i < 0) {
469 // we don't have it, add an initialized layer_state to our list
470 i = mStates.add(dummy);
471 }
472 return mStates.editArray() + i;
473}
474
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700475layer_state_t* SurfaceComposerClient::_lockLayerState(SurfaceID id)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800476{
477 layer_state_t* s;
478 mLock.lock();
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700479 s = _get_state_l(id);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800480 if (!s) mLock.unlock();
481 return s;
482}
483
484void SurfaceComposerClient::_unlockLayerState()
485{
486 mLock.unlock();
487}
488
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700489status_t SurfaceComposerClient::setPosition(SurfaceID id, int32_t x, int32_t y)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800490{
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700491 layer_state_t* s = _lockLayerState(id);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800492 if (!s) return BAD_INDEX;
493 s->what |= ISurfaceComposer::ePositionChanged;
494 s->x = x;
495 s->y = y;
496 _unlockLayerState();
497 return NO_ERROR;
498}
499
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700500status_t SurfaceComposerClient::setSize(SurfaceID id, uint32_t w, uint32_t h)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800501{
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700502 layer_state_t* s = _lockLayerState(id);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800503 if (!s) return BAD_INDEX;
504 s->what |= ISurfaceComposer::eSizeChanged;
505 s->w = w;
506 s->h = h;
507 _unlockLayerState();
508 return NO_ERROR;
509}
510
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700511status_t SurfaceComposerClient::setLayer(SurfaceID id, int32_t z)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800512{
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700513 layer_state_t* s = _lockLayerState(id);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800514 if (!s) return BAD_INDEX;
515 s->what |= ISurfaceComposer::eLayerChanged;
516 s->z = z;
517 _unlockLayerState();
518 return NO_ERROR;
519}
520
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700521status_t SurfaceComposerClient::hide(SurfaceID id)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800522{
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700523 return setFlags(id, ISurfaceComposer::eLayerHidden,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800524 ISurfaceComposer::eLayerHidden);
525}
526
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700527status_t SurfaceComposerClient::show(SurfaceID id, int32_t)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800528{
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700529 return setFlags(id, 0, ISurfaceComposer::eLayerHidden);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800530}
531
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700532status_t SurfaceComposerClient::freeze(SurfaceID id)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800533{
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700534 return setFlags(id, ISurfaceComposer::eLayerFrozen,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800535 ISurfaceComposer::eLayerFrozen);
536}
537
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700538status_t SurfaceComposerClient::unfreeze(SurfaceID id)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800539{
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700540 return setFlags(id, 0, ISurfaceComposer::eLayerFrozen);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800541}
542
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700543status_t SurfaceComposerClient::setFlags(SurfaceID id,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800544 uint32_t flags, uint32_t mask)
545{
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700546 layer_state_t* s = _lockLayerState(id);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800547 if (!s) return BAD_INDEX;
548 s->what |= ISurfaceComposer::eVisibilityChanged;
549 s->flags &= ~mask;
550 s->flags |= (flags & mask);
551 s->mask |= mask;
552 _unlockLayerState();
553 return NO_ERROR;
554}
555
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800556status_t SurfaceComposerClient::setTransparentRegionHint(
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700557 SurfaceID id, const Region& transparentRegion)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800558{
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700559 layer_state_t* s = _lockLayerState(id);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800560 if (!s) return BAD_INDEX;
561 s->what |= ISurfaceComposer::eTransparentRegionChanged;
562 s->transparentRegion = transparentRegion;
563 _unlockLayerState();
564 return NO_ERROR;
565}
566
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700567status_t SurfaceComposerClient::setAlpha(SurfaceID id, float alpha)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800568{
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700569 layer_state_t* s = _lockLayerState(id);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800570 if (!s) return BAD_INDEX;
571 s->what |= ISurfaceComposer::eAlphaChanged;
572 s->alpha = alpha;
573 _unlockLayerState();
574 return NO_ERROR;
575}
576
577status_t SurfaceComposerClient::setMatrix(
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700578 SurfaceID id,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800579 float dsdx, float dtdx,
580 float dsdy, float dtdy )
581{
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700582 layer_state_t* s = _lockLayerState(id);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800583 if (!s) return BAD_INDEX;
584 s->what |= ISurfaceComposer::eMatrixChanged;
585 layer_state_t::matrix22_t matrix;
586 matrix.dsdx = dsdx;
587 matrix.dtdx = dtdx;
588 matrix.dsdy = dsdy;
589 matrix.dtdy = dtdy;
590 s->matrix = matrix;
591 _unlockLayerState();
592 return NO_ERROR;
593}
594
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700595status_t SurfaceComposerClient::setFreezeTint(SurfaceID id, uint32_t tint)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800596{
Mathias Agopian6d2c0bc2009-04-16 16:19:50 -0700597 layer_state_t* s = _lockLayerState(id);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800598 if (!s) return BAD_INDEX;
599 s->what |= ISurfaceComposer::eFreezeTintChanged;
600 s->tint = tint;
601 _unlockLayerState();
602 return NO_ERROR;
603}
604
605}; // namespace android
606