summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2011-11-15 11:28:34 -0800
committerChris Craik <ccraik@google.com>2011-11-16 16:19:16 -0800
commitdfd2fb1ed3c17d0cbb4af895f74704c22130587f (patch)
tree7585dc40af1e239b777c4a339bc4ae128e796d73 /Source/WebCore/platform/graphics/android/PaintedSurface.cpp
parentd34224ca67791aa7215160c7be4900f965f79eea (diff)
downloadexternal_webkit-dfd2fb1ed3c17d0cbb4af895f74704c22130587f.zip
external_webkit-dfd2fb1ed3c17d0cbb4af895f74704c22130587f.tar.gz
external_webkit-dfd2fb1ed3c17d0cbb4af895f74704c22130587f.tar.bz2
synchronous layer updates, and animation deferral during paint
bug:5522081 bug:5239801 bug:5297563 Change-Id: I600f66999e093f720a8ea97ef3e15d3d1d297a8f
Diffstat (limited to 'Source/WebCore/platform/graphics/android/PaintedSurface.cpp')
-rw-r--r--Source/WebCore/platform/graphics/android/PaintedSurface.cpp117
1 files changed, 47 insertions, 70 deletions
diff --git a/Source/WebCore/platform/graphics/android/PaintedSurface.cpp b/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
index 939d106..d3c1e15 100644
--- a/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
+++ b/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
@@ -28,6 +28,7 @@
#include "LayerAndroid.h"
+#include "TiledTexture.h"
#include "TilesManager.h"
#include "SkCanvas.h"
#include "SkPicture.h"
@@ -57,107 +58,64 @@
namespace WebCore {
-PaintedSurface::PaintedSurface(LayerAndroid* layer)
- : m_layer(layer)
+PaintedSurface::PaintedSurface()
+ : m_drawingLayer(0)
+ , m_paintingLayer(0)
, m_tiledTexture(0)
, m_scale(0)
, m_pictureUsed(0)
{
TilesManager::instance()->addPaintedSurface(this);
- SkSafeRef(m_layer);
#ifdef DEBUG_COUNT
ClassTracker::instance()->increment("PaintedSurface");
#endif
m_tiledTexture = new DualTiledTexture(this);
- if (layer && layer->picture())
- m_updateManager.updatePicture(layer->picture());
}
PaintedSurface::~PaintedSurface()
{
- XLOG("dtor of %x m_layer: %x", this, m_layer);
- android::Mutex::Autolock lock(m_layerLock);
- SkSafeUnref(m_layer);
#ifdef DEBUG_COUNT
ClassTracker::instance()->decrement("PaintedSurface");
#endif
delete m_tiledTexture;
}
-void PaintedSurface::removeLayer()
-{
- android::Mutex::Autolock lock(m_layerLock);
- if (m_layer)
- m_layer->removeTexture(this);
- SkSafeUnref(m_layer);
- m_layer = 0;
-}
-
-void PaintedSurface::removeLayer(LayerAndroid* layer)
-{
- android::Mutex::Autolock lock(m_layerLock);
- if (m_layer != layer)
- return;
- SkSafeUnref(m_layer);
- m_layer = 0;
-}
-
-void PaintedSurface::replaceLayer(LayerAndroid* layer)
-{
- android::Mutex::Autolock lock(m_layerLock);
- if (!layer)
- return;
-
- if (m_layer && layer->uniqueId() != m_layer->uniqueId())
- return;
-
- SkSafeRef(layer);
- SkSafeUnref(m_layer);
- m_layer = layer;
- if (layer && layer->picture())
- m_updateManager.updatePicture(layer->picture());
-}
-
void PaintedSurface::prepare(GLWebViewState* state)
{
- if (!m_layer)
- return;
+ XLOG("PS %p has PL %p, DL %p", this, m_paintingLayer, m_drawingLayer);
+ LayerAndroid* paintingLayer = m_paintingLayer;
+ if (!paintingLayer)
+ paintingLayer = m_drawingLayer;
- if (!m_layer->needsTexture())
+ if (!paintingLayer)
return;
bool startFastSwap = false;
if (state->isScrolling()) {
// when scrolling, block updates and swap tiles as soon as they're ready
startFastSwap = true;
- } else {
- // when not, push updates down to TiledTexture in every prepare
- m_updateManager.swap();
- m_tiledTexture->update(m_updateManager.getPaintingInval(),
- m_updateManager.getPaintingPicture());
- m_updateManager.clearPaintingInval();
}
XLOG("prepare layer %d %x at scale %.2f",
- m_layer->uniqueId(), m_layer,
- m_layer->getScale());
+ paintingLayer->uniqueId(), paintingLayer,
+ paintingLayer->getScale());
- IntRect visibleArea = computeVisibleArea(m_layer);
+ IntRect visibleArea = computeVisibleArea(paintingLayer);
m_scale = state->scale();
// If we do not have text, we may as well limit ourselves to
// a scale factor of one... this saves up textures.
- if (m_scale > 1 && !m_layer->hasText())
+ if (m_scale > 1 && !paintingLayer->hasText())
m_scale = 1;
- m_tiledTexture->prepare(state, m_scale, m_pictureUsed != m_layer->pictureUsed(),
+ m_tiledTexture->prepare(state, m_scale, m_pictureUsed != paintingLayer->pictureUsed(),
startFastSwap, visibleArea);
}
bool PaintedSurface::draw()
{
- if (!m_layer || !m_layer->needsTexture())
+ if (!m_drawingLayer || !m_drawingLayer->needsTexture())
return false;
bool askRedraw = false;
@@ -167,22 +125,38 @@ bool PaintedSurface::draw()
return askRedraw;
}
-void PaintedSurface::markAsDirty(const SkRegion& dirtyArea)
+void PaintedSurface::setPaintingLayer(LayerAndroid* layer, const SkRegion& dirtyArea)
+{
+ m_paintingLayer = layer;
+ if (m_tiledTexture)
+ m_tiledTexture->update(dirtyArea, layer->picture());
+}
+
+bool PaintedSurface::isReady()
+{
+ if (m_tiledTexture)
+ return m_tiledTexture->isReady();
+ return false;
+}
+
+void PaintedSurface::swapTiles()
{
- m_updateManager.updateInval(dirtyArea);
+ if (m_tiledTexture)
+ m_tiledTexture->swapTiles();
}
float PaintedSurface::opacity() {
- if (m_layer)
- return m_layer->drawOpacity();
+ if (m_drawingLayer)
+ return m_drawingLayer->drawOpacity();
return 1.0;
}
const TransformationMatrix* PaintedSurface::transform() {
- if (!m_layer)
+ // used exclusively for drawing, so only use m_drawingLayer
+ if (!m_drawingLayer)
return 0;
- return m_layer->drawTransform();
+ return m_drawingLayer->drawTransform();
}
void PaintedSurface::computeTexturesAmount(TexturesResult* result)
@@ -190,11 +164,14 @@ void PaintedSurface::computeTexturesAmount(TexturesResult* result)
if (!m_tiledTexture)
return;
- if (!m_layer)
+ // for now, always done on drawinglayer
+ LayerAndroid* layer = m_drawingLayer;
+
+ if (!layer)
return;
- IntRect unclippedArea = m_layer->unclippedArea();
- IntRect clippedVisibleArea = m_layer->visibleArea();
+ IntRect unclippedArea = layer->unclippedArea();
+ IntRect clippedVisibleArea = layer->visibleArea();
// get two numbers here:
// - textures needed for a clipped area
// - textures needed for an un-clipped area
@@ -202,19 +179,19 @@ void PaintedSurface::computeTexturesAmount(TexturesResult* result)
int nbTexturesClipped = m_tiledTexture->nbTextures(clippedVisibleArea, m_scale);
// Set kFixedLayers level
- if (m_layer->isFixed())
+ if (layer->isFixed())
result->fixed += nbTexturesClipped;
// Set kScrollableAndFixedLayers level
- if (m_layer->contentIsScrollable()
- || m_layer->isFixed())
+ if (layer->contentIsScrollable()
+ || layer->isFixed())
result->scrollable += nbTexturesClipped;
// Set kClippedTextures level
result->clipped += nbTexturesClipped;
// Set kAllTextures level
- if (m_layer->contentIsScrollable())
+ if (layer->contentIsScrollable())
result->full += nbTexturesClipped;
else
result->full += nbTexturesUnclipped;