summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform
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/WebCore/platform
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/WebCore/platform')
-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
4 files changed, 43 insertions, 41 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;