summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp')
-rw-r--r--Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp140
1 files changed, 31 insertions, 109 deletions
diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
index 9c7716c..c9a8b9a 100644
--- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
@@ -29,6 +29,7 @@
#if USE(ACCELERATED_COMPOSITING)
#include "ClassTracker.h"
#include "GLUtils.h"
+#include "LayerGroup.h"
#include "ShaderProgram.h"
#include "SkCanvas.h"
#include "TilesManager.h"
@@ -67,6 +68,7 @@ using namespace android;
BaseLayerAndroid::BaseLayerAndroid()
#if USE(ACCELERATED_COMPOSITING)
: m_color(Color::white)
+ , m_content(0)
, m_scrollState(NotScrolling)
#endif
{
@@ -77,23 +79,17 @@ BaseLayerAndroid::BaseLayerAndroid()
BaseLayerAndroid::~BaseLayerAndroid()
{
- m_content.clear();
+ SkSafeUnref(m_content);
#ifdef DEBUG_COUNT
ClassTracker::instance()->decrement("BaseLayerAndroid");
#endif
}
-void BaseLayerAndroid::setContent(const PictureSet& src)
+void BaseLayerAndroid::setContent(LayerContent* content)
{
-#if USE(ACCELERATED_COMPOSITING)
- // FIXME: We lock here because we do not want
- // to paint and change the m_content concurrently.
- // We should instead refactor PictureSet to use
- // an atomic refcounting scheme and use atomic operations
- // to swap PictureSets.
- android::Mutex::Autolock lock(m_drawLock);
-#endif
- m_content.set(src);
+ SkSafeRef(content);
+ SkSafeUnref(m_content);
+ m_content = content;
// FIXME: We cannot set the size of the base layer because it will screw up
// the matrix used. We need to fix matrix computation for the base layer
// and then we can set the size.
@@ -102,17 +98,15 @@ void BaseLayerAndroid::setContent(const PictureSet& src)
bool BaseLayerAndroid::drawCanvas(SkCanvas* canvas)
{
-#if USE(ACCELERATED_COMPOSITING)
android::Mutex::Autolock lock(m_drawLock);
-#endif
- if (!m_content.isEmpty())
- m_content.draw(canvas);
+ if (m_content && !m_content->isEmpty())
+ m_content->draw(canvas);
return true;
}
#if USE(ACCELERATED_COMPOSITING)
-void BaseLayerAndroid::prefetchBasePicture(SkRect& viewport, float currentScale,
+void BaseLayerAndroid::prefetchBasePicture(const SkRect& viewport, float currentScale,
TiledPage* prefetchTiledPage, bool draw)
{
SkIRect bounds;
@@ -131,7 +125,7 @@ void BaseLayerAndroid::prefetchBasePicture(SkRect& viewport, float currentScale,
viewport.fTop,
viewport.fRight,
viewport.fBottom,
- scale);
+ currentScale);
bounds.fLeft = static_cast<int>(floorf(viewport.fLeft * invTileWidth)) - PREFETCH_X_DIST;
bounds.fTop = static_cast<int>(floorf(viewport.fTop * invTileHeight)) - PREFETCH_Y_DIST;
@@ -141,11 +135,11 @@ void BaseLayerAndroid::prefetchBasePicture(SkRect& viewport, float currentScale,
XLOG("prefetch rect %d %d %d %d, scale %f, preparing page %p",
bounds.fLeft, bounds.fTop,
bounds.fRight, bounds.fBottom,
- scale * PREFETCH_SCALE,
+ prefetchScale,
prefetchTiledPage);
prefetchTiledPage->setScale(prefetchScale);
- prefetchTiledPage->updateTileDirtiness(bounds);
+ prefetchTiledPage->updateTileDirtiness();
prefetchTiledPage->prepare(goingDown, goingLeft, bounds,
TiledPage::ExpandedBounds);
prefetchTiledPage->swapBuffersIfReady(bounds,
@@ -167,20 +161,11 @@ bool BaseLayerAndroid::isReady()
return false;
}
- LayerAndroid* compositedRoot = static_cast<LayerAndroid*>(getChild(0));
- if (compositedRoot) {
- XLOG("base layer is ready, how about children?");
- return compositedRoot->isReady();
- }
-
return true;
}
void BaseLayerAndroid::swapTiles()
{
- if (countChildren())
- getChild(0)->swapTiles(); // TODO: move to parent impl
-
m_state->frontPage()->swapBuffersIfReady(m_state->preZoomBounds(),
m_state->zoomManager()->currentScale());
@@ -188,37 +173,22 @@ void BaseLayerAndroid::swapTiles()
m_state->zoomManager()->currentScale());
}
-void BaseLayerAndroid::setIsDrawing(bool isDrawing)
-{
- if (countChildren())
- getChild(0)->setIsDrawing(isDrawing); // TODO: move to parent impl
-}
-
-void BaseLayerAndroid::setIsPainting(Layer* drawingTree)
+void BaseLayerAndroid::setIsPainting()
{
- XLOG("BLA %p painting, dirty %d", this, isDirty());
- if (drawingTree)
- drawingTree = drawingTree->getChild(0);
-
- if (countChildren())
- getChild(0)->setIsPainting(drawingTree); // TODO: move to parent impl
-
+ XLOG("BLA %p setIsPainting, dirty %d", this, isDirty());
m_state->invalRegion(m_dirtyRegion);
m_dirtyRegion.setEmpty();
}
-void BaseLayerAndroid::mergeInvalsInto(Layer* replacementTree)
+void BaseLayerAndroid::mergeInvalsInto(BaseLayerAndroid* replacementLayer)
{
- XLOG("merging invals (empty=%d) from BLA %p to %p", m_dirtyRegion.isEmpty(), this, replacementTree);
- if (countChildren() && replacementTree->countChildren())
- getChild(0)->mergeInvalsInto(replacementTree->getChild(0));
-
- replacementTree->markAsDirty(m_dirtyRegion);
+ replacementLayer->markAsDirty(m_dirtyRegion);
}
-bool BaseLayerAndroid::prepareBasePictureInGL(SkRect& viewport, float scale,
- double currentTime)
+void BaseLayerAndroid::prepareGL(const SkRect& viewport, float scale, double currentTime)
{
+ XLOG("prepareGL BLA %p, m_state %p", this, m_state);
+
ZoomManager* zoomManager = m_state->zoomManager();
bool goingDown = m_state->goingDown();
@@ -241,8 +211,7 @@ bool BaseLayerAndroid::prepareBasePictureInGL(SkRect& viewport, float scale,
nextTiledPage->setScale(scale);
m_state->setFutureViewport(viewportTileBounds);
- // ignore dirtiness return value since while zooming we repaint regardless
- nextTiledPage->updateTileDirtiness(viewportTileBounds);
+ nextTiledPage->updateTileDirtiness();
nextTiledPage->prepare(goingDown, goingLeft, viewportTileBounds,
TiledPage::VisibleBounds);
@@ -279,10 +248,7 @@ bool BaseLayerAndroid::prepareBasePictureInGL(SkRect& viewport, float scale,
m_state->swapPages();
}
- bool needsRedraw = zooming;
-
- // if applied invals mark tiles dirty, need to redraw
- needsRedraw |= tiledPage->updateTileDirtiness(preZoomBounds);
+ tiledPage->updateTileDirtiness();
// paint what's needed unless we're zooming, since the new tiles won't
// be relevant soon anyway
@@ -290,8 +256,7 @@ bool BaseLayerAndroid::prepareBasePictureInGL(SkRect& viewport, float scale,
tiledPage->prepare(goingDown, goingLeft, preZoomBounds,
TiledPage::ExpandedBounds);
- XLOG("scrolling %d, zooming %d, needsRedraw %d",
- scrolling, zooming, needsRedraw);
+ XLOG("scrollState %d, zooming %d", m_scrollState, zooming);
// prefetch in the nextTiledPage if unused by zooming (even if not scrolling
// since we want the tiles to be ready before they're needed)
@@ -305,8 +270,6 @@ bool BaseLayerAndroid::prepareBasePictureInGL(SkRect& viewport, float scale,
}
tiledPage->prepareForDrawGL(transparency, preZoomBounds);
-
- return needsRedraw;
}
void BaseLayerAndroid::drawBasePictureInGL()
@@ -315,13 +278,13 @@ void BaseLayerAndroid::drawBasePictureInGL()
m_state->frontPage()->drawGL();
}
-#endif // USE(ACCELERATED_COMPOSITING)
-
-void BaseLayerAndroid::updateLayerPositions(SkRect& visibleRect)
+void BaseLayerAndroid::updateLayerPositions(const SkRect& visibleRect)
{
LayerAndroid* compositedRoot = static_cast<LayerAndroid*>(getChild(0));
+ if (!compositedRoot)
+ return;
TransformationMatrix ident;
- compositedRoot->updateFixedLayersPositions(visibleRect);
+ compositedRoot->updateLayerPositions(visibleRect);
FloatRect clip(0, 0, content()->width(), content()->height());
compositedRoot->updateGLPositionsAndScale(
ident, clip, 1, m_state->zoomManager()->layersScale());
@@ -334,57 +297,16 @@ void BaseLayerAndroid::updateLayerPositions(SkRect& visibleRect)
#endif
}
-bool BaseLayerAndroid::prepare(double currentTime, IntRect& viewRect,
- SkRect& visibleRect, float scale)
-{
- XLOG("preparing BLA %p", this);
-
- // base layer is simply drawn in prepare, since there is always a base layer it doesn't matter
- bool needsRedraw = prepareBasePictureInGL(visibleRect, scale, currentTime);
-
- LayerAndroid* compositedRoot = static_cast<LayerAndroid*>(getChild(0));
- if (compositedRoot) {
- updateLayerPositions(visibleRect);
-
- XLOG("preparing BLA %p, root %p", this, compositedRoot);
- compositedRoot->prepare();
- }
-
- return needsRedraw;
-}
+#endif // USE(ACCELERATED_COMPOSITING)
-bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
- float scale)
+void BaseLayerAndroid::drawGL(float scale)
{
- XLOG("drawing BLA %p", this);
+ XLOG("drawGL BLA %p", this);
// TODO: consider moving drawBackground outside of prepare (into tree manager)
m_state->drawBackground(m_color);
drawBasePictureInGL();
-
- bool needsRedraw = false;
-
-#if USE(ACCELERATED_COMPOSITING)
-
- LayerAndroid* compositedRoot = static_cast<LayerAndroid*>(getChild(0));
- if (compositedRoot) {
- updateLayerPositions(visibleRect);
- // For now, we render layers only if the rendering mode
- // is kAllTextures or kClippedTextures
- if (compositedRoot->drawGL()) {
- if (TilesManager::instance()->layerTexturesRemain()) {
- // only try redrawing for layers if layer textures remain,
- // otherwise we'll repaint without getting anything done
- needsRedraw = true;
- }
- }
- }
-
-#endif // USE(ACCELERATED_COMPOSITING)
-#ifdef DEBUG
- ClassTracker::instance()->show();
-#endif
- return needsRedraw;
+ m_state->glExtras()->drawGL(0);
}
} // namespace WebCore