Added: trunk/LayoutTests/compositing/backface-visibility-hierarchical-transform-expected.png (0 => 93387)
--- trunk/LayoutTests/compositing/backface-visibility-hierarchical-transform-expected.png (rev 0)
+++ trunk/LayoutTests/compositing/backface-visibility-hierarchical-transform-expected.png 2011-08-19 05:44:52 UTC (rev 93387)
@@ -0,0 +1,6 @@
+\x89PNG
+
+
+IHDR X ' )tEXtchecksum e43420b383792f6c4145eca7e3911331g\xED\xCF\xE0
+\xD0IDATx\x9C\xED\xDC1
+\xC30EA)\xF8\xDE\xC6'\xDF\xDC \xD5#1Ӫ\xF9\xE5c\xED\x99Y t>o 8\x8D\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\xD8\xF5\xFBy?\xFB?;0\xB7?\xF1\x80\xB5\\xB0 r &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b{f\xDE\xDE p, \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\xD8\xF5\xFBy?\xFB?;0\xB7?\xF1\x80\xB5\\xB0 r &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b &\xB0 b{f\xDE\xDE p, \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\x98\xC0 \x88 , \x80\xD8 \x8E\xA9\xC4\xB5E IEND\xAEB`\x82
\ No newline at end of file
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp (93386 => 93387)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp 2011-08-19 04:51:38 UTC (rev 93386)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp 2011-08-19 05:44:52 UTC (rev 93387)
@@ -130,7 +130,7 @@
// Recursively walks the layer tree starting at the given node and computes all the
// necessary transformations, scissor rectangles, render surfaces, etc.
template<typename LayerType, typename RenderSurfaceType, typename LayerSorter>
-void calculateDrawTransformsAndVisibility(LayerType* layer, LayerType* rootLayer, const TransformationMatrix& parentMatrix, Vector<RefPtr<LayerType> >& renderSurfaceLayerList, Vector<RefPtr<LayerType> >& layerList, LayerSorter* layerSorter, int maxTextureSize)
+void calculateDrawTransformsAndVisibility(LayerType* layer, LayerType* rootLayer, const TransformationMatrix& parentMatrix, const TransformationMatrix& fullHierarchyMatrix, Vector<RefPtr<LayerType> >& renderSurfaceLayerList, Vector<RefPtr<LayerType> >& layerList, LayerSorter* layerSorter, int maxTextureSize)
{
typedef Vector<RefPtr<LayerType> > LayerList;
// Compute the new matrix transformation that will be applied to this layer and
@@ -173,6 +173,10 @@
FloatRect layerRect(-0.5 * layer->bounds().width(), -0.5 * layer->bounds().height(), layer->bounds().width(), layer->bounds().height());
IntRect transformedLayerRect;
+ // fullHierarchyMatrix is the matrix that transforms objects between screen space (except projection matrix) and the most recent RenderSurface's space.
+ // nextHierarchyMatrix will only change if this layer uses a new RenderSurface, otherwise remains the same.
+ TransformationMatrix nextHierarchyMatrix = fullHierarchyMatrix;
+
// FIXME: This seems like the wrong place to set this
layer->setUsesLayerScissor(false);
@@ -214,6 +218,9 @@
layerOriginTransform.translate3d(-0.5 * bounds.width(), -0.5 * bounds.height(), 0);
renderSurface->setOriginTransform(layerOriginTransform);
+ // Update the aggregate hierarchy matrix to include the transform of the newly created RenderSurface.
+ nextHierarchyMatrix.multiply(layerOriginTransform);
+
// The render surface scissor rect is the scissor rect that needs to
// be applied before drawing the render surface onto its containing
// surface and is therefore expressed in the parent's coordinate system.
@@ -262,6 +269,14 @@
}
}
+ // Note that at this point, layer->drawTransform() is not necessarily the same as local variable drawTransform.
+ // layerScreenSpaceTransform represents the transform between layer space (in pixels) and screen space.
+ // So we do not include projection P or scaling transform S (see comments above that describe P*M*S).
+ TransformationMatrix layerScreenSpaceTransform = nextHierarchyMatrix;
+ layerScreenSpaceTransform.multiply(layer->drawTransform());
+ layerScreenSpaceTransform.translate3d(-0.5 * bounds.width(), -0.5 * bounds.height(), 0);
+ layer->setScreenSpaceTransform(layerScreenSpaceTransform);
+
if (layer->renderSurface())
layer->setTargetRenderSurface(layer->renderSurface());
else {
@@ -307,7 +322,7 @@
for (size_t i = 0; i < layer->children().size(); ++i) {
LayerType* child = layer->children()[i].get();
- calculateDrawTransformsAndVisibility<LayerType, RenderSurfaceType, LayerSorter>(child, rootLayer, sublayerMatrix, renderSurfaceLayerList, descendants, layerSorter, maxTextureSize);
+ calculateDrawTransformsAndVisibility<LayerType, RenderSurfaceType, LayerSorter>(child, rootLayer, sublayerMatrix, nextHierarchyMatrix, renderSurfaceLayerList, descendants, layerSorter, maxTextureSize);
if (child->renderSurface()) {
RenderSurfaceType* childRenderSurface = child->renderSurface();
@@ -605,7 +620,7 @@
{
TRACE_EVENT("LayerRendererChromium::updateLayers::calcDrawEtc", this, 0);
- calculateDrawTransformsAndVisibility<LayerChromium, RenderSurfaceChromium, void*>(rootLayer, rootLayer, identityMatrix, renderSurfaceLayerList, rootRenderSurface->layerList(), 0, m_maxTextureSize);
+ calculateDrawTransformsAndVisibility<LayerChromium, RenderSurfaceChromium, void*>(rootLayer, rootLayer, identityMatrix, identityMatrix, renderSurfaceLayerList, rootRenderSurface->layerList(), 0, m_maxTextureSize);
}
#ifndef NDEBUG
@@ -737,7 +752,7 @@
{
TRACE_EVENT("LayerRendererChromium::drawLayersInternal::calcDrawEtc", this, 0);
- calculateDrawTransformsAndVisibility<CCLayerImpl, CCRenderSurface, CCLayerSorter>(rootDrawLayer, rootDrawLayer, identityMatrix, renderSurfaceLayerList, m_defaultRenderSurface->layerList(), &m_layerSorter, m_maxTextureSize);
+ calculateDrawTransformsAndVisibility<CCLayerImpl, CCRenderSurface, CCLayerSorter>(rootDrawLayer, rootDrawLayer, identityMatrix, identityMatrix, renderSurfaceLayerList, m_defaultRenderSurface->layerList(), &m_layerSorter, m_maxTextureSize);
}
// The GL viewport covers the entire visible area, including the scrollbars.
@@ -1013,18 +1028,11 @@
} else
GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
+ // The layer should not be drawn if (1) it is not double-sided and (2) the back of the layer is facing the screen.
+ // This second condition is checked by computing the transformed normal of the layer.
if (!layer->doubleSided()) {
- // FIXME: Need to take into account the cumulative render surface transforms all the way from
- // the default render surface in order to determine visibility.
- TransformationMatrix combinedDrawMatrix;
- if (layer->targetRenderSurface()) {
- combinedDrawMatrix = layer->targetRenderSurface()->drawTransform();
- combinedDrawMatrix.multiply(layer->drawTransform());
- } else
- combinedDrawMatrix = layer->drawTransform();
-
FloatRect layerRect(FloatPoint(0, 0), FloatSize(layer->bounds()));
- FloatQuad mappedLayer = combinedDrawMatrix.mapQuad(FloatQuad(layerRect));
+ FloatQuad mappedLayer = layer->screenSpaceTransform().mapQuad(FloatQuad(layerRect));
FloatSize horizontalDir = mappedLayer.p2() - mappedLayer.p1();
FloatSize verticalDir = mappedLayer.p4() - mappedLayer.p1();
FloatPoint3D xAxis(horizontalDir.width(), horizontalDir.height(), 0);