blob: 72b27edaaada6492fb420b90cf013c671d6f1347 [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 "Surface"
18
19#include <stdint.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080020#include <errno.h>
21#include <sys/types.h>
22#include <sys/stat.h>
23
Mathias Agopiancbb288b2009-09-07 16:32:45 -070024#include <utils/CallStack.h>
Mathias Agopiana67932f2011-04-20 14:20:59 -070025#include <utils/Errors.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080026#include <utils/Log.h>
Mathias Agopiana67932f2011-04-20 14:20:59 -070027#include <utils/threads.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080028
Mathias Agopiana67932f2011-04-20 14:20:59 -070029#include <binder/IPCThreadState.h>
30
Mathias Agopian076b1cc2009-04-10 14:24:30 -070031#include <ui/DisplayInfo.h>
Mathias Agopian3330b202009-10-05 17:07:12 -070032#include <ui/GraphicBuffer.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080033#include <ui/Rect.h>
34
Mathias Agopian90ac7992012-02-25 18:48:35 -080035#include <gui/ISurface.h>
36#include <gui/ISurfaceComposer.h>
37#include <gui/Surface.h>
38#include <gui/SurfaceComposerClient.h>
39#include <gui/SurfaceTextureClient.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070040
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080041namespace android {
42
Mathias Agopian62185b72009-04-16 16:19:50 -070043// ============================================================================
44// SurfaceControl
45// ============================================================================
46
Mathias Agopian01b76682009-04-16 20:04:08 -070047SurfaceControl::SurfaceControl(
48 const sp<SurfaceComposerClient>& client,
Mathias Agopian62185b72009-04-16 16:19:50 -070049 const sp<ISurface>& surface,
Mathias Agopianc10d9d92011-07-20 16:46:11 -070050 const ISurfaceComposerClient::surface_data_t& data)
Mathias Agopian62185b72009-04-16 16:19:50 -070051 : mClient(client), mSurface(surface),
Mathias Agopianc10d9d92011-07-20 16:46:11 -070052 mToken(data.token), mIdentity(data.identity)
Mathias Agopian62185b72009-04-16 16:19:50 -070053{
54}
Mathias Agopian18d84462009-04-16 20:30:22 -070055
Mathias Agopian62185b72009-04-16 16:19:50 -070056SurfaceControl::~SurfaceControl()
57{
58 destroy();
59}
60
61void SurfaceControl::destroy()
62{
Mathias Agopian18d84462009-04-16 20:30:22 -070063 if (isValid()) {
Mathias Agopian62185b72009-04-16 16:19:50 -070064 mClient->destroySurface(mToken);
65 }
66
67 // clear all references and trigger an IPC now, to make sure things
68 // happen without delay, since these resources are quite heavy.
69 mClient.clear();
70 mSurface.clear();
71 IPCThreadState::self()->flushCommands();
72}
73
74void SurfaceControl::clear()
75{
76 // here, the window manager tells us explicitly that we should destroy
77 // the surface's resource. Soon after this call, it will also release
78 // its last reference (which will call the dtor); however, it is possible
79 // that a client living in the same process still holds references which
80 // would delay the call to the dtor -- that is why we need this explicit
81 // "clear()" call.
82 destroy();
83}
84
Mathias Agopian62185b72009-04-16 16:19:50 -070085bool SurfaceControl::isSameSurface(
86 const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs)
87{
88 if (lhs == 0 || rhs == 0)
89 return false;
90 return lhs->mSurface->asBinder() == rhs->mSurface->asBinder();
91}
92
Mathias Agopian01b76682009-04-16 20:04:08 -070093status_t SurfaceControl::setLayer(int32_t layer) {
Mathias Agopian963abad2009-11-13 15:26:29 -080094 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -070095 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -070096 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -070097 return client->setLayer(mToken, layer);
98}
99status_t SurfaceControl::setPosition(int32_t x, int32_t y) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800100 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700101 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700102 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700103 return client->setPosition(mToken, x, y);
104}
105status_t SurfaceControl::setSize(uint32_t w, uint32_t h) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800106 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700107 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700108 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700109 return client->setSize(mToken, w, h);
110}
111status_t SurfaceControl::hide() {
Mathias Agopian963abad2009-11-13 15:26:29 -0800112 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700113 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700114 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700115 return client->hide(mToken);
116}
117status_t SurfaceControl::show(int32_t layer) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800118 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700119 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700120 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700121 return client->show(mToken, layer);
122}
123status_t SurfaceControl::freeze() {
Mathias Agopian963abad2009-11-13 15:26:29 -0800124 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700125 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700126 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700127 return client->freeze(mToken);
128}
129status_t SurfaceControl::unfreeze() {
Mathias Agopian963abad2009-11-13 15:26:29 -0800130 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700131 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700132 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700133 return client->unfreeze(mToken);
134}
135status_t SurfaceControl::setFlags(uint32_t flags, uint32_t mask) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800136 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700137 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700138 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700139 return client->setFlags(mToken, flags, mask);
140}
141status_t SurfaceControl::setTransparentRegionHint(const Region& transparent) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800142 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700143 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700144 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700145 return client->setTransparentRegionHint(mToken, transparent);
146}
147status_t SurfaceControl::setAlpha(float alpha) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800148 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700149 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700150 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700151 return client->setAlpha(mToken, alpha);
152}
153status_t SurfaceControl::setMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800154 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700155 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700156 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700157 return client->setMatrix(mToken, dsdx, dtdx, dsdy, dtdy);
158}
159status_t SurfaceControl::setFreezeTint(uint32_t tint) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800160 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700161 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700162 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700163 return client->setFreezeTint(mToken, tint);
164}
Mathias Agopian62185b72009-04-16 16:19:50 -0700165
Mathias Agopian963abad2009-11-13 15:26:29 -0800166status_t SurfaceControl::validate() const
Mathias Agopian62185b72009-04-16 16:19:50 -0700167{
168 if (mToken<0 || mClient==0) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000169 ALOGE("invalid token (%d, identity=%u) or client (%p)",
Mathias Agopian62185b72009-04-16 16:19:50 -0700170 mToken, mIdentity, mClient.get());
171 return NO_INIT;
172 }
Mathias Agopian62185b72009-04-16 16:19:50 -0700173 return NO_ERROR;
174}
175
Mathias Agopian01b76682009-04-16 20:04:08 -0700176status_t SurfaceControl::writeSurfaceToParcel(
177 const sp<SurfaceControl>& control, Parcel* parcel)
178{
Mathias Agopian579b3f82010-06-08 19:54:15 -0700179 sp<ISurface> sur;
Mathias Agopian01b76682009-04-16 20:04:08 -0700180 uint32_t identity = 0;
Mathias Agopian01b76682009-04-16 20:04:08 -0700181 if (SurfaceControl::isValid(control)) {
Mathias Agopian01b76682009-04-16 20:04:08 -0700182 sur = control->mSurface;
Mathias Agopian579b3f82010-06-08 19:54:15 -0700183 identity = control->mIdentity;
Mathias Agopian01b76682009-04-16 20:04:08 -0700184 }
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700185 parcel->writeStrongBinder(sur!=0 ? sur->asBinder() : NULL);
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700186 parcel->writeStrongBinder(NULL); // NULL ISurfaceTexture in this case.
Mathias Agopian01b76682009-04-16 20:04:08 -0700187 parcel->writeInt32(identity);
Mathias Agopian01b76682009-04-16 20:04:08 -0700188 return NO_ERROR;
189}
190
191sp<Surface> SurfaceControl::getSurface() const
192{
193 Mutex::Autolock _l(mLock);
194 if (mSurfaceData == 0) {
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700195 sp<SurfaceControl> surface_control(const_cast<SurfaceControl*>(this));
196 mSurfaceData = new Surface(surface_control);
Mathias Agopian01b76682009-04-16 20:04:08 -0700197 }
198 return mSurfaceData;
199}
200
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700201// ============================================================================
202// Surface
203// ============================================================================
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800204
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700205// ---------------------------------------------------------------------------
206
Mathias Agopian01b76682009-04-16 20:04:08 -0700207Surface::Surface(const sp<SurfaceControl>& surface)
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700208 : SurfaceTextureClient(),
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700209 mSurface(surface->mSurface),
Mathias Agopianc10d9d92011-07-20 16:46:11 -0700210 mIdentity(surface->mIdentity)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800211{
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700212 sp<ISurfaceTexture> st;
213 if (mSurface != NULL) {
214 st = mSurface->getSurfaceTexture();
215 }
216 init(st);
Mathias Agopian01b76682009-04-16 20:04:08 -0700217}
Mathias Agopian62185b72009-04-16 16:19:50 -0700218
Mathias Agopiana0c30e92010-06-04 18:26:32 -0700219Surface::Surface(const Parcel& parcel, const sp<IBinder>& ref)
Mathias Agopianc10d9d92011-07-20 16:46:11 -0700220 : SurfaceTextureClient()
Mathias Agopian01b76682009-04-16 20:04:08 -0700221{
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700222 mSurface = interface_cast<ISurface>(ref);
223 sp<IBinder> st_binder(parcel.readStrongBinder());
224 sp<ISurfaceTexture> st;
225 if (st_binder != NULL) {
226 st = interface_cast<ISurfaceTexture>(st_binder);
227 } else if (mSurface != NULL) {
228 st = mSurface->getSurfaceTexture();
229 }
230
Mathias Agopian01b76682009-04-16 20:04:08 -0700231 mIdentity = parcel.readInt32();
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700232 init(st);
233}
234
235Surface::Surface(const sp<ISurfaceTexture>& st)
236 : SurfaceTextureClient(),
237 mSurface(NULL),
238 mIdentity(0)
239{
240 init(st);
Mathias Agopian01b76682009-04-16 20:04:08 -0700241}
242
Mathias Agopian579b3f82010-06-08 19:54:15 -0700243status_t Surface::writeToParcel(
244 const sp<Surface>& surface, Parcel* parcel)
245{
246 sp<ISurface> sur;
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700247 sp<ISurfaceTexture> st;
Mathias Agopian579b3f82010-06-08 19:54:15 -0700248 uint32_t identity = 0;
Mathias Agopian579b3f82010-06-08 19:54:15 -0700249 if (Surface::isValid(surface)) {
250 sur = surface->mSurface;
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700251 st = surface->getISurfaceTexture();
Mathias Agopian579b3f82010-06-08 19:54:15 -0700252 identity = surface->mIdentity;
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700253 } else if (surface != 0 &&
254 (surface->mSurface != NULL ||
255 surface->getISurfaceTexture() != NULL)) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000256 ALOGE("Parceling invalid surface with non-NULL ISurface/ISurfaceTexture as NULL: "
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700257 "mSurface = %p, surfaceTexture = %p, mIdentity = %d, ",
258 surface->mSurface.get(), surface->getISurfaceTexture().get(),
259 surface->mIdentity);
Mathias Agopian579b3f82010-06-08 19:54:15 -0700260 }
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700261
262 parcel->writeStrongBinder(sur != NULL ? sur->asBinder() : NULL);
263 parcel->writeStrongBinder(st != NULL ? st->asBinder() : NULL);
Mathias Agopian579b3f82010-06-08 19:54:15 -0700264 parcel->writeInt32(identity);
Mathias Agopian579b3f82010-06-08 19:54:15 -0700265 return NO_ERROR;
266
267}
268
Jamie Gennisaca4e222010-07-15 17:29:15 -0700269Mutex Surface::sCachedSurfacesLock;
Mathias Agopian455d18d2010-12-13 16:47:31 -0800270DefaultKeyedVector<wp<IBinder>, wp<Surface> > Surface::sCachedSurfaces;
Jamie Gennisaca4e222010-07-15 17:29:15 -0700271
272sp<Surface> Surface::readFromParcel(const Parcel& data) {
273 Mutex::Autolock _l(sCachedSurfacesLock);
Mathias Agopiana0c30e92010-06-04 18:26:32 -0700274 sp<IBinder> binder(data.readStrongBinder());
Jamie Gennisaca4e222010-07-15 17:29:15 -0700275 sp<Surface> surface = sCachedSurfaces.valueFor(binder).promote();
276 if (surface == 0) {
277 surface = new Surface(data, binder);
278 sCachedSurfaces.add(binder, surface);
Ted Bonkenburge5d6eb82011-08-09 22:38:41 -0700279 } else {
280 // The Surface was found in the cache, but we still should clear any
281 // remaining data from the parcel.
282 data.readStrongBinder(); // ISurfaceTexture
283 data.readInt32(); // identity
Mathias Agopiana0c30e92010-06-04 18:26:32 -0700284 }
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700285 if (surface->mSurface == NULL && surface->getISurfaceTexture() == NULL) {
286 surface = 0;
Jamie Gennisaca4e222010-07-15 17:29:15 -0700287 }
Mathias Agopian455d18d2010-12-13 16:47:31 -0800288 cleanCachedSurfacesLocked();
Jamie Gennisaca4e222010-07-15 17:29:15 -0700289 return surface;
290}
291
292// Remove the stale entries from the surface cache. This should only be called
293// with sCachedSurfacesLock held.
Mathias Agopian455d18d2010-12-13 16:47:31 -0800294void Surface::cleanCachedSurfacesLocked() {
Jamie Gennisaca4e222010-07-15 17:29:15 -0700295 for (int i = sCachedSurfaces.size()-1; i >= 0; --i) {
296 wp<Surface> s(sCachedSurfaces.valueAt(i));
297 if (s == 0 || s.promote() == 0) {
298 sCachedSurfaces.removeItemsAt(i);
299 }
300 }
Mathias Agopiana0c30e92010-06-04 18:26:32 -0700301}
302
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700303void Surface::init(const sp<ISurfaceTexture>& surfaceTexture)
Mathias Agopian01b76682009-04-16 20:04:08 -0700304{
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700305 if (mSurface != NULL || surfaceTexture != NULL) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000306 ALOGE_IF(surfaceTexture==0, "got a NULL ISurfaceTexture from ISurface");
Mathias Agopiana67932f2011-04-20 14:20:59 -0700307 if (surfaceTexture != NULL) {
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700308 setISurfaceTexture(surfaceTexture);
309 setUsage(GraphicBuffer::USAGE_HW_RENDER);
Mathias Agopiana67932f2011-04-20 14:20:59 -0700310 }
Mathias Agopian631f3582010-05-25 17:51:34 -0700311
Mathias Agopiana67932f2011-04-20 14:20:59 -0700312 DisplayInfo dinfo;
313 SurfaceComposerClient::getDisplayInfo(0, &dinfo);
314 const_cast<float&>(ANativeWindow::xdpi) = dinfo.xdpi;
315 const_cast<float&>(ANativeWindow::ydpi) = dinfo.ydpi;
Mathias Agopiana67932f2011-04-20 14:20:59 -0700316 const_cast<uint32_t&>(ANativeWindow::flags) = 0;
Mathias Agopian631f3582010-05-25 17:51:34 -0700317 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800318}
319
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800320Surface::~Surface()
321{
Mathias Agopian40b7f6e2009-04-14 18:21:47 -0700322 // clear all references and trigger an IPC now, to make sure things
323 // happen without delay, since these resources are quite heavy.
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800324 mSurface.clear();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800325 IPCThreadState::self()->flushCommands();
326}
327
Mathias Agopian631f3582010-05-25 17:51:34 -0700328bool Surface::isValid() {
Mathias Agopianc10d9d92011-07-20 16:46:11 -0700329 return getISurfaceTexture() != NULL;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800330}
331
tedbo1e7fa9e2011-06-22 15:52:53 -0700332sp<ISurfaceTexture> Surface::getSurfaceTexture() {
Mathias Agopianc10d9d92011-07-20 16:46:11 -0700333 return getISurfaceTexture();
tedbo1e7fa9e2011-06-22 15:52:53 -0700334}
335
Mathias Agopian47d87302011-04-05 15:44:20 -0700336sp<IBinder> Surface::asBinder() const {
337 return mSurface!=0 ? mSurface->asBinder() : 0;
Mathias Agopian631f3582010-05-25 17:51:34 -0700338}
339
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700340// ----------------------------------------------------------------------------
341
Mathias Agopiana67932f2011-04-20 14:20:59 -0700342int Surface::query(int what, int* value) const {
Mathias Agopiancb6b9042009-07-30 18:14:56 -0700343 switch (what) {
Jamie Gennis391bbe22011-03-14 15:00:06 -0700344 case NATIVE_WINDOW_CONCRETE_TYPE:
345 *value = NATIVE_WINDOW_SURFACE;
346 return NO_ERROR;
347 }
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700348 return SurfaceTextureClient::query(what, value);
Eino-Ville Talvala1d01a122011-02-18 11:02:42 -0800349}
350
Mathias Agopiana138f892010-05-21 17:24:35 -0700351// ----------------------------------------------------------------------------
352
Mathias Agopian87a96ea2011-08-23 21:09:41 -0700353status_t Surface::lock(SurfaceInfo* other, Region* inOutDirtyRegion) {
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700354 ANativeWindow_Buffer outBuffer;
Mathias Agopian55fa2512010-03-11 15:06:54 -0800355
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700356 ARect temp;
357 ARect* inOutDirtyBounds = NULL;
Mathias Agopian87a96ea2011-08-23 21:09:41 -0700358 if (inOutDirtyRegion) {
359 temp = inOutDirtyRegion->getBounds();
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700360 inOutDirtyBounds = &temp;
Mathias Agopian55fa2512010-03-11 15:06:54 -0800361 }
362
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700363 status_t err = SurfaceTextureClient::lock(&outBuffer, inOutDirtyBounds);
Mathias Agopian90147262010-01-22 11:47:55 -0800364
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700365 if (err == NO_ERROR) {
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700366 other->w = uint32_t(outBuffer.width);
367 other->h = uint32_t(outBuffer.height);
368 other->s = uint32_t(outBuffer.stride);
369 other->usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN;
370 other->format = uint32_t(outBuffer.format);
371 other->bits = outBuffer.bits;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700372 }
Mathias Agopian87a96ea2011-08-23 21:09:41 -0700373
374 if (inOutDirtyRegion) {
375 inOutDirtyRegion->set( static_cast<Rect const&>(temp) );
376 }
377
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700378 return err;
379}
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700380
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700381status_t Surface::unlockAndPost() {
382 return SurfaceTextureClient::unlockAndPost();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800383}
384
Mathias Agopiana138f892010-05-21 17:24:35 -0700385// ----------------------------------------------------------------------------
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800386}; // namespace android