blob: 33cc48023eeb6692b40b6036fc941b8aa3d5931b [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
Jeff Brown9d4e3d22012-08-24 20:00:51 -070095status_t SurfaceControl::setLayerStack(int32_t layerStack) {
96 status_t err = validate();
97 if (err < 0) return err;
98 const sp<SurfaceComposerClient>& client(mClient);
99 return client->setLayerStack(mToken, layerStack);
100}
Mathias Agopian01b76682009-04-16 20:04:08 -0700101status_t SurfaceControl::setLayer(int32_t layer) {
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->setLayer(mToken, layer);
106}
107status_t SurfaceControl::setPosition(int32_t x, int32_t y) {
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->setPosition(mToken, x, y);
112}
113status_t SurfaceControl::setSize(uint32_t w, uint32_t h) {
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->setSize(mToken, w, h);
118}
119status_t SurfaceControl::hide() {
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->hide(mToken);
124}
125status_t SurfaceControl::show(int32_t layer) {
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->show(mToken, layer);
130}
Mathias Agopian01b76682009-04-16 20:04:08 -0700131status_t SurfaceControl::setFlags(uint32_t flags, uint32_t mask) {
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->setFlags(mToken, flags, mask);
136}
137status_t SurfaceControl::setTransparentRegionHint(const Region& transparent) {
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->setTransparentRegionHint(mToken, transparent);
142}
143status_t SurfaceControl::setAlpha(float alpha) {
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->setAlpha(mToken, alpha);
148}
149status_t SurfaceControl::setMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
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->setMatrix(mToken, dsdx, dtdx, dsdy, dtdy);
154}
Jamie Gennisf15a83f2012-05-10 20:43:55 -0700155status_t SurfaceControl::setCrop(const Rect& crop) {
156 status_t err = validate();
157 if (err < 0) return err;
158 const sp<SurfaceComposerClient>& client(mClient);
159 return client->setCrop(mToken, crop);
160}
Mathias Agopian62185b72009-04-16 16:19:50 -0700161
Mathias Agopian963abad2009-11-13 15:26:29 -0800162status_t SurfaceControl::validate() const
Mathias Agopian62185b72009-04-16 16:19:50 -0700163{
164 if (mToken<0 || mClient==0) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000165 ALOGE("invalid token (%d, identity=%u) or client (%p)",
Mathias Agopian62185b72009-04-16 16:19:50 -0700166 mToken, mIdentity, mClient.get());
167 return NO_INIT;
168 }
Mathias Agopian62185b72009-04-16 16:19:50 -0700169 return NO_ERROR;
170}
171
Mathias Agopian01b76682009-04-16 20:04:08 -0700172status_t SurfaceControl::writeSurfaceToParcel(
173 const sp<SurfaceControl>& control, Parcel* parcel)
174{
Mathias Agopian579b3f82010-06-08 19:54:15 -0700175 sp<ISurface> sur;
Mathias Agopian01b76682009-04-16 20:04:08 -0700176 uint32_t identity = 0;
Mathias Agopian01b76682009-04-16 20:04:08 -0700177 if (SurfaceControl::isValid(control)) {
Mathias Agopian01b76682009-04-16 20:04:08 -0700178 sur = control->mSurface;
Mathias Agopian579b3f82010-06-08 19:54:15 -0700179 identity = control->mIdentity;
Mathias Agopian01b76682009-04-16 20:04:08 -0700180 }
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700181 parcel->writeStrongBinder(sur!=0 ? sur->asBinder() : NULL);
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700182 parcel->writeStrongBinder(NULL); // NULL ISurfaceTexture in this case.
Mathias Agopian01b76682009-04-16 20:04:08 -0700183 parcel->writeInt32(identity);
Mathias Agopian01b76682009-04-16 20:04:08 -0700184 return NO_ERROR;
185}
186
187sp<Surface> SurfaceControl::getSurface() const
188{
189 Mutex::Autolock _l(mLock);
190 if (mSurfaceData == 0) {
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700191 sp<SurfaceControl> surface_control(const_cast<SurfaceControl*>(this));
192 mSurfaceData = new Surface(surface_control);
Mathias Agopian01b76682009-04-16 20:04:08 -0700193 }
194 return mSurfaceData;
195}
196
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700197// ============================================================================
198// Surface
199// ============================================================================
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800200
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700201// ---------------------------------------------------------------------------
202
Mathias Agopian01b76682009-04-16 20:04:08 -0700203Surface::Surface(const sp<SurfaceControl>& surface)
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700204 : SurfaceTextureClient(),
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700205 mSurface(surface->mSurface),
Mathias Agopianc10d9d92011-07-20 16:46:11 -0700206 mIdentity(surface->mIdentity)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800207{
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700208 sp<ISurfaceTexture> st;
209 if (mSurface != NULL) {
210 st = mSurface->getSurfaceTexture();
211 }
212 init(st);
Mathias Agopian01b76682009-04-16 20:04:08 -0700213}
Mathias Agopian62185b72009-04-16 16:19:50 -0700214
Mathias Agopiana0c30e92010-06-04 18:26:32 -0700215Surface::Surface(const Parcel& parcel, const sp<IBinder>& ref)
Mathias Agopianc10d9d92011-07-20 16:46:11 -0700216 : SurfaceTextureClient()
Mathias Agopian01b76682009-04-16 20:04:08 -0700217{
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700218 mSurface = interface_cast<ISurface>(ref);
219 sp<IBinder> st_binder(parcel.readStrongBinder());
220 sp<ISurfaceTexture> st;
221 if (st_binder != NULL) {
222 st = interface_cast<ISurfaceTexture>(st_binder);
223 } else if (mSurface != NULL) {
224 st = mSurface->getSurfaceTexture();
225 }
226
Mathias Agopian01b76682009-04-16 20:04:08 -0700227 mIdentity = parcel.readInt32();
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700228 init(st);
229}
230
231Surface::Surface(const sp<ISurfaceTexture>& st)
232 : SurfaceTextureClient(),
233 mSurface(NULL),
234 mIdentity(0)
235{
236 init(st);
Mathias Agopian01b76682009-04-16 20:04:08 -0700237}
238
Mathias Agopian579b3f82010-06-08 19:54:15 -0700239status_t Surface::writeToParcel(
240 const sp<Surface>& surface, Parcel* parcel)
241{
242 sp<ISurface> sur;
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700243 sp<ISurfaceTexture> st;
Mathias Agopian579b3f82010-06-08 19:54:15 -0700244 uint32_t identity = 0;
Mathias Agopian579b3f82010-06-08 19:54:15 -0700245 if (Surface::isValid(surface)) {
246 sur = surface->mSurface;
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700247 st = surface->getISurfaceTexture();
Mathias Agopian579b3f82010-06-08 19:54:15 -0700248 identity = surface->mIdentity;
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700249 } else if (surface != 0 &&
250 (surface->mSurface != NULL ||
251 surface->getISurfaceTexture() != NULL)) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000252 ALOGE("Parceling invalid surface with non-NULL ISurface/ISurfaceTexture as NULL: "
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700253 "mSurface = %p, surfaceTexture = %p, mIdentity = %d, ",
254 surface->mSurface.get(), surface->getISurfaceTexture().get(),
255 surface->mIdentity);
Mathias Agopian579b3f82010-06-08 19:54:15 -0700256 }
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700257
258 parcel->writeStrongBinder(sur != NULL ? sur->asBinder() : NULL);
259 parcel->writeStrongBinder(st != NULL ? st->asBinder() : NULL);
Mathias Agopian579b3f82010-06-08 19:54:15 -0700260 parcel->writeInt32(identity);
Mathias Agopian579b3f82010-06-08 19:54:15 -0700261 return NO_ERROR;
262
263}
264
Jamie Gennisaca4e222010-07-15 17:29:15 -0700265Mutex Surface::sCachedSurfacesLock;
Mathias Agopian455d18d2010-12-13 16:47:31 -0800266DefaultKeyedVector<wp<IBinder>, wp<Surface> > Surface::sCachedSurfaces;
Jamie Gennisaca4e222010-07-15 17:29:15 -0700267
268sp<Surface> Surface::readFromParcel(const Parcel& data) {
269 Mutex::Autolock _l(sCachedSurfacesLock);
Mathias Agopiana0c30e92010-06-04 18:26:32 -0700270 sp<IBinder> binder(data.readStrongBinder());
Jamie Gennisaca4e222010-07-15 17:29:15 -0700271 sp<Surface> surface = sCachedSurfaces.valueFor(binder).promote();
272 if (surface == 0) {
273 surface = new Surface(data, binder);
274 sCachedSurfaces.add(binder, surface);
Ted Bonkenburge5d6eb82011-08-09 22:38:41 -0700275 } else {
276 // The Surface was found in the cache, but we still should clear any
277 // remaining data from the parcel.
278 data.readStrongBinder(); // ISurfaceTexture
279 data.readInt32(); // identity
Mathias Agopiana0c30e92010-06-04 18:26:32 -0700280 }
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700281 if (surface->mSurface == NULL && surface->getISurfaceTexture() == NULL) {
282 surface = 0;
Jamie Gennisaca4e222010-07-15 17:29:15 -0700283 }
Mathias Agopian455d18d2010-12-13 16:47:31 -0800284 cleanCachedSurfacesLocked();
Jamie Gennisaca4e222010-07-15 17:29:15 -0700285 return surface;
286}
287
288// Remove the stale entries from the surface cache. This should only be called
289// with sCachedSurfacesLock held.
Mathias Agopian455d18d2010-12-13 16:47:31 -0800290void Surface::cleanCachedSurfacesLocked() {
Jamie Gennisaca4e222010-07-15 17:29:15 -0700291 for (int i = sCachedSurfaces.size()-1; i >= 0; --i) {
292 wp<Surface> s(sCachedSurfaces.valueAt(i));
293 if (s == 0 || s.promote() == 0) {
294 sCachedSurfaces.removeItemsAt(i);
295 }
296 }
Mathias Agopiana0c30e92010-06-04 18:26:32 -0700297}
298
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700299void Surface::init(const sp<ISurfaceTexture>& surfaceTexture)
Mathias Agopian01b76682009-04-16 20:04:08 -0700300{
Ted Bonkenburgbd050ab2011-07-15 15:10:10 -0700301 if (mSurface != NULL || surfaceTexture != NULL) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000302 ALOGE_IF(surfaceTexture==0, "got a NULL ISurfaceTexture from ISurface");
Mathias Agopiana67932f2011-04-20 14:20:59 -0700303 if (surfaceTexture != NULL) {
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700304 setISurfaceTexture(surfaceTexture);
305 setUsage(GraphicBuffer::USAGE_HW_RENDER);
Mathias Agopiana67932f2011-04-20 14:20:59 -0700306 }
Mathias Agopian631f3582010-05-25 17:51:34 -0700307
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700308 // TODO: the display metrics should come from the display manager
Mathias Agopiana67932f2011-04-20 14:20:59 -0700309 DisplayInfo dinfo;
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700310 sp<IBinder> display = SurfaceComposerClient::getBuiltInDisplay(
311 ISurfaceComposer::eDisplayIdMain);
312 SurfaceComposerClient::getDisplayInfo(display, &dinfo);
Mathias Agopiana67932f2011-04-20 14:20:59 -0700313 const_cast<float&>(ANativeWindow::xdpi) = dinfo.xdpi;
314 const_cast<float&>(ANativeWindow::ydpi) = dinfo.ydpi;
Mathias Agopiana67932f2011-04-20 14:20:59 -0700315 const_cast<uint32_t&>(ANativeWindow::flags) = 0;
Mathias Agopian631f3582010-05-25 17:51:34 -0700316 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800317}
318
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800319Surface::~Surface()
320{
Mathias Agopian40b7f6e2009-04-14 18:21:47 -0700321 // clear all references and trigger an IPC now, to make sure things
322 // happen without delay, since these resources are quite heavy.
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800323 mSurface.clear();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800324 IPCThreadState::self()->flushCommands();
325}
326
Mathias Agopian631f3582010-05-25 17:51:34 -0700327bool Surface::isValid() {
Mathias Agopianc10d9d92011-07-20 16:46:11 -0700328 return getISurfaceTexture() != NULL;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800329}
330
tedbo1e7fa9e2011-06-22 15:52:53 -0700331sp<ISurfaceTexture> Surface::getSurfaceTexture() {
Mathias Agopianc10d9d92011-07-20 16:46:11 -0700332 return getISurfaceTexture();
tedbo1e7fa9e2011-06-22 15:52:53 -0700333}
334
Mathias Agopian47d87302011-04-05 15:44:20 -0700335sp<IBinder> Surface::asBinder() const {
336 return mSurface!=0 ? mSurface->asBinder() : 0;
Mathias Agopian631f3582010-05-25 17:51:34 -0700337}
338
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700339// ----------------------------------------------------------------------------
340
Mathias Agopiana67932f2011-04-20 14:20:59 -0700341int Surface::query(int what, int* value) const {
Mathias Agopiancb6b9042009-07-30 18:14:56 -0700342 switch (what) {
Jamie Gennis391bbe22011-03-14 15:00:06 -0700343 case NATIVE_WINDOW_CONCRETE_TYPE:
344 *value = NATIVE_WINDOW_SURFACE;
345 return NO_ERROR;
346 }
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700347 return SurfaceTextureClient::query(what, value);
Eino-Ville Talvala1d01a122011-02-18 11:02:42 -0800348}
349
Mathias Agopiana138f892010-05-21 17:24:35 -0700350// ----------------------------------------------------------------------------
351
Mathias Agopian87a96ea2011-08-23 21:09:41 -0700352status_t Surface::lock(SurfaceInfo* other, Region* inOutDirtyRegion) {
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700353 ANativeWindow_Buffer outBuffer;
Mathias Agopian55fa2512010-03-11 15:06:54 -0800354
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700355 ARect temp;
356 ARect* inOutDirtyBounds = NULL;
Mathias Agopian87a96ea2011-08-23 21:09:41 -0700357 if (inOutDirtyRegion) {
358 temp = inOutDirtyRegion->getBounds();
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700359 inOutDirtyBounds = &temp;
Mathias Agopian55fa2512010-03-11 15:06:54 -0800360 }
361
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700362 status_t err = SurfaceTextureClient::lock(&outBuffer, inOutDirtyBounds);
Mathias Agopian90147262010-01-22 11:47:55 -0800363
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700364 if (err == NO_ERROR) {
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700365 other->w = uint32_t(outBuffer.width);
366 other->h = uint32_t(outBuffer.height);
367 other->s = uint32_t(outBuffer.stride);
368 other->usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN;
369 other->format = uint32_t(outBuffer.format);
370 other->bits = outBuffer.bits;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700371 }
Mathias Agopian87a96ea2011-08-23 21:09:41 -0700372
373 if (inOutDirtyRegion) {
374 inOutDirtyRegion->set( static_cast<Rect const&>(temp) );
375 }
376
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700377 return err;
378}
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700379
Mathias Agopian8f9dbf92011-07-13 17:39:11 -0700380status_t Surface::unlockAndPost() {
381 return SurfaceTextureClient::unlockAndPost();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800382}
383
Mathias Agopiana138f892010-05-21 17:24:35 -0700384// ----------------------------------------------------------------------------
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800385}; // namespace android