Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (C) 2010 The Android Open Source Project |
michael@0 | 3 | * Copyright (C) 2012 Mozilla Foundation |
michael@0 | 4 | * |
michael@0 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 6 | * you may not use this file except in compliance with the License. |
michael@0 | 7 | * You may obtain a copy of the License at |
michael@0 | 8 | * |
michael@0 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 10 | * |
michael@0 | 11 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 14 | * See the License for the specific language governing permissions and |
michael@0 | 15 | * limitations under the License. |
michael@0 | 16 | */ |
michael@0 | 17 | |
michael@0 | 18 | #include "base/basictypes.h" |
michael@0 | 19 | |
michael@0 | 20 | #include "CameraCommon.h" |
michael@0 | 21 | #include "GonkNativeWindow.h" |
michael@0 | 22 | #include "GonkNativeWindowClient.h" |
michael@0 | 23 | #include "nsDebug.h" |
michael@0 | 24 | |
michael@0 | 25 | /** |
michael@0 | 26 | * DOM_CAMERA_LOGI() is enabled in debug builds, and turned on by setting |
michael@0 | 27 | * NSPR_LOG_MODULES=Camera:N environment variable, where N >= 3. |
michael@0 | 28 | * |
michael@0 | 29 | * CNW_LOGE() is always enabled. |
michael@0 | 30 | */ |
michael@0 | 31 | #define CNW_LOGD(...) DOM_CAMERA_LOGI(__VA_ARGS__) |
michael@0 | 32 | #define CNW_LOGE(...) {(void)printf_stderr(__VA_ARGS__);} |
michael@0 | 33 | |
michael@0 | 34 | using namespace android; |
michael@0 | 35 | using namespace mozilla::layers; |
michael@0 | 36 | |
michael@0 | 37 | GonkNativeWindowClient::GonkNativeWindowClient(const sp<GonkNativeWindow>& window) |
michael@0 | 38 | : mNativeWindow(window) { |
michael@0 | 39 | GonkNativeWindowClient::init(); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | GonkNativeWindowClient::~GonkNativeWindowClient() { |
michael@0 | 43 | if (mConnectedToCpu) { |
michael@0 | 44 | GonkNativeWindowClient::disconnect(NATIVE_WINDOW_API_CPU); |
michael@0 | 45 | } |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | void GonkNativeWindowClient::init() { |
michael@0 | 49 | // Initialize the ANativeWindow function pointers. |
michael@0 | 50 | ANativeWindow::setSwapInterval = hook_setSwapInterval; |
michael@0 | 51 | ANativeWindow::dequeueBuffer = hook_dequeueBuffer; |
michael@0 | 52 | ANativeWindow::cancelBuffer = hook_cancelBuffer; |
michael@0 | 53 | ANativeWindow::lockBuffer = hook_lockBuffer; |
michael@0 | 54 | ANativeWindow::queueBuffer = hook_queueBuffer; |
michael@0 | 55 | ANativeWindow::query = hook_query; |
michael@0 | 56 | ANativeWindow::perform = hook_perform; |
michael@0 | 57 | |
michael@0 | 58 | mReqWidth = 0; |
michael@0 | 59 | mReqHeight = 0; |
michael@0 | 60 | mReqFormat = 0; |
michael@0 | 61 | mReqUsage = 0; |
michael@0 | 62 | mTimestamp = NATIVE_WINDOW_TIMESTAMP_AUTO; |
michael@0 | 63 | mDefaultWidth = 0; |
michael@0 | 64 | mDefaultHeight = 0; |
michael@0 | 65 | mTransformHint = 0; |
michael@0 | 66 | mConnectedToCpu = false; |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | |
michael@0 | 70 | int GonkNativeWindowClient::hook_setSwapInterval(ANativeWindow* window, int interval) { |
michael@0 | 71 | GonkNativeWindowClient* c = getSelf(window); |
michael@0 | 72 | return c->setSwapInterval(interval); |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | int GonkNativeWindowClient::hook_dequeueBuffer(ANativeWindow* window, |
michael@0 | 76 | ANativeWindowBuffer** buffer) { |
michael@0 | 77 | GonkNativeWindowClient* c = getSelf(window); |
michael@0 | 78 | return c->dequeueBuffer(buffer); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | int GonkNativeWindowClient::hook_cancelBuffer(ANativeWindow* window, |
michael@0 | 82 | ANativeWindowBuffer* buffer) { |
michael@0 | 83 | GonkNativeWindowClient* c = getSelf(window); |
michael@0 | 84 | return c->cancelBuffer(buffer); |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | int GonkNativeWindowClient::hook_lockBuffer(ANativeWindow* window, |
michael@0 | 88 | ANativeWindowBuffer* buffer) { |
michael@0 | 89 | GonkNativeWindowClient* c = getSelf(window); |
michael@0 | 90 | return c->lockBuffer(buffer); |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | int GonkNativeWindowClient::hook_queueBuffer(ANativeWindow* window, |
michael@0 | 94 | ANativeWindowBuffer* buffer) { |
michael@0 | 95 | GonkNativeWindowClient* c = getSelf(window); |
michael@0 | 96 | return c->queueBuffer(buffer); |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | int GonkNativeWindowClient::hook_query(const ANativeWindow* window, |
michael@0 | 100 | int what, int* value) { |
michael@0 | 101 | const GonkNativeWindowClient* c = getSelf(window); |
michael@0 | 102 | return c->query(what, value); |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | int GonkNativeWindowClient::hook_perform(ANativeWindow* window, int operation, ...) { |
michael@0 | 106 | va_list args; |
michael@0 | 107 | va_start(args, operation); |
michael@0 | 108 | GonkNativeWindowClient* c = getSelf(window); |
michael@0 | 109 | return c->perform(operation, args); |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | int GonkNativeWindowClient::setSwapInterval(int interval) { |
michael@0 | 113 | return NO_ERROR; |
michael@0 | 114 | } |
michael@0 | 115 | |
michael@0 | 116 | int GonkNativeWindowClient::dequeueBuffer(android_native_buffer_t** buffer) { |
michael@0 | 117 | CNW_LOGD("GonkNativeWindowClient::dequeueBuffer"); |
michael@0 | 118 | Mutex::Autolock lock(mMutex); |
michael@0 | 119 | int buf = -1; |
michael@0 | 120 | status_t result = mNativeWindow->dequeueBuffer(&buf, mReqWidth, mReqHeight, |
michael@0 | 121 | mReqFormat, mReqUsage); |
michael@0 | 122 | if (result < 0) { |
michael@0 | 123 | CNW_LOGD("dequeueBuffer: ISurfaceTexture::dequeueBuffer(%d, %d, %d, %d)" |
michael@0 | 124 | "failed: %d", mReqWidth, mReqHeight, mReqFormat, mReqUsage, |
michael@0 | 125 | result); |
michael@0 | 126 | return result; |
michael@0 | 127 | } |
michael@0 | 128 | sp<GraphicBuffer>& gbuf(mSlots[buf]); |
michael@0 | 129 | if (result & ISurfaceTexture::RELEASE_ALL_BUFFERS) { |
michael@0 | 130 | freeAllBuffers(); |
michael@0 | 131 | } |
michael@0 | 132 | |
michael@0 | 133 | if ((result & ISurfaceTexture::BUFFER_NEEDS_REALLOCATION) || gbuf == 0) { |
michael@0 | 134 | result = mNativeWindow->requestBuffer(buf, &gbuf); |
michael@0 | 135 | if (result != NO_ERROR) { |
michael@0 | 136 | CNW_LOGE("dequeueBuffer: ISurfaceTexture::requestBuffer failed: %d", |
michael@0 | 137 | result); |
michael@0 | 138 | return result; |
michael@0 | 139 | } |
michael@0 | 140 | } |
michael@0 | 141 | *buffer = gbuf.get(); |
michael@0 | 142 | return OK; |
michael@0 | 143 | } |
michael@0 | 144 | |
michael@0 | 145 | int GonkNativeWindowClient::cancelBuffer(ANativeWindowBuffer* buffer) { |
michael@0 | 146 | CNW_LOGD("GonkNativeWindowClient::cancelBuffer"); |
michael@0 | 147 | Mutex::Autolock lock(mMutex); |
michael@0 | 148 | int i = getSlotFromBufferLocked(buffer); |
michael@0 | 149 | if (i < 0) { |
michael@0 | 150 | return i; |
michael@0 | 151 | } |
michael@0 | 152 | mNativeWindow->cancelBuffer(i); |
michael@0 | 153 | return OK; |
michael@0 | 154 | } |
michael@0 | 155 | |
michael@0 | 156 | int GonkNativeWindowClient::getSlotFromBufferLocked( |
michael@0 | 157 | android_native_buffer_t* buffer) const { |
michael@0 | 158 | bool dumpedState = false; |
michael@0 | 159 | for (int i = 0; i < NUM_BUFFER_SLOTS; i++) { |
michael@0 | 160 | // XXX: Dump the slots whenever we hit a NULL entry while searching for |
michael@0 | 161 | // a buffer. |
michael@0 | 162 | if (mSlots[i] == NULL) { |
michael@0 | 163 | if (!dumpedState) { |
michael@0 | 164 | CNW_LOGD("getSlotFromBufferLocked: encountered NULL buffer in slot %d " |
michael@0 | 165 | "looking for buffer %p", i, buffer->handle); |
michael@0 | 166 | for (int j = 0; j < NUM_BUFFER_SLOTS; j++) { |
michael@0 | 167 | if (mSlots[j] == NULL) { |
michael@0 | 168 | CNW_LOGD("getSlotFromBufferLocked: %02d: NULL", j); |
michael@0 | 169 | } else { |
michael@0 | 170 | CNW_LOGD("getSlotFromBufferLocked: %02d: %p", j, mSlots[j]->handle); |
michael@0 | 171 | } |
michael@0 | 172 | } |
michael@0 | 173 | dumpedState = true; |
michael@0 | 174 | } |
michael@0 | 175 | } |
michael@0 | 176 | |
michael@0 | 177 | if (mSlots[i] != NULL && mSlots[i]->handle == buffer->handle) { |
michael@0 | 178 | return i; |
michael@0 | 179 | } |
michael@0 | 180 | } |
michael@0 | 181 | CNW_LOGE("getSlotFromBufferLocked: unknown buffer: %p", buffer->handle); |
michael@0 | 182 | return BAD_VALUE; |
michael@0 | 183 | } |
michael@0 | 184 | |
michael@0 | 185 | |
michael@0 | 186 | int GonkNativeWindowClient::lockBuffer(android_native_buffer_t* buffer) { |
michael@0 | 187 | CNW_LOGD("GonkNativeWindowClient::lockBuffer"); |
michael@0 | 188 | Mutex::Autolock lock(mMutex); |
michael@0 | 189 | return OK; |
michael@0 | 190 | } |
michael@0 | 191 | |
michael@0 | 192 | int GonkNativeWindowClient::queueBuffer(android_native_buffer_t* buffer) { |
michael@0 | 193 | CNW_LOGD("GonkNativeWindowClient::queueBuffer"); |
michael@0 | 194 | Mutex::Autolock lock(mMutex); |
michael@0 | 195 | int64_t timestamp; |
michael@0 | 196 | if (mTimestamp == NATIVE_WINDOW_TIMESTAMP_AUTO) { |
michael@0 | 197 | timestamp = systemTime(SYSTEM_TIME_MONOTONIC); |
michael@0 | 198 | CNW_LOGD("GonkNativeWindowClient::queueBuffer making up timestamp: %.2f ms", |
michael@0 | 199 | timestamp / 1000000.f); |
michael@0 | 200 | } else { |
michael@0 | 201 | timestamp = mTimestamp; |
michael@0 | 202 | } |
michael@0 | 203 | int i = getSlotFromBufferLocked(buffer); |
michael@0 | 204 | if (i < 0) { |
michael@0 | 205 | return i; |
michael@0 | 206 | } |
michael@0 | 207 | status_t err = mNativeWindow->queueBuffer(i, timestamp, |
michael@0 | 208 | &mDefaultWidth, &mDefaultHeight, &mTransformHint); |
michael@0 | 209 | if (err != OK) { |
michael@0 | 210 | CNW_LOGE("queueBuffer: error queuing buffer to GonkNativeWindow, %d", err); |
michael@0 | 211 | } |
michael@0 | 212 | return err; |
michael@0 | 213 | } |
michael@0 | 214 | |
michael@0 | 215 | int GonkNativeWindowClient::query(int what, int* value) const { |
michael@0 | 216 | CNW_LOGD("query"); |
michael@0 | 217 | { // scope for the lock |
michael@0 | 218 | Mutex::Autolock lock(mMutex); |
michael@0 | 219 | switch (what) { |
michael@0 | 220 | case NATIVE_WINDOW_FORMAT: |
michael@0 | 221 | if (mReqFormat) { |
michael@0 | 222 | *value = mReqFormat; |
michael@0 | 223 | return NO_ERROR; |
michael@0 | 224 | } |
michael@0 | 225 | break; |
michael@0 | 226 | case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER: |
michael@0 | 227 | *value = 0; |
michael@0 | 228 | return NO_ERROR; |
michael@0 | 229 | case NATIVE_WINDOW_CONCRETE_TYPE: |
michael@0 | 230 | *value = NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT; |
michael@0 | 231 | return NO_ERROR; |
michael@0 | 232 | case NATIVE_WINDOW_DEFAULT_WIDTH: |
michael@0 | 233 | *value = mDefaultWidth; |
michael@0 | 234 | return NO_ERROR; |
michael@0 | 235 | case NATIVE_WINDOW_DEFAULT_HEIGHT: |
michael@0 | 236 | *value = mDefaultHeight; |
michael@0 | 237 | return NO_ERROR; |
michael@0 | 238 | case NATIVE_WINDOW_TRANSFORM_HINT: |
michael@0 | 239 | *value = mTransformHint; |
michael@0 | 240 | return NO_ERROR; |
michael@0 | 241 | } |
michael@0 | 242 | } |
michael@0 | 243 | return mNativeWindow->query(what, value); |
michael@0 | 244 | } |
michael@0 | 245 | |
michael@0 | 246 | int GonkNativeWindowClient::perform(int operation, va_list args) |
michael@0 | 247 | { |
michael@0 | 248 | int res = NO_ERROR; |
michael@0 | 249 | switch (operation) { |
michael@0 | 250 | case NATIVE_WINDOW_CONNECT: |
michael@0 | 251 | // deprecated. must return NO_ERROR. |
michael@0 | 252 | break; |
michael@0 | 253 | case NATIVE_WINDOW_DISCONNECT: |
michael@0 | 254 | // deprecated. must return NO_ERROR. |
michael@0 | 255 | break; |
michael@0 | 256 | case NATIVE_WINDOW_SET_SCALING_MODE: |
michael@0 | 257 | return NO_ERROR; |
michael@0 | 258 | case NATIVE_WINDOW_SET_USAGE: |
michael@0 | 259 | res = dispatchSetUsage(args); |
michael@0 | 260 | break; |
michael@0 | 261 | case NATIVE_WINDOW_SET_CROP: |
michael@0 | 262 | //not implemented |
michael@0 | 263 | break; |
michael@0 | 264 | case NATIVE_WINDOW_SET_BUFFER_COUNT: |
michael@0 | 265 | res = dispatchSetBufferCount(args); |
michael@0 | 266 | break; |
michael@0 | 267 | case NATIVE_WINDOW_SET_BUFFERS_GEOMETRY: |
michael@0 | 268 | res = dispatchSetBuffersGeometry(args); |
michael@0 | 269 | break; |
michael@0 | 270 | case NATIVE_WINDOW_SET_BUFFERS_TRANSFORM: |
michael@0 | 271 | //not implemented |
michael@0 | 272 | break; |
michael@0 | 273 | case NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP: |
michael@0 | 274 | res = dispatchSetBuffersTimestamp(args); |
michael@0 | 275 | break; |
michael@0 | 276 | case NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS: |
michael@0 | 277 | res = dispatchSetBuffersDimensions(args); |
michael@0 | 278 | break; |
michael@0 | 279 | case NATIVE_WINDOW_SET_BUFFERS_FORMAT: |
michael@0 | 280 | res = dispatchSetBuffersFormat(args); |
michael@0 | 281 | break; |
michael@0 | 282 | case NATIVE_WINDOW_LOCK: |
michael@0 | 283 | res = INVALID_OPERATION;// not supported |
michael@0 | 284 | break; |
michael@0 | 285 | case NATIVE_WINDOW_UNLOCK_AND_POST: |
michael@0 | 286 | res = INVALID_OPERATION;// not supported |
michael@0 | 287 | break; |
michael@0 | 288 | case NATIVE_WINDOW_API_CONNECT: |
michael@0 | 289 | res = dispatchConnect(args); |
michael@0 | 290 | break; |
michael@0 | 291 | case NATIVE_WINDOW_API_DISCONNECT: |
michael@0 | 292 | res = dispatchDisconnect(args); |
michael@0 | 293 | break; |
michael@0 | 294 | case NATIVE_WINDOW_SET_BUFFERS_SIZE: |
michael@0 | 295 | //not implemented |
michael@0 | 296 | break; |
michael@0 | 297 | default: |
michael@0 | 298 | res = NAME_NOT_FOUND; |
michael@0 | 299 | break; |
michael@0 | 300 | } |
michael@0 | 301 | return res; |
michael@0 | 302 | } |
michael@0 | 303 | |
michael@0 | 304 | int GonkNativeWindowClient::dispatchConnect(va_list args) { |
michael@0 | 305 | int api = va_arg(args, int); |
michael@0 | 306 | return connect(api); |
michael@0 | 307 | } |
michael@0 | 308 | |
michael@0 | 309 | int GonkNativeWindowClient::dispatchDisconnect(va_list args) { |
michael@0 | 310 | int api = va_arg(args, int); |
michael@0 | 311 | return disconnect(api); |
michael@0 | 312 | } |
michael@0 | 313 | |
michael@0 | 314 | int GonkNativeWindowClient::dispatchSetUsage(va_list args) { |
michael@0 | 315 | int usage = va_arg(args, int); |
michael@0 | 316 | return setUsage(usage); |
michael@0 | 317 | } |
michael@0 | 318 | |
michael@0 | 319 | int GonkNativeWindowClient::dispatchSetBufferCount(va_list args) { |
michael@0 | 320 | size_t bufferCount = va_arg(args, size_t); |
michael@0 | 321 | return setBufferCount(bufferCount); |
michael@0 | 322 | } |
michael@0 | 323 | |
michael@0 | 324 | int GonkNativeWindowClient::dispatchSetBuffersGeometry(va_list args) { |
michael@0 | 325 | int w = va_arg(args, int); |
michael@0 | 326 | int h = va_arg(args, int); |
michael@0 | 327 | int f = va_arg(args, int); |
michael@0 | 328 | int err = setBuffersDimensions(w, h); |
michael@0 | 329 | if (err != 0) { |
michael@0 | 330 | return err; |
michael@0 | 331 | } |
michael@0 | 332 | return setBuffersFormat(f); |
michael@0 | 333 | } |
michael@0 | 334 | |
michael@0 | 335 | int GonkNativeWindowClient::dispatchSetBuffersDimensions(va_list args) { |
michael@0 | 336 | int w = va_arg(args, int); |
michael@0 | 337 | int h = va_arg(args, int); |
michael@0 | 338 | return setBuffersDimensions(w, h); |
michael@0 | 339 | } |
michael@0 | 340 | |
michael@0 | 341 | int GonkNativeWindowClient::dispatchSetBuffersFormat(va_list args) { |
michael@0 | 342 | int f = va_arg(args, int); |
michael@0 | 343 | return setBuffersFormat(f); |
michael@0 | 344 | } |
michael@0 | 345 | |
michael@0 | 346 | int GonkNativeWindowClient::dispatchSetBuffersTimestamp(va_list args) { |
michael@0 | 347 | int64_t timestamp = va_arg(args, int64_t); |
michael@0 | 348 | return setBuffersTimestamp(timestamp); |
michael@0 | 349 | } |
michael@0 | 350 | |
michael@0 | 351 | int GonkNativeWindowClient::connect(int api) { |
michael@0 | 352 | CNW_LOGD("GonkNativeWindowClient::connect"); |
michael@0 | 353 | Mutex::Autolock lock(mMutex); |
michael@0 | 354 | int err = mNativeWindow->connect(api, |
michael@0 | 355 | &mDefaultWidth, &mDefaultHeight, &mTransformHint); |
michael@0 | 356 | if (!err && api == NATIVE_WINDOW_API_CPU) { |
michael@0 | 357 | mConnectedToCpu = true; |
michael@0 | 358 | } |
michael@0 | 359 | return err; |
michael@0 | 360 | } |
michael@0 | 361 | |
michael@0 | 362 | int GonkNativeWindowClient::disconnect(int api) { |
michael@0 | 363 | CNW_LOGD("GonkNativeWindowClient::disconnect"); |
michael@0 | 364 | Mutex::Autolock lock(mMutex); |
michael@0 | 365 | freeAllBuffers(); |
michael@0 | 366 | int err = mNativeWindow->disconnect(api); |
michael@0 | 367 | if (!err) { |
michael@0 | 368 | mReqFormat = 0; |
michael@0 | 369 | mReqWidth = 0; |
michael@0 | 370 | mReqHeight = 0; |
michael@0 | 371 | mReqUsage = 0; |
michael@0 | 372 | if (api == NATIVE_WINDOW_API_CPU) { |
michael@0 | 373 | mConnectedToCpu = false; |
michael@0 | 374 | } |
michael@0 | 375 | } |
michael@0 | 376 | return err; |
michael@0 | 377 | } |
michael@0 | 378 | |
michael@0 | 379 | int GonkNativeWindowClient::setUsage(uint32_t reqUsage) |
michael@0 | 380 | { |
michael@0 | 381 | CNW_LOGD("GonkNativeWindowClient::setUsage"); |
michael@0 | 382 | Mutex::Autolock lock(mMutex); |
michael@0 | 383 | mReqUsage = reqUsage; |
michael@0 | 384 | return OK; |
michael@0 | 385 | } |
michael@0 | 386 | |
michael@0 | 387 | int GonkNativeWindowClient::setBufferCount(int bufferCount) |
michael@0 | 388 | { |
michael@0 | 389 | CNW_LOGD("GonkNativeWindowClient::setBufferCount"); |
michael@0 | 390 | Mutex::Autolock lock(mMutex); |
michael@0 | 391 | |
michael@0 | 392 | status_t err = mNativeWindow->setBufferCount(bufferCount); |
michael@0 | 393 | if (err == NO_ERROR) { |
michael@0 | 394 | freeAllBuffers(); |
michael@0 | 395 | } |
michael@0 | 396 | |
michael@0 | 397 | return err; |
michael@0 | 398 | } |
michael@0 | 399 | |
michael@0 | 400 | int GonkNativeWindowClient::setBuffersDimensions(int w, int h) |
michael@0 | 401 | { |
michael@0 | 402 | CNW_LOGD("GonkNativeWindowClient::setBuffersDimensions"); |
michael@0 | 403 | Mutex::Autolock lock(mMutex); |
michael@0 | 404 | |
michael@0 | 405 | if (w<0 || h<0) |
michael@0 | 406 | return BAD_VALUE; |
michael@0 | 407 | |
michael@0 | 408 | if ((w && !h) || (!w && h)) |
michael@0 | 409 | return BAD_VALUE; |
michael@0 | 410 | |
michael@0 | 411 | mReqWidth = w; |
michael@0 | 412 | mReqHeight = h; |
michael@0 | 413 | |
michael@0 | 414 | status_t err = OK; |
michael@0 | 415 | |
michael@0 | 416 | return err; |
michael@0 | 417 | } |
michael@0 | 418 | |
michael@0 | 419 | int GonkNativeWindowClient::setBuffersFormat(int format) |
michael@0 | 420 | { |
michael@0 | 421 | CNW_LOGD("GonkNativeWindowClient::setBuffersFormat"); |
michael@0 | 422 | Mutex::Autolock lock(mMutex); |
michael@0 | 423 | |
michael@0 | 424 | if (format<0) |
michael@0 | 425 | return BAD_VALUE; |
michael@0 | 426 | |
michael@0 | 427 | mReqFormat = format; |
michael@0 | 428 | |
michael@0 | 429 | return NO_ERROR; |
michael@0 | 430 | } |
michael@0 | 431 | |
michael@0 | 432 | |
michael@0 | 433 | int GonkNativeWindowClient::setBuffersTimestamp(int64_t timestamp) |
michael@0 | 434 | { |
michael@0 | 435 | CNW_LOGD("GonkNativeWindowClient::setBuffersTimestamp"); |
michael@0 | 436 | Mutex::Autolock lock(mMutex); |
michael@0 | 437 | mTimestamp = timestamp; |
michael@0 | 438 | return NO_ERROR; |
michael@0 | 439 | } |
michael@0 | 440 | |
michael@0 | 441 | void GonkNativeWindowClient::freeAllBuffers() { |
michael@0 | 442 | for (int i = 0; i < NUM_BUFFER_SLOTS; i++) { |
michael@0 | 443 | mSlots[i] = 0; |
michael@0 | 444 | } |
michael@0 | 445 | } |
michael@0 | 446 |