summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeng-Hui Zhu <ztenghui@google.com>2012-02-27 14:31:00 -0800
committerTeng-Hui Zhu <ztenghui@google.com>2012-02-27 16:40:57 -0800
commit886eb87d34570b706a0f17fa944d98870ed6a2af (patch)
tree9ddf1fdc73d0c25a0cdea7aa7b662d480b0c7e11
parenteec5b0af072de315fa24ad51ff99ad9c09ace399 (diff)
downloadexternal_webkit-886eb87d34570b706a0f17fa944d98870ed6a2af.zip
external_webkit-886eb87d34570b706a0f17fa944d98870ed6a2af.tar.gz
external_webkit-886eb87d34570b706a0f17fa944d98870ed6a2af.tar.bz2
Gl resource should be re-initialized after EGL context changed
EGLContext can be re-created when memory pressure is very high, that will delete all the GL resources automatically. After this, we should re-create the GL resources for webView. bug:6075574 Change-Id: I3035554d124cee38df3ba2dfae1eda0568b45d0f
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp18
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.cpp1
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.h5
-rw-r--r--Source/WebKit/android/nav/WebView.cpp4
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 9e3c094..7919fdd 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -2267,8 +2267,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);