summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android/TransferQueue.cpp
diff options
context:
space:
mode:
authorTeng-Hui Zhu <ztenghui@google.com>2011-08-17 14:55:16 -0700
committerTeng-Hui Zhu <ztenghui@google.com>2011-08-18 09:40:35 -0700
commitf0e3a5c2ed05701bffd2e85c8c87337a9f5d2d52 (patch)
treea8673aff0a07c9ee577c6de0869e3bf2df6a5c34 /Source/WebCore/platform/graphics/android/TransferQueue.cpp
parentbd7e9ea6769039d66b97b4286e096416b53bdc4a (diff)
downloadexternal_webkit-f0e3a5c2ed05701bffd2e85c8c87337a9f5d2d52.zip
external_webkit-f0e3a5c2ed05701bffd2e85c8c87337a9f5d2d52.tar.gz
external_webkit-f0e3a5c2ed05701bffd2e85c8c87337a9f5d2d52.tar.bz2
refactor the nativeWindow handling in TransferQueue
bug:5161750 Change-Id: I33735f258abf850fa3afd7769385b38691365da3
Diffstat (limited to 'Source/WebCore/platform/graphics/android/TransferQueue.cpp')
-rw-r--r--Source/WebCore/platform/graphics/android/TransferQueue.cpp64
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);