diff options
Diffstat (limited to 'Source')
4 files changed, 22 insertions, 6 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index 76d7324..86f33e0 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -351,18 +351,26 @@ double GLWebViewState::setupDrawing(const IntRect& viewRect, const SkRect& visib int top = viewRect.y(); int width = viewRect.width(); int height = viewRect.height(); + TilesManager* tilesManager = TilesManager::instance(); + + // Make sure the GL Context has not changed, otherwise, re-create all GL + // resources. Only check this after onTrimMemory happens. + bool contextChanged = tilesManager->contextChanged(); + tilesManager->setContextChanged(false); // Make sure GL resources are created on the UI thread. - ShaderProgram* shader = TilesManager::instance()->shader(); - if (shader->needsInit()) { - XLOG("Reinit shader"); + ShaderProgram* shader = tilesManager->shader(); + if (shader->needsInit() || contextChanged) { + XLOGC("Reinit shader"); shader->init(); } - TransferQueue* transferQueue = TilesManager::instance()->transferQueue(); - if (transferQueue->needsInit()) { + TransferQueue* transferQueue = tilesManager->transferQueue(); + if (transferQueue->needsInit() || contextChanged) { + XLOGC("Reinit transferQueue"); transferQueue->initGLResources(TilesManager::tileWidth(), TilesManager::tileHeight()); } + // TODO: Add the video GL resource re-initialization code here. shader->setupDrawing(viewRect, visibleRect, webViewRect, titleBarHeight, screenClip, scale); diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index 184d80c..6640230 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -110,6 +110,7 @@ TilesManager::TilesManager() , m_drawGLCount(1) , m_lastTimeLayersUsed(0) , m_hasLayerTextures(false) + , m_EGLContextChanged(true) { XLOG("TilesManager ctor"); m_textures.reserveCapacity(MAX_TEXTURE_ALLOCATION); diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h index b670055..749ba98 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.h +++ b/Source/WebCore/platform/graphics/android/TilesManager.h @@ -110,6 +110,9 @@ public: void setHighEndGfx(bool highEnd); bool highEndGfx(); + bool contextChanged() { return m_EGLContextChanged; } + void setContextChanged(bool changed) { m_EGLContextChanged = changed; } + int maxTextureCount(); int maxLayerTextureCount(); void setMaxTextureCount(int max); @@ -263,6 +266,8 @@ private: unsigned long long m_drawGLCount; double m_lastTimeLayersUsed; bool m_hasLayerTextures; + + bool m_EGLContextChanged; }; } // namespace WebCore diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 162d6bd..3abdd26 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -2151,8 +2151,10 @@ static void nativeOnTrimMemory(JNIEnv *env, jobject obj, jint level) // Texture to avoid ANR b/c framework may destroy the EGL context. // Refer to WindowManagerImpl.java for conditions we followed. if (level >= TRIM_MEMORY_MODERATE - && !TilesManager::instance()->highEndGfx()) + && !TilesManager::instance()->highEndGfx()) { TilesManager::instance()->transferQueue()->emptyQueue(); + TilesManager::instance()->setContextChanged(true); + } bool freeAllTextures = (level > TRIM_MEMORY_UI_HIDDEN), glTextures = true; TilesManager::instance()->discardTextures(freeAllTextures, glTextures); |