summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2012-05-25 15:48:48 -0700
committerChris Craik <ccraik@google.com>2012-05-25 16:55:15 -0700
commitcfbfb3bbc3ed10f3e061b52c70e5c7935e96a45a (patch)
tree6f2b67c1fc3c4c4915cc198b6a347d056bcc6425
parent385ef015bf9d84a940d65586b9f70292f6b6fb63 (diff)
downloadexternal_webkit-cfbfb3bbc3ed10f3e061b52c70e5c7935e96a45a.zip
external_webkit-cfbfb3bbc3ed10f3e061b52c70e5c7935e96a45a.tar.gz
external_webkit-cfbfb3bbc3ed10f3e061b52c70e5c7935e96a45a.tar.bz2
Reduce UI-thread computation
If the current clip covers the entire view, we don't have to calculate framework invals from swapping layers - we already draw them immediately. bug:6530473 Change-Id: I4b639e06781371e37c246f3220b79f28e7d95649
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.h2
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp41
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.h9
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/Surface.cpp4
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/Surface.h2
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp4
7 files changed, 24 insertions, 40 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
index 4440912..d0273cf 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -333,6 +333,8 @@ int GLWebViewState::drawGL(IntRect& invScreenRect, SkRect& visibleContentRect,
screenRect.x(), screenRect.y(), screenRect.width(), screenRect.height(),
screenClip.x(), screenClip.y(), screenClip.width(), screenClip.height(), scale, titleBarHeight);
+ m_inUnclippedDraw = shouldDraw && (screenRect == screenClip);
+
resetLayersDirtyArea();
if (scale < MIN_SCALE_WARNING || scale > MAX_SCALE_WARNING)
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h
index b643405..4921e89 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.h
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h
@@ -190,6 +190,7 @@ public:
void addDirtyArea(const IntRect& rect);
void resetLayersDirtyArea();
void doFrameworkFullInval();
+ bool inUnclippedDraw() { return m_inUnclippedDraw; }
bool goingDown() { return m_goingDown; }
bool goingLeft() { return m_goingLeft; }
@@ -221,6 +222,7 @@ private:
SkRect m_visibleContentRect;
IntRect m_frameworkLayersInval;
bool m_doFrameworkFullInval;
+ bool m_inUnclippedDraw;
#ifdef MEASURES_PERF
unsigned int m_totalTimeCounter;
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
index 18f65c7..906b1c1 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
@@ -385,11 +385,9 @@ void LayerAndroid::updatePositions()
this->getChild(i)->updatePositions();
}
-void LayerAndroid::updateLocalGLPositionsAndScale(const TransformationMatrix& parentMatrix,
- const FloatRect& clipping, float opacity,
- float scale)
+void LayerAndroid::updateLocalTransformAndClip(const TransformationMatrix& parentMatrix,
+ const FloatRect& clipping)
{
- TRACE_METHOD();
FloatPoint position(getPosition().x() + m_replicatedLayerPosition.x() - getScrollOffset().x(),
getPosition().y() + m_replicatedLayerPosition.y() - getScrollOffset().y());
float originX = getAnchorPoint().x() * getWidth();
@@ -415,8 +413,8 @@ void LayerAndroid::updateLocalGLPositionsAndScale(const TransformationMatrix& pa
// that layers (defined in content coordinates) will align to display/view pixels
// the surface may not allow fudging if it uses the draw transform at paint time
- float desiredContentX = round(m_drawTransform.m41() * scale) / scale;
- float desiredContentY = round(m_drawTransform.m42() * scale) / scale;
+ float desiredContentX = round(m_drawTransform.m41() * m_scale) / m_scale;
+ float desiredContentY = round(m_drawTransform.m42() * m_scale) / m_scale;
ALOGV("fudging translation from %f, %f to %f, %f",
m_drawTransform.m41(), m_drawTransform.m42(),
desiredContentX, desiredContentY);
@@ -428,13 +426,6 @@ void LayerAndroid::updateLocalGLPositionsAndScale(const TransformationMatrix& pa
getSize().width(),
getSize().height());
- m_atomicSync.lock();
- m_scale = scale;
- m_atomicSync.unlock();
-
- opacity *= getOpacity();
- setDrawOpacity(opacity);
-
if (m_haveClip) {
// The clipping rect calculation and intersetion will be done in content
// coordinates.
@@ -450,28 +441,27 @@ void LayerAndroid::updateLocalGLPositionsAndScale(const TransformationMatrix& pa
m_haveClip, m_clippingRect.x(), m_clippingRect.y(),
m_clippingRect.width(), m_clippingRect.height());
- if (!m_backfaceVisibility
- && m_drawTransform.inverse().m33() < 0) {
- setVisible(false);
- return;
- } else {
- setVisible(true);
- }
+ setVisible(m_backfaceVisibility || m_drawTransform.inverse().m33() >= 0);
}
void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentMatrix,
const FloatRect& clipping, float opacity,
float scale, bool forceCalculation)
{
+ m_scale = scale;
+
+ opacity *= getOpacity();
+ setDrawOpacity(opacity);
+
// constantly recalculate the draw transform of layers that may require it (and their children)
forceCalculation |= isPositionFixed()
|| contentIsScrollable()
|| (m_animations.size() != 0);
if (forceCalculation)
- updateLocalGLPositionsAndScale(parentMatrix, clipping, opacity, scale);
+ updateLocalTransformAndClip(parentMatrix, clipping);
- if (!countChildren())
+ if (!countChildren() || !m_visible)
return;
TransformationMatrix localMatrix = m_drawTransform;
@@ -815,11 +805,6 @@ bool LayerAndroid::drawCanvas(SkCanvas* canvas, bool drawChildren, PaintStyle st
// When the layer is dirty, the UI thread should be notified to redraw.
askScreenUpdate |= drawChildrenCanvas(canvas, style);
- m_atomicSync.lock();
- if (askScreenUpdate || m_hasRunningAnimations || m_drawTransform.hasPerspective())
- addDirtyArea();
-
- m_atomicSync.unlock();
return askScreenUpdate;
}
@@ -835,10 +820,8 @@ bool LayerAndroid::drawGL(bool layerTilesDisabled)
state()->glExtras()->drawGL(this);
bool askScreenUpdate = false;
- m_atomicSync.lock();
if (m_hasRunningAnimations)
askScreenUpdate = true;
- m_atomicSync.unlock();
return askScreenUpdate;
}
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
index cd26356..936ced0 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
@@ -303,8 +303,8 @@ protected:
int m_uniqueId;
private:
- void updateLocalGLPositionsAndScale(const TransformationMatrix& parentMatrix,
- const FloatRect& clip, float opacity, float scale);
+ void updateLocalTransformAndClip(const TransformationMatrix& parentMatrix,
+ const FloatRect& clip);
#if DUMP_NAV_CACHE
friend class CachedLayer::Debug; // debugging access only
@@ -375,11 +375,6 @@ private:
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.
- android::Mutex m_atomicSync;
-
RenderLayer* m_owningLayer;
LayerType m_type;
diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
index 94b7b6e..106b045 100644
--- a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
@@ -264,12 +264,12 @@ bool Surface::drawGL(bool layerTilesDisabled)
return askRedraw;
}
-void Surface::swapTiles()
+void Surface::swapTiles(bool calculateFrameworkInvals)
{
if (!m_surfaceBacking)
return;
- if (m_surfaceBacking->swapTiles())
+ if (m_surfaceBacking->swapTiles() && calculateFrameworkInvals)
addFrameworkInvals();
}
diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.h b/Source/WebCore/platform/graphics/android/rendering/Surface.h
index 535d2c1..f9f38e6 100644
--- a/Source/WebCore/platform/graphics/android/rendering/Surface.h
+++ b/Source/WebCore/platform/graphics/android/rendering/Surface.h
@@ -51,7 +51,7 @@ public:
void addLayer(LayerAndroid* layer, const TransformationMatrix& transform);
void prepareGL(bool layerTilesDisabled, bool updateWithBlit);
bool drawGL(bool layerTilesDisabled);
- void swapTiles();
+ void swapTiles(bool calculateFrameworkInvals);
void addFrameworkInvals();
bool isReady();
bool isMissingContent();
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
index 83b81a1..093c947 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
@@ -137,9 +137,11 @@ Color SurfaceCollection::getBackgroundColor()
void SurfaceCollection::swapTiles()
{
+ bool calculateFrameworkInvals = !m_compositedRoot->state()->inUnclippedDraw();
+
TRACE_METHOD();
for (unsigned int i = 0; i < m_surfaces.size(); i++)
- m_surfaces[i]->swapTiles();
+ m_surfaces[i]->swapTiles(calculateFrameworkInvals);
}
void SurfaceCollection::addFrameworkInvals()