blob: 059f3136df5e832c77cb54482d45c55a85e61449 [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 Agopianb0e76f42012-03-23 14:15:44 -070024#include <android/native_window.h>
25
Mathias Agopiancbb288b2009-09-07 16:32:45 -070026#include <utils/CallStack.h>
Mathias Agopiana67932f2011-04-20 14:20:59 -070027#include <utils/Errors.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080028#include <utils/Log.h>
Mathias Agopiana67932f2011-04-20 14:20:59 -070029#include <utils/threads.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080030
Mathias Agopiana67932f2011-04-20 14:20:59 -070031#include <binder/IPCThreadState.h>
32
Mathias Agopian076b1cc2009-04-10 14:24:30 -070033#include <ui/DisplayInfo.h>
Mathias Agopian3330b202009-10-05 17:07:12 -070034#include <ui/GraphicBuffer.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080035#include <ui/Rect.h>
36
Mathias Agopian90ac7992012-02-25 18:48:35 -080037#include <gui/ISurface.h>
38#include <gui/ISurfaceComposer.h>
39#include <gui/Surface.h>
40#include <gui/SurfaceComposerClient.h>
41#include <gui/SurfaceTextureClient.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070042
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080043namespace android {
44
Mathias Agopian62185b72009-04-16 16:19:50 -070045// ============================================================================
46// SurfaceControl
47// ============================================================================
48
Mathias Agopian01b76682009-04-16 20:04:08 -070049SurfaceControl::SurfaceControl(
50 const sp<SurfaceComposerClient>& client,
Mathias Agopian62185b72009-04-16 16:19:50 -070051 const sp<ISurface>& surface,
Mathias Agopianc10d9d92011-07-20 16:46:11 -070052 const ISurfaceComposerClient::surface_data_t& data)
Mathias Agopian62185b72009-04-16 16:19:50 -070053 : mClient(client), mSurface(surface),
Mathias Agopianc10d9d92011-07-20 16:46:11 -070054 mToken(data.token), mIdentity(data.identity)
Mathias Agopian62185b72009-04-16 16:19:50 -070055{
56}
Mathias Agopian18d84462009-04-16 20:30:22 -070057
Mathias Agopian62185b72009-04-16 16:19:50 -070058SurfaceControl::~SurfaceControl()
59{
60 destroy();
61}
62
63void SurfaceControl::destroy()
64{
Mathias Agopian18d84462009-04-16 20:30:22 -070065 if (isValid()) {
Mathias Agopian62185b72009-04-16 16:19:50 -070066 mClient->destroySurface(mToken);
67 }
68
69 // clear all references and trigger an IPC now, to make sure things
70 // happen without delay, since these resources are quite heavy.
71 mClient.clear();
72 mSurface.clear();
73 IPCThreadState::self()->flushCommands();
74}
75
76void SurfaceControl::clear()
77{
78 // here, the window manager tells us explicitly that we should destroy
79 // the surface's resource. Soon after this call, it will also release
80 // its last reference (which will call the dtor); however, it is possible
81 // that a client living in the same process still holds references which
82 // would delay the call to the dtor -- that is why we need this explicit
83 // "clear()" call.
84 destroy();
85}
86
Mathias Agopian62185b72009-04-16 16:19:50 -070087bool SurfaceControl::isSameSurface(
88 const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs)
89{
90 if (lhs == 0 || rhs == 0)
91 return false;
92 return lhs->mSurface->asBinder() == rhs->mSurface->asBinder();
93}
94
Mathias Agopian01b76682009-04-16 20:04:08 -070095status_t SurfaceControl::setLayer(int32_t layer) {
Mathias Agopian963abad2009-11-13 15:26:29 -080096 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -070097 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -070098 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -070099 return client->setLayer(mToken, layer);
100}
101status_t SurfaceControl::setPosition(int32_t x, int32_t y) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800102 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700103 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700104 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700105 return client->setPosition(mToken, x, y);
106}
107status_t SurfaceControl::setSize(uint32_t w, uint32_t h) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800108 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700109 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700110 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700111 return client->setSize(mToken, w, h);
112}
113status_t SurfaceControl::hide() {
Mathias Agopian963abad2009-11-13 15:26:29 -0800114 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700115 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700116 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700117 return client->hide(mToken);
118}
119status_t SurfaceControl::show(int32_t layer) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800120 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700121 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700122 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700123 return client->show(mToken, layer);
124}
125status_t SurfaceControl::freeze() {
Mathias Agopian963abad2009-11-13 15:26:29 -0800126 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700127 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700128 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700129 return client->freeze(mToken);
130}
131status_t SurfaceControl::unfreeze() {
Mathias Agopian963abad2009-11-13 15:26:29 -0800132 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700133 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700134 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700135 return client->unfreeze(mToken);
136}
137status_t SurfaceControl::setFlags(uint32_t flags, uint32_t mask) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800138 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700139 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700140 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700141 return client->setFlags(mToken, flags, mask);
142}
143status_t SurfaceControl::setTransparentRegionHint(const Region& transparent) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800144 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700145 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700146 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700147 return client->setTransparentRegionHint(mToken, transparent);
148}
149status_t SurfaceControl::setAlpha(float alpha) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800150 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700151 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700152 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700153 return client->setAlpha(mToken, alpha);
154}
155status_t SurfaceControl::setMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800156 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700157 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700158 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700159 return client->setMatrix(mToken, dsdx, dtdx, dsdy, dtdy);
160}
161status_t SurfaceControl::setFreezeTint(uint32_t tint) {
Mathias Agopian963abad2009-11-13 15:26:29 -0800162 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700163 if (err < 0) return err;
Mathias Agopian631f3582010-05-25 17:51:34 -0700164 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian01b76682009-04-16 20:04:08 -0700165 return client->setFreezeTint(mToken, tint);
166}
Mathias Agopian62185b72009-04-16 16:19:50 -0700167
Mathias Agopian963abad2009-11-13 15:26:29 -0800168status_t SurfaceControl::validate() const
Mathias Agopian62185b72009-04-16 16:19:50 -0700169{
170 if (mToken<0 || mClient==0) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000171 ALOGE("invalid token (%d, identity=%u) or client (%p)",
Mathias Agopian62185b72009-04-16 16:19:50 -0700172 mToken, mIdentity, mClient.get());
173 return NO_INIT;
174 }
Mathias Agopian62185b72009-04-16 16:19:50 -0700175 return NO_ERROR;
176}
177
Mathias Agopian01b76682009-04-16 20:04:08 -0700178status_t SurfaceControl::writeSurfaceToParcel(
179 const sp<SurfaceControl>& control, Parcel* parcel)
180{
Mathias Agopian579b3f82010-06-08 19:54:15 -0700181 sp<ISurface> sur;
Mathias Agopian01b76682009-04-16 20:04:08 -0700182 uint32_t identity = 0;
Mathias Agopian01b76682009-04-16 20:04:08 -0700183 if (SurfaceControl::isValid(control)) {
Mathias Agopian01b76682009-04-16 20:04:08 -0700184 sur = control->mSurface;
Mathias Agopian579b3f82010-06-08 19:54:15 -0700185 identity = control->mIdentity;
Mathias Agopian01b76682009-04-16 20:04:08 -0700186 }
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700187 parcel->writeStrongBinder(sur!=0 ? sur->asBinder() : NULL);
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700188 parcel->writeStrongBinder(NULL); // NULL ISurfaceTexture in this case.
Mathias Agopian01b76682009-04-16 20:04:08 -0700189 parcel->writeInt32(identity);
Mathias Agopian01b76682009-04-16 20:04:08 -0700190 return NO_ERROR;
191}
192
193sp<Surface> SurfaceControl::getSurface() const
194{
195 Mutex::Autolock _l(mLock);
196 if (mSurfaceData == 0) {
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700197 sp<SurfaceControl> surface_control(const_cast<SurfaceControl*>(this));
198 mSurfaceData = new Surface(surface_control);
Mathias Agopian01b76682009-04-16 20:04:08 -0700199 }
200 return mSurfaceData;
201}
202
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700203// ============================================================================
204// Surface
205// ============================================================================
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800206
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700207// ---------------------------------------------------------------------------
208
Mathias Agopian01b76682009-04-16 20:04:08 -0700209Surface::Surface(const sp<SurfaceControl>& surface)
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700210 : SurfaceTextureClient(),
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700211 mSurface(surface->mSurface),
Mathias Agopianc10d9d92011-07-20 16:46:11 -0700212 mIdentity(surface->mIdentity)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800213{
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700214 sp<ISurfaceTexture> st;
215 if (mSurface != NULL) {
216 st = mSurface->getSurfaceTexture();
217 }
218 init(st);
Mathias Agopian01b76682009-04-16 20:04:08 -0700219}
Mathias Agopian62185b72009-04-16 16:19:50 -0700220
Mathias Agopiana0c30e92010-06-04 18:26:32 -0700221Surface::Surface(const Parcel& parcel, const sp<IBinder>& ref)
Mathias Agopianc10d9d92011-07-20 16:46:11 -0700222 : SurfaceTextureClient()
Mathias Agopian01b76682009-04-16 20:04:08 -0700223{
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700224 mSurface = interface_cast<ISurface>(ref);
225 sp<IBinder> st_binder(parcel.readStrongBinder());
226 sp<ISurfaceTexture> st;
227 if (st_binder != NULL) {
228 st = interface_cast<ISurfaceTexture>(st_binder);
229 } else if (mSurface != NULL) {
230 st = mSurface->getSurfaceTexture();
231 }
232
Mathias Agopian01b76682009-04-16 20:04:08 -0700233 mIdentity = parcel.readInt32();
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700234 init(st);
235}
236
237Surface::Surface(const sp<ISurfaceTexture>& st)
238 : SurfaceTextureClient(),
239 mSurface(NULL),
240 mIdentity(0)
241{
242 init(st);
Mathias Agopian01b76682009-04-16 20:04:08 -0700243}
244
Mathias Agopian579b3f82010-06-08 19:54:15 -0700245status_t Surface::writeToParcel(
246 const sp<Surface>& surface, Parcel* parcel)
247{
248 sp<ISurface> sur;
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700249 sp<ISurfaceTexture> st;
Mathias Agopian579b3f82010-06-08 19:54:15 -0700250 uint32_t identity = 0;
Mathias Agopian579b3f82010-06-08 19:54:15 -0700251 if (Surface::isValid(surface)) {
252 sur = surface->mSurface;
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700253 st = surface->getISurfaceTexture();
Mathias Agopian579b3f82010-06-08 19:54:15 -0700254 identity = surface->mIdentity;
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700255 } else if (surface != 0 &&
256 (surface->mSurface != NULL ||
257 surface->getISurfaceTexture() != NULL)) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000258 ALOGE("Parceling invalid surface with non-NULL ISurface/ISurfaceTexture as NULL: "
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700259 "mSurface = %p, surfaceTexture = %p, mIdentity = %d, ",
260 surface->mSurface.get(), surface->getISurfaceTexture().get(),
261 surface->mIdentity);
Mathias Agopian579b3f82010-06-08 19:54:15 -0700262 }
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700263
264 parcel->writeStrongBinder(sur != NULL ? sur->asBinder() : NULL);
265 parcel->writeStrongBinder(st != NULL ? st->asBinder() : NULL);
Mathias Agopian579b3f82010-06-08 19:54:15 -0700266 parcel->writeInt32(identity);
Mathias Agopian579b3f82010-06-08 19:54:15 -0700267 return NO_ERROR;
268
269}
270
Jamie Gennisaca4e222010-07-15 17:29:15 -0700271Mutex Surface::sCachedSurfacesLock;
Mathias Agopian455d18d2010-12-13 16:47:31 -0800272DefaultKeyedVector<wp<IBinder>, wp<Surface> > Surface::sCachedSurfaces;
Jamie Gennisaca4e222010-07-15 17:29:15 -0700273
274sp<Surface> Surface::readFromParcel(const Parcel& data) {
275 Mutex::Autolock _l(sCachedSurfacesLock);
Mathias Agopiana0c30e92010-06-04 18:26:32 -0700276 sp<IBinder> binder(data.readStrongBinder());
Jamie Gennisaca4e222010-07-15 17:29:15 -0700277 sp<Surface> surface = sCachedSurfaces.valueFor(binder).promote();
278 if (surface == 0) {
279 surface = new Surface(data, binder);
280 sCachedSurfaces.add(binder, surface);
Ted Bonkenburge5d6eb82011-08-09 22:38:41 -0700281 } else {
282 // The Surface was found in the cache, but we still should clear any
283 // remaining data from the parcel.
284 data.readStrongBinder(); // ISurfaceTexture
285 data.readInt32(); // identity
Mathias Agopiana0c30e92010-06-04 18:26:32 -0700286 }
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700287 if (surface->mSurface == NULL && surface->getISurfaceTexture() == NULL) {
288 surface = 0;
Jamie Gennisaca4e222010-07-15 17:29:15 -0700289 }
Mathias Agopian455d18d2010-12-13 16:47:31 -0800290 cleanCachedSurfacesLocked();
Jamie Gennisaca4e222010-07-15 17:29:15 -0700291 return surface;
292}
293
294// Remove the stale entries from the surface cache. This should only be called
295// with sCachedSurfacesLock held.
Mathias Agopian455d18d2010-12-13 16:47:31 -0800296void Surface::cleanCachedSurfacesLocked() {
Jamie Gennisaca4e222010-07-15 17:29:15 -0700297 for (int i = sCachedSurfaces.size()-1; i >= 0; --i) {
298 wp<Surface> s(sCachedSurfaces.valueAt(i));
299 if (s == 0 || s.promote() == 0) {
300 sCachedSurfaces.removeItemsAt(i);
301 }
302 }
Mathias Agopiana0c30e92010-06-04 18:26:32 -0700303}
304
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700305void Surface::init(const sp<ISurfaceTexture>& surfaceTexture)
Mathias Agopian01b76682009-04-16 20:04:08 -0700306{
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700307 if (mSurface != NULL || surfaceTexture != NULL) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000308 ALOGE_IF(surfaceTexture==0, "got a NULL ISurfaceTexture from ISurface");
Mathias Agopiana67932f2011-04-20 14:20:59 -0700309 if (surfaceTexture != NULL) {
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700310 setISurfaceTexture(surfaceTexture);
311 setUsage(GraphicBuffer::USAGE_HW_RENDER);
Mathias Agopiana67932f2011-04-20 14:20:59 -0700312 }
Mathias Agopian631f3582010-05-25 17:51:34 -0700313
Mathias Agopiana67932f2011-04-20 14:20:59 -0700314 DisplayInfo dinfo;
315 SurfaceComposerClient::getDisplayInfo(0, &dinfo);
316 const_cast<float&>(ANativeWindow::xdpi) = dinfo.xdpi;
317 const_cast<float&>(ANativeWindow::ydpi) = dinfo.ydpi;
Mathias Agopiana67932f2011-04-20 14:20:59 -0700318 const_cast<uint32_t&>(ANativeWindow::flags) = 0;
Mathias Agopian631f3582010-05-25 17:51:34 -0700319 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800320}
321
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800322Surface::~Surface()
323{
Mathias Agopian40b7f6e2009-04-14 18:21:47 -0700324 // clear all references and trigger an IPC now, to make sure things
325 // happen without delay, since these resources are quite heavy.
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800326 mSurface.clear();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800327 IPCThreadState::self()->flushCommands();
328}
329
Mathias Agopian631f3582010-05-25 17:51:34 -0700330bool Surface::isValid() {
Mathias Agopianc10d9d92011-07-20 16:46:11 -0700331 return getISurfaceTexture() != NULL;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800332}
333
tedbo1e7fa9e2011-06-22 15:52:53 -0700334sp<ISurfaceTexture> Surface::getSurfaceTexture() {
Mathias Agopianc10d9d92011-07-20 16:46:11 -0700335 return getISurfaceTexture();
tedbo1e7fa9e2011-06-22 15:52:53 -0700336}
337
Mathias Agopian47d87302011-04-05 15:44:20 -0700338sp<IBinder> Surface::asBinder() const {
339 return mSurface!=0 ? mSurface->asBinder() : 0;
Mathias Agopian631f3582010-05-25 17:51:34 -0700340}
341
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700342// ----------------------------------------------------------------------------
343
Mathias Agopiana67932f2011-04-20 14:20:59 -0700344int Surface::query(int what, int* value) const {
Mathias Agopiancb6b9042009-07-30 18:14:56 -0700345 switch (what) {
Jamie Gennis391bbe22011-03-14 15:00:06 -0700346 case NATIVE_WINDOW_CONCRETE_TYPE:
347 *value = NATIVE_WINDOW_SURFACE;
348 return NO_ERROR;
349 }
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700350 return SurfaceTextureClient::query(what, value);
Eino-Ville Talvala1d01a122011-02-18 11:02:42 -0800351}
352
Mathias Agopiana138f892010-05-21 17:24:35 -0700353// ----------------------------------------------------------------------------
354
Mathias Agopian87a96ea2011-08-23 21:09:41 -0700355status_t Surface::lock(SurfaceInfo* other, Region* inOutDirtyRegion) {
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700356 ANativeWindow_Buffer outBuffer;
Mathias Agopian55fa2512010-03-11 15:06:54 -0800357
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700358 ARect temp;
359 ARect* inOutDirtyBounds = NULL;
Mathias Agopian87a96ea2011-08-23 21:09:41 -0700360 if (inOutDirtyRegion) {
361 temp = inOutDirtyRegion->getBounds();
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700362 inOutDirtyBounds = &temp;
Mathias Agopian55fa2512010-03-11 15:06:54 -0800363 }
364
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700365 status_t err = SurfaceTextureClient::lock(&outBuffer, inOutDirtyBounds);
Mathias Agopian90147262010-01-22 11:47:55 -0800366
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700367 if (err == NO_ERROR) {
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700368 other->w = uint32_t(outBuffer.width);
369 other->h = uint32_t(outBuffer.height);
370 other->s = uint32_t(outBuffer.stride);
371 other->usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN;
372 other->format = uint32_t(outBuffer.format);
373 other->bits = outBuffer.bits;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700374 }
Mathias Agopian87a96ea2011-08-23 21:09:41 -0700375
376 if (inOutDirtyRegion) {
377 inOutDirtyRegion->set( static_cast<Rect const&>(temp) );
378 }
379
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700380 return err;
381}
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700382
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700383status_t Surface::unlockAndPost() {
384 return SurfaceTextureClient::unlockAndPost();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800385}
386
Mathias Agopiana138f892010-05-21 17:24:35 -0700387// ----------------------------------------------------------------------------
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800388}; // namespace android