diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WebCore/platform/graphics/android/TransferQueue.cpp | 49 | ||||
-rw-r--r-- | Source/WebKit/android/jni/PictureSet.cpp | 32 |
2 files changed, 65 insertions, 16 deletions
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/TransferQueue.cpp index a6b2e26..d84033c 100644 --- a/Source/WebCore/platform/graphics/android/TransferQueue.cpp +++ b/Source/WebCore/platform/graphics/android/TransferQueue.cpp @@ -52,6 +52,10 @@ #define ST_BUFFER_NUMBER 4 +// Set this to 1 if we would like to take the new GpuUpload approach which +// relied on the glCopyTexSubImage2D instead of a glDraw call +#define GPU_UPLOAD_WITHOUT_DRAW 0 + namespace WebCore { TransferQueue::TransferQueue() @@ -86,7 +90,11 @@ void TransferQueue::initSharedSurfaceTextures(int width, int height) if (!m_sharedSurfaceTextureId) { glGenTextures(1, &m_sharedSurfaceTextureId); m_sharedSurfaceTexture = +#if GPU_UPLOAD_WITHOUT_DRAW + new android::SurfaceTexture(m_sharedSurfaceTextureId, true, GL_TEXTURE_2D); +#else new android::SurfaceTexture(m_sharedSurfaceTextureId); +#endif m_ANW = new android::SurfaceTextureClient(m_sharedSurfaceTexture); m_sharedSurfaceTexture->setSynchronousMode(true); m_sharedSurfaceTexture->setBufferCount(ST_BUFFER_NUMBER+1); @@ -137,6 +145,18 @@ void TransferQueue::blitTileFromQueue(GLuint fboID, BaseTileTexture* destTex, GLuint srcTexId, GLenum srcTexTarget, int index) { +#if GPU_UPLOAD_WITHOUT_DRAW + glBindFramebuffer(GL_FRAMEBUFFER, fboID); + glFramebufferTexture2D(GL_FRAMEBUFFER, + GL_COLOR_ATTACHMENT0, + GL_TEXTURE_2D, + srcTexId, + 0); + glBindTexture(GL_TEXTURE_2D, destTex->m_ownTextureId); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, + destTex->getSize().width(), + destTex->getSize().height()); +#else // Then set up the FBO and copy the SurfTex content in. glBindFramebuffer(GL_FRAMEBUFFER, fboID); glFramebufferTexture2D(GL_FRAMEBUFFER, @@ -174,10 +194,7 @@ void TransferQueue::blitTileFromQueue(GLuint fboID, BaseTileTexture* destTex, 0); } GLUtils::checkEglError("CreateSyncKHR"); - // Clean up FBO setup. - glBindFramebuffer(GL_FRAMEBUFFER, 0); // rebind the standard FBO - - GLUtils::checkGlError("copy the surface texture into the normal one"); +#endif } void TransferQueue::interruptTransferQueue(bool interrupt) @@ -261,8 +278,6 @@ void TransferQueue::discardQueue() // Call on UI thread to copy from the shared Surface Texture to the BaseTile's texture. void TransferQueue::updateDirtyBaseTiles() { - if (m_currentUploadType == GpuUpload) - saveGLState(); android::Mutex::Autolock lock(m_transferQueueItemLocks); cleanupTransportQueue(); @@ -273,6 +288,7 @@ void TransferQueue::updateDirtyBaseTiles() // the texture and blit that into each BaseTile's texture. const int nextItemIndex = getNextTransferQueueIndex(); int index = nextItemIndex; + bool usedFboForUpload = false; for (int k = 0; k < ST_BUFFER_NUMBER ; k++) { if (m_transferQueue[index].status == pendingBlit) { bool obsoleteBaseTile = checkObsolete(index); @@ -299,6 +315,10 @@ void TransferQueue::updateDirtyBaseTiles() GLUtils::updateTextureWithBitmap(destTexture->m_ownTextureId, 0, 0, *m_transferQueue[index].bitmap); } else { + if (!usedFboForUpload) { + saveGLState(); + usedFboForUpload = true; + } blitTileFromQueue(m_fboID, destTexture, m_sharedSurfaceTextureId, m_sharedSurfaceTexture->getCurrentTextureTarget(), @@ -321,8 +341,14 @@ void TransferQueue::updateDirtyBaseTiles() index = (index + 1) % ST_BUFFER_NUMBER; } - if (m_currentUploadType == GpuUpload) + // Clean up FBO setup. Doing this for both CPU/GPU upload can make the + // dynamic switch possible. Moving this out from the loop can save some + // milli-seconds. + if (usedFboForUpload) { + glBindFramebuffer(GL_FRAMEBUFFER, 0); // rebind the standard FBO restoreGLState(); + GLUtils::checkGlError("updateDirtyBaseTiles"); + } m_emptyItemCount = ST_BUFFER_NUMBER; m_transferQueueItemCond.signal(); @@ -462,7 +488,9 @@ void TransferQueue::saveGLState() glGetIntegerv(GL_VIEWPORT, m_GLStateBeforeBlit.viewport); glGetBooleanv(GL_SCISSOR_TEST, m_GLStateBeforeBlit.scissor); glGetBooleanv(GL_DEPTH_TEST, m_GLStateBeforeBlit.depth); +#if DEBUG glGetFloatv(GL_COLOR_CLEAR_VALUE, m_GLStateBeforeBlit.clearColor); +#endif } void TransferQueue::setGLStateForCopy(int width, int height) @@ -471,9 +499,11 @@ void TransferQueue::setGLStateForCopy(int width, int height) glViewport(0, 0, width, height); glDisable(GL_SCISSOR_TEST); glDisable(GL_DEPTH_TEST); - + // Clear the content is only for debug purpose. +#if DEBUG glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); +#endif } void TransferQueue::restoreGLState() @@ -488,11 +518,12 @@ void TransferQueue::restoreGLState() if (m_GLStateBeforeBlit.depth[0]) glEnable(GL_DEPTH_TEST); - +#if DEBUG glClearColor(m_GLStateBeforeBlit.clearColor[0], m_GLStateBeforeBlit.clearColor[1], m_GLStateBeforeBlit.clearColor[2], m_GLStateBeforeBlit.clearColor[3]); +#endif } int TransferQueue::getNextTransferQueueIndex() diff --git a/Source/WebKit/android/jni/PictureSet.cpp b/Source/WebKit/android/jni/PictureSet.cpp index 3f40174..6edb7ba 100644 --- a/Source/WebKit/android/jni/PictureSet.cpp +++ b/Source/WebKit/android/jni/PictureSet.cpp @@ -81,17 +81,23 @@ public: namespace android { -PictureSet::PictureSet() - : mBucketSizeX(0), mBucketSizeY(0), mBucketCountX(0), mBucketCountY(0), - mHeight(0), mWidth(0) +PictureSet::PictureSet() : +#ifdef FAST_PICTURESET + mBucketSizeX(BUCKET_SIZE), mBucketSizeY(BUCKET_SIZE), + mBucketCountX(0), mBucketCountY(0), +#endif + mHeight(0), mWidth(0) { setDimensions(0, 0); mBaseArea = mAdditionalArea = 0; } -PictureSet::PictureSet(SkPicture* picture) - : mBucketSizeX(0), mBucketSizeY(0), mBucketCountX(0), mBucketCountY(0), - mHeight(0), mWidth(0) +PictureSet::PictureSet(SkPicture* picture) : +#ifdef FAST_PICTURESET + mBucketSizeX(BUCKET_SIZE), mBucketSizeY(BUCKET_SIZE), + mBucketCountX(0), mBucketCountY(0), +#endif + mHeight(0), mWidth(0) { mBaseArea = mAdditionalArea = 0; if (!picture) { @@ -311,6 +317,12 @@ void PictureSet::gatherBucketsForArea(WTF::Vector<Bucket*>& list, const SkIRect& rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, rect.width(), rect.height()); + if (!mBucketSizeX || !mBucketSizeY) { + XLOGC("PictureSet::gatherBucketsForArea() called with bad bucket size: x=%d y=%d", + mBucketSizeX, mBucketSizeY); + return; + } + int x = rect.fLeft; int y = rect.fTop; int firstTileX = rect.fLeft / mBucketSizeX; @@ -337,6 +349,12 @@ void PictureSet::splitAdd(const SkIRect& rect) rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, rect.width(), rect.height()); + if (!mBucketSizeX || !mBucketSizeY) { + XLOGC("PictureSet::splitAdd() called with bad bucket size: x=%d y=%d", + mBucketSizeX, mBucketSizeY); + return; + } + // TODO: reuse gatherBucketsForArea() (change Bucket to be a class) int x = rect.fLeft; int y = rect.fTop; @@ -631,6 +649,7 @@ void PictureSet::clear() bucket->clear(); } mBuckets.clear(); + mBucketSizeX = mBucketSizeY = BUCKET_SIZE; #else Pictures* last = mPictures.end(); for (Pictures* working = mPictures.begin(); working != last; working++) { @@ -640,7 +659,6 @@ void PictureSet::clear() mPictures.clear(); #endif // FAST_PICTURESET mWidth = mHeight = 0; - mBucketSizeX = mBucketSizeY = 0; } bool PictureSet::draw(SkCanvas* canvas) |