| 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 "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "cc/heads_up_display_layer_impl.h" | 10 #include "cc/heads_up_display_layer_impl.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 namespace cc { | 23 namespace cc { |
| 24 | 24 |
| 25 ScrollAndScaleSet::ScrollAndScaleSet() | 25 ScrollAndScaleSet::ScrollAndScaleSet() |
| 26 { | 26 { |
| 27 } | 27 } |
| 28 | 28 |
| 29 ScrollAndScaleSet::~ScrollAndScaleSet() | 29 ScrollAndScaleSet::~ScrollAndScaleSet() |
| 30 { | 30 { |
| 31 } | 31 } |
| 32 | 32 |
| 33 static void sortLayers(std::vector<Layer*>::iterator first, std::vector<Layer*>:
:iterator end, LayerSorter* layerSorter) | 33 static void sortLayers(std::vector<scoped_refptr<Layer> >::iterator forst, std::
vector<scoped_refptr<Layer> >::iterator end, void* layerSorter) |
| 34 { | 34 { |
| 35 NOTREACHED(); | 35 NOTREACHED(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 static void sortLayers(std::vector<LayerImpl*>::iterator first, std::vector<Laye
rImpl*>::iterator end, LayerSorter* layerSorter) | 38 static void sortLayers(std::vector<LayerImpl*>::iterator first, std::vector<Laye
rImpl*>::iterator end, LayerSorter* layerSorter) |
| 39 { | 39 { |
| 40 DCHECK(layerSorter); | 40 DCHECK(layerSorter); |
| 41 TRACE_EVENT0("cc", "layer_tree_host_common::sortLayers"); | 41 TRACE_EVENT0("cc", "layer_tree_host_common::sortLayers"); |
| 42 layerSorter->Sort(first, end); | 42 layerSorter->Sort(first, end); |
| 43 } | 43 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 static inline bool isRootLayer(LayerType* layer) | 79 static inline bool isRootLayer(LayerType* layer) |
| 80 { | 80 { |
| 81 return !layer->parent(); | 81 return !layer->parent(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 template<typename LayerType> | 84 template<typename LayerType> |
| 85 static inline bool layerIsInExisting3DRenderingContext(LayerType* layer) | 85 static inline bool layerIsInExisting3DRenderingContext(LayerType* layer) |
| 86 { | 86 { |
| 87 // According to current W3C spec on CSS transforms, a layer is part of an es
tablished | 87 // According to current W3C spec on CSS transforms, a layer is part of an es
tablished |
| 88 // 3d rendering context if its parent has transform-style of preserves-3d. | 88 // 3d rendering context if its parent has transform-style of preserves-3d. |
| 89 return layer->parent() && layer->parent()->preserves3D(); | 89 return layer->parent() && layer->parent()->preserves_3d(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 template<typename LayerType> | 92 template<typename LayerType> |
| 93 static bool isRootLayerOfNewRenderingContext(LayerType* layer) | 93 static bool isRootLayerOfNewRenderingContext(LayerType* layer) |
| 94 { | 94 { |
| 95 // According to current W3C spec on CSS transforms (Section 6.1), a layer is
the | 95 // According to current W3C spec on CSS transforms (Section 6.1), a layer is
the |
| 96 // beginning of 3d rendering context if its parent does not have transform-s
tyle: | 96 // beginning of 3d rendering context if its parent does not have transform-s
tyle: |
| 97 // preserve-3d, but this layer itself does. | 97 // preserve-3d, but this layer itself does. |
| 98 if (layer->parent()) | 98 if (layer->parent()) |
| 99 return !layer->parent()->preserves3D() && layer->preserves3D(); | 99 return !layer->parent()->preserves_3d() && layer->preserves_3d(); |
| 100 | 100 |
| 101 return layer->preserves3D(); | 101 return layer->preserves_3d(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 template<typename LayerType> | 104 template<typename LayerType> |
| 105 static bool isLayerBackFaceVisible(LayerType* layer) | 105 static bool isLayerBackFaceVisible(LayerType* layer) |
| 106 { | 106 { |
| 107 // The current W3C spec on CSS transforms says that backface visibility shou
ld be | 107 // The current W3C spec on CSS transforms says that backface visibility shou
ld be |
| 108 // determined differently depending on whether the layer is in a "3d renderi
ng | 108 // determined differently depending on whether the layer is in a "3d renderi
ng |
| 109 // context" or not. For Chromium code, we can determine whether we are in a
3d | 109 // context" or not. For Chromium code, we can determine whether we are in a
3d |
| 110 // rendering context by checking if the parent preserves 3d. | 110 // rendering context by checking if the parent preserves 3d. |
| 111 | 111 |
| 112 if (layerIsInExisting3DRenderingContext(layer)) | 112 if (layerIsInExisting3DRenderingContext(layer)) |
| 113 return layer->drawTransform().IsBackFaceVisible(); | 113 return layer->draw_transform().IsBackFaceVisible(); |
| 114 | 114 |
| 115 // In this case, either the layer establishes a new 3d rendering context, or
is not in | 115 // In this case, either the layer establishes a new 3d rendering context, or
is not in |
| 116 // a 3d rendering context at all. | 116 // a 3d rendering context at all. |
| 117 return layer->transform().IsBackFaceVisible(); | 117 return layer->transform().IsBackFaceVisible(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 template<typename LayerType> | 120 template<typename LayerType> |
| 121 static bool isSurfaceBackFaceVisible(LayerType* layer, const gfx::Transform& dra
wTransform) | 121 static bool isSurfaceBackFaceVisible(LayerType* layer, const gfx::Transform& dra
wTransform) |
| 122 { | 122 { |
| 123 if (layerIsInExisting3DRenderingContext(layer)) | 123 if (layerIsInExisting3DRenderingContext(layer)) |
| 124 return drawTransform.IsBackFaceVisible(); | 124 return drawTransform.IsBackFaceVisible(); |
| 125 | 125 |
| 126 if (isRootLayerOfNewRenderingContext(layer)) | 126 if (isRootLayerOfNewRenderingContext(layer)) |
| 127 return layer->transform().IsBackFaceVisible(); | 127 return layer->transform().IsBackFaceVisible(); |
| 128 | 128 |
| 129 // If the renderSurface is not part of a new or existing rendering context,
then the | 129 // If the renderSurface is not part of a new or existing rendering context,
then the |
| 130 // layers that contribute to this surface will decide back-face visibility f
or themselves. | 130 // layers that contribute to this surface will decide back-face visibility f
or themselves. |
| 131 return false; | 131 return false; |
| 132 } | 132 } |
| 133 | 133 |
| 134 template<typename LayerType> | 134 template<typename LayerType> |
| 135 static inline bool layerClipsSubtree(LayerType* layer) | 135 static inline bool layerClipsSubtree(LayerType* layer) |
| 136 { | 136 { |
| 137 return layer->masksToBounds() || layer->maskLayer(); | 137 return layer->masks_to_bounds() || layer->mask_layer(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 template<typename LayerType> | 140 template<typename LayerType> |
| 141 static gfx::Rect calculateVisibleContentRect(LayerType* layer, const gfx::Rect&
ancestorClipRectInDescendantSurfaceSpace, const gfx::Rect& layerRectInTargetSpac
e) | 141 static gfx::Rect calculateVisibleContentRect(LayerType* layer, const gfx::Rect&
ancestorClipRectInDescendantSurfaceSpace, const gfx::Rect& layerRectInTargetSpac
e) |
| 142 { | 142 { |
| 143 DCHECK(layer->renderTarget()); | 143 DCHECK(layer->render_target()); |
| 144 | 144 |
| 145 // Nothing is visible if the layer bounds are empty. | 145 // Nothing is visible if the layer bounds are empty. |
| 146 if (!layer->drawsContent() || layer->contentBounds().IsEmpty() || layer->dra
wableContentRect().IsEmpty()) | 146 if (!layer->DrawsContent() || layer->content_bounds().IsEmpty() || layer->dr
awable_content_rect().IsEmpty()) |
| 147 return gfx::Rect(); | 147 return gfx::Rect(); |
| 148 | 148 |
| 149 // Compute visible bounds in target surface space. | 149 // Compute visible bounds in target surface space. |
| 150 gfx::Rect visibleRectInTargetSurfaceSpace = layer->drawableContentRect(); | 150 gfx::Rect visibleRectInTargetSurfaceSpace = layer->drawable_content_rect(); |
| 151 | 151 |
| 152 if (!layer->renderTarget()->renderSurface()->clip_rect().IsEmpty()) { | 152 if (!layer->render_target()->render_surface()->clip_rect().IsEmpty()) { |
| 153 // In this case the target surface does clip layers that contribute to | 153 // In this case the target surface does clip layers that contribute to |
| 154 // it. So, we have to convert the current surface's clipRect from its | 154 // it. So, we have to convert the current surface's clipRect from its |
| 155 // ancestor surface space to the current (descendant) surface | 155 // ancestor surface space to the current (descendant) surface |
| 156 // space. This conversion is done outside this function so that it can | 156 // space. This conversion is done outside this function so that it can |
| 157 // be cached instead of computing it redundantly for every layer. | 157 // be cached instead of computing it redundantly for every layer. |
| 158 visibleRectInTargetSurfaceSpace.Intersect(ancestorClipRectInDescendantSu
rfaceSpace); | 158 visibleRectInTargetSurfaceSpace.Intersect(ancestorClipRectInDescendantSu
rfaceSpace); |
| 159 } | 159 } |
| 160 | 160 |
| 161 if (visibleRectInTargetSurfaceSpace.IsEmpty()) | 161 if (visibleRectInTargetSurfaceSpace.IsEmpty()) |
| 162 return gfx::Rect(); | 162 return gfx::Rect(); |
| 163 | 163 |
| 164 return calculateVisibleRectWithCachedLayerRect(visibleRectInTargetSurfaceSpa
ce, gfx::Rect(gfx::Point(), layer->contentBounds()), layerRectInTargetSpace, lay
er->drawTransform()); | 164 return calculateVisibleRectWithCachedLayerRect(visibleRectInTargetSurfaceSpa
ce, gfx::Rect(gfx::Point(), layer->content_bounds()), layerRectInTargetSpace, la
yer->draw_transform()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 static inline bool transformToParentIsKnown(LayerImpl*) | 167 static inline bool transformToParentIsKnown(LayerImpl*) |
| 168 { | 168 { |
| 169 return true; | 169 return true; |
| 170 } | 170 } |
| 171 | 171 |
| 172 static inline bool transformToParentIsKnown(Layer* layer) | 172 static inline bool transformToParentIsKnown(Layer* layer) |
| 173 { | 173 { |
| 174 | 174 |
| 175 return !layer->transformIsAnimating(); | 175 return !layer->TransformIsAnimating(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 static inline bool transformToScreenIsKnown(LayerImpl*) | 178 static inline bool transformToScreenIsKnown(LayerImpl*) |
| 179 { | 179 { |
| 180 return true; | 180 return true; |
| 181 } | 181 } |
| 182 | 182 |
| 183 static inline bool transformToScreenIsKnown(Layer* layer) | 183 static inline bool transformToScreenIsKnown(Layer* layer) |
| 184 { | 184 { |
| 185 return !layer->screenSpaceTransformIsAnimating(); | 185 return !layer->screen_space_transform_is_animating(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 template<typename LayerType> | 188 template<typename LayerType> |
| 189 static bool layerShouldBeSkipped(LayerType* layer) | 189 static bool layerShouldBeSkipped(LayerType* layer) |
| 190 { | 190 { |
| 191 // Layers can be skipped if any of these conditions are met. | 191 // Layers can be skipped if any of these conditions are met. |
| 192 // - does not draw content. | 192 // - does not draw content. |
| 193 // - is transparent | 193 // - is transparent |
| 194 // - has empty bounds | 194 // - has empty bounds |
| 195 // - the layer is not double-sided, but its back face is visible. | 195 // - the layer is not double-sided, but its back face is visible. |
| 196 // | 196 // |
| 197 // Some additional conditions need to be computed at a later point after the
recursion is finished. | 197 // Some additional conditions need to be computed at a later point after the
recursion is finished. |
| 198 // - the intersection of render surface content and layer clipRect is empt
y | 198 // - the intersection of render surface content and layer clipRect is empt
y |
| 199 // - the visibleContentRect is empty | 199 // - the visibleContentRect is empty |
| 200 // | 200 // |
| 201 // Note, if the layer should not have been drawn due to being fully transpar
ent, | 201 // Note, if the layer should not have been drawn due to being fully transpar
ent, |
| 202 // we would have skipped the entire subtree and never made it into this func
tion, | 202 // we would have skipped the entire subtree and never made it into this func
tion, |
| 203 // so it is safe to omit this check here. | 203 // so it is safe to omit this check here. |
| 204 | 204 |
| 205 if (!layer->drawsContent() || layer->bounds().IsEmpty()) | 205 if (!layer->DrawsContent() || layer->bounds().IsEmpty()) |
| 206 return true; | 206 return true; |
| 207 | 207 |
| 208 LayerType* backfaceTestLayer = layer; | 208 LayerType* backfaceTestLayer = layer; |
| 209 if (layer->useParentBackfaceVisibility()) { | 209 if (layer->use_parent_backface_visibility()) { |
| 210 DCHECK(layer->parent()); | 210 DCHECK(layer->parent()); |
| 211 DCHECK(!layer->parent()->useParentBackfaceVisibility()); | 211 DCHECK(!layer->parent()->use_parent_backface_visibility()); |
| 212 backfaceTestLayer = layer->parent(); | 212 backfaceTestLayer = layer->parent(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 // 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. | 215 // 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. |
| 216 if (!backfaceTestLayer->doubleSided() && transformToScreenIsKnown(backfaceTe
stLayer) && isLayerBackFaceVisible(backfaceTestLayer)) | 216 if (!backfaceTestLayer->double_sided() && transformToScreenIsKnown(backfaceT
estLayer) && isLayerBackFaceVisible(backfaceTestLayer)) |
| 217 return true; | 217 return true; |
| 218 | 218 |
| 219 return false; | 219 return false; |
| 220 } | 220 } |
| 221 | 221 |
| 222 static inline bool subtreeShouldBeSkipped(LayerImpl* layer) | 222 static inline bool subtreeShouldBeSkipped(LayerImpl* layer) |
| 223 { | 223 { |
| 224 // The opacity of a layer always applies to its children (either implicitly | 224 // The opacity of a layer always applies to its children (either implicitly |
| 225 // via a render surface or explicitly if the parent preserves 3D), so the | 225 // via a render surface or explicitly if the parent preserves 3D), so the |
| 226 // entire subtree can be skipped if this layer is fully transparent. | 226 // entire subtree can be skipped if this layer is fully transparent. |
| 227 return !layer->opacity(); | 227 return !layer->opacity(); |
| 228 } | 228 } |
| 229 | 229 |
| 230 static inline bool subtreeShouldBeSkipped(Layer* layer) | 230 static inline bool subtreeShouldBeSkipped(Layer* layer) |
| 231 { | 231 { |
| 232 // If the opacity is being animated then the opacity on the main thread is u
nreliable | 232 // If the opacity is being animated then the opacity on the main thread is u
nreliable |
| 233 // (since the impl thread may be using a different opacity), so it should no
t be trusted. | 233 // (since the impl thread may be using a different opacity), so it should no
t be trusted. |
| 234 // In particular, it should not cause the subtree to be skipped. | 234 // In particular, it should not cause the subtree to be skipped. |
| 235 return !layer->opacity() && !layer->opacityIsAnimating(); | 235 return !layer->opacity() && !layer->OpacityIsAnimating(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 // Called on each layer that could be drawn after all information from | 238 // Called on each layer that could be drawn after all information from |
| 239 // calcDrawProperties has been updated on that layer. May have some false | 239 // calcDrawProperties has been updated on that layer. May have some false |
| 240 // positives (e.g. layers get this called on them but don't actually get drawn). | 240 // positives (e.g. layers get this called on them but don't actually get drawn). |
| 241 static inline void updateTilePrioritiesForLayer(LayerImpl* layer) | 241 static inline void updateTilePrioritiesForLayer(LayerImpl* layer) |
| 242 { | 242 { |
| 243 layer->updateTilePriorities(); | 243 layer->UpdateTilePriorities(); |
| 244 | 244 |
| 245 // Mask layers don't get this call, so explicitly update them so they can | 245 // Mask layers don't get this call, so explicitly update them so they can |
| 246 // kick off tile rasterization. | 246 // kick off tile rasterization. |
| 247 if (layer->maskLayer()) | 247 if (layer->mask_layer()) |
| 248 layer->maskLayer()->updateTilePriorities(); | 248 layer->mask_layer()->UpdateTilePriorities(); |
| 249 if (layer->replicaLayer() && layer->replicaLayer()->maskLayer()) | 249 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) |
| 250 layer->replicaLayer()->maskLayer()->updateTilePriorities(); | 250 layer->replica_layer()->mask_layer()->UpdateTilePriorities(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 static inline void updateTilePrioritiesForLayer(Layer* layer) | 253 static inline void updateTilePrioritiesForLayer(Layer* layer) |
| 254 { | 254 { |
| 255 } | 255 } |
| 256 | 256 |
| 257 template<typename LayerType> | 257 template<typename LayerType> |
| 258 static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlig
nedWithRespectToParent) | 258 static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlig
nedWithRespectToParent) |
| 259 { | 259 { |
| 260 // | 260 // |
| 261 // A layer and its descendants should render onto a new RenderSurfaceImpl if
any of these rules hold: | 261 // A layer and its descendants should render onto a new RenderSurfaceImpl if
any of these rules hold: |
| 262 // | 262 // |
| 263 | 263 |
| 264 // The root layer should always have a renderSurface. | 264 // The root layer should always have a renderSurface. |
| 265 if (isRootLayer(layer)) | 265 if (isRootLayer(layer)) |
| 266 return true; | 266 return true; |
| 267 | 267 |
| 268 // If we force it. | 268 // If we force it. |
| 269 if (layer->forceRenderSurface()) | 269 if (layer->force_render_surface()) |
| 270 return true; | 270 return true; |
| 271 | 271 |
| 272 // If the layer uses a mask. | 272 // If the layer uses a mask. |
| 273 if (layer->maskLayer()) | 273 if (layer->mask_layer()) |
| 274 return true; | 274 return true; |
| 275 | 275 |
| 276 // If the layer has a reflection. | 276 // If the layer has a reflection. |
| 277 if (layer->replicaLayer()) | 277 if (layer->replica_layer()) |
| 278 return true; | 278 return true; |
| 279 | 279 |
| 280 // If the layer uses a CSS filter. | 280 // If the layer uses a CSS filter. |
| 281 if (!layer->filters().isEmpty() || !layer->backgroundFilters().isEmpty() ||
layer->filter()) | 281 if (!layer->filters().isEmpty() || !layer->background_filters().isEmpty() ||
layer->filter()) |
| 282 return true; | 282 return true; |
| 283 | 283 |
| 284 int numDescendantsThatDrawContent = layer->drawProperties().num_descendants_
that_draw_content; | 284 int numDescendantsThatDrawContent = layer->draw_properties().num_descendants
_that_draw_content; |
| 285 | 285 |
| 286 // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), b
ut it is | 286 // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), b
ut it is |
| 287 // treated as a 3D object by its parent (i.e. parent does preserve-3d). | 287 // treated as a 3D object by its parent (i.e. parent does preserve-3d). |
| 288 if (layerIsInExisting3DRenderingContext(layer) && !layer->preserves3D() && n
umDescendantsThatDrawContent > 0) { | 288 if (layerIsInExisting3DRenderingContext(layer) && !layer->preserves_3d() &&
numDescendantsThatDrawContent > 0) { |
| 289 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface flatteni
ng"); | 289 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface flatteni
ng"); |
| 290 return true; | 290 return true; |
| 291 } | 291 } |
| 292 | 292 |
| 293 // If the layer clips its descendants but it is not axis-aligned with respec
t to its parent. | 293 // If the layer clips its descendants but it is not axis-aligned with respec
t to its parent. |
| 294 bool layerClipsExternalContent = layerClipsSubtree(layer) || layer->hasDeleg
atedContent(); | 294 bool layerClipsExternalContent = layerClipsSubtree(layer) || layer->HasDeleg
atedContent(); |
| 295 if (layerClipsExternalContent && !axisAlignedWithRespectToParent && !layer->
drawProperties().descendants_can_clip_selves) | 295 if (layerClipsExternalContent && !axisAlignedWithRespectToParent && !layer->
draw_properties().descendants_can_clip_selves) |
| 296 { | 296 { |
| 297 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface clipping
"); | 297 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface clipping
"); |
| 298 return true; | 298 return true; |
| 299 } | 299 } |
| 300 | 300 |
| 301 // If the layer has some translucency and does not have a preserves-3d trans
form style. | 301 // If the layer has some translucency and does not have a preserves-3d trans
form style. |
| 302 // This condition only needs a render surface if two or more layers in the | 302 // This condition only needs a render surface if two or more layers in the |
| 303 // subtree overlap. But checking layer overlaps is unnecessarily costly so | 303 // subtree overlap. But checking layer overlaps is unnecessarily costly so |
| 304 // instead we conservatively create a surface whenever at least two layers | 304 // instead we conservatively create a surface whenever at least two layers |
| 305 // draw content for this subtree. | 305 // draw content for this subtree. |
| 306 bool atLeastTwoLayersInSubtreeDrawContent = numDescendantsThatDrawContent >
0 && (layer->drawsContent() || numDescendantsThatDrawContent > 1); | 306 bool atLeastTwoLayersInSubtreeDrawContent = numDescendantsThatDrawContent >
0 && (layer->DrawsContent() || numDescendantsThatDrawContent > 1); |
| 307 | 307 |
| 308 if (layer->opacity() != 1 && !layer->preserves3D() && atLeastTwoLayersInSubt
reeDrawContent) { | 308 if (layer->opacity() != 1.f && !layer->preserves_3d() && atLeastTwoLayersInS
ubtreeDrawContent) { |
| 309 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface opacity"
); | 309 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface opacity"
); |
| 310 return true; | 310 return true; |
| 311 } | 311 } |
| 312 | 312 |
| 313 return false; | 313 return false; |
| 314 } | 314 } |
| 315 | 315 |
| 316 gfx::Transform computeScrollCompensationForThisLayer(LayerImpl* scrollingLayer,
const gfx::Transform& parentMatrix) | 316 gfx::Transform computeScrollCompensationForThisLayer(LayerImpl* scrollingLayer,
const gfx::Transform& parentMatrix) |
| 317 { | 317 { |
| 318 // For every layer that has non-zero scrollDelta, we have to compute a trans
form that can undo the | 318 // For every layer that has non-zero scrollDelta, we have to compute a trans
form that can undo the |
| 319 // scrollDelta translation. In particular, we want this matrix to premultipl
y a fixed-position layer's | 319 // scrollDelta translation. In particular, we want this matrix to premultipl
y a fixed-position layer's |
| 320 // parentMatrix, so we design this transform in three steps as follows. The
steps described here apply | 320 // parentMatrix, so we design this transform in three steps as follows. The
steps described here apply |
| 321 // from right-to-left, so Step 1 would be the right-most matrix: | 321 // from right-to-left, so Step 1 would be the right-most matrix: |
| 322 // | 322 // |
| 323 // Step 1. transform from target surface space to the exact space where
scrollDelta is actually applied. | 323 // Step 1. transform from target surface space to the exact space where
scrollDelta is actually applied. |
| 324 // -- this is inverse of the matrix in step 3 | 324 // -- this is inverse of the matrix in step 3 |
| 325 // Step 2. undo the scrollDelta | 325 // Step 2. undo the scrollDelta |
| 326 // -- this is just a translation by scrollDelta. | 326 // -- this is just a translation by scrollDelta. |
| 327 // Step 3. transform back to target surface space. | 327 // Step 3. transform back to target surface space. |
| 328 // -- this transform is the "partialLayerOriginTransform" = (paren
tMatrix * scale(layer->pageScaleDelta())); | 328 // -- this transform is the "partialLayerOriginTransform" = (paren
tMatrix * scale(layer->pageScaleDelta())); |
| 329 // | 329 // |
| 330 // These steps create a matrix that both start and end in targetSurfaceSpace
. So this matrix can | 330 // These steps create a matrix that both start and end in targetSurfaceSpace
. So this matrix can |
| 331 // pre-multiply any fixed-position layer's drawTransform to undo the scrollD
eltas -- as long as | 331 // pre-multiply any fixed-position layer's drawTransform to undo the scrollD
eltas -- as long as |
| 332 // that fixed position layer is fixed onto the same renderTarget as this scr
ollingLayer. | 332 // that fixed position layer is fixed onto the same renderTarget as this scr
ollingLayer. |
| 333 // | 333 // |
| 334 | 334 |
| 335 gfx::Transform partialLayerOriginTransform = parentMatrix; | 335 gfx::Transform partialLayerOriginTransform = parentMatrix; |
| 336 partialLayerOriginTransform.PreconcatTransform(scrollingLayer->implTransform
()); | 336 partialLayerOriginTransform.PreconcatTransform(scrollingLayer->impl_transfor
m()); |
| 337 | 337 |
| 338 gfx::Transform scrollCompensationForThisLayer = partialLayerOriginTransform;
// Step 3 | 338 gfx::Transform scrollCompensationForThisLayer = partialLayerOriginTransform;
// Step 3 |
| 339 scrollCompensationForThisLayer.Translate(scrollingLayer->scrollDelta().x(),
scrollingLayer->scrollDelta().y()); // Step 2 | 339 scrollCompensationForThisLayer.Translate(scrollingLayer->scroll_delta().x(),
scrollingLayer->scroll_delta().y()); // Step 2 |
| 340 | 340 |
| 341 gfx::Transform inversePartialLayerOriginTransform(gfx::Transform::kSkipIniti
alization); | 341 gfx::Transform inversePartialLayerOriginTransform(gfx::Transform::kSkipIniti
alization); |
| 342 if (!partialLayerOriginTransform.GetInverse(&inversePartialLayerOriginTransf
orm)) { | 342 if (!partialLayerOriginTransform.GetInverse(&inversePartialLayerOriginTransf
orm)) { |
| 343 // TODO(shawnsingh): Either we need to handle uninvertible transforms | 343 // TODO(shawnsingh): Either we need to handle uninvertible transforms |
| 344 // here, or DCHECK that the transform is invertible. | 344 // here, or DCHECK that the transform is invertible. |
| 345 } | 345 } |
| 346 scrollCompensationForThisLayer.PreconcatTransform(inversePartialLayerOriginT
ransform); // Step 1 | 346 scrollCompensationForThisLayer.PreconcatTransform(inversePartialLayerOriginT
ransform); // Step 1 |
| 347 return scrollCompensationForThisLayer; | 347 return scrollCompensationForThisLayer; |
| 348 } | 348 } |
| 349 | 349 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 366 // without a renderSurface, the renderSurface is irrelevant in that case. | 366 // without a renderSurface, the renderSurface is irrelevant in that case. |
| 367 // - A layer that does not have an explicit container is simply fixed to th
e viewport. | 367 // - A layer that does not have an explicit container is simply fixed to th
e viewport. |
| 368 // (i.e. the root renderSurface.) | 368 // (i.e. the root renderSurface.) |
| 369 // - If the fixed-position layer has its own renderSurface, then the render
Surface is | 369 // - If the fixed-position layer has its own renderSurface, then the render
Surface is |
| 370 // the one who gets fixed. | 370 // the one who gets fixed. |
| 371 // | 371 // |
| 372 // This function needs to be called AFTER layers create their own renderSurf
aces. | 372 // This function needs to be called AFTER layers create their own renderSurf
aces. |
| 373 // | 373 // |
| 374 | 374 |
| 375 // Avoid the overheads (including stack allocation and matrix initialization
/copy) if we know that the scroll compensation doesn't need to be reset or adjus
ted. | 375 // Avoid the overheads (including stack allocation and matrix initialization
/copy) if we know that the scroll compensation doesn't need to be reset or adjus
ted. |
| 376 if (!layer->isContainerForFixedPositionLayers() && layer->scrollDelta().IsZe
ro() && !layer->renderSurface()) | 376 if (!layer->is_container_for_fixed_position_layers() && layer->scroll_delta(
).IsZero() && !layer->render_surface()) |
| 377 return currentScrollCompensationMatrix; | 377 return currentScrollCompensationMatrix; |
| 378 | 378 |
| 379 // Start as identity matrix. | 379 // Start as identity matrix. |
| 380 gfx::Transform nextScrollCompensationMatrix; | 380 gfx::Transform nextScrollCompensationMatrix; |
| 381 | 381 |
| 382 // If this layer is not a container, then it inherits the existing scroll co
mpensations. | 382 // If this layer is not a container, then it inherits the existing scroll co
mpensations. |
| 383 if (!layer->isContainerForFixedPositionLayers()) | 383 if (!layer->is_container_for_fixed_position_layers()) |
| 384 nextScrollCompensationMatrix = currentScrollCompensationMatrix; | 384 nextScrollCompensationMatrix = currentScrollCompensationMatrix; |
| 385 | 385 |
| 386 // If the current layer has a non-zero scrollDelta, then we should compute i
ts local scrollCompensation | 386 // If the current layer has a non-zero scrollDelta, then we should compute i
ts local scrollCompensation |
| 387 // and accumulate it to the nextScrollCompensationMatrix. | 387 // and accumulate it to the nextScrollCompensationMatrix. |
| 388 if (!layer->scrollDelta().IsZero()) { | 388 if (!layer->scroll_delta().IsZero()) { |
| 389 gfx::Transform scrollCompensationForThisLayer = computeScrollCompensatio
nForThisLayer(layer, parentMatrix); | 389 gfx::Transform scrollCompensationForThisLayer = computeScrollCompensatio
nForThisLayer(layer, parentMatrix); |
| 390 nextScrollCompensationMatrix.PreconcatTransform(scrollCompensationForThi
sLayer); | 390 nextScrollCompensationMatrix.PreconcatTransform(scrollCompensationForThi
sLayer); |
| 391 } | 391 } |
| 392 | 392 |
| 393 // If the layer created its own renderSurface, we have to adjust nextScrollC
ompensationMatrix. | 393 // If the layer created its own renderSurface, we have to adjust nextScrollC
ompensationMatrix. |
| 394 // The adjustment allows us to continue using the scrollCompensation on the
next surface. | 394 // The adjustment allows us to continue using the scrollCompensation on the
next surface. |
| 395 // Step 1 (right-most in the math): transform from the new surface to the o
riginal ancestor surface | 395 // Step 1 (right-most in the math): transform from the new surface to the o
riginal ancestor surface |
| 396 // Step 2: apply the scroll compensation | 396 // Step 2: apply the scroll compensation |
| 397 // Step 3: transform back to the new surface. | 397 // Step 3: transform back to the new surface. |
| 398 if (layer->renderSurface() && !nextScrollCompensationMatrix.IsIdentity()) { | 398 if (layer->render_surface() && !nextScrollCompensationMatrix.IsIdentity()) { |
| 399 gfx::Transform inverseSurfaceDrawTransform(gfx::Transform::kSkipInitiali
zation); | 399 gfx::Transform inverseSurfaceDrawTransform(gfx::Transform::kSkipInitiali
zation); |
| 400 if (!layer->renderSurface()->draw_transform().GetInverse(&inverseSurface
DrawTransform)) { | 400 if (!layer->render_surface()->draw_transform().GetInverse(&inverseSurfac
eDrawTransform)) { |
| 401 // TODO(shawnsingh): Either we need to handle uninvertible transform
s | 401 // TODO(shawnsingh): Either we need to handle uninvertible transform
s |
| 402 // here, or DCHECK that the transform is invertible. | 402 // here, or DCHECK that the transform is invertible. |
| 403 } | 403 } |
| 404 nextScrollCompensationMatrix = inverseSurfaceDrawTransform * nextScrollC
ompensationMatrix * layer->renderSurface()->draw_transform(); | 404 nextScrollCompensationMatrix = inverseSurfaceDrawTransform * nextScrollC
ompensationMatrix * layer->render_surface()->draw_transform(); |
| 405 } | 405 } |
| 406 | 406 |
| 407 return nextScrollCompensationMatrix; | 407 return nextScrollCompensationMatrix; |
| 408 } | 408 } |
| 409 | 409 |
| 410 template<typename LayerType> | 410 template<typename LayerType> |
| 411 static inline void calculateContentsScale(LayerType* layer, float contentsScale,
bool animatingTransformToScreen) | 411 static inline void CalculateContentsScale(LayerType* layer, float contentsScale,
bool animating_transform_to_screen) |
| 412 { | 412 { |
| 413 layer->calculateContentsScale( | 413 layer->CalculateContentsScale( |
| 414 contentsScale, | 414 contentsScale, |
| 415 animatingTransformToScreen, | 415 animating_transform_to_screen, |
| 416 &layer->drawProperties().contents_scale_x, | 416 &layer->draw_properties().contents_scale_x, |
| 417 &layer->drawProperties().contents_scale_y, | 417 &layer->draw_properties().contents_scale_y, |
| 418 &layer->drawProperties().content_bounds); | 418 &layer->draw_properties().content_bounds); |
| 419 | 419 |
| 420 LayerType* maskLayer = layer->maskLayer(); | 420 LayerType* maskLayer = layer->mask_layer(); |
| 421 if (maskLayer) | 421 if (maskLayer) |
| 422 { | 422 { |
| 423 maskLayer->calculateContentsScale( | 423 maskLayer->CalculateContentsScale( |
| 424 contentsScale, | 424 contentsScale, |
| 425 animatingTransformToScreen, | 425 animating_transform_to_screen, |
| 426 &maskLayer->drawProperties().contents_scale_x, | 426 &maskLayer->draw_properties().contents_scale_x, |
| 427 &maskLayer->drawProperties().contents_scale_y, | 427 &maskLayer->draw_properties().contents_scale_y, |
| 428 &maskLayer->drawProperties().content_bounds); | 428 &maskLayer->draw_properties().content_bounds); |
| 429 } | 429 } |
| 430 | 430 |
| 431 LayerType* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLayer()-
>maskLayer() : 0; | 431 LayerType* replicaMaskLayer = layer->replica_layer() ? layer->replica_layer(
)->mask_layer() : 0; |
| 432 if (replicaMaskLayer) | 432 if (replicaMaskLayer) |
| 433 { | 433 { |
| 434 replicaMaskLayer->calculateContentsScale( | 434 replicaMaskLayer->CalculateContentsScale( |
| 435 contentsScale, | 435 contentsScale, |
| 436 animatingTransformToScreen, | 436 animating_transform_to_screen, |
| 437 &replicaMaskLayer->drawProperties().contents_scale_x, | 437 &replicaMaskLayer->draw_properties().contents_scale_x, |
| 438 &replicaMaskLayer->drawProperties().contents_scale_y, | 438 &replicaMaskLayer->draw_properties().contents_scale_y, |
| 439 &replicaMaskLayer->drawProperties().content_bounds); | 439 &replicaMaskLayer->draw_properties().content_bounds); |
| 440 } | 440 } |
| 441 } | 441 } |
| 442 | 442 |
| 443 static inline void updateLayerContentsScale(LayerImpl* layer, const gfx::Transfo
rm& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool anim
atingTransformToScreen) | 443 static inline void updateLayerContentsScale(LayerImpl* layer, const gfx::Transfo
rm& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool anim
ating_transform_to_screen) |
| 444 { | 444 { |
| 445 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleComponents(
combinedTransform, deviceScaleFactor * pageScaleFactor); | 445 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleComponents(
combinedTransform, deviceScaleFactor * pageScaleFactor); |
| 446 float contentsScale = std::max(transformScale.x(), transformScale.y()); | 446 float contentsScale = std::max(transformScale.x(), transformScale.y()); |
| 447 calculateContentsScale(layer, contentsScale, animatingTransformToScreen); | 447 CalculateContentsScale(layer, contentsScale, animating_transform_to_screen); |
| 448 } | 448 } |
| 449 | 449 |
| 450 static inline void updateLayerContentsScale(Layer* layer, const gfx::Transform&
combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animatin
gTransformToScreen) | 450 static inline void updateLayerContentsScale(Layer* layer, const gfx::Transform&
combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animatin
g_transform_to_screen) |
| 451 { | 451 { |
| 452 float rasterScale = layer->rasterScale(); | 452 float rasterScale = layer->raster_scale(); |
| 453 | 453 |
| 454 if (layer->automaticallyComputeRasterScale()) { | 454 if (layer->automatically_compute_raster_scale()) { |
| 455 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleCompone
nts(combinedTransform, 0.f); | 455 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleCompone
nts(combinedTransform, 0.f); |
| 456 float combinedScale = std::max(transformScale.x(), transformScale.y()); | 456 float combinedScale = std::max(transformScale.x(), transformScale.y()); |
| 457 float idealRasterScale = combinedScale / deviceScaleFactor; | 457 float idealRasterScale = combinedScale / deviceScaleFactor; |
| 458 if (!layer->boundsContainPageScale()) | 458 if (!layer->bounds_contain_page_scale()) |
| 459 idealRasterScale /= pageScaleFactor; | 459 idealRasterScale /= pageScaleFactor; |
| 460 | 460 |
| 461 bool needToSetRasterScale = !rasterScale; | 461 bool needToSetRasterScale = !rasterScale; |
| 462 | 462 |
| 463 // If we've previously saved a rasterScale but the ideal changes, things
are unpredictable and we should just use 1. | 463 // If we've previously saved a rasterScale but the ideal changes, things
are unpredictable and we should just use 1. |
| 464 if (rasterScale && rasterScale != 1.f && idealRasterScale != rasterScale
) { | 464 if (rasterScale && rasterScale != 1.f && idealRasterScale != rasterScale
) { |
| 465 idealRasterScale = 1.f; | 465 idealRasterScale = 1.f; |
| 466 needToSetRasterScale = true; | 466 needToSetRasterScale = true; |
| 467 } | 467 } |
| 468 | 468 |
| 469 if (needToSetRasterScale) { | 469 if (needToSetRasterScale) { |
| 470 bool useAndSaveIdealScale = idealRasterScale >= 1.f && !animatingTra
nsformToScreen; | 470 bool useAndSaveIdealScale = idealRasterScale >= 1.f && !animating_tr
ansform_to_screen; |
| 471 if (useAndSaveIdealScale) { | 471 if (useAndSaveIdealScale) { |
| 472 rasterScale = idealRasterScale; | 472 rasterScale = idealRasterScale; |
| 473 layer->setRasterScale(rasterScale); | 473 layer->SetRasterScale(rasterScale); |
| 474 } | 474 } |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 | 477 |
| 478 if (!rasterScale) | 478 if (!rasterScale) |
| 479 rasterScale = 1.f; | 479 rasterScale = 1.f; |
| 480 | 480 |
| 481 float contentsScale = rasterScale * deviceScaleFactor; | 481 float contentsScale = rasterScale * deviceScaleFactor; |
| 482 if (!layer->boundsContainPageScale()) | 482 if (!layer->bounds_contain_page_scale()) |
| 483 contentsScale *= pageScaleFactor; | 483 contentsScale *= pageScaleFactor; |
| 484 | 484 |
| 485 calculateContentsScale(layer, contentsScale, animatingTransformToScreen); | 485 CalculateContentsScale(layer, contentsScale, animating_transform_to_screen); |
| 486 } | 486 } |
| 487 | 487 |
| 488 template<typename LayerType, typename LayerList> | 488 template<typename LayerType, typename LayerList> |
| 489 static inline void removeSurfaceForEarlyExit(LayerType* layerToRemove, LayerList
& renderSurfaceLayerList) | 489 static inline void removeSurfaceForEarlyExit(LayerType* layerToRemove, LayerList
& renderSurfaceLayerList) |
| 490 { | 490 { |
| 491 DCHECK(layerToRemove->renderSurface()); | 491 DCHECK(layerToRemove->render_surface()); |
| 492 // Technically, we know that the layer we want to remove should be | 492 // Technically, we know that the layer we want to remove should be |
| 493 // at the back of the renderSurfaceLayerList. However, we have had | 493 // at the back of the renderSurfaceLayerList. However, we have had |
| 494 // bugs before that added unnecessary layers here | 494 // bugs before that added unnecessary layers here |
| 495 // (https://bugs.webkit.org/show_bug.cgi?id=74147), but that causes | 495 // (https://bugs.webkit.org/show_bug.cgi?id=74147), but that causes |
| 496 // things to crash. So here we proactively remove any additional | 496 // things to crash. So here we proactively remove any additional |
| 497 // layers from the end of the list. | 497 // layers from the end of the list. |
| 498 while (renderSurfaceLayerList.back() != layerToRemove) { | 498 while (renderSurfaceLayerList.back() != layerToRemove) { |
| 499 renderSurfaceLayerList.back()->clearRenderSurface(); | 499 renderSurfaceLayerList.back()->ClearRenderSurface(); |
| 500 renderSurfaceLayerList.pop_back(); | 500 renderSurfaceLayerList.pop_back(); |
| 501 } | 501 } |
| 502 DCHECK(renderSurfaceLayerList.back() == layerToRemove); | 502 DCHECK(renderSurfaceLayerList.back() == layerToRemove); |
| 503 renderSurfaceLayerList.pop_back(); | 503 renderSurfaceLayerList.pop_back(); |
| 504 layerToRemove->clearRenderSurface(); | 504 layerToRemove->ClearRenderSurface(); |
| 505 } | 505 } |
| 506 | 506 |
| 507 // Recursively walks the layer tree to compute any information that is needed | 507 // Recursively walks the layer tree to compute any information that is needed |
| 508 // before doing the main recursion. | 508 // before doing the main recursion. |
| 509 template<typename LayerType> | 509 template<typename LayerType> |
| 510 static void preCalculateMetaInformation(LayerType* layer) | 510 static void preCalculateMetaInformation(LayerType* layer) |
| 511 { | 511 { |
| 512 if (layer->hasDelegatedContent()) { | 512 if (layer->HasDelegatedContent()) { |
| 513 // Layers with delegated content need to be treated as if they have as m
any children as the number | 513 // Layers with delegated content need to be treated as if they have as m
any children as the number |
| 514 // of layers they own delegated quads for. Since we don't know this numb
er right now, we choose | 514 // of layers they own delegated quads for. Since we don't know this numb
er right now, we choose |
| 515 // one that acts like infinity for our purposes. | 515 // one that acts like infinity for our purposes. |
| 516 layer->drawProperties().num_descendants_that_draw_content = 1000; | 516 layer->draw_properties().num_descendants_that_draw_content = 1000; |
| 517 layer->drawProperties().descendants_can_clip_selves = false; | 517 layer->draw_properties().descendants_can_clip_selves = false; |
| 518 return; | 518 return; |
| 519 } | 519 } |
| 520 | 520 |
| 521 int numDescendantsThatDrawContent = 0; | 521 int numDescendantsThatDrawContent = 0; |
| 522 bool descendantsCanClipSelves = true; | 522 bool descendantsCanClipSelves = true; |
| 523 bool sublayerTransformPreventsClip = !layer->sublayerTransform().IsPositiveS
caleOrTranslation(); | 523 bool sublayerTransformPreventsClip = !layer->sublayer_transform().IsPositive
ScaleOrTranslation(); |
| 524 | 524 |
| 525 for (size_t i = 0; i < layer->children().size(); ++i) { | 525 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 526 LayerType* childLayer = layer->children()[i]; | 526 LayerType* childLayer = layer->children()[i]; |
| 527 preCalculateMetaInformation<LayerType>(childLayer); | 527 preCalculateMetaInformation<LayerType>(childLayer); |
| 528 | 528 |
| 529 numDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0; | 529 numDescendantsThatDrawContent += childLayer->DrawsContent() ? 1 : 0; |
| 530 numDescendantsThatDrawContent += childLayer->drawProperties().num_descen
dants_that_draw_content; | 530 numDescendantsThatDrawContent += childLayer->draw_properties().num_desce
ndants_that_draw_content; |
| 531 | 531 |
| 532 if ((childLayer->drawsContent() && !childLayer->canClipSelf()) || | 532 if ((childLayer->DrawsContent() && !childLayer->CanClipSelf()) || |
| 533 !childLayer->drawProperties().descendants_can_clip_selves || | 533 !childLayer->draw_properties().descendants_can_clip_selves || |
| 534 sublayerTransformPreventsClip || | 534 sublayerTransformPreventsClip || |
| 535 !childLayer->transform().IsPositiveScaleOrTranslation()) | 535 !childLayer->transform().IsPositiveScaleOrTranslation()) |
| 536 descendantsCanClipSelves = false; | 536 descendantsCanClipSelves = false; |
| 537 } | 537 } |
| 538 | 538 |
| 539 layer->drawProperties().num_descendants_that_draw_content = numDescendantsTh
atDrawContent; | 539 layer->draw_properties().num_descendants_that_draw_content = numDescendantsT
hatDrawContent; |
| 540 layer->drawProperties().descendants_can_clip_selves = descendantsCanClipSelv
es; | 540 layer->draw_properties().descendants_can_clip_selves = descendantsCanClipSel
ves; |
| 541 } | 541 } |
| 542 | 542 |
| 543 static void roundTranslationComponents(gfx::Transform* transform) | 543 static void roundTranslationComponents(gfx::Transform* transform) |
| 544 { | 544 { |
| 545 transform->matrix().setDouble(0, 3, MathUtil::Round(transform->matrix().getD
ouble(0, 3))); | 545 transform->matrix().setDouble(0, 3, MathUtil::Round(transform->matrix().getD
ouble(0, 3))); |
| 546 transform->matrix().setDouble(1, 3, MathUtil::Round(transform->matrix().getD
ouble(1, 3))); | 546 transform->matrix().setDouble(1, 3, MathUtil::Round(transform->matrix().getD
ouble(1, 3))); |
| 547 } | 547 } |
| 548 | 548 |
| 549 // Recursively walks the layer tree starting at the given node and computes all
the | 549 // Recursively walks the layer tree starting at the given node and computes all
the |
| 550 // necessary transformations, clipRects, render surfaces, etc. | 550 // necessary transformations, clipRects, render surfaces, etc. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 573 // of the layer map to [bounds.width(), bounds.height()]. | 573 // of the layer map to [bounds.width(), bounds.height()]. |
| 574 // | 574 // |
| 575 // 3. Definition of various transforms used: | 575 // 3. Definition of various transforms used: |
| 576 // M[parent] is the parent matrix, with respect to the nearest render
surface, passed down recursively. | 576 // M[parent] is the parent matrix, with respect to the nearest render
surface, passed down recursively. |
| 577 // M[root] is the full hierarchy, with respect to the root, passed do
wn recursively. | 577 // M[root] is the full hierarchy, with respect to the root, passed do
wn recursively. |
| 578 // Tr[origin] is the translation matrix from the parent's origin to t
his layer's origin. | 578 // Tr[origin] is the translation matrix from the parent's origin to t
his layer's origin. |
| 579 // Tr[origin2anchor] is the translation from the layer's origin to it
s anchor point | 579 // Tr[origin2anchor] is the translation from the layer's origin to it
s anchor point |
| 580 // Tr[origin2center] is the translation from the layer's origin to it
s center | 580 // Tr[origin2center] is the translation from the layer's origin to it
s center |
| 581 // M[layer] is the layer's matrix (applied at the anchor point) | 581 // M[layer] is the layer's matrix (applied at the anchor point) |
| 582 // M[sublayer] is the layer's sublayer transform (also applied at the
layer's anchor point) | 582 // M[sublayer] is the layer's sublayer transform (also applied at the
layer's anchor point) |
| 583 // S[layer2content] is the ratio of a layer's contentBounds() to its
bounds(). | 583 // S[layer2content] is the ratio of a layer's ContentBounds() to its
Bounds(). |
| 584 // | 584 // |
| 585 // Some composite transforms can help in understanding the sequence of tr
ansforms: | 585 // Some composite transforms can help in understanding the sequence of tr
ansforms: |
| 586 // compositeLayerTransform = Tr[origin2anchor] * M[layer] * Tr[origin
2anchor].inverse() | 586 // compositeLayerTransform = Tr[origin2anchor] * M[layer] * Tr[origin
2anchor].inverse() |
| 587 // compositeSublayerTransform = Tr[origin2anchor] * M[sublayer] * Tr[
origin2anchor].inverse() | 587 // compositeSublayerTransform = Tr[origin2anchor] * M[sublayer] * Tr[
origin2anchor].inverse() |
| 588 // | 588 // |
| 589 // 4. When a layer (or render surface) is drawn, it is drawn into a "target
render surface". Therefore the draw | 589 // 4. When a layer (or render surface) is drawn, it is drawn into a "target
render surface". Therefore the draw |
| 590 // transform does not necessarily transform from screen space to local la
yer space. Instead, the draw transform | 590 // transform does not necessarily transform from screen space to local la
yer space. Instead, the draw transform |
| 591 // is the transform between the "target render surface space" and local l
ayer space. Note that render surfaces, | 591 // is the transform between the "target render surface space" and local l
ayer space. Note that render surfaces, |
| 592 // except for the root, also draw themselves into a different target rend
er surface, and so their draw | 592 // except for the root, also draw themselves into a different target rend
er surface, and so their draw |
| 593 // transform and origin transforms are also described with respect to the
target. | 593 // transform and origin transforms are also described with respect to the
target. |
| 594 // | 594 // |
| 595 // Using these definitions, then: | 595 // Using these definitions, then: |
| 596 // | 596 // |
| 597 // The draw transform for the layer is: | 597 // The draw transform for the layer is: |
| 598 // M[draw] = M[parent] * Tr[origin] * compositeLayerTransform * S[lay
er2content] | 598 // M[draw] = M[parent] * Tr[origin] * compositeLayerTransform * S[lay
er2content] |
| 599 // = M[parent] * Tr[layer->position() + anchor] * M[layer] *
Tr[anchor2origin] * S[layer2content] | 599 // = M[parent] * Tr[layer->Position() + anchor] * M[layer] *
Tr[anchor2origin] * S[layer2content] |
| 600 // | 600 // |
| 601 // Interpreting the math left-to-right, this transforms from the laye
r's render surface to the origin of the layer in content space. | 601 // Interpreting the math left-to-right, this transforms from the laye
r's render surface to the origin of the layer in content space. |
| 602 // | 602 // |
| 603 // The screen space transform is: | 603 // The screen space transform is: |
| 604 // M[screenspace] = M[root] * Tr[origin] * compositeLayerTransform *
S[layer2content] | 604 // M[screenspace] = M[root] * Tr[origin] * compositeLayerTransform *
S[layer2content] |
| 605 // = M[root] * Tr[layer->position() + anchor] * M[laye
r] * Tr[anchor2origin] * S[layer2content] | 605 // = M[root] * Tr[layer->Position() + anchor] * M[laye
r] * Tr[anchor2origin] * S[layer2content] |
| 606 // | 606 // |
| 607 // Interpreting the math left-to-right, this transforms from the root
render surface's content space to the origin of the layer in content space. | 607 // Interpreting the math left-to-right, this transforms from the root
render surface's content space to the origin of the layer in content space. |
| 608 // | 608 // |
| 609 // The transform hierarchy that is passed on to children (i.e. the child's p
arentMatrix) is: | 609 // The transform hierarchy that is passed on to children (i.e. the child's p
arentMatrix) is: |
| 610 // M[parent]_for_child = M[parent] * Tr[origin] * compositeLayerTrans
form * compositeSublayerTransform | 610 // M[parent]_for_child = M[parent] * Tr[origin] * compositeLayerTrans
form * compositeSublayerTransform |
| 611 // = M[parent] * Tr[layer->position() + anchor] *
M[layer] * Tr[anchor2origin] * compositeSublayerTransform | 611 // = M[parent] * Tr[layer->Position() + anchor] *
M[layer] * Tr[anchor2origin] * compositeSublayerTransform |
| 612 // | 612 // |
| 613 // and a similar matrix for the full hierarchy with respect to the ro
ot. | 613 // and a similar matrix for the full hierarchy with respect to the ro
ot. |
| 614 // | 614 // |
| 615 // Finally, note that the final matrix used by the shader for the layer is P
* M[draw] * S . This final product | 615 // Finally, note that the final matrix used by the shader for the layer is P
* M[draw] * S . This final product |
| 616 // is computed in drawTexturedQuad(), where: | 616 // is computed in drawTexturedQuad(), where: |
| 617 // P is the projection matrix | 617 // P is the projection matrix |
| 618 // S is the scale adjustment (to scale up a canonical quad to the lay
er's size) | 618 // S is the scale adjustment (to scale up a canonical quad to the lay
er's size) |
| 619 // | 619 // |
| 620 // When a render surface has a replica layer, that layer's transform is used
to draw a second copy of the surface. | 620 // When a render surface has a replica layer, that layer's transform is used
to draw a second copy of the surface. |
| 621 // gfx::Transforms named here are relative to the surface, unless they speci
fy they are relative to the replica layer. | 621 // gfx::Transforms named here are relative to the surface, unless they speci
fy they are relative to the replica layer. |
| 622 // | 622 // |
| 623 // We will denote a scale by device scale S[deviceScale] | 623 // We will denote a scale by device scale S[deviceScale] |
| 624 // | 624 // |
| 625 // The render surface draw transform to its target surface origin is: | 625 // The render surface draw transform to its target surface origin is: |
| 626 // M[surfaceDraw] = M[owningLayer->Draw] | 626 // M[surfaceDraw] = M[owningLayer->Draw] |
| 627 // | 627 // |
| 628 // The render surface origin transform to its the root (screen space) origin
is: | 628 // The render surface origin transform to its the root (screen space) origin
is: |
| 629 // M[surface2root] = M[owningLayer->screenspace] * S[deviceScale].in
verse() | 629 // M[surface2root] = M[owningLayer->screenspace] * S[deviceScale].in
verse() |
| 630 // | 630 // |
| 631 // The replica draw transform to its target surface origin is: | 631 // The replica draw transform to its target surface origin is: |
| 632 // M[replicaDraw] = S[deviceScale] * M[surfaceDraw] * Tr[replica->pos
ition() + replica->anchor()] * Tr[replica] * Tr[origin2anchor].inverse() * S[con
tentsScale].inverse() | 632 // M[replicaDraw] = S[deviceScale] * M[surfaceDraw] * Tr[replica->Pos
ition() + replica->anchor()] * Tr[replica] * Tr[origin2anchor].inverse() * S[con
tentsScale].inverse() |
| 633 // | 633 // |
| 634 // The replica draw transform to the root (screen space) origin is: | 634 // The replica draw transform to the root (screen space) origin is: |
| 635 // M[replica2root] = M[surface2root] * Tr[replica->position()] * Tr[r
eplica] * Tr[origin2anchor].inverse() | 635 // M[replica2root] = M[surface2root] * Tr[replica->Position()] * Tr[r
eplica] * Tr[origin2anchor].inverse() |
| 636 // | 636 // |
| 637 | 637 |
| 638 // If we early-exit anywhere in this function, the drawableContentRect of th
is subtree should be considered empty. | 638 // If we early-exit anywhere in this function, the drawableContentRect of th
is subtree should be considered empty. |
| 639 drawableContentRectOfSubtree = gfx::Rect(); | 639 drawableContentRectOfSubtree = gfx::Rect(); |
| 640 | 640 |
| 641 // The root layer cannot skip calcDrawProperties. | 641 // The root layer cannot skip calcDrawProperties. |
| 642 if (!isRootLayer(layer) && subtreeShouldBeSkipped(layer)) | 642 if (!isRootLayer(layer) && subtreeShouldBeSkipped(layer)) |
| 643 return; | 643 return; |
| 644 | 644 |
| 645 // As this function proceeds, these are the properties for the current | 645 // As this function proceeds, these are the properties for the current |
| 646 // layer that actually get computed. To avoid unnecessary copies | 646 // layer that actually get computed. To avoid unnecessary copies |
| 647 // (particularly for matrices), we do computations directly on these values | 647 // (particularly for matrices), we do computations directly on these values |
| 648 // when possible. | 648 // when possible. |
| 649 DrawProperties<LayerType, RenderSurfaceType>& layerDrawProperties = layer->d
rawProperties(); | 649 DrawProperties<LayerType, RenderSurfaceType>& layerDrawProperties = layer->d
raw_properties(); |
| 650 | 650 |
| 651 gfx::Rect clipRectForSubtree; | 651 gfx::Rect clipRectForSubtree; |
| 652 bool subtreeShouldBeClipped = false; | 652 bool subtreeShouldBeClipped = false; |
| 653 | 653 |
| 654 // This value is cached on the stack so that we don't have to inverse-projec
t | 654 // This value is cached on the stack so that we don't have to inverse-projec
t |
| 655 // the surface's clipRect redundantly for every layer. This value is the | 655 // the surface's clipRect redundantly for every layer. This value is the |
| 656 // same as the surface's clipRect, except that instead of being described | 656 // same as the surface's clipRect, except that instead of being described |
| 657 // in the target surface space (i.e. the ancestor surface space), it is | 657 // in the target surface space (i.e. the ancestor surface space), it is |
| 658 // described in the current surface space. | 658 // described in the current surface space. |
| 659 gfx::Rect clipRectForSubtreeInDescendantSpace; | 659 gfx::Rect clipRectForSubtreeInDescendantSpace; |
| 660 | 660 |
| 661 float accumulatedDrawOpacity = layer->opacity(); | 661 float accumulatedDrawOpacity = layer->opacity(); |
| 662 bool animatingOpacityToTarget = layer->opacityIsAnimating(); | 662 bool animatingOpacityToTarget = layer->OpacityIsAnimating(); |
| 663 bool animatingOpacityToScreen = animatingOpacityToTarget; | 663 bool animatingOpacityToScreen = animatingOpacityToTarget; |
| 664 if (layer->parent()) { | 664 if (layer->parent()) { |
| 665 accumulatedDrawOpacity *= layer->parent()->drawOpacity(); | 665 accumulatedDrawOpacity *= layer->parent()->draw_opacity(); |
| 666 animatingOpacityToTarget |= layer->parent()->drawOpacityIsAnimating(); | 666 animatingOpacityToTarget |= layer->parent()->draw_opacity_is_animating()
; |
| 667 animatingOpacityToScreen |= layer->parent()->screenSpaceOpacityIsAnimati
ng(); | 667 animatingOpacityToScreen |= layer->parent()->screen_space_opacity_is_ani
mating(); |
| 668 } | 668 } |
| 669 | 669 |
| 670 bool animatingTransformToTarget = layer->transformIsAnimating(); | 670 bool animatingTransformToTarget = layer->TransformIsAnimating(); |
| 671 bool animatingTransformToScreen = animatingTransformToTarget; | 671 bool animating_transform_to_screen = animatingTransformToTarget; |
| 672 if (layer->parent()) { | 672 if (layer->parent()) { |
| 673 animatingTransformToTarget |= layer->parent()->drawTransformIsAnimating(
); | 673 animatingTransformToTarget |= layer->parent()->draw_transform_is_animati
ng(); |
| 674 animatingTransformToScreen |= layer->parent()->screenSpaceTransformIsAni
mating(); | 674 animating_transform_to_screen |= layer->parent()->screen_space_transform
_is_animating(); |
| 675 } | 675 } |
| 676 | 676 |
| 677 gfx::Size bounds = layer->bounds(); | 677 gfx::Size bounds = layer->bounds(); |
| 678 gfx::PointF anchorPoint = layer->anchorPoint(); | 678 gfx::PointF anchorPoint = layer->anchor_point(); |
| 679 gfx::PointF position = layer->position() - layer->scrollDelta(); | 679 gfx::PointF position = layer->position() - layer->scroll_delta(); |
| 680 | 680 |
| 681 gfx::Transform combinedTransform = parentMatrix; | 681 gfx::Transform combinedTransform = parentMatrix; |
| 682 if (!layer->transform().IsIdentity()) { | 682 if (!layer->transform().IsIdentity()) { |
| 683 // LT = Tr[origin] * Tr[origin2anchor] | 683 // LT = Tr[origin] * Tr[origin2anchor] |
| 684 combinedTransform.Translate3d(position.x() + anchorPoint.x() * bounds.wi
dth(), position.y() + anchorPoint.y() * bounds.height(), layer->anchorPointZ()); | 684 combinedTransform.Translate3d(position.x() + anchorPoint.x() * bounds.wi
dth(), position.y() + anchorPoint.y() * bounds.height(), layer->anchor_point_z()
); |
| 685 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] | 685 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] |
| 686 combinedTransform.PreconcatTransform(layer->transform()); | 686 combinedTransform.PreconcatTransform(layer->transform()); |
| 687 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2origin] | 687 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2origin] |
| 688 combinedTransform.Translate3d(-anchorPoint.x() * bounds.width(), -anchor
Point.y() * bounds.height(), -layer->anchorPointZ()); | 688 combinedTransform.Translate3d(-anchorPoint.x() * bounds.width(), -anchor
Point.y() * bounds.height(), -layer->anchor_point_z()); |
| 689 } else { | 689 } else { |
| 690 combinedTransform.Translate(position.x(), position.y()); | 690 combinedTransform.Translate(position.x(), position.y()); |
| 691 } | 691 } |
| 692 | 692 |
| 693 // The layer's contentsSize is determined from the combinedTransform, which
then informs the | 693 // The layer's contentsSize is determined from the combinedTransform, which
then informs the |
| 694 // layer's drawTransform. | 694 // layer's drawTransform. |
| 695 updateLayerContentsScale(layer, combinedTransform, deviceScaleFactor, pageSc
aleFactor, animatingTransformToScreen); | 695 updateLayerContentsScale(layer, combinedTransform, deviceScaleFactor, pageSc
aleFactor, animating_transform_to_screen); |
| 696 | 696 |
| 697 // If there is a transformation from the impl thread then it should be at | 697 // If there is a transformation from the impl thread then it should be at |
| 698 // the start of the combinedTransform, but we don't want it to affect the | 698 // the start of the combinedTransform, but we don't want it to affect the |
| 699 // computation of contentsScale above. | 699 // computation of contentsScale above. |
| 700 // Note carefully: this is Concat, not Preconcat (implTransform * combinedTr
ansform). | 700 // Note carefully: this is Concat, not Preconcat (implTransform * combinedTr
ansform). |
| 701 combinedTransform.ConcatTransform(layer->implTransform()); | 701 combinedTransform.ConcatTransform(layer->impl_transform()); |
| 702 | 702 |
| 703 if (!animatingTransformToTarget && layer->scrollable() && combinedTransform.
IsScaleOrTranslation()) { | 703 if (!animatingTransformToTarget && layer->scrollable() && combinedTransform.
IsScaleOrTranslation()) { |
| 704 // Align the scrollable layer's position to screen space pixels to avoid
blurriness. | 704 // Align the scrollable layer's position to screen space pixels to avoid
blurriness. |
| 705 // To avoid side-effects, do this only if the transform is simple. | 705 // To avoid side-effects, do this only if the transform is simple. |
| 706 roundTranslationComponents(&combinedTransform); | 706 roundTranslationComponents(&combinedTransform); |
| 707 } | 707 } |
| 708 | 708 |
| 709 if (layer->fixedToContainerLayer()) { | 709 if (layer->fixed_to_container_layer()) { |
| 710 // Special case: this layer is a composited fixed-position layer; we nee
d to | 710 // Special case: this layer is a composited fixed-position layer; we nee
d to |
| 711 // explicitly compensate for all ancestors' nonzero scrollDeltas to keep
this layer | 711 // explicitly compensate for all ancestors' nonzero scrollDeltas to keep
this layer |
| 712 // fixed correctly. | 712 // fixed correctly. |
| 713 // Note carefully: this is Concat, not Preconcat (currentScrollCompensat
ion * combinedTransform). | 713 // Note carefully: this is Concat, not Preconcat (currentScrollCompensat
ion * combinedTransform). |
| 714 combinedTransform.ConcatTransform(currentScrollCompensationMatrix); | 714 combinedTransform.ConcatTransform(currentScrollCompensationMatrix); |
| 715 } | 715 } |
| 716 | 716 |
| 717 // The drawTransform that gets computed below is effectively the layer's dra
wTransform, unless | 717 // The drawTransform that gets computed below is effectively the layer's dra
wTransform, unless |
| 718 // the layer itself creates a renderSurface. In that case, the renderSurface
re-parents the transforms. | 718 // the layer itself creates a renderSurface. In that case, the renderSurface
re-parents the transforms. |
| 719 layerDrawProperties.target_space_transform = combinedTransform; | 719 layerDrawProperties.target_space_transform = combinedTransform; |
| 720 // M[draw] = M[parent] * LT * S[layer2content] | 720 // M[draw] = M[parent] * LT * S[layer2content] |
| 721 layerDrawProperties.target_space_transform.Scale(1.0 / layer->contentsScaleX
(), 1.0 / layer->contentsScaleY()); | 721 layerDrawProperties.target_space_transform.Scale(1.0 / layer->contents_scale
_x(), 1.0 / layer->contents_scale_y()); |
| 722 | 722 |
| 723 // layerScreenSpaceTransform represents the transform between root layer's "
screen space" and local content space. | 723 // layerScreenSpaceTransform represents the transform between root layer's "
screen space" and local content space. |
| 724 layerDrawProperties.screen_space_transform = fullHierarchyMatrix; | 724 layerDrawProperties.screen_space_transform = fullHierarchyMatrix; |
| 725 if (!layer->preserves3D()) | 725 if (!layer->preserves_3d()) |
| 726 layerDrawProperties.screen_space_transform.FlattenTo2d(); | 726 layerDrawProperties.screen_space_transform.FlattenTo2d(); |
| 727 layerDrawProperties.screen_space_transform.PreconcatTransform(layerDrawPrope
rties.target_space_transform); | 727 layerDrawProperties.screen_space_transform.PreconcatTransform(layerDrawPrope
rties.target_space_transform); |
| 728 | 728 |
| 729 // Adjusting text AA method during animation may cause repaints, which in-tu
rn causes jank. | 729 // Adjusting text AA method during animation may cause repaints, which in-tu
rn causes jank. |
| 730 bool adjustTextAA = !animatingOpacityToScreen && !animatingTransformToScreen
; | 730 bool adjustTextAA = !animatingOpacityToScreen && !animating_transform_to_scr
een; |
| 731 // To avoid color fringing, LCD text should only be used on opaque layers wi
th just integral translation. | 731 // To avoid color fringing, LCD text should only be used on opaque layers wi
th just integral translation. |
| 732 bool layerCanUseLCDText = subtreeCanUseLCDText && | 732 bool layerCanUseLCDText = subtreeCanUseLCDText && |
| 733 (accumulatedDrawOpacity == 1.0) && | 733 (accumulatedDrawOpacity == 1.0) && |
| 734 layerDrawProperties.target_space_transform.IsIdent
ityOrIntegerTranslation(); | 734 layerDrawProperties.target_space_transform.IsIdent
ityOrIntegerTranslation(); |
| 735 | 735 |
| 736 gfx::RectF contentRect(gfx::PointF(), layer->contentBounds()); | 736 gfx::RectF contentRect(gfx::PointF(), layer->content_bounds()); |
| 737 | 737 |
| 738 // fullHierarchyMatrix is the matrix that transforms objects between screen
space (except projection matrix) and the most recent RenderSurfaceImpl's space. | 738 // fullHierarchyMatrix is the matrix that transforms objects between screen
space (except projection matrix) and the most recent RenderSurfaceImpl's space. |
| 739 // nextHierarchyMatrix will only change if this layer uses a new RenderSurfa
ceImpl, otherwise remains the same. | 739 // nextHierarchyMatrix will only change if this layer uses a new RenderSurfa
ceImpl, otherwise remains the same. |
| 740 gfx::Transform nextHierarchyMatrix = fullHierarchyMatrix; | 740 gfx::Transform nextHierarchyMatrix = fullHierarchyMatrix; |
| 741 gfx::Transform sublayerMatrix; | 741 gfx::Transform sublayerMatrix; |
| 742 | 742 |
| 743 gfx::Vector2dF renderSurfaceSublayerScale = MathUtil::computeTransform2dScal
eComponents(combinedTransform, deviceScaleFactor * pageScaleFactor); | 743 gfx::Vector2dF renderSurfaceSublayerScale = MathUtil::computeTransform2dScal
eComponents(combinedTransform, deviceScaleFactor * pageScaleFactor); |
| 744 | 744 |
| 745 if (subtreeShouldRenderToSeparateSurface(layer, combinedTransform.IsScaleOrT
ranslation())) { | 745 if (subtreeShouldRenderToSeparateSurface(layer, combinedTransform.IsScaleOrT
ranslation())) { |
| 746 // Check back-face visibility before continuing with this surface and it
s subtree | 746 // Check back-face visibility before continuing with this surface and it
s subtree |
| 747 if (!layer->doubleSided() && transformToParentIsKnown(layer) && isSurfac
eBackFaceVisible(layer, combinedTransform)) | 747 if (!layer->double_sided() && transformToParentIsKnown(layer) && isSurfa
ceBackFaceVisible(layer, combinedTransform)) |
| 748 return; | 748 return; |
| 749 | 749 |
| 750 if (!layer->renderSurface()) | 750 if (!layer->render_surface()) |
| 751 layer->createRenderSurface(); | 751 layer->CreateRenderSurface(); |
| 752 | 752 |
| 753 RenderSurfaceType* renderSurface = layer->renderSurface(); | 753 RenderSurfaceType* renderSurface = layer->render_surface(); |
| 754 renderSurface->ClearLayerLists(); | 754 renderSurface->ClearLayerLists(); |
| 755 | 755 |
| 756 // The owning layer's draw transform has a scale from content to layer | 756 // The owning layer's draw transform has a scale from content to layer |
| 757 // space which we do not want; so here we use the combinedTransform | 757 // space which we do not want; so here we use the combinedTransform |
| 758 // instead of the drawTransform. However, we do need to add a different | 758 // instead of the drawTransform. However, we do need to add a different |
| 759 // scale factor that accounts for the surface's pixel dimensions. | 759 // scale factor that accounts for the surface's pixel dimensions. |
| 760 combinedTransform.Scale(1 / renderSurfaceSublayerScale.x(), 1 / renderSu
rfaceSublayerScale.y()); | 760 combinedTransform.Scale(1 / renderSurfaceSublayerScale.x(), 1 / renderSu
rfaceSublayerScale.y()); |
| 761 renderSurface->SetDrawTransform(combinedTransform); | 761 renderSurface->SetDrawTransform(combinedTransform); |
| 762 | 762 |
| 763 // The owning layer's transform was re-parented by the surface, so the l
ayer's new drawTransform | 763 // The owning layer's transform was re-parented by the surface, so the l
ayer's new drawTransform |
| 764 // only needs to scale the layer to surface space. | 764 // only needs to scale the layer to surface space. |
| 765 layerDrawProperties.target_space_transform.MakeIdentity(); | 765 layerDrawProperties.target_space_transform.MakeIdentity(); |
| 766 layerDrawProperties.target_space_transform.Scale(renderSurfaceSublayerSc
ale.x() / layer->contentsScaleX(), renderSurfaceSublayerScale.y() / layer->conte
ntsScaleY()); | 766 layerDrawProperties.target_space_transform.Scale(renderSurfaceSublayerSc
ale.x() / layer->contents_scale_x(), renderSurfaceSublayerScale.y() / layer->con
tents_scale_y()); |
| 767 | 767 |
| 768 // Inside the surface's subtree, we scale everything to the owning layer
's scale. | 768 // Inside the surface's subtree, we scale everything to the owning layer
's scale. |
| 769 // The sublayer matrix transforms layer rects into target | 769 // The sublayer matrix transforms layer rects into target |
| 770 // surface content space. | 770 // surface content space. |
| 771 DCHECK(sublayerMatrix.IsIdentity()); | 771 DCHECK(sublayerMatrix.IsIdentity()); |
| 772 sublayerMatrix.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublay
erScale.y()); | 772 sublayerMatrix.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublay
erScale.y()); |
| 773 | 773 |
| 774 // The opacity value is moved from the layer to its surface, so that the
entire subtree properly inherits opacity. | 774 // The opacity value is moved from the layer to its surface, so that the
entire subtree properly inherits opacity. |
| 775 renderSurface->SetDrawOpacity(accumulatedDrawOpacity); | 775 renderSurface->SetDrawOpacity(accumulatedDrawOpacity); |
| 776 renderSurface->SetDrawOpacityIsAnimating(animatingOpacityToTarget); | 776 renderSurface->SetDrawOpacityIsAnimating(animatingOpacityToTarget); |
| 777 animatingOpacityToTarget = false; | 777 animatingOpacityToTarget = false; |
| 778 layerDrawProperties.opacity = 1; | 778 layerDrawProperties.opacity = 1; |
| 779 layerDrawProperties.opacity_is_animating = animatingOpacityToTarget; | 779 layerDrawProperties.opacity_is_animating = animatingOpacityToTarget; |
| 780 layerDrawProperties.screen_space_opacity_is_animating = animatingOpacity
ToScreen; | 780 layerDrawProperties.screen_space_opacity_is_animating = animatingOpacity
ToScreen; |
| 781 | 781 |
| 782 renderSurface->SetTargetSurfaceTransformsAreAnimating(animatingTransform
ToTarget); | 782 renderSurface->SetTargetSurfaceTransformsAreAnimating(animatingTransform
ToTarget); |
| 783 renderSurface->SetScreenSpaceTransformsAreAnimating(animatingTransformTo
Screen); | 783 renderSurface->SetScreenSpaceTransformsAreAnimating(animating_transform_
to_screen); |
| 784 animatingTransformToTarget = false; | 784 animatingTransformToTarget = false; |
| 785 layerDrawProperties.target_space_transform_is_animating = animatingTrans
formToTarget; | 785 layerDrawProperties.target_space_transform_is_animating = animatingTrans
formToTarget; |
| 786 layerDrawProperties.screen_space_transform_is_animating = animatingTrans
formToScreen; | 786 layerDrawProperties.screen_space_transform_is_animating = animating_tran
sform_to_screen; |
| 787 | 787 |
| 788 // Update the aggregate hierarchy matrix to include the transform of the | 788 // Update the aggregate hierarchy matrix to include the transform of the |
| 789 // newly created RenderSurfaceImpl. | 789 // newly created RenderSurfaceImpl. |
| 790 nextHierarchyMatrix.PreconcatTransform(renderSurface->draw_transform()); | 790 nextHierarchyMatrix.PreconcatTransform(renderSurface->draw_transform()); |
| 791 | 791 |
| 792 // The new renderSurface here will correctly clip the entire subtree. So
, we do | 792 // The new renderSurface here will correctly clip the entire subtree. So
, we do |
| 793 // not need to continue propagating the clipping state further down the
tree. This | 793 // not need to continue propagating the clipping state further down the
tree. This |
| 794 // way, we can avoid transforming clipRects from ancestor target surface
space to | 794 // way, we can avoid transforming clipRects from ancestor target surface
space to |
| 795 // current target surface space that could cause more w < 0 headaches. | 795 // current target surface space that could cause more w < 0 headaches. |
| 796 subtreeShouldBeClipped = false; | 796 subtreeShouldBeClipped = false; |
| 797 | 797 |
| 798 if (layer->maskLayer()) { | 798 if (layer->mask_layer()) { |
| 799 DrawProperties<LayerType, RenderSurfaceType>& maskLayerDrawPropertie
s = layer->maskLayer()->drawProperties(); | 799 DrawProperties<LayerType, RenderSurfaceType>& maskLayerDrawPropertie
s = layer->mask_layer()->draw_properties(); |
| 800 maskLayerDrawProperties.render_target = layer; | 800 maskLayerDrawProperties.render_target = layer; |
| 801 maskLayerDrawProperties.visible_content_rect = gfx::Rect(gfx::Point(
), layer->contentBounds()); | 801 maskLayerDrawProperties.visible_content_rect = gfx::Rect(gfx::Point(
), layer->content_bounds()); |
| 802 } | 802 } |
| 803 | 803 |
| 804 if (layer->replicaLayer() && layer->replicaLayer()->maskLayer()) { | 804 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { |
| 805 DrawProperties<LayerType, RenderSurfaceType>& replicaMaskDrawPropert
ies = layer->replicaLayer()->maskLayer()->drawProperties(); | 805 DrawProperties<LayerType, RenderSurfaceType>& replicaMaskDrawPropert
ies = layer->replica_layer()->mask_layer()->draw_properties(); |
| 806 replicaMaskDrawProperties.render_target = layer; | 806 replicaMaskDrawProperties.render_target = layer; |
| 807 replicaMaskDrawProperties.visible_content_rect = gfx::Rect(gfx::Poin
t(), layer->contentBounds()); | 807 replicaMaskDrawProperties.visible_content_rect = gfx::Rect(gfx::Poin
t(), layer->content_bounds()); |
| 808 } | 808 } |
| 809 | 809 |
| 810 // FIXME: make this smarter for the SkImageFilter case (check for | 810 // FIXME: make this smarter for the SkImageFilter case (check for |
| 811 // pixel-moving filters) | 811 // pixel-moving filters) |
| 812 if (layer->filters().hasFilterThatMovesPixels() || layer->filter()) | 812 if (layer->filters().hasFilterThatMovesPixels() || layer->filter()) |
| 813 nearestAncestorThatMovesPixels = renderSurface; | 813 nearestAncestorThatMovesPixels = renderSurface; |
| 814 | 814 |
| 815 // The render surface clipRect is expressed in the space where this surf
ace draws, i.e. the same space as clipRectFromAncestor. | 815 // The render surface clipRect is expressed in the space where this surf
ace draws, i.e. the same space as clipRectFromAncestor. |
| 816 renderSurface->SetIsClipped(ancestorClipsSubtree); | 816 renderSurface->SetIsClipped(ancestorClipsSubtree); |
| 817 if (ancestorClipsSubtree) { | 817 if (ancestorClipsSubtree) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 834 // then the subtree that gets drawn on this render surface cannot use LC
D text. | 834 // then the subtree that gets drawn on this render surface cannot use LC
D text. |
| 835 subtreeCanUseLCDText = layerCanUseLCDText; | 835 subtreeCanUseLCDText = layerCanUseLCDText; |
| 836 | 836 |
| 837 renderSurfaceLayerList.push_back(layer); | 837 renderSurfaceLayerList.push_back(layer); |
| 838 } else { | 838 } else { |
| 839 DCHECK(layer->parent()); | 839 DCHECK(layer->parent()); |
| 840 | 840 |
| 841 // Note: layerDrawProperties.target_space_transform is computed above, | 841 // Note: layerDrawProperties.target_space_transform is computed above, |
| 842 // before this if-else statement. | 842 // before this if-else statement. |
| 843 layerDrawProperties.target_space_transform_is_animating = animatingTrans
formToTarget; | 843 layerDrawProperties.target_space_transform_is_animating = animatingTrans
formToTarget; |
| 844 layerDrawProperties.screen_space_transform_is_animating = animatingTrans
formToScreen; | 844 layerDrawProperties.screen_space_transform_is_animating = animating_tran
sform_to_screen; |
| 845 layerDrawProperties.opacity = accumulatedDrawOpacity; | 845 layerDrawProperties.opacity = accumulatedDrawOpacity; |
| 846 layerDrawProperties.opacity_is_animating = animatingOpacityToTarget; | 846 layerDrawProperties.opacity_is_animating = animatingOpacityToTarget; |
| 847 layerDrawProperties.screen_space_opacity_is_animating = animatingOpacity
ToScreen; | 847 layerDrawProperties.screen_space_opacity_is_animating = animatingOpacity
ToScreen; |
| 848 sublayerMatrix = combinedTransform; | 848 sublayerMatrix = combinedTransform; |
| 849 | 849 |
| 850 layer->clearRenderSurface(); | 850 layer->ClearRenderSurface(); |
| 851 | 851 |
| 852 // Layers without renderSurfaces directly inherit the ancestor's clip st
atus. | 852 // Layers without renderSurfaces directly inherit the ancestor's clip st
atus. |
| 853 subtreeShouldBeClipped = ancestorClipsSubtree; | 853 subtreeShouldBeClipped = ancestorClipsSubtree; |
| 854 if (ancestorClipsSubtree) | 854 if (ancestorClipsSubtree) |
| 855 clipRectForSubtree = clipRectFromAncestor; | 855 clipRectForSubtree = clipRectFromAncestor; |
| 856 | 856 |
| 857 // The surface's cached clipRect value propagates regardless of what cli
pping goes on between layers here. | 857 // The surface's cached clipRect value propagates regardless of what cli
pping goes on between layers here. |
| 858 clipRectForSubtreeInDescendantSpace = clipRectFromAncestorInDescendantSp
ace; | 858 clipRectForSubtreeInDescendantSpace = clipRectFromAncestorInDescendantSp
ace; |
| 859 | 859 |
| 860 // Layers that are not their own renderTarget will render into the targe
t of their nearest ancestor. | 860 // Layers that are not their own renderTarget will render into the targe
t of their nearest ancestor. |
| 861 layerDrawProperties.render_target = layer->parent()->renderTarget(); | 861 layerDrawProperties.render_target = layer->parent()->render_target(); |
| 862 } | 862 } |
| 863 | 863 |
| 864 if (adjustTextAA) | 864 if (adjustTextAA) |
| 865 layerDrawProperties.can_use_lcd_text = layerCanUseLCDText; | 865 layerDrawProperties.can_use_lcd_text = layerCanUseLCDText; |
| 866 | 866 |
| 867 gfx::Rect rectInTargetSpace = ToEnclosingRect(MathUtil::mapClippedRect(layer
->drawTransform(), contentRect)); | 867 gfx::Rect rectInTargetSpace = ToEnclosingRect(MathUtil::mapClippedRect(layer
->draw_transform(), contentRect)); |
| 868 | 868 |
| 869 if (layerClipsSubtree(layer)) { | 869 if (layerClipsSubtree(layer)) { |
| 870 subtreeShouldBeClipped = true; | 870 subtreeShouldBeClipped = true; |
| 871 if (ancestorClipsSubtree && !layer->renderSurface()) { | 871 if (ancestorClipsSubtree && !layer->render_surface()) { |
| 872 clipRectForSubtree = clipRectFromAncestor; | 872 clipRectForSubtree = clipRectFromAncestor; |
| 873 clipRectForSubtree.Intersect(rectInTargetSpace); | 873 clipRectForSubtree.Intersect(rectInTargetSpace); |
| 874 } else | 874 } else |
| 875 clipRectForSubtree = rectInTargetSpace; | 875 clipRectForSubtree = rectInTargetSpace; |
| 876 } | 876 } |
| 877 | 877 |
| 878 // Flatten to 2D if the layer doesn't preserve 3D. | 878 // Flatten to 2D if the layer doesn't preserve 3D. |
| 879 if (!layer->preserves3D()) | 879 if (!layer->preserves_3d()) |
| 880 sublayerMatrix.FlattenTo2d(); | 880 sublayerMatrix.FlattenTo2d(); |
| 881 | 881 |
| 882 // Apply the sublayer transform at the anchor point of the layer. | 882 // Apply the sublayer transform at the anchor point of the layer. |
| 883 if (!layer->sublayerTransform().IsIdentity()) { | 883 if (!layer->sublayer_transform().IsIdentity()) { |
| 884 sublayerMatrix.Translate(layer->anchorPoint().x() * bounds.width(), laye
r->anchorPoint().y() * bounds.height()); | 884 sublayerMatrix.Translate(layer->anchor_point().x() * bounds.width(), lay
er->anchor_point().y() * bounds.height()); |
| 885 sublayerMatrix.PreconcatTransform(layer->sublayerTransform()); | 885 sublayerMatrix.PreconcatTransform(layer->sublayer_transform()); |
| 886 sublayerMatrix.Translate(-layer->anchorPoint().x() * bounds.width(), -la
yer->anchorPoint().y() * bounds.height()); | 886 sublayerMatrix.Translate(-layer->anchor_point().x() * bounds.width(), -l
ayer->anchor_point().y() * bounds.height()); |
| 887 } | 887 } |
| 888 | 888 |
| 889 LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->l
ayer_list() : layerList); | 889 LayerList& descendants = (layer->render_surface() ? layer->render_surface()-
>layer_list() : layerList); |
| 890 | 890 |
| 891 // Any layers that are appended after this point are in the layer's subtree
and should be included in the sorting process. | 891 // Any layers that are appended after this point are in the layer's subtree
and should be included in the sorting process. |
| 892 unsigned sortingStartIndex = descendants.size(); | 892 unsigned sortingStartIndex = descendants.size(); |
| 893 | 893 |
| 894 if (!layerShouldBeSkipped(layer)) | 894 if (!layerShouldBeSkipped(layer)) |
| 895 descendants.push_back(layer); | 895 descendants.push_back(layer); |
| 896 | 896 |
| 897 gfx::Transform nextScrollCompensationMatrix = computeScrollCompensationMatri
xForChildren(layer, parentMatrix, currentScrollCompensationMatrix);; | 897 gfx::Transform nextScrollCompensationMatrix = computeScrollCompensationMatri
xForChildren(layer, parentMatrix, currentScrollCompensationMatrix);; |
| 898 | 898 |
| 899 gfx::Rect accumulatedDrawableContentRectOfChildren; | 899 gfx::Rect accumulatedDrawableContentRectOfChildren; |
| 900 for (size_t i = 0; i < layer->children().size(); ++i) { | 900 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 901 LayerType* child = LayerTreeHostCommon::getChildAsRawPtr(layer->children
(), i); | 901 LayerType* child = LayerTreeHostCommon::getChildAsRawPtr(layer->children
(), i); |
| 902 gfx::Rect drawableContentRectOfChildSubtree; | 902 gfx::Rect drawableContentRectOfChildSubtree; |
| 903 calculateDrawPropertiesInternal<LayerType, LayerList, RenderSurfaceType>
(child, sublayerMatrix, nextHierarchyMatrix, nextScrollCompensationMatrix, | 903 calculateDrawPropertiesInternal<LayerType, LayerList, RenderSurfaceType>
(child, sublayerMatrix, nextHierarchyMatrix, nextScrollCompensationMatrix, |
| 904
clipRectForSubtree, clipRectForSubtreeInDescendantSpace, subtreeShouldBeClipped
, nearestAncestorThatMovesPixels, | 904
clipRectForSubtree, clipRectForSubtreeInDescendantSpace, subtreeShouldBeClipped
, nearestAncestorThatMovesPixels, |
| 905
renderSurfaceLayerList, descendants, layerSorter, maxTextureSize, deviceScaleFa
ctor, pageScaleFactor, | 905
renderSurfaceLayerList, descendants, layerSorter, maxTextureSize, deviceScaleFa
ctor, pageScaleFactor, |
| 906
subtreeCanUseLCDText, drawableContentRectOfChildSubtree, updateTilePriorities); | 906
subtreeCanUseLCDText, drawableContentRectOfChildSubtree, updateTilePriorities); |
| 907 if (!drawableContentRectOfChildSubtree.IsEmpty()) { | 907 if (!drawableContentRectOfChildSubtree.IsEmpty()) { |
| 908 accumulatedDrawableContentRectOfChildren.Union(drawableContentRectOf
ChildSubtree); | 908 accumulatedDrawableContentRectOfChildren.Union(drawableContentRectOf
ChildSubtree); |
| 909 if (child->renderSurface()) | 909 if (child->render_surface()) |
| 910 descendants.push_back(child); | 910 descendants.push_back(child); |
| 911 } | 911 } |
| 912 } | 912 } |
| 913 | 913 |
| 914 if (layer->renderSurface() && !isRootLayer(layer) && !layer->renderSurface()
->layer_list().size()) { | 914 if (layer->render_surface() && !isRootLayer(layer) && !layer->render_surface
()->layer_list().size()) { |
| 915 removeSurfaceForEarlyExit(layer, renderSurfaceLayerList); | 915 removeSurfaceForEarlyExit(layer, renderSurfaceLayerList); |
| 916 return; | 916 return; |
| 917 } | 917 } |
| 918 | 918 |
| 919 // Compute the total drawableContentRect for this subtree (the rect is in ta
rgetSurface space) | 919 // Compute the total drawableContentRect for this subtree (the rect is in ta
rgetSurface space) |
| 920 gfx::Rect localDrawableContentRectOfSubtree = accumulatedDrawableContentRect
OfChildren; | 920 gfx::Rect localDrawableContentRectOfSubtree = accumulatedDrawableContentRect
OfChildren; |
| 921 if (layer->drawsContent()) | 921 if (layer->DrawsContent()) |
| 922 localDrawableContentRectOfSubtree.Union(rectInTargetSpace); | 922 localDrawableContentRectOfSubtree.Union(rectInTargetSpace); |
| 923 if (subtreeShouldBeClipped) | 923 if (subtreeShouldBeClipped) |
| 924 localDrawableContentRectOfSubtree.Intersect(clipRectForSubtree); | 924 localDrawableContentRectOfSubtree.Intersect(clipRectForSubtree); |
| 925 | 925 |
| 926 // Compute the layer's drawable content rect (the rect is in targetSurface s
pace) | 926 // Compute the layer's drawable content rect (the rect is in targetSurface s
pace) |
| 927 layerDrawProperties.drawable_content_rect = rectInTargetSpace; | 927 layerDrawProperties.drawable_content_rect = rectInTargetSpace; |
| 928 if (subtreeShouldBeClipped) | 928 if (subtreeShouldBeClipped) |
| 929 layerDrawProperties.drawable_content_rect.Intersect(clipRectForSubtree); | 929 layerDrawProperties.drawable_content_rect.Intersect(clipRectForSubtree); |
| 930 | 930 |
| 931 // Tell the layer the rect that is clipped by. In theory we could use a | 931 // Tell the layer the rect that is clipped by. In theory we could use a |
| 932 // tighter clipRect here (drawableContentRect), but that actually does not | 932 // tighter clipRect here (drawableContentRect), but that actually does not |
| 933 // reduce how much would be drawn, and instead it would create unnecessary | 933 // reduce how much would be drawn, and instead it would create unnecessary |
| 934 // changes to scissor state affecting GPU performance. | 934 // changes to scissor state affecting GPU performance. |
| 935 layerDrawProperties.is_clipped = subtreeShouldBeClipped; | 935 layerDrawProperties.is_clipped = subtreeShouldBeClipped; |
| 936 if (subtreeShouldBeClipped) | 936 if (subtreeShouldBeClipped) |
| 937 layerDrawProperties.clip_rect = clipRectForSubtree; | 937 layerDrawProperties.clip_rect = clipRectForSubtree; |
| 938 else { | 938 else { |
| 939 // Initialize the clipRect to a safe value that will not clip the | 939 // Initialize the clipRect to a safe value that will not clip the |
| 940 // layer, just in case clipping is still accidentally used. | 940 // layer, just in case clipping is still accidentally used. |
| 941 layerDrawProperties.clip_rect = rectInTargetSpace; | 941 layerDrawProperties.clip_rect = rectInTargetSpace; |
| 942 } | 942 } |
| 943 | 943 |
| 944 // Compute the layer's visible content rect (the rect is in content space) | 944 // Compute the layer's visible content rect (the rect is in content space) |
| 945 layerDrawProperties.visible_content_rect = calculateVisibleContentRect(layer
, clipRectForSubtreeInDescendantSpace, rectInTargetSpace); | 945 layerDrawProperties.visible_content_rect = calculateVisibleContentRect(layer
, clipRectForSubtreeInDescendantSpace, rectInTargetSpace); |
| 946 | 946 |
| 947 // Compute the remaining properties for the render surface, if the layer has
one. | 947 // Compute the remaining properties for the render surface, if the layer has
one. |
| 948 if (isRootLayer(layer)) { | 948 if (isRootLayer(layer)) { |
| 949 // The root layer's surface's contentRect is always the entire viewport. | 949 // The root layer's surface's contentRect is always the entire viewport. |
| 950 DCHECK(layer->renderSurface()); | 950 DCHECK(layer->render_surface()); |
| 951 layer->renderSurface()->SetContentRect(clipRectFromAncestor); | 951 layer->render_surface()->SetContentRect(clipRectFromAncestor); |
| 952 } else if (layer->renderSurface() && !isRootLayer(layer)) { | 952 } else if (layer->render_surface() && !isRootLayer(layer)) { |
| 953 RenderSurfaceType* renderSurface = layer->renderSurface(); | 953 RenderSurfaceType* renderSurface = layer->render_surface(); |
| 954 gfx::Rect clippedContentRect = localDrawableContentRectOfSubtree; | 954 gfx::Rect clippedContentRect = localDrawableContentRectOfSubtree; |
| 955 | 955 |
| 956 // Don't clip if the layer is reflected as the reflection shouldn't be | 956 // Don't clip if the layer is reflected as the reflection shouldn't be |
| 957 // clipped. If the layer is animating, then the surface's transform to | 957 // clipped. If the layer is animating, then the surface's transform to |
| 958 // its target is not known on the main thread, and we should not use it | 958 // its target is not known on the main thread, and we should not use it |
| 959 // to clip. | 959 // to clip. |
| 960 if (!layer->replicaLayer() && transformToParentIsKnown(layer)) { | 960 if (!layer->replica_layer() && transformToParentIsKnown(layer)) { |
| 961 // Note, it is correct to use ancestorClipsSubtree here, because we
are looking at this layer's renderSurface, not the layer itself. | 961 // Note, it is correct to use ancestorClipsSubtree here, because we
are looking at this layer's renderSurface, not the layer itself. |
| 962 if (ancestorClipsSubtree && !clippedContentRect.IsEmpty()) { | 962 if (ancestorClipsSubtree && !clippedContentRect.IsEmpty()) { |
| 963 gfx::Rect surfaceClipRect = LayerTreeHostCommon::calculateVisibl
eRect(renderSurface->clip_rect(), clippedContentRect, renderSurface->draw_transf
orm()); | 963 gfx::Rect surfaceClipRect = LayerTreeHostCommon::calculateVisibl
eRect(renderSurface->clip_rect(), clippedContentRect, renderSurface->draw_transf
orm()); |
| 964 clippedContentRect.Intersect(surfaceClipRect); | 964 clippedContentRect.Intersect(surfaceClipRect); |
| 965 } | 965 } |
| 966 } | 966 } |
| 967 | 967 |
| 968 // The RenderSurfaceImpl backing texture cannot exceed the maximum suppo
rted | 968 // The RenderSurfaceImpl backing texture cannot exceed the maximum suppo
rted |
| 969 // texture size. | 969 // texture size. |
| 970 clippedContentRect.set_width(std::min(clippedContentRect.width(), maxTex
tureSize)); | 970 clippedContentRect.set_width(std::min(clippedContentRect.width(), maxTex
tureSize)); |
| 971 clippedContentRect.set_height(std::min(clippedContentRect.height(), maxT
extureSize)); | 971 clippedContentRect.set_height(std::min(clippedContentRect.height(), maxT
extureSize)); |
| 972 | 972 |
| 973 if (clippedContentRect.IsEmpty()) { | 973 if (clippedContentRect.IsEmpty()) { |
| 974 renderSurface->ClearLayerLists(); | 974 renderSurface->ClearLayerLists(); |
| 975 removeSurfaceForEarlyExit(layer, renderSurfaceLayerList); | 975 removeSurfaceForEarlyExit(layer, renderSurfaceLayerList); |
| 976 return; | 976 return; |
| 977 } | 977 } |
| 978 | 978 |
| 979 renderSurface->SetContentRect(clippedContentRect); | 979 renderSurface->SetContentRect(clippedContentRect); |
| 980 | 980 |
| 981 // The owning layer's screenSpaceTransform has a scale from content to l
ayer space which we need to undo and | 981 // The owning layer's screenSpaceTransform has a scale from content to l
ayer space which we need to undo and |
| 982 // replace with a scale from the surface's subtree into layer space. | 982 // replace with a scale from the surface's subtree into layer space. |
| 983 gfx::Transform screenSpaceTransform = layer->screenSpaceTransform(); | 983 gfx::Transform screenSpaceTransform = layer->screen_space_transform(); |
| 984 screenSpaceTransform.Scale(layer->contentsScaleX() / renderSurfaceSublay
erScale.x(), layer->contentsScaleY() / renderSurfaceSublayerScale.y()); | 984 screenSpaceTransform.Scale(layer->contents_scale_x() / renderSurfaceSubl
ayerScale.x(), layer->contents_scale_y() / renderSurfaceSublayerScale.y()); |
| 985 renderSurface->SetScreenSpaceTransform(screenSpaceTransform); | 985 renderSurface->SetScreenSpaceTransform(screenSpaceTransform); |
| 986 | 986 |
| 987 if (layer->replicaLayer()) { | 987 if (layer->replica_layer()) { |
| 988 gfx::Transform surfaceOriginToReplicaOriginTransform; | 988 gfx::Transform surfaceOriginToReplicaOriginTransform; |
| 989 surfaceOriginToReplicaOriginTransform.Scale(renderSurfaceSublayerSca
le.x(), renderSurfaceSublayerScale.y()); | 989 surfaceOriginToReplicaOriginTransform.Scale(renderSurfaceSublayerSca
le.x(), renderSurfaceSublayerScale.y()); |
| 990 surfaceOriginToReplicaOriginTransform.Translate(layer->replicaLayer(
)->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(), | 990 surfaceOriginToReplicaOriginTransform.Translate(layer->replica_layer
()->position().x() + layer->replica_layer()->anchor_point().x() * bounds.width()
, |
| 991 layer->replicaLayer(
)->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height()); | 991 layer->replica_layer
()->position().y() + layer->replica_layer()->anchor_point().y() * bounds.height(
)); |
| 992 surfaceOriginToReplicaOriginTransform.PreconcatTransform(layer->repl
icaLayer()->transform()); | 992 surfaceOriginToReplicaOriginTransform.PreconcatTransform(layer->repl
ica_layer()->transform()); |
| 993 surfaceOriginToReplicaOriginTransform.Translate(-layer->replicaLayer
()->anchorPoint().x() * bounds.width(), -layer->replicaLayer()->anchorPoint().y(
) * bounds.height()); | 993 surfaceOriginToReplicaOriginTransform.Translate(-layer->replica_laye
r()->anchor_point().x() * bounds.width(), -layer->replica_layer()->anchor_point(
).y() * bounds.height()); |
| 994 surfaceOriginToReplicaOriginTransform.Scale(1 / renderSurfaceSublaye
rScale.x(), 1 / renderSurfaceSublayerScale.y()); | 994 surfaceOriginToReplicaOriginTransform.Scale(1 / renderSurfaceSublaye
rScale.x(), 1 / renderSurfaceSublayerScale.y()); |
| 995 | 995 |
| 996 // Compute the replica's "originTransform" that maps from the replic
a's origin space to the target surface origin space. | 996 // Compute the replica's "originTransform" that maps from the replic
a's origin space to the target surface origin space. |
| 997 gfx::Transform replicaOriginTransform = layer->renderSurface()->draw
_transform() * surfaceOriginToReplicaOriginTransform; | 997 gfx::Transform replicaOriginTransform = layer->render_surface()->dra
w_transform() * surfaceOriginToReplicaOriginTransform; |
| 998 renderSurface->SetReplicaDrawTransform(replicaOriginTransform); | 998 renderSurface->SetReplicaDrawTransform(replicaOriginTransform); |
| 999 | 999 |
| 1000 // Compute the replica's "screenSpaceTransform" that maps from the r
eplica's origin space to the screen's origin space. | 1000 // Compute the replica's "screenSpaceTransform" that maps from the r
eplica's origin space to the screen's origin space. |
| 1001 gfx::Transform replicaScreenSpaceTransform = layer->renderSurface()-
>screen_space_transform() * surfaceOriginToReplicaOriginTransform; | 1001 gfx::Transform replicaScreenSpaceTransform = layer->render_surface()
->screen_space_transform() * surfaceOriginToReplicaOriginTransform; |
| 1002 renderSurface->SetReplicaScreenSpaceTransform(replicaScreenSpaceTran
sform); | 1002 renderSurface->SetReplicaScreenSpaceTransform(replicaScreenSpaceTran
sform); |
| 1003 } | 1003 } |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 if (updateTilePriorities) | 1006 if (updateTilePriorities) |
| 1007 updateTilePrioritiesForLayer(layer); | 1007 updateTilePrioritiesForLayer(layer); |
| 1008 | 1008 |
| 1009 // If neither this layer nor any of its children were added, early out. | 1009 // If neither this layer nor any of its children were added, early out. |
| 1010 if (sortingStartIndex == descendants.size()) | 1010 if (sortingStartIndex == descendants.size()) |
| 1011 return; | 1011 return; |
| 1012 | 1012 |
| 1013 // If preserves-3d then sort all the descendants in 3D so that they can be | 1013 // If preserves-3d then sort all the descendants in 3D so that they can be |
| 1014 // drawn from back to front. If the preserves-3d property is also set on the
parent then | 1014 // drawn from back to front. If the preserves-3d property is also set on the
parent then |
| 1015 // skip the sorting as the parent will sort all the descendants anyway. | 1015 // skip the sorting as the parent will sort all the descendants anyway. |
| 1016 if (layerSorter && descendants.size() && layer->preserves3D() && (!layer->pa
rent() || !layer->parent()->preserves3D())) | 1016 if (layerSorter && descendants.size() && layer->preserves_3d() && (!layer->p
arent() || !layer->parent()->preserves_3d())) |
| 1017 sortLayers(descendants.begin() + sortingStartIndex, descendants.end(), l
ayerSorter); | 1017 sortLayers(descendants.begin() + sortingStartIndex, descendants.end(), l
ayerSorter); |
| 1018 | 1018 |
| 1019 if (layer->renderSurface()) | 1019 if (layer->render_surface()) |
| 1020 drawableContentRectOfSubtree = gfx::ToEnclosingRect(layer->renderSurface
()->DrawableContentRect()); | 1020 drawableContentRectOfSubtree = gfx::ToEnclosingRect(layer->render_surfac
e()->DrawableContentRect()); |
| 1021 else | 1021 else |
| 1022 drawableContentRectOfSubtree = localDrawableContentRectOfSubtree; | 1022 drawableContentRectOfSubtree = localDrawableContentRectOfSubtree; |
| 1023 | 1023 |
| 1024 if (layer->hasContributingDelegatedRenderPasses()) | 1024 if (layer->HasContributingDelegatedRenderPasses()) |
| 1025 layer->renderTarget()->renderSurface()->AddContributingDelegatedRenderPa
ssLayer(layer); | 1025 layer->render_target()->render_surface()->AddContributingDelegatedRender
PassLayer(layer); |
| 1026 } | 1026 } |
| 1027 | 1027 |
| 1028 void LayerTreeHostCommon::calculateDrawProperties(Layer* rootLayer, const gfx::S
ize& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int max
TextureSize, bool canUseLCDText, std::vector<scoped_refptr<Layer> >& renderSurfa
ceLayerList) | 1028 void LayerTreeHostCommon::calculateDrawProperties(Layer* rootLayer, const gfx::S
ize& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int max
TextureSize, bool canUseLCDText, std::vector<scoped_refptr<Layer> >& renderSurfa
ceLayerList) |
| 1029 { | 1029 { |
| 1030 gfx::Rect totalDrawableContentRect; | 1030 gfx::Rect totalDrawableContentRect; |
| 1031 gfx::Transform identityMatrix; | 1031 gfx::Transform identityMatrix; |
| 1032 gfx::Transform deviceScaleTransform; | 1032 gfx::Transform deviceScaleTransform; |
| 1033 deviceScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor); | 1033 deviceScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor); |
| 1034 std::vector<scoped_refptr<Layer> > dummyLayerList; | 1034 std::vector<scoped_refptr<Layer> > dummyLayerList; |
| 1035 | 1035 |
| 1036 // The root layer's renderSurface should receive the deviceViewport as the i
nitial clipRect. | 1036 // The root layer's renderSurface should receive the deviceViewport as the i
nitial clipRect. |
| 1037 bool subtreeShouldBeClipped = true; | 1037 bool subtreeShouldBeClipped = true; |
| 1038 gfx::Rect deviceViewportRect(gfx::Point(), deviceViewportSize); | 1038 gfx::Rect deviceViewportRect(gfx::Point(), deviceViewportSize); |
| 1039 bool updateTilePriorities = false; | 1039 bool updateTilePriorities = false; |
| 1040 | 1040 |
| 1041 // This function should have received a root layer. | 1041 // This function should have received a root layer. |
| 1042 DCHECK(isRootLayer(rootLayer)); | 1042 DCHECK(isRootLayer(rootLayer)); |
| 1043 | 1043 |
| 1044 preCalculateMetaInformation<Layer>(rootLayer); | 1044 preCalculateMetaInformation<Layer>(rootLayer); |
| 1045 calculateDrawPropertiesInternal<Layer, std::vector<scoped_refptr<Layer> >, R
enderSurface>( | 1045 calculateDrawPropertiesInternal<Layer, std::vector<scoped_refptr<Layer> >, R
enderSurface>( |
| 1046 rootLayer, deviceScaleTransform, identityMatrix, identityMatrix, | 1046 rootLayer, deviceScaleTransform, identityMatrix, identityMatrix, |
| 1047 deviceViewportRect, deviceViewportRect, subtreeShouldBeClipped, 0, rende
rSurfaceLayerList, | 1047 deviceViewportRect, deviceViewportRect, subtreeShouldBeClipped, 0, rende
rSurfaceLayerList, |
| 1048 dummyLayerList, 0, maxTextureSize, | 1048 dummyLayerList, 0, maxTextureSize, |
| 1049 deviceScaleFactor, pageScaleFactor, canUseLCDText, totalDrawableContentR
ect, | 1049 deviceScaleFactor, pageScaleFactor, canUseLCDText, totalDrawableContentR
ect, |
| 1050 updateTilePriorities); | 1050 updateTilePriorities); |
| 1051 | 1051 |
| 1052 // The dummy layer list should not have been used. | 1052 // The dummy layer list should not have been used. |
| 1053 DCHECK(dummyLayerList.size() == 0); | 1053 DCHECK(dummyLayerList.size() == 0); |
| 1054 // A root layer renderSurface should always exist after calculateDrawPropert
ies. | 1054 // A root layer renderSurface should always exist after calculateDrawPropert
ies. |
| 1055 DCHECK(rootLayer->renderSurface()); | 1055 DCHECK(rootLayer->render_surface()); |
| 1056 } | 1056 } |
| 1057 | 1057 |
| 1058 void LayerTreeHostCommon::calculateDrawProperties(LayerImpl* rootLayer, const gf
x::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int
maxTextureSize, bool canUseLCDText, std::vector<LayerImpl*>& renderSurfaceLayer
List, bool updateTilePriorities) | 1058 void LayerTreeHostCommon::calculateDrawProperties(LayerImpl* rootLayer, const gf
x::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int
maxTextureSize, bool canUseLCDText, std::vector<LayerImpl*>& renderSurfaceLayer
List, bool updateTilePriorities) |
| 1059 { | 1059 { |
| 1060 gfx::Rect totalDrawableContentRect; | 1060 gfx::Rect totalDrawableContentRect; |
| 1061 gfx::Transform identityMatrix; | 1061 gfx::Transform identityMatrix; |
| 1062 gfx::Transform deviceScaleTransform; | 1062 gfx::Transform deviceScaleTransform; |
| 1063 deviceScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor); | 1063 deviceScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor); |
| 1064 std::vector<LayerImpl*> dummyLayerList; | 1064 std::vector<LayerImpl*> dummyLayerList; |
| 1065 LayerSorter layerSorter; | 1065 LayerSorter layerSorter; |
| 1066 | 1066 |
| 1067 // The root layer's renderSurface should receive the deviceViewport as the i
nitial clipRect. | 1067 // The root layer's renderSurface should receive the deviceViewport as the i
nitial clipRect. |
| 1068 bool subtreeShouldBeClipped = true; | 1068 bool subtreeShouldBeClipped = true; |
| 1069 gfx::Rect deviceViewportRect(gfx::Point(), deviceViewportSize); | 1069 gfx::Rect deviceViewportRect(gfx::Point(), deviceViewportSize); |
| 1070 | 1070 |
| 1071 // This function should have received a root layer. | 1071 // This function should have received a root layer. |
| 1072 DCHECK(isRootLayer(rootLayer)); | 1072 DCHECK(isRootLayer(rootLayer)); |
| 1073 | 1073 |
| 1074 preCalculateMetaInformation<LayerImpl>(rootLayer); | 1074 preCalculateMetaInformation<LayerImpl>(rootLayer); |
| 1075 calculateDrawPropertiesInternal<LayerImpl, std::vector<LayerImpl*>, RenderSu
rfaceImpl>( | 1075 calculateDrawPropertiesInternal<LayerImpl, std::vector<LayerImpl*>, RenderSu
rfaceImpl>( |
| 1076 rootLayer, deviceScaleTransform, identityMatrix, identityMatrix, | 1076 rootLayer, deviceScaleTransform, identityMatrix, identityMatrix, |
| 1077 deviceViewportRect, deviceViewportRect, subtreeShouldBeClipped, 0, rende
rSurfaceLayerList, | 1077 deviceViewportRect, deviceViewportRect, subtreeShouldBeClipped, 0, rende
rSurfaceLayerList, |
| 1078 dummyLayerList, &layerSorter, maxTextureSize, | 1078 dummyLayerList, &layerSorter, maxTextureSize, |
| 1079 deviceScaleFactor, pageScaleFactor, canUseLCDText, totalDrawableContentR
ect, | 1079 deviceScaleFactor, pageScaleFactor, canUseLCDText, totalDrawableContentR
ect, |
| 1080 updateTilePriorities); | 1080 updateTilePriorities); |
| 1081 | 1081 |
| 1082 // The dummy layer list should not have been used. | 1082 // The dummy layer list should not have been used. |
| 1083 DCHECK(dummyLayerList.size() == 0); | 1083 DCHECK(dummyLayerList.size() == 0); |
| 1084 // A root layer renderSurface should always exist after calculateDrawPropert
ies. | 1084 // A root layer renderSurface should always exist after calculateDrawPropert
ies. |
| 1085 DCHECK(rootLayer->renderSurface()); | 1085 DCHECK(rootLayer->render_surface()); |
| 1086 } | 1086 } |
| 1087 | 1087 |
| 1088 static bool pointHitsRect(const gfx::PointF& screenSpacePoint, const gfx::Transf
orm& localSpaceToScreenSpaceTransform, gfx::RectF localSpaceRect) | 1088 static bool pointHitsRect(const gfx::PointF& screenSpacePoint, const gfx::Transf
orm& localSpaceToScreenSpaceTransform, gfx::RectF localSpaceRect) |
| 1089 { | 1089 { |
| 1090 // If the transform is not invertible, then assume that this point doesn't h
it this rect. | 1090 // If the transform is not invertible, then assume that this point doesn't h
it this rect. |
| 1091 gfx::Transform inverseLocalSpaceToScreenSpace(gfx::Transform::kSkipInitializ
ation); | 1091 gfx::Transform inverseLocalSpaceToScreenSpace(gfx::Transform::kSkipInitializ
ation); |
| 1092 if (!localSpaceToScreenSpaceTransform.GetInverse(&inverseLocalSpaceToScreenS
pace)) | 1092 if (!localSpaceToScreenSpaceTransform.GetInverse(&inverseLocalSpaceToScreenS
pace)) |
| 1093 return false; | 1093 return false; |
| 1094 | 1094 |
| 1095 // Transform the hit test point from screen space to the local space of the
given rect. | 1095 // Transform the hit test point from screen space to the local space of the
given rect. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1121 | 1121 |
| 1122 return layerSpaceRegion.Contains(gfx::ToRoundedPoint(hitTestPointInLayerSpac
e)); | 1122 return layerSpaceRegion.Contains(gfx::ToRoundedPoint(hitTestPointInLayerSpac
e)); |
| 1123 } | 1123 } |
| 1124 | 1124 |
| 1125 static bool pointIsClippedBySurfaceOrClipRect(const gfx::PointF& screenSpacePoin
t, LayerImpl* layer) | 1125 static bool pointIsClippedBySurfaceOrClipRect(const gfx::PointF& screenSpacePoin
t, LayerImpl* layer) |
| 1126 { | 1126 { |
| 1127 LayerImpl* currentLayer = layer; | 1127 LayerImpl* currentLayer = layer; |
| 1128 | 1128 |
| 1129 // Walk up the layer tree and hit-test any renderSurfaces and any layer clip
Rects that are active. | 1129 // Walk up the layer tree and hit-test any renderSurfaces and any layer clip
Rects that are active. |
| 1130 while (currentLayer) { | 1130 while (currentLayer) { |
| 1131 if (currentLayer->renderSurface() && !pointHitsRect(screenSpacePoint, cu
rrentLayer->renderSurface()->screen_space_transform(), currentLayer->renderSurfa
ce()->content_rect())) | 1131 if (currentLayer->render_surface() && !pointHitsRect(screenSpacePoint, c
urrentLayer->render_surface()->screen_space_transform(), currentLayer->render_su
rface()->content_rect())) |
| 1132 return true; | 1132 return true; |
| 1133 | 1133 |
| 1134 // Note that drawableContentRects are actually in targetSurface space, s
o the transform we | 1134 // Note that drawableContentRects are actually in targetSurface space, s
o the transform we |
| 1135 // have to provide is the target surface's screenSpaceTransform. | 1135 // have to provide is the target surface's screenSpaceTransform. |
| 1136 LayerImpl* renderTarget = currentLayer->renderTarget(); | 1136 LayerImpl* renderTarget = currentLayer->render_target(); |
| 1137 if (layerClipsSubtree(currentLayer) && !pointHitsRect(screenSpacePoint,
renderTarget->renderSurface()->screen_space_transform(), currentLayer->drawableC
ontentRect())) | 1137 if (layerClipsSubtree(currentLayer) && !pointHitsRect(screenSpacePoint,
renderTarget->render_surface()->screen_space_transform(), currentLayer->drawable
_content_rect())) |
| 1138 return true; | 1138 return true; |
| 1139 | 1139 |
| 1140 currentLayer = currentLayer->parent(); | 1140 currentLayer = currentLayer->parent(); |
| 1141 } | 1141 } |
| 1142 | 1142 |
| 1143 // If we have finished walking all ancestors without having already exited,
then the point is not clipped by any ancestors. | 1143 // If we have finished walking all ancestors without having already exited,
then the point is not clipped by any ancestors. |
| 1144 return false; | 1144 return false; |
| 1145 } | 1145 } |
| 1146 | 1146 |
| 1147 LayerImpl* LayerTreeHostCommon::findLayerThatIsHitByPoint(const gfx::PointF& scr
eenSpacePoint, const std::vector<LayerImpl*>& renderSurfaceLayerList) | 1147 LayerImpl* LayerTreeHostCommon::findLayerThatIsHitByPoint(const gfx::PointF& scr
eenSpacePoint, const std::vector<LayerImpl*>& renderSurfaceLayerList) |
| 1148 { | 1148 { |
| 1149 LayerImpl* foundLayer = 0; | 1149 LayerImpl* foundLayer = 0; |
| 1150 | 1150 |
| 1151 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl,
LayerIteratorActions::FrontToBack> LayerIteratorType; | 1151 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl,
LayerIteratorActions::FrontToBack> LayerIteratorType; |
| 1152 LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList); | 1152 LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList); |
| 1153 | 1153 |
| 1154 for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList
); it != end; ++it) { | 1154 for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList
); it != end; ++it) { |
| 1155 // We don't want to consider renderSurfaces for hit testing. | 1155 // We don't want to consider renderSurfaces for hit testing. |
| 1156 if (!it.representsItself()) | 1156 if (!it.representsItself()) |
| 1157 continue; | 1157 continue; |
| 1158 | 1158 |
| 1159 LayerImpl* currentLayer = (*it); | 1159 LayerImpl* currentLayer = (*it); |
| 1160 | 1160 |
| 1161 gfx::RectF contentRect(gfx::PointF(), currentLayer->contentBounds()); | 1161 gfx::RectF contentRect(gfx::PointF(), currentLayer->content_bounds()); |
| 1162 if (!pointHitsRect(screenSpacePoint, currentLayer->screenSpaceTransform(
), contentRect)) | 1162 if (!pointHitsRect(screenSpacePoint, currentLayer->screen_space_transfor
m(), contentRect)) |
| 1163 continue; | 1163 continue; |
| 1164 | 1164 |
| 1165 // At this point, we think the point does hit the layer, but we need to
walk up | 1165 // At this point, we think the point does hit the layer, but we need to
walk up |
| 1166 // the parents to ensure that the layer was not clipped in such a way th
at the | 1166 // the parents to ensure that the layer was not clipped in such a way th
at the |
| 1167 // hit point actually should not hit the layer. | 1167 // hit point actually should not hit the layer. |
| 1168 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, currentLayer)) | 1168 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, currentLayer)) |
| 1169 continue; | 1169 continue; |
| 1170 | 1170 |
| 1171 // Skip the HUD layer. | 1171 // Skip the HUD layer. |
| 1172 if (currentLayer == currentLayer->layerTreeImpl()->hud_layer()) | 1172 if (currentLayer == currentLayer->layer_tree_impl()->hud_layer()) |
| 1173 continue; | 1173 continue; |
| 1174 | 1174 |
| 1175 foundLayer = currentLayer; | 1175 foundLayer = currentLayer; |
| 1176 break; | 1176 break; |
| 1177 } | 1177 } |
| 1178 | 1178 |
| 1179 // This can potentially return 0, which means the screenSpacePoint did not s
uccessfully hit test any layers, not even the root layer. | 1179 // This can potentially return 0, which means the screenSpacePoint did not s
uccessfully hit test any layers, not even the root layer. |
| 1180 return foundLayer; | 1180 return foundLayer; |
| 1181 } | 1181 } |
| 1182 | 1182 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1199 | 1199 |
| 1200 foundLayer = currentLayer; | 1200 foundLayer = currentLayer; |
| 1201 break; | 1201 break; |
| 1202 } | 1202 } |
| 1203 | 1203 |
| 1204 // This can potentially return 0, which means the screenSpacePoint did not s
uccessfully hit test any layers, not even the root layer. | 1204 // This can potentially return 0, which means the screenSpacePoint did not s
uccessfully hit test any layers, not even the root layer. |
| 1205 return foundLayer; | 1205 return foundLayer; |
| 1206 } | 1206 } |
| 1207 | 1207 |
| 1208 bool LayerTreeHostCommon::layerHasTouchEventHandlersAt(const gfx::PointF& screen
SpacePoint, LayerImpl* layerImpl) { | 1208 bool LayerTreeHostCommon::layerHasTouchEventHandlersAt(const gfx::PointF& screen
SpacePoint, LayerImpl* layerImpl) { |
| 1209 if (layerImpl->touchEventHandlerRegion().IsEmpty()) | 1209 if (layerImpl->touch_event_handler_region().IsEmpty()) |
| 1210 return false; | 1210 return false; |
| 1211 | 1211 |
| 1212 if (!pointHitsRegion(screenSpacePoint, layerImpl->screenSpaceTransform(), laye
rImpl->touchEventHandlerRegion(), layerImpl->contentsScaleX(), layerImpl->conten
tsScaleY())) | 1212 if (!pointHitsRegion(screenSpacePoint, layerImpl->screen_space_transform(), la
yerImpl->touch_event_handler_region(), layerImpl->contents_scale_x(), layerImpl-
>contents_scale_y())) |
| 1213 return false;; | 1213 return false;; |
| 1214 | 1214 |
| 1215 // At this point, we think the point does hit the touch event handler region o
n the layer, but we need to walk up | 1215 // At this point, we think the point does hit the touch event handler region o
n the layer, but we need to walk up |
| 1216 // the parents to ensure that the layer was not clipped in such a way that the | 1216 // the parents to ensure that the layer was not clipped in such a way that the |
| 1217 // hit point actually should not hit the layer. | 1217 // hit point actually should not hit the layer. |
| 1218 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) | 1218 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) |
| 1219 return false; | 1219 return false; |
| 1220 | 1220 |
| 1221 return true; | 1221 return true; |
| 1222 } | 1222 } |
| 1223 } // namespace cc | 1223 } // namespace cc |
| OLD | NEW |