diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2011-09-30 09:22:46 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-09-30 09:22:46 -0700 |
commit | 4dc48f9adb7bd282ce905e3bce330d527377a609 (patch) | |
tree | b7347454cb42bf1773d577633274caad2101dc1b /Source/WebCore/platform/graphics/android/TransferQueue.cpp | |
parent | 70766d2b423da8555553b35dba98bad79529b97c (diff) | |
parent | a3d78debd21a173383183bacf55836fa9b87da1b (diff) | |
download | external_webkit-4dc48f9adb7bd282ce905e3bce330d527377a609.zip external_webkit-4dc48f9adb7bd282ce905e3bce330d527377a609.tar.gz external_webkit-4dc48f9adb7bd282ce905e3bce330d527377a609.tar.bz2 |
Merge "Make the Gpu Upload path faster"
Diffstat (limited to 'Source/WebCore/platform/graphics/android/TransferQueue.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/android/TransferQueue.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/TransferQueue.cpp index a6b2e26..e100838 100644 --- a/Source/WebCore/platform/graphics/android/TransferQueue.cpp +++ b/Source/WebCore/platform/graphics/android/TransferQueue.cpp @@ -174,9 +174,6 @@ 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"); } @@ -261,8 +258,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 +268,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 +295,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 +321,13 @@ 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(); + } m_emptyItemCount = ST_BUFFER_NUMBER; m_transferQueueItemCond.signal(); @@ -462,7 +467,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 +478,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 +497,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() |