| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/layer_tree_host_common.h" | 5 #include "cc/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "cc/layer.h" | 9 #include "cc/layer.h" |
| 10 #include "cc/layer_impl.h" | 10 #include "cc/layer_impl.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 template<typename LayerType> | 79 template<typename LayerType> |
| 80 static bool isLayerBackFaceVisible(LayerType* layer) | 80 static bool isLayerBackFaceVisible(LayerType* layer) |
| 81 { | 81 { |
| 82 // The current W3C spec on CSS transforms says that backface visibility shou
ld be | 82 // The current W3C spec on CSS transforms says that backface visibility shou
ld be |
| 83 // determined differently depending on whether the layer is in a "3d renderi
ng | 83 // determined differently depending on whether the layer is in a "3d renderi
ng |
| 84 // context" or not. For Chromium code, we can determine whether we are in a
3d | 84 // context" or not. For Chromium code, we can determine whether we are in a
3d |
| 85 // rendering context by checking if the parent preserves 3d. | 85 // rendering context by checking if the parent preserves 3d. |
| 86 | 86 |
| 87 if (layerIsInExisting3DRenderingContext(layer)) | 87 if (layerIsInExisting3DRenderingContext(layer)) |
| 88 return MathUtil::isBackFaceVisible(layer->drawTransform()); | 88 return layer->drawTransform().IsBackFaceVisible(); |
| 89 | 89 |
| 90 // In this case, either the layer establishes a new 3d rendering context, or
is not in | 90 // In this case, either the layer establishes a new 3d rendering context, or
is not in |
| 91 // a 3d rendering context at all. | 91 // a 3d rendering context at all. |
| 92 return MathUtil::isBackFaceVisible(layer->transform()); | 92 return layer->transform().IsBackFaceVisible(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 template<typename LayerType> | 95 template<typename LayerType> |
| 96 static bool isSurfaceBackFaceVisible(LayerType* layer, const gfx::Transform& dra
wTransform) | 96 static bool isSurfaceBackFaceVisible(LayerType* layer, const gfx::Transform& dra
wTransform) |
| 97 { | 97 { |
| 98 if (layerIsInExisting3DRenderingContext(layer)) | 98 if (layerIsInExisting3DRenderingContext(layer)) |
| 99 return MathUtil::isBackFaceVisible(drawTransform); | 99 return drawTransform.IsBackFaceVisible(); |
| 100 | 100 |
| 101 if (isRootLayerOfNewRenderingContext(layer)) | 101 if (isRootLayerOfNewRenderingContext(layer)) |
| 102 return MathUtil::isBackFaceVisible(layer->transform()); | 102 return layer->transform().IsBackFaceVisible(); |
| 103 | 103 |
| 104 // If the renderSurface is not part of a new or existing rendering context,
then the | 104 // If the renderSurface is not part of a new or existing rendering context,
then the |
| 105 // layers that contribute to this surface will decide back-face visibility f
or themselves. | 105 // layers that contribute to this surface will decide back-face visibility f
or themselves. |
| 106 return false; | 106 return false; |
| 107 } | 107 } |
| 108 | 108 |
| 109 template<typename LayerType> | 109 template<typename LayerType> |
| 110 static inline bool layerClipsSubtree(LayerType* layer) | 110 static inline bool layerClipsSubtree(LayerType* layer) |
| 111 { | 111 { |
| 112 return layer->masksToBounds() || layer->maskLayer(); | 112 return layer->masksToBounds() || layer->maskLayer(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 133 targetSurfaceClipRect = gfx::ToEnclosingRect(MathUtil::projectClippedRec
t(MathUtil::inverse(layer->renderTarget()->renderSurface()->drawTransform()), la
yer->renderTarget()->renderSurface()->clipRect())); | 133 targetSurfaceClipRect = gfx::ToEnclosingRect(MathUtil::projectClippedRec
t(MathUtil::inverse(layer->renderTarget()->renderSurface()->drawTransform()), la
yer->renderTarget()->renderSurface()->clipRect())); |
| 134 targetSurfaceClipRect.Intersect(layer->drawableContentRect()); | 134 targetSurfaceClipRect.Intersect(layer->drawableContentRect()); |
| 135 } | 135 } |
| 136 | 136 |
| 137 if (targetSurfaceClipRect.IsEmpty()) | 137 if (targetSurfaceClipRect.IsEmpty()) |
| 138 return gfx::Rect(); | 138 return gfx::Rect(); |
| 139 | 139 |
| 140 return LayerTreeHostCommon::calculateVisibleRect(targetSurfaceClipRect, gfx:
:Rect(gfx::Point(), layer->contentBounds()), layer->drawTransform()); | 140 return LayerTreeHostCommon::calculateVisibleRect(targetSurfaceClipRect, gfx:
:Rect(gfx::Point(), layer->contentBounds()), layer->drawTransform()); |
| 141 } | 141 } |
| 142 | 142 |
| 143 static bool isScaleOrTranslation(const gfx::Transform& m) | |
| 144 { | |
| 145 return !m.matrix().getDouble(1, 0) && !m.matrix().getDouble(2, 0) && !m.matr
ix().getDouble(3, 0) | |
| 146 && !m.matrix().getDouble(0, 1) && !m.matrix().getDouble(2, 1) && !m.m
atrix().getDouble(3, 1) | |
| 147 && !m.matrix().getDouble(0, 2) && !m.matrix().getDouble(1, 2) && !m.m
atrix().getDouble(2, 3) | |
| 148 && m.matrix().getDouble(3, 3); | |
| 149 } | |
| 150 | |
| 151 static inline bool transformToParentIsKnown(LayerImpl*) | 143 static inline bool transformToParentIsKnown(LayerImpl*) |
| 152 { | 144 { |
| 153 return true; | 145 return true; |
| 154 } | 146 } |
| 155 | 147 |
| 156 static inline bool transformToParentIsKnown(Layer* layer) | 148 static inline bool transformToParentIsKnown(Layer* layer) |
| 157 { | 149 { |
| 158 return !layer->transformIsAnimating(); | 150 return !layer->transformIsAnimating(); |
| 159 } | 151 } |
| 160 | 152 |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 | 547 |
| 556 gfx::RectF contentRect(gfx::PointF(), layer->contentBounds()); | 548 gfx::RectF contentRect(gfx::PointF(), layer->contentBounds()); |
| 557 | 549 |
| 558 // fullHierarchyMatrix is the matrix that transforms objects between screen
space (except projection matrix) and the most recent RenderSurfaceImpl's space. | 550 // fullHierarchyMatrix is the matrix that transforms objects between screen
space (except projection matrix) and the most recent RenderSurfaceImpl's space. |
| 559 // nextHierarchyMatrix will only change if this layer uses a new RenderSurfa
ceImpl, otherwise remains the same. | 551 // nextHierarchyMatrix will only change if this layer uses a new RenderSurfa
ceImpl, otherwise remains the same. |
| 560 gfx::Transform nextHierarchyMatrix = fullHierarchyMatrix; | 552 gfx::Transform nextHierarchyMatrix = fullHierarchyMatrix; |
| 561 gfx::Transform sublayerMatrix; | 553 gfx::Transform sublayerMatrix; |
| 562 | 554 |
| 563 gfx::Vector2dF renderSurfaceSublayerScale = MathUtil::computeTransform2dScal
eComponents(combinedTransform); | 555 gfx::Vector2dF renderSurfaceSublayerScale = MathUtil::computeTransform2dScal
eComponents(combinedTransform); |
| 564 | 556 |
| 565 if (subtreeShouldRenderToSeparateSurface(layer, isScaleOrTranslation(combine
dTransform))) { | 557 if (subtreeShouldRenderToSeparateSurface(layer, combinedTransform.IsScaleOrT
ranslation())) { |
| 566 // Check back-face visibility before continuing with this surface and it
s subtree | 558 // Check back-face visibility before continuing with this surface and it
s subtree |
| 567 if (!layer->doubleSided() && transformToParentIsKnown(layer) && isSurfac
eBackFaceVisible(layer, combinedTransform)) | 559 if (!layer->doubleSided() && transformToParentIsKnown(layer) && isSurfac
eBackFaceVisible(layer, combinedTransform)) |
| 568 return; | 560 return; |
| 569 | 561 |
| 570 if (!layer->renderSurface()) | 562 if (!layer->renderSurface()) |
| 571 layer->createRenderSurface(); | 563 layer->createRenderSurface(); |
| 572 | 564 |
| 573 RenderSurfaceType* renderSurface = layer->renderSurface(); | 565 RenderSurfaceType* renderSurface = layer->renderSurface(); |
| 574 renderSurface->clearLayerLists(); | 566 renderSurface->clearLayerLists(); |
| 575 | 567 |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 | 992 |
| 1001 foundLayer = currentLayer; | 993 foundLayer = currentLayer; |
| 1002 break; | 994 break; |
| 1003 } | 995 } |
| 1004 | 996 |
| 1005 // This can potentially return 0, which means the screenSpacePoint did not s
uccessfully hit test any layers, not even the root layer. | 997 // This can potentially return 0, which means the screenSpacePoint did not s
uccessfully hit test any layers, not even the root layer. |
| 1006 return foundLayer; | 998 return foundLayer; |
| 1007 } | 999 } |
| 1008 | 1000 |
| 1009 } // namespace cc | 1001 } // namespace cc |
| OLD | NEW |