From fd977d1127769acd8e0a441cf2ae17de6ab3b979 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Mon, 14 May 2012 17:05:09 -0700 Subject: calculate draw transforms before merging layers bug:6331760 bug:6331909 bug:6470927 Change-Id: I558ba1aafb6f7e6800f3bcd22dab5f98e197ddeb --- .../graphics/android/rendering/Surface.cpp | 23 +++++++++++----------- .../platform/graphics/android/rendering/Surface.h | 4 ++-- .../android/rendering/SurfaceCollection.cpp | 3 +-- 3 files changed, 14 insertions(+), 16 deletions(-) (limited to 'Source') diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp index 3b26ebc..2ec2659 100644 --- a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp @@ -106,8 +106,9 @@ bool Surface::tryUpdateSurface(Surface* oldSurface) break; } else if (!m_layers[i]->getInvalRegion()->isEmpty()) { // merge layer inval - translate the layer's inval region into surface coordinates - SkPoint pos = m_layers[i]->getPosition(); - m_layers[i]->getInvalRegion()->translate(pos.fX, pos.fY); + // TODO: handle scale/3d transform mapping + FloatRect layerPos = m_layers[i]->fullContentAreaMapped(); + m_layers[i]->getInvalRegion()->translate(layerPos.x(), layerPos.y()); invalRegion.op(*(m_layers[i]->getInvalRegion()), SkRegion::kUnion_Op); break; } @@ -130,29 +131,27 @@ void Surface::addLayer(LayerAndroid* layer, const TransformationMatrix& transfor m_needsTexture |= layer->needsTexture(); m_hasText |= layer->hasText(); - // calculate area size for comparison later - IntRect rect = layer->fullContentArea(); - SkPoint pos = layer->getPosition(); - rect.setLocation(IntPoint(pos.fX, pos.fY)); + // add this layer's size to the surface's area + // TODO: handle scale/3d transform mapping + IntRect rect = enclosingIntRect(layer->fullContentAreaMapped()); if (layer->needsTexture()) { if (m_fullContentArea.isEmpty()) { m_drawTransform = transform; - m_drawTransform.translate3d(-pos.fX, -pos.fY, 0); + m_drawTransform.translate3d(-rect.x(), -rect.y(), 0); m_fullContentArea = rect; } else m_fullContentArea.unite(rect); - ALOGV("Surf %p adding LA %p, size %d, %d %dx%d, now Surf size %d,%d %dx%d", - this, layer, rect.x(), rect.y(), rect.width(), rect.height(), - m_fullContentArea.x(), m_fullContentArea.y(), - m_fullContentArea.width(), m_fullContentArea.height()); + ALOGV("Surf %p adding LA %p, size " INT_RECT_FORMAT + " now fullContentArea " INT_RECT_FORMAT, + this, layer, INT_RECT_ARGS(rect), INT_RECT_ARGS(m_fullContentArea)); } if (isBase()) m_background = static_cast(layer)->getBackgroundColor(); } -IntRect Surface::visibleContentArea(bool force3dContentVisible) +IntRect Surface::visibleContentArea(bool force3dContentVisible) const { if (singleLayer()) return getFirstLayer()->visibleContentArea(force3dContentVisible); diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.h b/Source/WebCore/platform/graphics/android/rendering/Surface.h index bd1d21c..a79a286 100644 --- a/Source/WebCore/platform/graphics/android/rendering/Surface.h +++ b/Source/WebCore/platform/graphics/android/rendering/Surface.h @@ -71,9 +71,9 @@ public: private: IntRect computePrepareArea(); - IntRect visibleContentArea(bool force3dContentVisible = false); + IntRect visibleContentArea(bool force3dContentVisible = false) const; IntRect fullContentArea(); - bool singleLayer() { return m_layers.size() == 1; } + bool singleLayer() const { return m_layers.size() == 1; } bool useAggressiveRendering(); const TransformationMatrix* drawTransform(); diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp index 4badf8b..3b6b306 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp @@ -52,8 +52,7 @@ SurfaceCollection::SurfaceCollection(BaseLayerAndroid* layer) // calculate draw transforms and z values SkRect visibleRect = SkRect::MakeLTRB(0, 0, 1, 1); - m_compositedRoot->updateLayerPositions(visibleRect); - // TODO: updateGLPositionsAndScale? + m_compositedRoot->updatePositionsRecursive(visibleRect); // allocate surfaces for layers, merging where possible ALOGV("new tree, allocating surfaces for tree %p", m_baseLayer); -- cgit v1.1