Chromium Code Reviews| 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/layer.h" | 10 #include "cc/layer.h" |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 // The adjustment allows us to continue using the scrollCompensation on the next surface. | 357 // The adjustment allows us to continue using the scrollCompensation on the next surface. |
| 358 // Step 1 (right-most in the math): transform from the new surface to the o riginal ancestor surface | 358 // Step 1 (right-most in the math): transform from the new surface to the o riginal ancestor surface |
| 359 // Step 2: apply the scroll compensation | 359 // Step 2: apply the scroll compensation |
| 360 // Step 3: transform back to the new surface. | 360 // Step 3: transform back to the new surface. |
| 361 if (layer->renderSurface() && !nextScrollCompensationMatrix.IsIdentity()) | 361 if (layer->renderSurface() && !nextScrollCompensationMatrix.IsIdentity()) |
| 362 nextScrollCompensationMatrix = MathUtil::inverse(layer->renderSurface()- >drawTransform()) * nextScrollCompensationMatrix * layer->renderSurface()->drawT ransform(); | 362 nextScrollCompensationMatrix = MathUtil::inverse(layer->renderSurface()- >drawTransform()) * nextScrollCompensationMatrix * layer->renderSurface()->drawT ransform(); |
| 363 | 363 |
| 364 return nextScrollCompensationMatrix; | 364 return nextScrollCompensationMatrix; |
| 365 } | 365 } |
| 366 | 366 |
| 367 // There is no contentsScale on impl thread. | 367 static inline void updateLayerContentsScale(LayerImpl* layer, const gfx::Transfo rm& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool anim atingTransformToScreen) |
|
shawnsingh
2012/12/11 21:54:05
"update" was actually a word that really made me f
enne (OOO)
2012/12/11 23:23:44
Sure, I can rename this. Why is the word update p
| |
| 368 static inline void updateLayerContentsScale(LayerImpl*, const gfx::Transform&, f loat, float, bool) { } | 368 { |
| 369 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleComponents( combinedTransform); | |
| 370 float contentsScale = std::max(transformScale.x(), transformScale.y()); | |
| 371 layer->setIdealContentsScale(contentsScale); | |
| 372 | |
| 373 LayerImpl* maskLayer = layer->maskLayer(); | |
| 374 if (maskLayer) | |
| 375 maskLayer->setIdealContentsScale(contentsScale); | |
| 376 | |
| 377 LayerImpl* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLayer()- >maskLayer() : 0; | |
| 378 if (replicaMaskLayer) | |
| 379 replicaMaskLayer->setIdealContentsScale(contentsScale); | |
| 380 } | |
| 369 | 381 |
| 370 static inline void updateLayerContentsScale(Layer* layer, const gfx::Transform& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animatin gTransformToScreen) | 382 static inline void updateLayerContentsScale(Layer* layer, const gfx::Transform& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animatin gTransformToScreen) |
| 371 { | 383 { |
| 372 float rasterScale = layer->rasterScale(); | 384 float rasterScale = layer->rasterScale(); |
| 373 if (!rasterScale) { | 385 if (!rasterScale) { |
| 374 rasterScale = 1; | 386 rasterScale = 1; |
| 375 | 387 |
| 376 if (!animatingTransformToScreen && layer->automaticallyComputeRasterScal e()) { | 388 if (!animatingTransformToScreen && layer->automaticallyComputeRasterScal e()) { |
| 377 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleCom ponents(combinedTransform); | 389 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleCom ponents(combinedTransform); |
| 378 float combinedScale = std::max(transformScale.x(), transformScale.y( )); | 390 float combinedScale = std::max(transformScale.x(), transformScale.y( )); |
| 379 rasterScale = combinedScale / deviceScaleFactor; | 391 rasterScale = combinedScale / deviceScaleFactor; |
| 380 if (!layer->boundsContainPageScale()) | 392 if (!layer->boundsContainPageScale()) |
| 381 rasterScale /= pageScaleFactor; | 393 rasterScale /= pageScaleFactor; |
| 382 // Prevent scale factors below 1 from being used or saved. | 394 // Prevent scale factors below 1 from being used or saved. |
| 383 if (rasterScale < 1) | 395 if (rasterScale < 1) |
| 384 rasterScale = 1; | 396 rasterScale = 1; |
| 385 else | 397 else |
| 386 layer->setRasterScale(rasterScale); | 398 layer->setRasterScale(rasterScale); |
| 387 } | 399 } |
| 388 } | 400 } |
| 389 | 401 |
| 390 float contentsScale = rasterScale * deviceScaleFactor; | 402 float contentsScale = rasterScale * deviceScaleFactor; |
| 391 if (!layer->boundsContainPageScale()) | 403 if (!layer->boundsContainPageScale()) |
| 392 contentsScale *= pageScaleFactor; | 404 contentsScale *= pageScaleFactor; |
| 393 layer->setContentsScale(contentsScale); | 405 layer->setIdealContentsScale(contentsScale); |
| 394 | 406 |
| 395 Layer* maskLayer = layer->maskLayer(); | 407 Layer* maskLayer = layer->maskLayer(); |
| 396 if (maskLayer) | 408 if (maskLayer) |
| 397 maskLayer->setContentsScale(contentsScale); | 409 maskLayer->setIdealContentsScale(contentsScale); |
| 398 | 410 |
| 399 Layer* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLayer()->mas kLayer() : 0; | 411 Layer* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLayer()->mas kLayer() : 0; |
| 400 if (replicaMaskLayer) | 412 if (replicaMaskLayer) |
| 401 replicaMaskLayer->setContentsScale(contentsScale); | 413 replicaMaskLayer->setIdealContentsScale(contentsScale); |
| 402 } | 414 } |
| 403 | 415 |
| 404 // Recursively walks the layer tree starting at the given node and computes all the | 416 // Recursively walks the layer tree starting at the given node and computes all the |
| 405 // necessary transformations, clipRects, render surfaces, etc. | 417 // necessary transformations, clipRects, render surfaces, etc. |
| 406 template<typename LayerType, typename LayerList, typename RenderSurfaceType> | 418 template<typename LayerType, typename LayerList, typename RenderSurfaceType> |
| 407 static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo rm& parentMatrix, | 419 static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo rm& parentMatrix, |
| 408 const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScro llCompensationMatrix, | 420 const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScro llCompensationMatrix, |
| 409 const gfx::Rect& clipRectFromAncestor, bool ancestorClipsSubtree, | 421 const gfx::Rect& clipRectFromAncestor, bool ancestorClipsSubtree, |
| 410 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL ayerList, LayerList& layerList, | 422 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL ayerList, LayerList& layerList, |
| 411 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, gfx::Rect& drawableContentRectOfSubtree) | 423 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, gfx::Rect& drawableContentRectOfSubtree) |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1013 | 1025 |
| 1014 foundLayer = currentLayer; | 1026 foundLayer = currentLayer; |
| 1015 break; | 1027 break; |
| 1016 } | 1028 } |
| 1017 | 1029 |
| 1018 // This can potentially return 0, which means the screenSpacePoint did not s uccessfully hit test any layers, not even the root layer. | 1030 // This can potentially return 0, which means the screenSpacePoint did not s uccessfully hit test any layers, not even the root layer. |
| 1019 return foundLayer; | 1031 return foundLayer; |
| 1020 } | 1032 } |
| 1021 | 1033 |
| 1022 } // namespace cc | 1034 } // namespace cc |
| OLD | NEW |