diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2012-02-10 15:01:10 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-10 15:01:10 -0800 |
commit | cde0ee28aca1d56028645acbf5b1250d45bffac7 (patch) | |
tree | d7673f61559b65407bbc11ea4bf19373881ef013 /Source/WebCore/platform/graphics/android | |
parent | 048f0f59f7fde542ee8f86e956b92b9d2adbf4cc (diff) | |
parent | 451fcf2a39629f20f52ee6bb0294d217d8aa487f (diff) | |
download | external_webkit-cde0ee28aca1d56028645acbf5b1250d45bffac7.zip external_webkit-cde0ee28aca1d56028645acbf5b1250d45bffac7.tar.gz external_webkit-cde0ee28aca1d56028645acbf5b1250d45bffac7.tar.bz2 |
Merge "Shrink the transfer queue by default"
Diffstat (limited to 'Source/WebCore/platform/graphics/android')
4 files changed, 33 insertions, 19 deletions
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index 082f0bc..7fe856b 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -106,6 +106,7 @@ TilesManager::TilesManager() , m_useMinimalMemory(true) , m_useDoubleBuffering(true) , m_treeUpdates(0) + , m_queue(0) , m_drawGLCount(1) , m_lastTimeLayersUsed(0) , m_hasLayerTextures(false) @@ -427,6 +428,14 @@ void TilesManager::setMaxLayerTextureCount(int max) m_hasLayerTextures = true; } +TransferQueue* TilesManager::transferQueue() +{ + // To minimize the memory usage, transfer queue can be set to minimal size + // if required. + if (!m_queue) + m_queue = new TransferQueue(m_useMinimalMemory); + return m_queue; +} float TilesManager::tileWidth() { diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h index 855994d..b670055 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.h +++ b/Source/WebCore/platform/graphics/android/TilesManager.h @@ -82,7 +82,7 @@ public: void addPaintedSurface(PaintedSurface* surface); ShaderProgram* shader() { return &m_shader; } - TransferQueue* transferQueue() { return &m_queue; } + TransferQueue* transferQueue(); VideoLayerManager* videoLayerManager() { return &m_videoLayerManager; } void gatherLayerTextures(); @@ -254,7 +254,7 @@ private: static TilesManager* gInstance; ShaderProgram m_shader; - TransferQueue m_queue; + TransferQueue* m_queue; VideoLayerManager m_videoLayerManager; diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/TransferQueue.cpp index 00f851b..2d5be64 100644 --- a/Source/WebCore/platform/graphics/android/TransferQueue.cpp +++ b/Source/WebCore/platform/graphics/android/TransferQueue.cpp @@ -50,7 +50,10 @@ #endif // DEBUG -#define ST_BUFFER_NUMBER 6 +// For simple webView usage, MINIMAL_SIZE is recommended for memory saving. +// In browser case, EFFICIENT_SIZE is preferred. +#define MINIMAL_SIZE 1 +#define EFFICIENT_SIZE 6 // Set this to 1 if we would like to take the new GpuUpload approach which // relied on the glCopyTexSubImage2D instead of a glDraw call @@ -58,7 +61,7 @@ namespace WebCore { -TransferQueue::TransferQueue() +TransferQueue::TransferQueue(bool useMinimalMem) : m_eglSurface(EGL_NO_SURFACE) , m_transferQueueIndex(0) , m_fboID(0) @@ -69,10 +72,9 @@ TransferQueue::TransferQueue() , m_currentUploadType(DEFAULT_UPLOAD_TYPE) { memset(&m_GLStateBeforeBlit, 0, sizeof(m_GLStateBeforeBlit)); - - m_emptyItemCount = ST_BUFFER_NUMBER; - - m_transferQueue = new TileTransferData[ST_BUFFER_NUMBER]; + m_transferQueueSize = useMinimalMem ? MINIMAL_SIZE : EFFICIENT_SIZE; + m_emptyItemCount = m_transferQueueSize; + m_transferQueue = new TileTransferData[m_transferQueueSize]; } TransferQueue::~TransferQueue() @@ -118,7 +120,7 @@ void TransferQueue::initGLResources(int width, int height) int extraBuffersNeeded = 0; m_ANW->query(m_ANW.get(), NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &extraBuffersNeeded); - m_sharedSurfaceTexture->setBufferCount(ST_BUFFER_NUMBER + extraBuffersNeeded); + m_sharedSurfaceTexture->setBufferCount(m_transferQueueSize + extraBuffersNeeded); int result = native_window_set_buffers_geometry(m_ANW.get(), width, height, HAL_PIXEL_FORMAT_RGBA_8888); @@ -324,7 +326,7 @@ void TransferQueue::emptyQueue() // Must be called within a m_transferQueueItemLocks. void TransferQueue::setPendingDiscard() { - for (int i = 0 ; i < ST_BUFFER_NUMBER; i++) + for (int i = 0 ; i < m_transferQueueSize; i++) if (m_transferQueue[i].status == pendingBlit) m_transferQueue[i].status = pendingDiscard; @@ -377,7 +379,7 @@ void TransferQueue::updateDirtyBaseTiles() const int nextItemIndex = getNextTransferQueueIndex(); int index = nextItemIndex; bool usedFboForUpload = false; - for (int k = 0; k < ST_BUFFER_NUMBER ; k++) { + for (int k = 0; k < m_transferQueueSize ; k++) { if (m_transferQueue[index].status == pendingBlit) { bool obsoleteBaseTile = checkObsolete(&m_transferQueue[index]); // Save the needed info, update the Surf Tex, clean up the item in @@ -400,7 +402,7 @@ void TransferQueue::updateDirtyBaseTiles() m_transferQueue[index].status = emptyItem; if (obsoleteBaseTile) { XLOG("Warning: the texture is obsolete for this baseTile"); - index = (index + 1) % ST_BUFFER_NUMBER; + index = (index + 1) % m_transferQueueSize; continue; } @@ -437,7 +439,7 @@ void TransferQueue::updateDirtyBaseTiles() destTexture, destTexture->m_ownTextureId); } - index = (index + 1) % ST_BUFFER_NUMBER; + index = (index + 1) % m_transferQueueSize; } // Clean up FBO setup. Doing this for both CPU/GPU upload can make the @@ -449,7 +451,7 @@ void TransferQueue::updateDirtyBaseTiles() GLUtils::checkGlError("updateDirtyBaseTiles"); } - m_emptyItemCount = ST_BUFFER_NUMBER; + m_emptyItemCount = m_transferQueueSize; m_transferQueueItemCond.signal(); } @@ -572,7 +574,7 @@ void TransferQueue::addItemInTransferQueue(const TileRenderInfo* renderInfo, TextureUploadType type, const SkBitmap* bitmap) { - m_transferQueueIndex = (m_transferQueueIndex + 1) % ST_BUFFER_NUMBER; + m_transferQueueIndex = (m_transferQueueIndex + 1) % m_transferQueueSize; int index = m_transferQueueIndex; if (m_transferQueue[index].savedBaseTilePtr @@ -614,7 +616,7 @@ void TransferQueue::cleanupPendingDiscard() { int index = getNextTransferQueueIndex(); - for (int i = 0 ; i < ST_BUFFER_NUMBER; i++) { + for (int i = 0 ; i < m_transferQueueSize; i++) { if (m_transferQueue[index].status == pendingDiscard) { // No matter what the current upload type is, as long as there has // been a Surf Tex enqueue operation, this updateTexImage need to @@ -640,7 +642,7 @@ void TransferQueue::cleanupPendingDiscard() m_transferQueue[index].savedBaseTileTexturePtr = 0; m_transferQueue[index].status = emptyItem; } - index = (index + 1) % ST_BUFFER_NUMBER; + index = (index + 1) % m_transferQueueSize; } } @@ -689,7 +691,7 @@ void TransferQueue::restoreGLState() int TransferQueue::getNextTransferQueueIndex() { - return (m_transferQueueIndex + 1) % ST_BUFFER_NUMBER; + return (m_transferQueueIndex + 1) % m_transferQueueSize; } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.h b/Source/WebCore/platform/graphics/android/TransferQueue.h index ec3e5e2..5dd2e0a 100644 --- a/Source/WebCore/platform/graphics/android/TransferQueue.h +++ b/Source/WebCore/platform/graphics/android/TransferQueue.h @@ -108,7 +108,7 @@ public: class TransferQueue { public: - TransferQueue(); + TransferQueue(bool useMinimalMem); ~TransferQueue(); // This will be called by the browser through nativeSetProperty @@ -220,6 +220,9 @@ private: // resource limited. To get better performance, it is better to separate // the pure color tile into another queue. WTF::Vector<TileTransferData> m_pureColorTileQueue; + + // The number of items transfer queue can buffer up. + int m_transferQueueSize; }; } // namespace WebCore |