diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2011-08-18 10:58:45 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-08-18 10:58:45 -0700 |
commit | 6780ce115495842bead625e93043eeab3d4bd1cf (patch) | |
tree | c2a07f81566a4728ccb36515000896ac8c0ad7db /Source/WebCore/platform | |
parent | 7ec0d53864ebef98adc3a9cc4d58d94cf1616a38 (diff) | |
parent | f0e3a5c2ed05701bffd2e85c8c87337a9f5d2d52 (diff) | |
download | external_webkit-6780ce115495842bead625e93043eeab3d4bd1cf.zip external_webkit-6780ce115495842bead625e93043eeab3d4bd1cf.tar.gz external_webkit-6780ce115495842bead625e93043eeab3d4bd1cf.tar.bz2 |
Merge "refactor the nativeWindow handling in TransferQueue"
Diffstat (limited to 'Source/WebCore/platform')
-rw-r--r-- | Source/WebCore/platform/graphics/android/TransferQueue.cpp | 64 |
1 files changed, 26 insertions, 38 deletions
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/TransferQueue.cpp index 1a377f2..8b4b596 100644 --- a/Source/WebCore/platform/graphics/android/TransferQueue.cpp +++ b/Source/WebCore/platform/graphics/android/TransferQueue.cpp @@ -297,50 +297,38 @@ void TransferQueue::updateQueueWithBitmap(const TileRenderInfo* renderInfo, renderInfo->x, renderInfo->y); return; } - // Dequeue the Surface Texture. - sp<ANativeWindow> ANW = m_ANW; - if (!ANW.get()) { + + // a) Dequeue the Surface Texture and write into the buffer + if (!m_ANW.get()) { XLOG("ERROR: ANW is null"); return; } - ANativeWindowBuffer* anb; - - int status = ANW->dequeueBuffer(ANW.get(), &anb); - GLUtils::checkSurfaceTextureError("dequeueBuffer", status); - // a) Update surface texture - sp<android::GraphicBuffer> buf(new android::GraphicBuffer(anb, false)); - status |= ANW->lockBuffer(ANW.get(), buf->getNativeBuffer()); // Mutex Lock - GLUtils::checkSurfaceTextureError("lockBuffer", status); - - // Fill the buffer with the content of the bitmap - uint8_t* img = 0; - status |= buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img)); - GLUtils::checkSurfaceTextureError("lock", status); - - if (status == NO_ERROR) { - int row, col; - int bpp = 4; // Now we only deal with RGBA8888 format. - int width = TilesManager::instance()->tileWidth(); - int height = TilesManager::instance()->tileHeight(); - if (!x && !y && bitmap.width() == width && bitmap.height() == height) { - bitmap.lockPixels(); - uint8_t* bitmapOrigin = static_cast<uint8_t*>(bitmap.getPixels()); - // Copied line by line since we need to handle the offsets and stride. - for (row = 0 ; row < bitmap.height(); row ++) { - uint8_t* dst = &(img[(buf->getStride() * (row + x) + y) * bpp]); - uint8_t* src = &(bitmapOrigin[bitmap.width() * row * bpp]); - memcpy(dst, src, bpp * bitmap.width()); - } - bitmap.unlockPixels(); - } else { - // TODO: implement the partial invalidate here! - XLOG("ERROR: don't expect to get here yet before we support partial inval"); + + ANativeWindow_Buffer buffer; + if (ANativeWindow_lock(m_ANW.get(), &buffer, 0)) + return; + + uint8_t* img = (uint8_t*)buffer.bits; + int row, col; + int bpp = 4; // Now we only deal with RGBA8888 format. + int width = TilesManager::instance()->tileWidth(); + int height = TilesManager::instance()->tileHeight(); + if (!x && !y && bitmap.width() == width && bitmap.height() == height) { + bitmap.lockPixels(); + uint8_t* bitmapOrigin = static_cast<uint8_t*>(bitmap.getPixels()); + // Copied line by line since we need to handle the offsets and stride. + for (row = 0 ; row < bitmap.height(); row ++) { + uint8_t* dst = &(img[(buffer.stride * (row + x) + y) * bpp]); + uint8_t* src = &(bitmapOrigin[bitmap.width() * row * bpp]); + memcpy(dst, src, bpp * bitmap.width()); } + bitmap.unlockPixels(); + } else { + // TODO: implement the partial invalidate here! + XLOG("ERROR: don't expect to get here yet before we support partial inval"); } - buf->unlock(); - status = ANW->queueBuffer(ANW.get(), buf->getNativeBuffer()); - GLUtils::checkSurfaceTextureError("queueBuffer", status); + ANativeWindow_unlockAndPost(m_ANW.get()); // b) After update the Surface Texture, now udpate the transfer queue info. addItemInTransferQueue(renderInfo); |