| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "CCLayerTreeHostCommon.h" | 7 #include "CCLayerTreeHostCommon.h" |
| 8 | 8 |
| 9 #include "CCLayerImpl.h" | 9 #include "CCLayerImpl.h" |
| 10 #include "CCLayerIterator.h" | 10 #include "CCLayerIterator.h" |
| 11 #include "CCLayerSorter.h" | 11 #include "CCLayerSorter.h" |
| 12 #include "CCMathUtil.h" | 12 #include "CCMathUtil.h" |
| 13 #include "CCRenderSurface.h" | 13 #include "CCRenderSurface.h" |
| 14 #include "FloatQuad.h" | 14 #include "FloatQuad.h" |
| 15 #include "IntRect.h" | 15 #include "IntRect.h" |
| 16 #include "cc/layer.h" | 16 #include "cc/layer.h" |
| 17 #include "cc/render_surface.h" | 17 #include "cc/render_surface.h" |
| 18 #include <public/WebTransformationMatrix.h> | 18 #include <public/WebTransformationMatrix.h> |
| 19 | 19 |
| 20 using WebKit::WebTransformationMatrix; | 20 using WebKit::WebTransformationMatrix; |
| 21 | 21 |
| 22 namespace cc { | 22 namespace cc { |
| 23 | 23 |
| 24 CCScrollAndScaleSet::CCScrollAndScaleSet() | 24 ScrollAndScaleSet::ScrollAndScaleSet() |
| 25 { | 25 { |
| 26 } | 26 } |
| 27 | 27 |
| 28 CCScrollAndScaleSet::~CCScrollAndScaleSet() | 28 ScrollAndScaleSet::~ScrollAndScaleSet() |
| 29 { | 29 { |
| 30 } | 30 } |
| 31 | 31 |
| 32 IntRect CCLayerTreeHostCommon::calculateVisibleRect(const IntRect& targetSurface
Rect, const IntRect& layerBoundRect, const WebTransformationMatrix& transform) | 32 IntRect LayerTreeHostCommon::calculateVisibleRect(const IntRect& targetSurfaceRe
ct, const IntRect& layerBoundRect, const WebTransformationMatrix& transform) |
| 33 { | 33 { |
| 34 // Is this layer fully contained within the target surface? | 34 // Is this layer fully contained within the target surface? |
| 35 IntRect layerInSurfaceSpace = CCMathUtil::mapClippedRect(transform, layerBou
ndRect); | 35 IntRect layerInSurfaceSpace = MathUtil::mapClippedRect(transform, layerBound
Rect); |
| 36 if (targetSurfaceRect.contains(layerInSurfaceSpace)) | 36 if (targetSurfaceRect.contains(layerInSurfaceSpace)) |
| 37 return layerBoundRect; | 37 return layerBoundRect; |
| 38 | 38 |
| 39 // If the layer doesn't fill up the entire surface, then find the part of | 39 // If the layer doesn't fill up the entire surface, then find the part of |
| 40 // the surface rect where the layer could be visible. This avoids trying to | 40 // the surface rect where the layer could be visible. This avoids trying to |
| 41 // project surface rect points that are behind the projection point. | 41 // project surface rect points that are behind the projection point. |
| 42 IntRect minimalSurfaceRect = targetSurfaceRect; | 42 IntRect minimalSurfaceRect = targetSurfaceRect; |
| 43 minimalSurfaceRect.intersect(layerInSurfaceSpace); | 43 minimalSurfaceRect.intersect(layerInSurfaceSpace); |
| 44 | 44 |
| 45 // Project the corners of the target surface rect into the layer space. | 45 // Project the corners of the target surface rect into the layer space. |
| 46 // This bounding rectangle may be larger than it needs to be (being | 46 // This bounding rectangle may be larger than it needs to be (being |
| 47 // axis-aligned), but is a reasonable filter on the space to consider. | 47 // axis-aligned), but is a reasonable filter on the space to consider. |
| 48 // Non-invertible transforms will create an empty rect here. | 48 // Non-invertible transforms will create an empty rect here. |
| 49 const WebTransformationMatrix surfaceToLayer = transform.inverse(); | 49 const WebTransformationMatrix surfaceToLayer = transform.inverse(); |
| 50 IntRect layerRect = enclosingIntRect(CCMathUtil::projectClippedRect(surfaceT
oLayer, FloatRect(minimalSurfaceRect))); | 50 IntRect layerRect = enclosingIntRect(MathUtil::projectClippedRect(surfaceToL
ayer, FloatRect(minimalSurfaceRect))); |
| 51 layerRect.intersect(layerBoundRect); | 51 layerRect.intersect(layerBoundRect); |
| 52 return layerRect; | 52 return layerRect; |
| 53 } | 53 } |
| 54 | 54 |
| 55 template<typename LayerType> | 55 template<typename LayerType> |
| 56 static inline bool layerIsInExisting3DRenderingContext(LayerType* layer) | 56 static inline bool layerIsInExisting3DRenderingContext(LayerType* layer) |
| 57 { | 57 { |
| 58 // According to current W3C spec on CSS transforms, a layer is part of an es
tablished | 58 // According to current W3C spec on CSS transforms, a layer is part of an es
tablished |
| 59 // 3d rendering context if its parent has transform-style of preserves-3d. | 59 // 3d rendering context if its parent has transform-style of preserves-3d. |
| 60 return layer->parent() && layer->parent()->preserves3D(); | 60 return layer->parent() && layer->parent()->preserves3D(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 IntRect targetSurfaceClipRect; | 120 IntRect targetSurfaceClipRect; |
| 121 | 121 |
| 122 // First, compute visible bounds in target surface space. | 122 // First, compute visible bounds in target surface space. |
| 123 if (layer->renderTarget()->renderSurface()->clipRect().isEmpty()) | 123 if (layer->renderTarget()->renderSurface()->clipRect().isEmpty()) |
| 124 targetSurfaceClipRect = layer->drawableContentRect(); | 124 targetSurfaceClipRect = layer->drawableContentRect(); |
| 125 else { | 125 else { |
| 126 // In this case the target surface does clip layers that contribute to i
t. So, we | 126 // In this case the target surface does clip layers that contribute to i
t. So, we |
| 127 // have convert the current surface's clipRect from its ancestor surface
space to | 127 // have convert the current surface's clipRect from its ancestor surface
space to |
| 128 // the current surface space. | 128 // the current surface space. |
| 129 targetSurfaceClipRect = enclosingIntRect(CCMathUtil::projectClippedRect(
layer->renderTarget()->renderSurface()->drawTransform().inverse(), layer->render
Target()->renderSurface()->clipRect())); | 129 targetSurfaceClipRect = enclosingIntRect(MathUtil::projectClippedRect(la
yer->renderTarget()->renderSurface()->drawTransform().inverse(), layer->renderTa
rget()->renderSurface()->clipRect())); |
| 130 targetSurfaceClipRect.intersect(layer->drawableContentRect()); | 130 targetSurfaceClipRect.intersect(layer->drawableContentRect()); |
| 131 } | 131 } |
| 132 | 132 |
| 133 if (targetSurfaceClipRect.isEmpty()) | 133 if (targetSurfaceClipRect.isEmpty()) |
| 134 return IntRect(); | 134 return IntRect(); |
| 135 | 135 |
| 136 return CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceClipRect, In
tRect(IntPoint(), layer->contentBounds()), layer->drawTransform()); | 136 return LayerTreeHostCommon::calculateVisibleRect(targetSurfaceClipRect, IntR
ect(IntPoint(), layer->contentBounds()), layer->drawTransform()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 static bool isScaleOrTranslation(const WebTransformationMatrix& m) | 139 static bool isScaleOrTranslation(const WebTransformationMatrix& m) |
| 140 { | 140 { |
| 141 return !m.m12() && !m.m13() && !m.m14() | 141 return !m.m12() && !m.m13() && !m.m14() |
| 142 && !m.m21() && !m.m23() && !m.m24() | 142 && !m.m21() && !m.m23() && !m.m24() |
| 143 && !m.m31() && !m.m32() && !m.m43() | 143 && !m.m31() && !m.m32() && !m.m43() |
| 144 && m.m44(); | 144 && m.m44(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 static inline bool transformToParentIsKnown(CCLayerImpl*) | 147 static inline bool transformToParentIsKnown(LayerImpl*) |
| 148 { | 148 { |
| 149 return true; | 149 return true; |
| 150 } | 150 } |
| 151 | 151 |
| 152 static inline bool transformToParentIsKnown(LayerChromium* layer) | 152 static inline bool transformToParentIsKnown(Layer* layer) |
| 153 { | 153 { |
| 154 return !layer->transformIsAnimating(); | 154 return !layer->transformIsAnimating(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 static inline bool transformToScreenIsKnown(CCLayerImpl*) | 157 static inline bool transformToScreenIsKnown(LayerImpl*) |
| 158 { | 158 { |
| 159 return true; | 159 return true; |
| 160 } | 160 } |
| 161 | 161 |
| 162 static inline bool transformToScreenIsKnown(LayerChromium* layer) | 162 static inline bool transformToScreenIsKnown(Layer* layer) |
| 163 { | 163 { |
| 164 return !layer->screenSpaceTransformIsAnimating(); | 164 return !layer->screenSpaceTransformIsAnimating(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 template<typename LayerType> | 167 template<typename LayerType> |
| 168 static bool layerShouldBeSkipped(LayerType* layer) | 168 static bool layerShouldBeSkipped(LayerType* layer) |
| 169 { | 169 { |
| 170 // Layers can be skipped if any of these conditions are met. | 170 // Layers can be skipped if any of these conditions are met. |
| 171 // - does not draw content. | 171 // - does not draw content. |
| 172 // - is transparent | 172 // - is transparent |
| (...skipping 18 matching lines...) Expand all Loading... |
| 191 backfaceTestLayer = layer->parent(); | 191 backfaceTestLayer = layer->parent(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 // The layer should not be drawn if (1) it is not double-sided and (2) the b
ack of the layer is known to be facing the screen. | 194 // The layer should not be drawn if (1) it is not double-sided and (2) the b
ack of the layer is known to be facing the screen. |
| 195 if (!backfaceTestLayer->doubleSided() && transformToScreenIsKnown(backfaceTe
stLayer) && isLayerBackFaceVisible(backfaceTestLayer)) | 195 if (!backfaceTestLayer->doubleSided() && transformToScreenIsKnown(backfaceTe
stLayer) && isLayerBackFaceVisible(backfaceTestLayer)) |
| 196 return true; | 196 return true; |
| 197 | 197 |
| 198 return false; | 198 return false; |
| 199 } | 199 } |
| 200 | 200 |
| 201 static inline bool subtreeShouldBeSkipped(CCLayerImpl* layer) | 201 static inline bool subtreeShouldBeSkipped(LayerImpl* layer) |
| 202 { | 202 { |
| 203 // The opacity of a layer always applies to its children (either implicitly | 203 // The opacity of a layer always applies to its children (either implicitly |
| 204 // via a render surface or explicitly if the parent preserves 3D), so the | 204 // via a render surface or explicitly if the parent preserves 3D), so the |
| 205 // entire subtree can be skipped if this layer is fully transparent. | 205 // entire subtree can be skipped if this layer is fully transparent. |
| 206 return !layer->opacity(); | 206 return !layer->opacity(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 static inline bool subtreeShouldBeSkipped(LayerChromium* layer) | 209 static inline bool subtreeShouldBeSkipped(Layer* layer) |
| 210 { | 210 { |
| 211 // If the opacity is being animated then the opacity on the main thread is u
nreliable | 211 // If the opacity is being animated then the opacity on the main thread is u
nreliable |
| 212 // (since the impl thread may be using a different opacity), so it should no
t be trusted. | 212 // (since the impl thread may be using a different opacity), so it should no
t be trusted. |
| 213 // In particular, it should not cause the subtree to be skipped. | 213 // In particular, it should not cause the subtree to be skipped. |
| 214 return !layer->opacity() && !layer->opacityIsAnimating(); | 214 return !layer->opacity() && !layer->opacityIsAnimating(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 template<typename LayerType> | 217 template<typename LayerType> |
| 218 static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlig
nedWithRespectToParent) | 218 static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlig
nedWithRespectToParent) |
| 219 { | 219 { |
| 220 // The root layer has a special render surface that is set up externally, so | 220 // The root layer has a special render surface that is set up externally, so |
| 221 // it shouldn't be treated as a surface in this code. | 221 // it shouldn't be treated as a surface in this code. |
| 222 if (!layer->parent()) | 222 if (!layer->parent()) |
| 223 return false; | 223 return false; |
| 224 | 224 |
| 225 // Cache this value, because otherwise it walks the entire subtree several t
imes. | 225 // Cache this value, because otherwise it walks the entire subtree several t
imes. |
| 226 bool descendantDrawsContent = layer->descendantDrawsContent(); | 226 bool descendantDrawsContent = layer->descendantDrawsContent(); |
| 227 | 227 |
| 228 // | 228 // |
| 229 // A layer and its descendants should render onto a new RenderSurface if any
of these rules hold: | 229 // A layer and its descendants should render onto a new RenderSurfaceImpl if
any of these rules hold: |
| 230 // | 230 // |
| 231 | 231 |
| 232 // If we force it. | 232 // If we force it. |
| 233 if (layer->forceRenderSurface()) | 233 if (layer->forceRenderSurface()) |
| 234 return true; | 234 return true; |
| 235 | 235 |
| 236 // If the layer uses a mask. | 236 // If the layer uses a mask. |
| 237 if (layer->maskLayer()) | 237 if (layer->maskLayer()) |
| 238 return true; | 238 return true; |
| 239 | 239 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 254 if (layerClipsSubtree(layer) && !axisAlignedWithRespectToParent && descendan
tDrawsContent) | 254 if (layerClipsSubtree(layer) && !axisAlignedWithRespectToParent && descendan
tDrawsContent) |
| 255 return true; | 255 return true; |
| 256 | 256 |
| 257 // If the layer has opacity != 1 and does not have a preserves-3d transform
style. | 257 // If the layer has opacity != 1 and does not have a preserves-3d transform
style. |
| 258 if (layer->opacity() != 1 && !layer->preserves3D() && descendantDrawsContent
) | 258 if (layer->opacity() != 1 && !layer->preserves3D() && descendantDrawsContent
) |
| 259 return true; | 259 return true; |
| 260 | 260 |
| 261 return false; | 261 return false; |
| 262 } | 262 } |
| 263 | 263 |
| 264 WebTransformationMatrix computeScrollCompensationForThisLayer(CCLayerImpl* scrol
lingLayer, const WebTransformationMatrix& parentMatrix) | 264 WebTransformationMatrix computeScrollCompensationForThisLayer(LayerImpl* scrolli
ngLayer, const WebTransformationMatrix& parentMatrix) |
| 265 { | 265 { |
| 266 // For every layer that has non-zero scrollDelta, we have to compute a trans
form that can undo the | 266 // For every layer that has non-zero scrollDelta, we have to compute a trans
form that can undo the |
| 267 // scrollDelta translation. In particular, we want this matrix to premultipl
y a fixed-position layer's | 267 // scrollDelta translation. In particular, we want this matrix to premultipl
y a fixed-position layer's |
| 268 // parentMatrix, so we design this transform in three steps as follows. The
steps described here apply | 268 // parentMatrix, so we design this transform in three steps as follows. The
steps described here apply |
| 269 // from right-to-left, so Step 1 would be the right-most matrix: | 269 // from right-to-left, so Step 1 would be the right-most matrix: |
| 270 // | 270 // |
| 271 // Step 1. transform from target surface space to the exact space where
scrollDelta is actually applied. | 271 // Step 1. transform from target surface space to the exact space where
scrollDelta is actually applied. |
| 272 // -- this is inverse of the matrix in step 3 | 272 // -- this is inverse of the matrix in step 3 |
| 273 // Step 2. undo the scrollDelta | 273 // Step 2. undo the scrollDelta |
| 274 // -- this is just a translation by scrollDelta. | 274 // -- this is just a translation by scrollDelta. |
| 275 // Step 3. transform back to target surface space. | 275 // Step 3. transform back to target surface space. |
| 276 // -- this transform is the "partialLayerOriginTransform" = (paren
tMatrix * scale(layer->pageScaleDelta())); | 276 // -- this transform is the "partialLayerOriginTransform" = (paren
tMatrix * scale(layer->pageScaleDelta())); |
| 277 // | 277 // |
| 278 // These steps create a matrix that both start and end in targetSurfaceSpace
. So this matrix can | 278 // These steps create a matrix that both start and end in targetSurfaceSpace
. So this matrix can |
| 279 // pre-multiply any fixed-position layer's drawTransform to undo the scrollD
eltas -- as long as | 279 // pre-multiply any fixed-position layer's drawTransform to undo the scrollD
eltas -- as long as |
| 280 // that fixed position layer is fixed onto the same renderTarget as this scr
ollingLayer. | 280 // that fixed position layer is fixed onto the same renderTarget as this scr
ollingLayer. |
| 281 // | 281 // |
| 282 | 282 |
| 283 WebTransformationMatrix partialLayerOriginTransform = parentMatrix; | 283 WebTransformationMatrix partialLayerOriginTransform = parentMatrix; |
| 284 partialLayerOriginTransform.multiply(scrollingLayer->implTransform()); | 284 partialLayerOriginTransform.multiply(scrollingLayer->implTransform()); |
| 285 | 285 |
| 286 WebTransformationMatrix scrollCompensationForThisLayer = partialLayerOriginT
ransform; // Step 3 | 286 WebTransformationMatrix scrollCompensationForThisLayer = partialLayerOriginT
ransform; // Step 3 |
| 287 scrollCompensationForThisLayer.translate(scrollingLayer->scrollDelta().width
(), scrollingLayer->scrollDelta().height()); // Step 2 | 287 scrollCompensationForThisLayer.translate(scrollingLayer->scrollDelta().width
(), scrollingLayer->scrollDelta().height()); // Step 2 |
| 288 scrollCompensationForThisLayer.multiply(partialLayerOriginTransform.inverse(
)); // Step 1 | 288 scrollCompensationForThisLayer.multiply(partialLayerOriginTransform.inverse(
)); // Step 1 |
| 289 return scrollCompensationForThisLayer; | 289 return scrollCompensationForThisLayer; |
| 290 } | 290 } |
| 291 | 291 |
| 292 WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerChromium
* currentLayer, const WebTransformationMatrix& currentParentMatrix, const WebTra
nsformationMatrix& currentScrollCompensation) | 292 WebTransformationMatrix computeScrollCompensationMatrixForChildren(Layer* curren
tLayer, const WebTransformationMatrix& currentParentMatrix, const WebTransformat
ionMatrix& currentScrollCompensation) |
| 293 { | 293 { |
| 294 // The main thread (i.e. LayerChromium) does not need to worry about scroll
compensation. | 294 // The main thread (i.e. Layer) does not need to worry about scroll compensa
tion. |
| 295 // So we can just return an identity matrix here. | 295 // So we can just return an identity matrix here. |
| 296 return WebTransformationMatrix(); | 296 return WebTransformationMatrix(); |
| 297 } | 297 } |
| 298 | 298 |
| 299 WebTransformationMatrix computeScrollCompensationMatrixForChildren(CCLayerImpl*
layer, const WebTransformationMatrix& parentMatrix, const WebTransformationMatri
x& currentScrollCompensationMatrix) | 299 WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerImpl* la
yer, const WebTransformationMatrix& parentMatrix, const WebTransformationMatrix&
currentScrollCompensationMatrix) |
| 300 { | 300 { |
| 301 // "Total scroll compensation" is the transform needed to cancel out all scr
ollDelta translations that | 301 // "Total scroll compensation" is the transform needed to cancel out all scr
ollDelta translations that |
| 302 // occurred since the nearest container layer, even if there are renderSurfa
ces in-between. | 302 // occurred since the nearest container layer, even if there are renderSurfa
ces in-between. |
| 303 // | 303 // |
| 304 // There are some edge cases to be aware of, that are not explicit in the co
de: | 304 // There are some edge cases to be aware of, that are not explicit in the co
de: |
| 305 // - A layer that is both a fixed-position and container should not be its
own container, instead, that means | 305 // - A layer that is both a fixed-position and container should not be its
own container, instead, that means |
| 306 // it is fixed to an ancestor, and is a container for any fixed-position
descendants. | 306 // it is fixed to an ancestor, and is a container for any fixed-position
descendants. |
| 307 // - A layer that is a fixed-position container and has a renderSurface sho
uld behave the same as a container | 307 // - A layer that is a fixed-position container and has a renderSurface sho
uld behave the same as a container |
| 308 // without a renderSurface, the renderSurface is irrelevant in that case. | 308 // without a renderSurface, the renderSurface is irrelevant in that case. |
| 309 // - A layer that does not have an explicit container is simply fixed to th
e viewport | 309 // - A layer that does not have an explicit container is simply fixed to th
e viewport |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 WebTransformationMatrix drawTransform = combinedTransform; | 493 WebTransformationMatrix drawTransform = combinedTransform; |
| 494 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { | 494 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
| 495 // M[draw] = M[parent] * LT * S[layer2content] | 495 // M[draw] = M[parent] * LT * S[layer2content] |
| 496 drawTransform.scaleNonUniform(layer->bounds().width() / static_cast<doub
le>(layer->contentBounds().width()), | 496 drawTransform.scaleNonUniform(layer->bounds().width() / static_cast<doub
le>(layer->contentBounds().width()), |
| 497 layer->bounds().height() / static_cast<dou
ble>(layer->contentBounds().height())); | 497 layer->bounds().height() / static_cast<dou
ble>(layer->contentBounds().height())); |
| 498 } | 498 } |
| 499 | 499 |
| 500 // layerScreenSpaceTransform represents the transform between root layer's "
screen space" and local content space. | 500 // layerScreenSpaceTransform represents the transform between root layer's "
screen space" and local content space. |
| 501 WebTransformationMatrix layerScreenSpaceTransform = fullHierarchyMatrix; | 501 WebTransformationMatrix layerScreenSpaceTransform = fullHierarchyMatrix; |
| 502 if (!layer->preserves3D()) | 502 if (!layer->preserves3D()) |
| 503 CCMathUtil::flattenTransformTo2d(layerScreenSpaceTransform); | 503 MathUtil::flattenTransformTo2d(layerScreenSpaceTransform); |
| 504 layerScreenSpaceTransform.multiply(drawTransform); | 504 layerScreenSpaceTransform.multiply(drawTransform); |
| 505 layer->setScreenSpaceTransform(layerScreenSpaceTransform); | 505 layer->setScreenSpaceTransform(layerScreenSpaceTransform); |
| 506 | 506 |
| 507 bool animatingTransformToTarget = layer->transformIsAnimating(); | 507 bool animatingTransformToTarget = layer->transformIsAnimating(); |
| 508 bool animatingTransformToScreen = animatingTransformToTarget; | 508 bool animatingTransformToScreen = animatingTransformToTarget; |
| 509 if (layer->parent()) { | 509 if (layer->parent()) { |
| 510 animatingTransformToTarget |= layer->parent()->drawTransformIsAnimating(
); | 510 animatingTransformToTarget |= layer->parent()->drawTransformIsAnimating(
); |
| 511 animatingTransformToScreen |= layer->parent()->screenSpaceTransformIsAni
mating(); | 511 animatingTransformToScreen |= layer->parent()->screenSpaceTransformIsAni
mating(); |
| 512 } | 512 } |
| 513 | 513 |
| 514 FloatRect contentRect(FloatPoint(), layer->contentBounds()); | 514 FloatRect contentRect(FloatPoint(), layer->contentBounds()); |
| 515 | 515 |
| 516 // fullHierarchyMatrix is the matrix that transforms objects between screen
space (except projection matrix) and the most recent RenderSurface's space. | 516 // fullHierarchyMatrix is the matrix that transforms objects between screen
space (except projection matrix) and the most recent RenderSurfaceImpl's space. |
| 517 // nextHierarchyMatrix will only change if this layer uses a new RenderSurfa
ce, otherwise remains the same. | 517 // nextHierarchyMatrix will only change if this layer uses a new RenderSurfa
ceImpl, otherwise remains the same. |
| 518 WebTransformationMatrix nextHierarchyMatrix = fullHierarchyMatrix; | 518 WebTransformationMatrix nextHierarchyMatrix = fullHierarchyMatrix; |
| 519 WebTransformationMatrix sublayerMatrix; | 519 WebTransformationMatrix sublayerMatrix; |
| 520 | 520 |
| 521 if (subtreeShouldRenderToSeparateSurface(layer, isScaleOrTranslation(combine
dTransform))) { | 521 if (subtreeShouldRenderToSeparateSurface(layer, isScaleOrTranslation(combine
dTransform))) { |
| 522 // Check back-face visibility before continuing with this surface and it
s subtree | 522 // Check back-face visibility before continuing with this surface and it
s subtree |
| 523 if (!layer->doubleSided() && transformToParentIsKnown(layer) && isSurfac
eBackFaceVisible(layer, combinedTransform)) | 523 if (!layer->doubleSided() && transformToParentIsKnown(layer) && isSurfac
eBackFaceVisible(layer, combinedTransform)) |
| 524 return; | 524 return; |
| 525 | 525 |
| 526 if (!layer->renderSurface()) | 526 if (!layer->renderSurface()) |
| 527 layer->createRenderSurface(); | 527 layer->createRenderSurface(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 550 layer->setDrawOpacity(1); | 550 layer->setDrawOpacity(1); |
| 551 layer->setDrawOpacityIsAnimating(false); | 551 layer->setDrawOpacityIsAnimating(false); |
| 552 | 552 |
| 553 renderSurface->setTargetSurfaceTransformsAreAnimating(animatingTransform
ToTarget); | 553 renderSurface->setTargetSurfaceTransformsAreAnimating(animatingTransform
ToTarget); |
| 554 renderSurface->setScreenSpaceTransformsAreAnimating(animatingTransformTo
Screen); | 554 renderSurface->setScreenSpaceTransformsAreAnimating(animatingTransformTo
Screen); |
| 555 animatingTransformToTarget = false; | 555 animatingTransformToTarget = false; |
| 556 layer->setDrawTransformIsAnimating(animatingTransformToTarget); | 556 layer->setDrawTransformIsAnimating(animatingTransformToTarget); |
| 557 layer->setScreenSpaceTransformIsAnimating(animatingTransformToScreen); | 557 layer->setScreenSpaceTransformIsAnimating(animatingTransformToScreen); |
| 558 | 558 |
| 559 // Update the aggregate hierarchy matrix to include the transform of the | 559 // Update the aggregate hierarchy matrix to include the transform of the |
| 560 // newly created RenderSurface. | 560 // newly created RenderSurfaceImpl. |
| 561 nextHierarchyMatrix.multiply(renderSurface->drawTransform()); | 561 nextHierarchyMatrix.multiply(renderSurface->drawTransform()); |
| 562 | 562 |
| 563 // The new renderSurface here will correctly clip the entire subtree. So
, we do | 563 // The new renderSurface here will correctly clip the entire subtree. So
, we do |
| 564 // not need to continue propagating the clipping state further down the
tree. This | 564 // not need to continue propagating the clipping state further down the
tree. This |
| 565 // way, we can avoid transforming clipRects from ancestor target surface
space to | 565 // way, we can avoid transforming clipRects from ancestor target surface
space to |
| 566 // current target surface space that could cause more w < 0 headaches. | 566 // current target surface space that could cause more w < 0 headaches. |
| 567 subtreeShouldBeClipped = false; | 567 subtreeShouldBeClipped = false; |
| 568 | 568 |
| 569 if (layer->maskLayer()) { | 569 if (layer->maskLayer()) { |
| 570 layer->maskLayer()->setRenderTarget(layer); | 570 layer->maskLayer()->setRenderTarget(layer); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 } else { | 611 } else { |
| 612 // FIXME: This root layer special case code should eventually go awa
y. https://bugs.webkit.org/show_bug.cgi?id=92290 | 612 // FIXME: This root layer special case code should eventually go awa
y. https://bugs.webkit.org/show_bug.cgi?id=92290 |
| 613 ASSERT(!layer->parent()); | 613 ASSERT(!layer->parent()); |
| 614 ASSERT(layer->renderSurface()); | 614 ASSERT(layer->renderSurface()); |
| 615 ASSERT(ancestorClipsSubtree); | 615 ASSERT(ancestorClipsSubtree); |
| 616 layer->renderSurface()->setClipRect(clipRectFromAncestor); | 616 layer->renderSurface()->setClipRect(clipRectFromAncestor); |
| 617 subtreeShouldBeClipped = false; | 617 subtreeShouldBeClipped = false; |
| 618 } | 618 } |
| 619 } | 619 } |
| 620 | 620 |
| 621 IntRect rectInTargetSpace = enclosingIntRect(CCMathUtil::mapClippedRect(laye
r->drawTransform(), contentRect)); | 621 IntRect rectInTargetSpace = enclosingIntRect(MathUtil::mapClippedRect(layer-
>drawTransform(), contentRect)); |
| 622 | 622 |
| 623 if (layerClipsSubtree(layer)) { | 623 if (layerClipsSubtree(layer)) { |
| 624 subtreeShouldBeClipped = true; | 624 subtreeShouldBeClipped = true; |
| 625 if (ancestorClipsSubtree && !layer->renderSurface()) { | 625 if (ancestorClipsSubtree && !layer->renderSurface()) { |
| 626 clipRectForSubtree = clipRectFromAncestor; | 626 clipRectForSubtree = clipRectFromAncestor; |
| 627 clipRectForSubtree.intersect(rectInTargetSpace); | 627 clipRectForSubtree.intersect(rectInTargetSpace); |
| 628 } else | 628 } else |
| 629 clipRectForSubtree = rectInTargetSpace; | 629 clipRectForSubtree = rectInTargetSpace; |
| 630 } | 630 } |
| 631 | 631 |
| 632 // Flatten to 2D if the layer doesn't preserve 3D. | 632 // Flatten to 2D if the layer doesn't preserve 3D. |
| 633 if (!layer->preserves3D()) | 633 if (!layer->preserves3D()) |
| 634 CCMathUtil::flattenTransformTo2d(sublayerMatrix); | 634 MathUtil::flattenTransformTo2d(sublayerMatrix); |
| 635 | 635 |
| 636 // Apply the sublayer transform at the center of the layer. | 636 // Apply the sublayer transform at the center of the layer. |
| 637 sublayerMatrix.translate(0.5 * bounds.width(), 0.5 * bounds.height()); | 637 sublayerMatrix.translate(0.5 * bounds.width(), 0.5 * bounds.height()); |
| 638 sublayerMatrix.multiply(layer->sublayerTransform()); | 638 sublayerMatrix.multiply(layer->sublayerTransform()); |
| 639 sublayerMatrix.translate(-0.5 * bounds.width(), -0.5 * bounds.height()); | 639 sublayerMatrix.translate(-0.5 * bounds.width(), -0.5 * bounds.height()); |
| 640 | 640 |
| 641 LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->l
ayerList() : layerList); | 641 LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->l
ayerList() : layerList); |
| 642 | 642 |
| 643 // Any layers that are appended after this point are in the layer's subtree
and should be included in the sorting process. | 643 // Any layers that are appended after this point are in the layer's subtree
and should be included in the sorting process. |
| 644 unsigned sortingStartIndex = descendants.size(); | 644 unsigned sortingStartIndex = descendants.size(); |
| 645 | 645 |
| 646 if (!layerShouldBeSkipped(layer)) | 646 if (!layerShouldBeSkipped(layer)) |
| 647 descendants.push_back(layer); | 647 descendants.push_back(layer); |
| 648 | 648 |
| 649 WebTransformationMatrix nextScrollCompensationMatrix = computeScrollCompensa
tionMatrixForChildren(layer, parentMatrix, currentScrollCompensationMatrix);; | 649 WebTransformationMatrix nextScrollCompensationMatrix = computeScrollCompensa
tionMatrixForChildren(layer, parentMatrix, currentScrollCompensationMatrix);; |
| 650 | 650 |
| 651 IntRect accumulatedDrawableContentRectOfChildren; | 651 IntRect accumulatedDrawableContentRectOfChildren; |
| 652 for (size_t i = 0; i < layer->children().size(); ++i) { | 652 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 653 LayerType* child = CCLayerTreeHostCommon::getChildAsRawPtr(layer->childr
en(), i); | 653 LayerType* child = LayerTreeHostCommon::getChildAsRawPtr(layer->children
(), i); |
| 654 IntRect drawableContentRectOfChildSubtree; | 654 IntRect drawableContentRectOfChildSubtree; |
| 655 calculateDrawTransformsInternal<LayerType, LayerList, RenderSurfaceType,
LayerSorter>(child, rootLayer, sublayerMatrix, nextHierarchyMatrix, nextScrollC
ompensationMatrix, | 655 calculateDrawTransformsInternal<LayerType, LayerList, RenderSurfaceType,
LayerSorter>(child, rootLayer, sublayerMatrix, nextHierarchyMatrix, nextScrollC
ompensationMatrix, |
| 656
clipRectForSubtree, subtreeShouldBeClipped, nearestAncestorThatMov
esPixels, | 656
clipRectForSubtree, subtreeShouldBeClipped, nearestAncestorThatMov
esPixels, |
| 657
renderSurfaceLayerList, descendants, layerSorter, maxTextureSize,
deviceScaleFactor, drawableContentRectOfChildSubtree); | 657
renderSurfaceLayerList, descendants, layerSorter, maxTextureSize,
deviceScaleFactor, drawableContentRectOfChildSubtree); |
| 658 if (!drawableContentRectOfChildSubtree.isEmpty()) { | 658 if (!drawableContentRectOfChildSubtree.isEmpty()) { |
| 659 accumulatedDrawableContentRectOfChildren.unite(drawableContentRectOf
ChildSubtree); | 659 accumulatedDrawableContentRectOfChildren.unite(drawableContentRectOf
ChildSubtree); |
| 660 if (child->renderSurface()) | 660 if (child->renderSurface()) |
| 661 descendants.push_back(child); | 661 descendants.push_back(child); |
| 662 } | 662 } |
| 663 } | 663 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 684 RenderSurfaceType* renderSurface = layer->renderSurface(); | 684 RenderSurfaceType* renderSurface = layer->renderSurface(); |
| 685 IntRect clippedContentRect = localDrawableContentRectOfSubtree; | 685 IntRect clippedContentRect = localDrawableContentRectOfSubtree; |
| 686 | 686 |
| 687 // Don't clip if the layer is reflected as the reflection shouldn't be | 687 // Don't clip if the layer is reflected as the reflection shouldn't be |
| 688 // clipped. If the layer is animating, then the surface's transform to | 688 // clipped. If the layer is animating, then the surface's transform to |
| 689 // its target is not known on the main thread, and we should not use it | 689 // its target is not known on the main thread, and we should not use it |
| 690 // to clip. | 690 // to clip. |
| 691 if (!layer->replicaLayer() && transformToParentIsKnown(layer)) { | 691 if (!layer->replicaLayer() && transformToParentIsKnown(layer)) { |
| 692 // Note, it is correct to use ancestorClipsSubtree here, because we
are looking at this layer's renderSurface, not the layer itself. | 692 // Note, it is correct to use ancestorClipsSubtree here, because we
are looking at this layer's renderSurface, not the layer itself. |
| 693 if (ancestorClipsSubtree && !clippedContentRect.isEmpty()) { | 693 if (ancestorClipsSubtree && !clippedContentRect.isEmpty()) { |
| 694 IntRect surfaceClipRect = CCLayerTreeHostCommon::calculateVisibl
eRect(renderSurface->clipRect(), clippedContentRect, renderSurface->drawTransfor
m()); | 694 IntRect surfaceClipRect = LayerTreeHostCommon::calculateVisibleR
ect(renderSurface->clipRect(), clippedContentRect, renderSurface->drawTransform(
)); |
| 695 clippedContentRect.intersect(surfaceClipRect); | 695 clippedContentRect.intersect(surfaceClipRect); |
| 696 } | 696 } |
| 697 } | 697 } |
| 698 | 698 |
| 699 // The RenderSurface backing texture cannot exceed the maximum supported | 699 // The RenderSurfaceImpl backing texture cannot exceed the maximum suppo
rted |
| 700 // texture size. | 700 // texture size. |
| 701 clippedContentRect.setWidth(std::min(clippedContentRect.width(), maxText
ureSize)); | 701 clippedContentRect.setWidth(std::min(clippedContentRect.width(), maxText
ureSize)); |
| 702 clippedContentRect.setHeight(std::min(clippedContentRect.height(), maxTe
xtureSize)); | 702 clippedContentRect.setHeight(std::min(clippedContentRect.height(), maxTe
xtureSize)); |
| 703 | 703 |
| 704 if (clippedContentRect.isEmpty()) | 704 if (clippedContentRect.isEmpty()) |
| 705 renderSurface->clearLayerLists(); | 705 renderSurface->clearLayerLists(); |
| 706 | 706 |
| 707 renderSurface->setContentRect(clippedContentRect); | 707 renderSurface->setContentRect(clippedContentRect); |
| 708 renderSurface->setScreenSpaceTransform(layer->screenSpaceTransform()); | 708 renderSurface->setScreenSpaceTransform(layer->screenSpaceTransform()); |
| 709 | 709 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 | 755 |
| 756 if (layer->renderSurface()) | 756 if (layer->renderSurface()) |
| 757 drawableContentRectOfSubtree = enclosingIntRect(layer->renderSurface()->
drawableContentRect()); | 757 drawableContentRectOfSubtree = enclosingIntRect(layer->renderSurface()->
drawableContentRect()); |
| 758 else | 758 else |
| 759 drawableContentRectOfSubtree = localDrawableContentRectOfSubtree; | 759 drawableContentRectOfSubtree = localDrawableContentRectOfSubtree; |
| 760 | 760 |
| 761 if (layer->hasContributingDelegatedRenderPasses()) | 761 if (layer->hasContributingDelegatedRenderPasses()) |
| 762 layer->renderTarget()->renderSurface()->addContributingDelegatedRenderPa
ssLayer(layer); | 762 layer->renderTarget()->renderSurface()->addContributingDelegatedRenderPa
ssLayer(layer); |
| 763 } | 763 } |
| 764 | 764 |
| 765 void CCLayerTreeHostCommon::calculateDrawTransforms(LayerChromium* rootLayer, co
nst IntSize& deviceViewportSize, float deviceScaleFactor, int maxTextureSize, st
d::vector<scoped_refptr<LayerChromium> >& renderSurfaceLayerList) | 765 void LayerTreeHostCommon::calculateDrawTransforms(Layer* rootLayer, const IntSiz
e& deviceViewportSize, float deviceScaleFactor, int maxTextureSize, std::vector<
scoped_refptr<Layer> >& renderSurfaceLayerList) |
| 766 { | 766 { |
| 767 IntRect totalDrawableContentRect; | 767 IntRect totalDrawableContentRect; |
| 768 WebTransformationMatrix identityMatrix; | 768 WebTransformationMatrix identityMatrix; |
| 769 WebTransformationMatrix deviceScaleTransform; | 769 WebTransformationMatrix deviceScaleTransform; |
| 770 deviceScaleTransform.scale(deviceScaleFactor); | 770 deviceScaleTransform.scale(deviceScaleFactor); |
| 771 | 771 |
| 772 setupRootLayerAndSurfaceForRecursion<LayerChromium, std::vector<scoped_refpt
r<LayerChromium> > >(rootLayer, renderSurfaceLayerList, deviceViewportSize); | 772 setupRootLayerAndSurfaceForRecursion<Layer, std::vector<scoped_refptr<Layer>
> >(rootLayer, renderSurfaceLayerList, deviceViewportSize); |
| 773 | 773 |
| 774 cc::calculateDrawTransformsInternal<LayerChromium, std::vector<scoped_refptr
<LayerChromium> >, RenderSurfaceChromium, void>(rootLayer, rootLayer, deviceScal
eTransform, identityMatrix, identityMatrix, | 774 cc::calculateDrawTransformsInternal<Layer, std::vector<scoped_refptr<Layer>
>, RenderSurface, void>(rootLayer, rootLayer, deviceScaleTransform, identityMatr
ix, identityMatrix, |
| 775
rootLayer->renderSurface()->contentRect
(), true, 0, renderSurfaceLayerList, | 775
rootLayer->renderSurface()->contentRect
(), true, 0, renderSurfaceLayerList, |
| 776
rootLayer->renderSurface()->layerList()
, 0, maxTextureSize, deviceScaleFactor, totalDrawableContentRect); | 776
rootLayer->renderSurface()->layerList()
, 0, maxTextureSize, deviceScaleFactor, totalDrawableContentRect); |
| 777 } | 777 } |
| 778 | 778 |
| 779 void CCLayerTreeHostCommon::calculateDrawTransforms(CCLayerImpl* rootLayer, cons
t IntSize& deviceViewportSize, float deviceScaleFactor, CCLayerSorter* layerSort
er, int maxTextureSize, std::vector<CCLayerImpl*>& renderSurfaceLayerList) | 779 void LayerTreeHostCommon::calculateDrawTransforms(LayerImpl* rootLayer, const In
tSize& deviceViewportSize, float deviceScaleFactor, LayerSorter* layerSorter, in
t maxTextureSize, std::vector<LayerImpl*>& renderSurfaceLayerList) |
| 780 { | 780 { |
| 781 IntRect totalDrawableContentRect; | 781 IntRect totalDrawableContentRect; |
| 782 WebTransformationMatrix identityMatrix; | 782 WebTransformationMatrix identityMatrix; |
| 783 WebTransformationMatrix deviceScaleTransform; | 783 WebTransformationMatrix deviceScaleTransform; |
| 784 deviceScaleTransform.scale(deviceScaleFactor); | 784 deviceScaleTransform.scale(deviceScaleFactor); |
| 785 | 785 |
| 786 setupRootLayerAndSurfaceForRecursion<CCLayerImpl, std::vector<CCLayerImpl*>
>(rootLayer, renderSurfaceLayerList, deviceViewportSize); | 786 setupRootLayerAndSurfaceForRecursion<LayerImpl, std::vector<LayerImpl*> >(ro
otLayer, renderSurfaceLayerList, deviceViewportSize); |
| 787 | 787 |
| 788 cc::calculateDrawTransformsInternal<CCLayerImpl, std::vector<CCLayerImpl*>,
CCRenderSurface, CCLayerSorter>(rootLayer, rootLayer, deviceScaleTransform, iden
tityMatrix, identityMatrix, | 788 cc::calculateDrawTransformsInternal<LayerImpl, std::vector<LayerImpl*>, Rend
erSurfaceImpl, LayerSorter>(rootLayer, rootLayer, deviceScaleTransform, identity
Matrix, identityMatrix, |
| 789
rootLayer->renderSurface()->contentRect(), true,
0, renderSurfaceLayerList, | 789
rootLayer->renderSurface()->contentRect(), true,
0, renderSurfaceLayerList, |
| 790
rootLayer->renderSurface()->layerList(), layerSo
rter, maxTextureSize, deviceScaleFactor, totalDrawableContentRect); | 790
rootLayer->renderSurface()->layerList(), layerSo
rter, maxTextureSize, deviceScaleFactor, totalDrawableContentRect); |
| 791 } | 791 } |
| 792 | 792 |
| 793 static bool pointHitsRect(const IntPoint& viewportPoint, const WebTransformation
Matrix& localSpaceToScreenSpaceTransform, FloatRect localSpaceRect) | 793 static bool pointHitsRect(const IntPoint& viewportPoint, const WebTransformation
Matrix& localSpaceToScreenSpaceTransform, FloatRect localSpaceRect) |
| 794 { | 794 { |
| 795 // If the transform is not invertible, then assume that this point doesn't h
it this rect. | 795 // If the transform is not invertible, then assume that this point doesn't h
it this rect. |
| 796 if (!localSpaceToScreenSpaceTransform.isInvertible()) | 796 if (!localSpaceToScreenSpaceTransform.isInvertible()) |
| 797 return false; | 797 return false; |
| 798 | 798 |
| 799 // Transform the hit test point from screen space to the local space of the
given rect. | 799 // Transform the hit test point from screen space to the local space of the
given rect. |
| 800 bool clipped = false; | 800 bool clipped = false; |
| 801 FloatPoint hitTestPointInLocalSpace = CCMathUtil::projectPoint(localSpaceToS
creenSpaceTransform.inverse(), FloatPoint(viewportPoint), clipped); | 801 FloatPoint hitTestPointInLocalSpace = MathUtil::projectPoint(localSpaceToScr
eenSpaceTransform.inverse(), FloatPoint(viewportPoint), clipped); |
| 802 | 802 |
| 803 // If projectPoint could not project to a valid value, then we assume that t
his point doesn't hit this rect. | 803 // If projectPoint could not project to a valid value, then we assume that t
his point doesn't hit this rect. |
| 804 if (clipped) | 804 if (clipped) |
| 805 return false; | 805 return false; |
| 806 | 806 |
| 807 return localSpaceRect.contains(hitTestPointInLocalSpace); | 807 return localSpaceRect.contains(hitTestPointInLocalSpace); |
| 808 } | 808 } |
| 809 | 809 |
| 810 static bool pointIsClippedBySurfaceOrClipRect(const IntPoint& viewportPoint, CCL
ayerImpl* layer) | 810 static bool pointIsClippedBySurfaceOrClipRect(const IntPoint& viewportPoint, Lay
erImpl* layer) |
| 811 { | 811 { |
| 812 CCLayerImpl* currentLayer = layer; | 812 LayerImpl* currentLayer = layer; |
| 813 | 813 |
| 814 // Walk up the layer tree and hit-test any renderSurfaces and any layer clip
Rects that are active. | 814 // Walk up the layer tree and hit-test any renderSurfaces and any layer clip
Rects that are active. |
| 815 while (currentLayer) { | 815 while (currentLayer) { |
| 816 if (currentLayer->renderSurface() && !pointHitsRect(viewportPoint, curre
ntLayer->renderSurface()->screenSpaceTransform(), currentLayer->renderSurface()-
>contentRect())) | 816 if (currentLayer->renderSurface() && !pointHitsRect(viewportPoint, curre
ntLayer->renderSurface()->screenSpaceTransform(), currentLayer->renderSurface()-
>contentRect())) |
| 817 return true; | 817 return true; |
| 818 | 818 |
| 819 // Note that drawableContentRects are actually in targetSurface space, s
o the transform we | 819 // Note that drawableContentRects are actually in targetSurface space, s
o the transform we |
| 820 // have to provide is the target surface's screenSpaceTransform. | 820 // have to provide is the target surface's screenSpaceTransform. |
| 821 CCLayerImpl* renderTarget = currentLayer->renderTarget(); | 821 LayerImpl* renderTarget = currentLayer->renderTarget(); |
| 822 if (layerClipsSubtree(currentLayer) && !pointHitsRect(viewportPoint, ren
derTarget->renderSurface()->screenSpaceTransform(), currentLayer->drawableConten
tRect())) | 822 if (layerClipsSubtree(currentLayer) && !pointHitsRect(viewportPoint, ren
derTarget->renderSurface()->screenSpaceTransform(), currentLayer->drawableConten
tRect())) |
| 823 return true; | 823 return true; |
| 824 | 824 |
| 825 currentLayer = currentLayer->parent(); | 825 currentLayer = currentLayer->parent(); |
| 826 } | 826 } |
| 827 | 827 |
| 828 // If we have finished walking all ancestors without having already exited,
then the point is not clipped by any ancestors. | 828 // If we have finished walking all ancestors without having already exited,
then the point is not clipped by any ancestors. |
| 829 return false; | 829 return false; |
| 830 } | 830 } |
| 831 | 831 |
| 832 CCLayerImpl* CCLayerTreeHostCommon::findLayerThatIsHitByPoint(const IntPoint& vi
ewportPoint, std::vector<CCLayerImpl*>& renderSurfaceLayerList) | 832 LayerImpl* LayerTreeHostCommon::findLayerThatIsHitByPoint(const IntPoint& viewpo
rtPoint, std::vector<LayerImpl*>& renderSurfaceLayerList) |
| 833 { | 833 { |
| 834 CCLayerImpl* foundLayer = 0; | 834 LayerImpl* foundLayer = 0; |
| 835 | 835 |
| 836 typedef CCLayerIterator<CCLayerImpl, std::vector<CCLayerImpl*>, CCRenderSurf
ace, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType; | 836 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl,
LayerIteratorActions::FrontToBack> LayerIteratorType; |
| 837 CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceLayerList); | 837 LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList); |
| 838 | 838 |
| 839 for (CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayer
List); it != end; ++it) { | 839 for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList
); it != end; ++it) { |
| 840 // We don't want to consider renderSurfaces for hit testing. | 840 // We don't want to consider renderSurfaces for hit testing. |
| 841 if (!it.representsItself()) | 841 if (!it.representsItself()) |
| 842 continue; | 842 continue; |
| 843 | 843 |
| 844 CCLayerImpl* currentLayer = (*it); | 844 LayerImpl* currentLayer = (*it); |
| 845 | 845 |
| 846 FloatRect contentRect(FloatPoint::zero(), currentLayer->contentBounds())
; | 846 FloatRect contentRect(FloatPoint::zero(), currentLayer->contentBounds())
; |
| 847 if (!pointHitsRect(viewportPoint, currentLayer->screenSpaceTransform(),
contentRect)) | 847 if (!pointHitsRect(viewportPoint, currentLayer->screenSpaceTransform(),
contentRect)) |
| 848 continue; | 848 continue; |
| 849 | 849 |
| 850 // At this point, we think the point does hit the layer, but we need to
walk up | 850 // At this point, we think the point does hit the layer, but we need to
walk up |
| 851 // the parents to ensure that the layer was not clipped in such a way th
at the | 851 // the parents to ensure that the layer was not clipped in such a way th
at the |
| 852 // hit point actually should not hit the layer. | 852 // hit point actually should not hit the layer. |
| 853 if (pointIsClippedBySurfaceOrClipRect(viewportPoint, currentLayer)) | 853 if (pointIsClippedBySurfaceOrClipRect(viewportPoint, currentLayer)) |
| 854 continue; | 854 continue; |
| 855 | 855 |
| 856 foundLayer = currentLayer; | 856 foundLayer = currentLayer; |
| 857 break; | 857 break; |
| 858 } | 858 } |
| 859 | 859 |
| 860 // This can potentially return 0, which means the viewportPoint did not succ
essfully hit test any layers, not even the root layer. | 860 // This can potentially return 0, which means the viewportPoint did not succ
essfully hit test any layers, not even the root layer. |
| 861 return foundLayer; | 861 return foundLayer; |
| 862 } | 862 } |
| 863 | 863 |
| 864 } // namespace cc | 864 } // namespace cc |
| OLD | NEW |