diff options
author | Chris Craik <ccraik@google.com> | 2011-09-07 20:04:24 -0700 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2011-09-08 11:53:34 -0700 |
commit | 2986d27084d881dbe6f9c3ae35430a5978b7e659 (patch) | |
tree | d668f05a054a03035d07bae9e001ab8282f3d6ae /Source/WebCore/platform/graphics/android/BaseTileTexture.cpp | |
parent | 321b119b4942dca02c7557790c7951695473ae7d (diff) | |
download | external_webkit-2986d27084d881dbe6f9c3ae35430a5978b7e659.zip external_webkit-2986d27084d881dbe6f9c3ae35430a5978b7e659.tar.gz external_webkit-2986d27084d881dbe6f9c3ae35430a5978b7e659.tar.bz2 |
Deallocate graphics memory with onTrimMemory signals
bug:5269460
Deallocate the graphics memory backing a BaseTileTexture on onTrimMemory
signals, and accordingly allocate it lazily, as needed.
Change-Id: I52039723f47e6470e4fe8dd987d384017005390f
Diffstat (limited to 'Source/WebCore/platform/graphics/android/BaseTileTexture.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/android/BaseTileTexture.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp index 34de9e7..8cc67b9 100644 --- a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp +++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp @@ -58,7 +58,7 @@ BaseTileTexture::BaseTileTexture(uint32_t w, uint32_t h) , m_busy(false) { m_size.set(w, h); - m_ownTextureId = GLUtils::createBaseTileGLTexture(w, h); + m_ownTextureId = 0; // Make sure they are created on the UI thread. TilesManager::instance()->transferQueue()->initSharedSurfaceTextures(w, h); @@ -79,6 +79,18 @@ BaseTileTexture::~BaseTileTexture() #endif } +void BaseTileTexture::requireTexture() +{ + if (!m_ownTextureId) + m_ownTextureId = GLUtils::createBaseTileGLTexture(m_size.width(), m_size.height()); +} + +void BaseTileTexture::discardTexture() +{ + if (m_ownTextureId) + GLUtils::deleteTexture(&m_ownTextureId); +} + void BaseTileTexture::destroyTextures(SharedTexture** textures) { int x = 0; @@ -263,6 +275,13 @@ void BaseTileTexture::setOwnTextureTileInfoFromQueue(const TextureTileInfo* info bool BaseTileTexture::readyFor(BaseTile* baseTile) { + if (!m_ownTextureId) { + // If our backing opengl texture doesn't exist, allocate it and return + // false since it won't have useful data + requireTexture(); + return false; + } + const TextureTileInfo* info = &m_ownTextureTileInfo; if (info && (info->m_x == baseTile->x()) && |