summaryrefslogtreecommitdiffstats
path: root/WebCore/platform
diff options
context:
space:
mode:
authorNicolas Roard <nicolas@android.com>2011-02-15 17:48:19 -0800
committerNicolas Roard <nicolas@android.com>2011-02-15 17:48:19 -0800
commitf18fc03d63334e364d1a1b8e07dafb3fb0650c92 (patch)
treea96e3d634e643578b109487028ca034e55d137a0 /WebCore/platform
parente5c90f700f64667817813fbb2e8478ddb7a6927b (diff)
downloadexternal_webkit-f18fc03d63334e364d1a1b8e07dafb3fb0650c92.zip
external_webkit-f18fc03d63334e364d1a1b8e07dafb3fb0650c92.tar.gz
external_webkit-f18fc03d63334e364d1a1b8e07dafb3fb0650c92.tar.bz2
Improve layers repaint speed.
Computing the layers texture size is heavy; we delay this computation if one was done recently. bug:3375416 Change-Id: I0ce79cdfcaa15cd1521370a1d5b8df5a5e5ea2c5
Diffstat (limited to 'WebCore/platform')
-rw-r--r--WebCore/platform/graphics/android/BaseLayerAndroid.cpp14
-rw-r--r--WebCore/platform/graphics/android/BaseLayerAndroid.h2
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp13
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.h6
4 files changed, 20 insertions, 15 deletions
diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
index 2f0e999..35c3b36 100644
--- a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
@@ -116,12 +116,11 @@ void BaseLayerAndroid::drawCanvas(SkCanvas* canvas)
}
#if USE(ACCELERATED_COMPOSITING)
-bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale)
+bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale, double currentTime)
{
if (!m_glWebViewState)
return false;
- double currentTime = WTF::currentTime();
bool goingDown = m_previousVisible.fTop - viewport.fTop <= 0;
bool goingLeft = m_previousVisible.fLeft - viewport.fLeft >= 0;
@@ -282,7 +281,8 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
shader->setViewRect(viewRect);
shader->setViewport(visibleRect);
- ret = drawBasePictureInGL(visibleRect, scale);
+ double currentTime = WTF::currentTime();
+ ret = drawBasePictureInGL(visibleRect, scale, currentTime);
if (countChildren() >= 1) {
LayerAndroid* compositedRoot = static_cast<LayerAndroid*>(getChild(0));
@@ -311,7 +311,7 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
scale = m_glWebViewState->futureScale();
}
compositedRoot->setScale(scale);
- compositedRoot->computeTextureSize();
+ compositedRoot->computeTextureSize(currentTime);
compositedRoot->reserveGLTextures();
#ifdef DEBUG
@@ -337,12 +337,6 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
glBindBuffer(GL_ARRAY_BUFFER, 0);
m_previousVisible = visibleRect;
-#ifdef DEBUG_COUNT
- XLOG("GLWebViewState(%d) DoubleBufferedTexture(%d) BaseTile(%d) TileSet(%d) TiledPage(%d)",
- GLWebViewState::count(), DoubleBufferedTexture::count(),
- BaseTile::count(), TileSet::count(), TiledPage::count());
-#endif // DEBUG_COUNT
-
#endif // USE(ACCELERATED_COMPOSITING)
#ifdef DEBUG
ClassTracker::instance()->show();
diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.h b/WebCore/platform/graphics/android/BaseLayerAndroid.h
index c57b13d..cb1caef 100644
--- a/WebCore/platform/graphics/android/BaseLayerAndroid.h
+++ b/WebCore/platform/graphics/android/BaseLayerAndroid.h
@@ -59,7 +59,7 @@ public:
void swapExtra(BaseLayerAndroid* base) { m_extra.swap(base->m_extra); }
private:
#if USE(ACCELERATED_COMPOSITING)
- bool drawBasePictureInGL(SkRect& viewport, float scale);
+ bool drawBasePictureInGL(SkRect& viewport, float scale, double currentTime);
GLWebViewState* m_glWebViewState;
android::Mutex m_drawLock;
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index bee423c..7375cba 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -75,7 +75,8 @@ LayerAndroid::LayerAndroid(bool isRootLayer) : SkLayer(),
m_reservedTexture(0),
m_pictureUsed(0),
m_requestSent(false),
- m_scale(1)
+ m_scale(1),
+ m_lastComputeTextureSize(0)
{
m_backgroundColor = 0;
@@ -123,6 +124,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer),
m_dirty = layer.m_dirty;
m_pictureUsed = layer.m_pictureUsed;
m_scale = layer.m_scale;
+ m_lastComputeTextureSize = 0;
for (int i = 0; i < layer.countChildren(); i++)
addChild(layer.getChild(i)->copy())->unref();
@@ -147,7 +149,8 @@ LayerAndroid::LayerAndroid(SkPicture* picture) : SkLayer(),
m_drawingTexture(0),
m_reservedTexture(0),
m_requestSent(false),
- m_scale(1)
+ m_scale(1),
+ m_lastComputeTextureSize(0)
{
m_backgroundColor = 0;
m_dirty = false;
@@ -651,8 +654,12 @@ static inline bool compareLayerFullSize(const LayerAndroid* a, const LayerAndroi
return sizeA > sizeB;
}
-void LayerAndroid::computeTextureSize()
+void LayerAndroid::computeTextureSize(double time)
{
+ if (m_lastComputeTextureSize + s_computeTextureDelay > time)
+ return;
+ m_lastComputeTextureSize = time;
+
// First, we collect the layers, computing m_layerTextureRect
// as being clipped against the viewport
Vector <LayerAndroid*> layers;
diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h
index 2cb56c1..0d5a878 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/WebCore/platform/graphics/android/LayerAndroid.h
@@ -111,7 +111,7 @@ public:
void showLayers(int indent = 0);
// Texture size functions
- void computeTextureSize();
+ void computeTextureSize(double time);
void collect(Vector<LayerAndroid*>& layers,
int& size);
int clippedTextureSize() const;
@@ -325,6 +325,10 @@ private:
float m_scale;
+ // We try to not always compute the texture size, as this is quite heavy
+ static const double s_computeTextureDelay = 0.2; // 200 ms
+ double m_lastComputeTextureSize;
+
// This mutex serves two purposes. (1) It ensures that certain operations
// happen atomically and (2) it makes sure those operations are synchronized
// across all threads and cores.