diff options
author | Chris Craik <ccraik@google.com> | 2012-05-29 14:06:39 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-05-29 14:06:39 -0700 |
commit | 2b9e710f9c95f93eba3e3fca22f32f1784b197c3 (patch) | |
tree | aa0c40b5bce419f592f2fcdbc959b37de1974c91 /Source | |
parent | 97cb93b869e25703d6631b2fd1a6d96048049870 (diff) | |
parent | 9f9272088f0222ce4535b8b638036e5ec3340e74 (diff) | |
download | external_webkit-2b9e710f9c95f93eba3e3fca22f32f1784b197c3.zip external_webkit-2b9e710f9c95f93eba3e3fca22f32f1784b197c3.tar.gz external_webkit-2b9e710f9c95f93eba3e3fca22f32f1784b197c3.tar.bz2 |
am 9f927208: am bc9eaa14: Merge "Reduce UI-thread computation" into jb-dev
* commit '9f9272088f0222ce4535b8b638036e5ec3340e74':
Reduce UI-thread computation
Diffstat (limited to 'Source')
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 cc34be5..fd79a84 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() |