summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2012-01-30 18:22:08 -0800
committerChris Craik <ccraik@google.com>2012-02-02 15:38:32 -0800
commit246bd5b4427d0a0feaa2e1a128be9ad53100631c (patch)
tree3a0a41d5a39f8a95e30c1261b2970eb1165cd489 /Source
parent82921a8052f869822cbd9fb6d54750c480ac9054 (diff)
downloadexternal_webkit-246bd5b4427d0a0feaa2e1a128be9ad53100631c.zip
external_webkit-246bd5b4427d0a0feaa2e1a128be9ad53100631c.tar.gz
external_webkit-246bd5b4427d0a0feaa2e1a128be9ad53100631c.tar.bz2
Plumbing to notify WebViewCore when paints should pause
Change-Id: I93c76ccd401b1fe611cc9c1ea361251667422c7b
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp40
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.h2
-rw-r--r--Source/WebCore/platform/graphics/android/TreeManager.cpp35
-rw-r--r--Source/WebCore/platform/graphics/android/TreeManager.h7
-rw-r--r--Source/WebKit/android/nav/WebView.cpp60
5 files changed, 67 insertions, 77 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
index b701169..c96f5ea 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -94,6 +94,7 @@ GLWebViewState::GLWebViewState()
, m_expandedTileBoundsY(0)
, m_scale(1)
, m_layersRenderingMode(kAllTextures)
+ , m_treeManager(this)
{
m_viewport.setEmpty();
m_futureViewportTileBounds.setEmpty();
@@ -129,8 +130,8 @@ GLWebViewState::~GLWebViewState()
}
-void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const SkRegion& inval,
- bool showVisualIndicator, bool isPictureAfterFirstLayout)
+bool GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, bool showVisualIndicator,
+ bool isPictureAfterFirstLayout)
{
if (!layer || isPictureAfterFirstLayout) {
// TODO: move this into TreeManager
@@ -142,9 +143,8 @@ void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const SkRegion& inval
if (layer) {
XLOG("new base layer %p, (inval region empty %d) with child %p", layer, inval.isEmpty(), layer->getChild(0));
layer->setState(this);
- layer->markAsDirty(inval); // TODO: set in webview.cpp
}
- m_treeManager.updateWithTree(layer, isPictureAfterFirstLayout);
+ bool queueFull = m_treeManager.updateWithTree(layer, isPictureAfterFirstLayout);
m_glExtras.setDrawExtra(0);
#ifdef MEASURES_PERF
@@ -154,6 +154,7 @@ void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const SkRegion& inval
#endif
TilesManager::instance()->setShowVisualIndicator(showVisualIndicator);
+ return queueFull;
}
void GLWebViewState::scrollLayer(int layerId, int x, int y)
@@ -244,8 +245,24 @@ int GLWebViewState::baseContentHeight()
void GLWebViewState::setViewport(SkRect& viewport, float scale)
{
+ // allocate max possible number of tiles visible with this viewport / expandedTileBounds
+ const float invTileContentWidth = scale / TilesManager::tileWidth();
+ const float invTileContentHeight = scale / TilesManager::tileHeight();
+
+ int viewMaxTileX = static_cast<int>(ceilf((viewport.width()-1) * invTileContentWidth)) + 1;
+ int viewMaxTileY = static_cast<int>(ceilf((viewport.height()-1) * invTileContentHeight)) + 1;
+
+ TilesManager* manager = TilesManager::instance();
+ int maxTextureCount = (viewMaxTileX + m_expandedTileBoundsX * 2) *
+ (viewMaxTileY + m_expandedTileBoundsY * 2) * (manager->highEndGfx() ? 4 : 2);
+
+ manager->setMaxTextureCount(maxTextureCount);
+ m_tiledPageA->updateBaseTileSize();
+ m_tiledPageB->updateBaseTileSize();
+
if ((m_viewport == viewport) &&
(zoomManager()->futureScale() == scale)) {
+ // everything below will stay the same, early return.
m_isViewportScrolling = false;
return;
}
@@ -262,26 +279,11 @@ void GLWebViewState::setViewport(SkRect& viewport, float scale)
m_viewport.width(), m_viewport.height(), scale,
zoomManager()->currentScale(), zoomManager()->futureScale());
- const float invTileContentWidth = scale / TilesManager::tileWidth();
- const float invTileContentHeight = scale / TilesManager::tileHeight();
-
m_viewportTileBounds.set(
static_cast<int>(floorf(viewport.fLeft * invTileContentWidth)),
static_cast<int>(floorf(viewport.fTop * invTileContentHeight)),
static_cast<int>(ceilf(viewport.fRight * invTileContentWidth)),
static_cast<int>(ceilf(viewport.fBottom * invTileContentHeight)));
-
- // allocate max possible number of tiles visible with this viewport
- int viewMaxTileX = static_cast<int>(ceilf((viewport.width()-1) * invTileContentWidth)) + 1;
- int viewMaxTileY = static_cast<int>(ceilf((viewport.height()-1) * invTileContentHeight)) + 1;
-
- TilesManager* manager = TilesManager::instance();
- int maxTextureCount = (viewMaxTileX + m_expandedTileBoundsX * 2) *
- (viewMaxTileY + m_expandedTileBoundsY * 2) * (manager->highEndGfx() ? 4 : 2);
-
- manager->setMaxTextureCount(maxTextureCount);
- m_tiledPageA->updateBaseTileSize();
- m_tiledPageB->updateBaseTileSize();
}
#ifdef MEASURES_PERF
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h
index 169e276..cc0c56b 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.h
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h
@@ -176,7 +176,7 @@ public:
void setFutureViewport(const SkIRect& viewport) { m_futureViewportTileBounds = viewport; }
unsigned int paintBaseLayerContent(SkCanvas* canvas);
- void setBaseLayer(BaseLayerAndroid* layer, const SkRegion& inval, bool showVisualIndicator,
+ bool setBaseLayer(BaseLayerAndroid* layer, bool showVisualIndicator,
bool isPictureAfterFirstLayout);
void paintExtras();
diff --git a/Source/WebCore/platform/graphics/android/TreeManager.cpp b/Source/WebCore/platform/graphics/android/TreeManager.cpp
index be161a0..fd5e525 100644
--- a/Source/WebCore/platform/graphics/android/TreeManager.cpp
+++ b/Source/WebCore/platform/graphics/android/TreeManager.cpp
@@ -52,8 +52,9 @@
namespace WebCore {
-TreeManager::TreeManager()
- : m_drawingTree(0)
+TreeManager::TreeManager(GLWebViewState* state)
+ : m_state(state)
+ , m_drawingTree(0)
, m_paintingTree(0)
, m_queuedTree(0)
, m_fastSwapMode(false)
@@ -110,18 +111,13 @@ void TreeManager::clearTrees()
{
// remove painted surfaces from any tree in this view, and set trees as no
// longer drawing, to clear ptrs from surfaces to layers
- GLWebViewState* oldState = 0;
- if (m_drawingTree) {
- oldState = m_drawingTree->state();
+ if (m_drawingTree)
m_drawingTree->setIsDrawing(false);
- }
- if (m_paintingTree) {
- oldState = m_paintingTree->state();
+ if (m_paintingTree)
m_paintingTree->setIsDrawing(false);
- }
- XLOG("TreeManager %p removing PS from state %p", this, oldState);
- TilesManager::instance()->paintedSurfacesCleanup(oldState);
+ XLOG("TreeManager %p removing PS from state %p", this, m_state);
+ TilesManager::instance()->paintedSurfacesCleanup(m_state);
SkSafeUnref(m_drawingTree);
m_drawingTree = 0;
@@ -132,8 +128,9 @@ void TreeManager::clearTrees()
}
// a new layer tree has arrived, queue it if we're painting something already,
-// or start painting it if we aren't
-void TreeManager::updateWithTree(Layer* newTree, bool brandNew)
+// or start painting it if we aren't. Returns true if the manager has two trees
+// already queued.
+bool TreeManager::updateWithTree(Layer* newTree, bool brandNew)
{
XLOG("updateWithTree - %p, has children %d, has animations %d",
newTree, newTree && newTree->countChildren(),
@@ -153,7 +150,7 @@ void TreeManager::updateWithTree(Layer* newTree, bool brandNew)
m_paintingTree = newTree;
m_paintingTree->setIsPainting(m_drawingTree);
}
- return;
+ return false;
}
if (m_queuedTree || m_paintingTree) {
@@ -175,12 +172,12 @@ void TreeManager::updateWithTree(Layer* newTree, bool brandNew)
}
SkSafeUnref(m_queuedTree);
m_queuedTree = newTree;
- return;
+ } else {
+ // don't have painting tree, paint this one!
+ m_paintingTree = newTree;
+ m_paintingTree->setIsPainting(m_drawingTree);
}
-
- // don't have painting tree, paint this one!
- m_paintingTree = newTree;
- m_paintingTree->setIsPainting(m_drawingTree);
+ return m_drawingTree && TilesManager::instance()->useDoubleBuffering();
}
void TreeManager::updateScrollableLayerInTree(Layer* tree, int layerId, int x, int y)
diff --git a/Source/WebCore/platform/graphics/android/TreeManager.h b/Source/WebCore/platform/graphics/android/TreeManager.h
index 83d5300..a571d1a 100644
--- a/Source/WebCore/platform/graphics/android/TreeManager.h
+++ b/Source/WebCore/platform/graphics/android/TreeManager.h
@@ -36,16 +36,17 @@ class SkCanvas;
namespace WebCore {
+class GLWebViewState;
class IntRect;
class TexturesResult;
class TEST_EXPORT TreeManager {
public:
- TreeManager();
+ TreeManager(GLWebViewState* state);
~TreeManager();
- void updateWithTree(Layer* tree, bool brandNew);
+ bool updateWithTree(Layer* tree, bool brandNew);
void updateScrollableLayer(int layerId, int x, int y);
@@ -70,6 +71,8 @@ private:
android::Mutex m_paintSwapLock;
+ GLWebViewState* m_state;
+
Layer* m_drawingTree;
Layer* m_paintingTree;
Layer* m_queuedTree;
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index efdb67f..8e819fb 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -201,7 +201,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl, WTF::String drawableDir,
m_isDrawingPaused = false;
#if USE(ACCELERATED_COMPOSITING)
m_glWebViewState = 0;
- m_pageSwapCallbackRegistered = false;
#endif
}
@@ -470,7 +469,6 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect,
if (!m_glWebViewState) {
TilesManager::instance()->setHighEndGfx(m_isHighEndGfx);
-
m_glWebViewState = new GLWebViewState();
m_glWebViewState->glExtras()->setCursorRingExtra(&m_ring);
m_glWebViewState->glExtras()->setFindOnPageExtra(&m_findOnPage);
@@ -479,7 +477,8 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect,
SkIRect rect;
rect.set(0, 0, m_baseLayer->content()->width(), m_baseLayer->content()->height());
region.setRect(rect);
- m_glWebViewState->setBaseLayer(m_baseLayer, region, false, true);
+ m_baseLayer->markAsDirty(region);
+ m_glWebViewState->setBaseLayer(m_baseLayer, false, true);
}
}
@@ -498,8 +497,7 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect,
bool ret = m_glWebViewState->drawGL(viewRect, m_visibleRect, invalRect,
webViewRect, titleBarHeight, clip, scale,
&treesSwapped, &newTreeHasAnim);
- if (treesSwapped && (m_pageSwapCallbackRegistered || newTreeHasAnim)) {
- m_pageSwapCallbackRegistered = false;
+ if (treesSwapped) {
ALOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!");
JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject javaObject = m_javaGlue.object(env);
@@ -1324,19 +1322,17 @@ static void copyScrollPositionRecursive(const LayerAndroid* from,
}
#endif
-void registerPageSwapCallback()
-{
- m_pageSwapCallbackRegistered = true;
-}
-
-void setBaseLayer(BaseLayerAndroid* layer, SkRegion& inval, bool showVisualIndicator,
- bool isPictureAfterFirstLayout, bool registerPageSwapCallback)
+bool setBaseLayer(BaseLayerAndroid* layer, SkRegion& inval, bool showVisualIndicator,
+ bool isPictureAfterFirstLayout)
{
+ bool queueFull = false;
#if USE(ACCELERATED_COMPOSITING)
- if (m_glWebViewState)
- m_glWebViewState->setBaseLayer(layer, inval, showVisualIndicator,
- isPictureAfterFirstLayout);
- m_pageSwapCallbackRegistered |= registerPageSwapCallback;
+ if (m_glWebViewState) {
+ if (layer)
+ layer->markAsDirty(inval);
+ queueFull = m_glWebViewState->setBaseLayer(layer, showVisualIndicator,
+ isPictureAfterFirstLayout);
+ }
#endif
#if ENABLE(ANDROID_OVERFLOW_SCROLL)
@@ -1349,10 +1345,12 @@ void setBaseLayer(BaseLayerAndroid* layer, SkRegion& inval, bool showVisualIndic
SkSafeUnref(m_baseLayer);
m_baseLayer = layer;
CachedRoot* root = getFrameCache(DontAllowNewer);
- if (!root)
- return;
- root->resetLayers();
- root->setRootLayer(compositeRoot());
+ if (root) {
+ root->resetLayers();
+ root->setRootLayer(compositeRoot());
+ }
+
+ return queueFull;
}
void replaceBaseContent(PictureSet* set)
@@ -1450,7 +1448,6 @@ private: // local state for WebView
Functor* m_glDrawFunctor;
#if USE(ACCELERATED_COMPOSITING)
GLWebViewState* m_glWebViewState;
- bool m_pageSwapCallbackRegistered;
#endif
SkRect m_visibleRect;
bool m_isHighEndGfx;
@@ -1824,18 +1821,16 @@ static bool nativeEvaluateLayersAnimations(JNIEnv *env, jobject obj, jint native
return false;
}
-static void nativeSetBaseLayer(JNIEnv *env, jobject obj, jint nativeView, jint layer, jobject inval,
- jboolean showVisualIndicator,
- jboolean isPictureAfterFirstLayout,
- jboolean registerPageSwapCallback)
+static bool nativeSetBaseLayer(JNIEnv *env, jobject obj, jint nativeView, jint layer, jobject inval,
+ jboolean showVisualIndicator,
+ jboolean isPictureAfterFirstLayout)
{
BaseLayerAndroid* layerImpl = reinterpret_cast<BaseLayerAndroid*>(layer);
SkRegion invalRegion;
if (inval)
invalRegion = *GraphicsJNI::getNativeRegion(env, inval);
- ((WebView*)nativeView)->setBaseLayer(layerImpl, invalRegion, showVisualIndicator,
- isPictureAfterFirstLayout,
- registerPageSwapCallback);
+ return ((WebView*)nativeView)->setBaseLayer(layerImpl, invalRegion, showVisualIndicator,
+ isPictureAfterFirstLayout);
}
static BaseLayerAndroid* nativeGetBaseLayer(JNIEnv *env, jobject obj)
@@ -2357,11 +2352,6 @@ static jobject nativeGetSelection(JNIEnv *env, jobject obj)
return wtfStringToJstring(env, selection);
}
-static void nativeRegisterPageSwapCallback(JNIEnv *env, jobject obj, jint nativeView)
-{
- ((WebView*)nativeView)->registerPageSwapCallback();
-}
-
static void nativeDiscardAllTextures(JNIEnv *env, jobject obj)
{
//discard all textures for debugging/test purposes, but not gl backing memory
@@ -2757,7 +2747,7 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeSetFindIsUp },
{ "nativeSetHeightCanMeasure", "(Z)V",
(void*) nativeSetHeightCanMeasure },
- { "nativeSetBaseLayer", "(IILandroid/graphics/Region;ZZZ)V",
+ { "nativeSetBaseLayer", "(IILandroid/graphics/Region;ZZ)Z",
(void*) nativeSetBaseLayer },
{ "nativeGetBaseLayer", "()I",
(void*) nativeGetBaseLayer },
@@ -2769,8 +2759,6 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeHasContent },
{ "nativeShowCursorTimed", "()V",
(void*) nativeShowCursorTimed },
- { "nativeRegisterPageSwapCallback", "(I)V",
- (void*) nativeRegisterPageSwapCallback },
{ "nativeDiscardAllTextures", "()V",
(void*) nativeDiscardAllTextures },
{ "nativeTileProfilingStart", "()V",