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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 // The adjustment allows us to continue using the scrollCompensation on the
next surface. | 382 // The adjustment allows us to continue using the scrollCompensation on the
next surface. |
383 // Step 1 (right-most in the math): transform from the new surface to the o
riginal ancestor surface | 383 // Step 1 (right-most in the math): transform from the new surface to the o
riginal ancestor surface |
384 // Step 2: apply the scroll compensation | 384 // Step 2: apply the scroll compensation |
385 // Step 3: transform back to the new surface. | 385 // Step 3: transform back to the new surface. |
386 if (layer->renderSurface() && !nextScrollCompensationMatrix.IsIdentity()) | 386 if (layer->renderSurface() && !nextScrollCompensationMatrix.IsIdentity()) |
387 nextScrollCompensationMatrix = MathUtil::inverse(layer->renderSurface()-
>drawTransform()) * nextScrollCompensationMatrix * layer->renderSurface()->drawT
ransform(); | 387 nextScrollCompensationMatrix = MathUtil::inverse(layer->renderSurface()-
>drawTransform()) * nextScrollCompensationMatrix * layer->renderSurface()->drawT
ransform(); |
388 | 388 |
389 return nextScrollCompensationMatrix; | 389 return nextScrollCompensationMatrix; |
390 } | 390 } |
391 | 391 |
| 392 template<typename LayerType> |
| 393 static inline void calculateContentsScale(LayerType* layer, float contentsScale) |
| 394 { |
| 395 layer->calculateContentsScale( |
| 396 contentsScale, |
| 397 &layer->drawProperties().contents_scale_x, |
| 398 &layer->drawProperties().contents_scale_y, |
| 399 &layer->drawProperties().content_bounds); |
| 400 |
| 401 LayerType* maskLayer = layer->maskLayer(); |
| 402 if (maskLayer) |
| 403 { |
| 404 maskLayer->calculateContentsScale( |
| 405 contentsScale, |
| 406 &maskLayer->drawProperties().contents_scale_x, |
| 407 &maskLayer->drawProperties().contents_scale_y, |
| 408 &maskLayer->drawProperties().content_bounds); |
| 409 } |
| 410 |
| 411 LayerType* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLayer()-
>maskLayer() : 0; |
| 412 if (replicaMaskLayer) |
| 413 { |
| 414 replicaMaskLayer->calculateContentsScale( |
| 415 contentsScale, |
| 416 &replicaMaskLayer->drawProperties().contents_scale_x, |
| 417 &replicaMaskLayer->drawProperties().contents_scale_y, |
| 418 &replicaMaskLayer->drawProperties().content_bounds); |
| 419 } |
| 420 } |
| 421 |
392 static inline void updateLayerContentsScale(LayerImpl* layer, const gfx::Transfo
rm& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool anim
atingTransformToScreen) | 422 static inline void updateLayerContentsScale(LayerImpl* layer, const gfx::Transfo
rm& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool anim
atingTransformToScreen) |
393 { | 423 { |
| 424 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleComponents(
combinedTransform, deviceScaleFactor * pageScaleFactor); |
| 425 float contentsScale = std::max(transformScale.x(), transformScale.y()); |
| 426 calculateContentsScale(layer, contentsScale); |
394 } | 427 } |
395 | 428 |
396 static inline void updateLayerContentsScale(Layer* layer, const gfx::Transform&
combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animatin
gTransformToScreen) | 429 static inline void updateLayerContentsScale(Layer* layer, const gfx::Transform&
combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animatin
gTransformToScreen) |
397 { | 430 { |
398 float rasterScale = layer->rasterScale(); | 431 float rasterScale = layer->rasterScale(); |
399 if (!rasterScale) { | 432 if (!rasterScale) { |
400 rasterScale = 1; | 433 rasterScale = 1; |
401 | 434 |
402 if (!animatingTransformToScreen && layer->automaticallyComputeRasterScal
e()) { | 435 if (!animatingTransformToScreen && layer->automaticallyComputeRasterScal
e()) { |
403 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleCom
ponents(combinedTransform, 0.f); | 436 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleCom
ponents(combinedTransform, 0.f); |
404 float combinedScale = std::max(transformScale.x(), transformScale.y(
)); | 437 float combinedScale = std::max(transformScale.x(), transformScale.y(
)); |
405 rasterScale = combinedScale / deviceScaleFactor; | 438 rasterScale = combinedScale / deviceScaleFactor; |
406 if (!layer->boundsContainPageScale()) | 439 if (!layer->boundsContainPageScale()) |
407 rasterScale /= pageScaleFactor; | 440 rasterScale /= pageScaleFactor; |
408 // Prevent scale factors below 1 from being used or saved. | 441 // Prevent scale factors below 1 from being used or saved. |
409 if (rasterScale < 1) | 442 if (rasterScale < 1) |
410 rasterScale = 1; | 443 rasterScale = 1; |
411 else | 444 else |
412 layer->setRasterScale(rasterScale); | 445 layer->setRasterScale(rasterScale); |
413 } | 446 } |
414 } | 447 } |
415 | 448 |
416 float contentsScale = rasterScale * deviceScaleFactor; | 449 float contentsScale = rasterScale * deviceScaleFactor; |
417 if (!layer->boundsContainPageScale()) | 450 if (!layer->boundsContainPageScale()) |
418 contentsScale *= pageScaleFactor; | 451 contentsScale *= pageScaleFactor; |
419 layer->calculateContentsScale( | |
420 contentsScale, | |
421 &layer->drawProperties().contents_scale_x, | |
422 &layer->drawProperties().contents_scale_y, | |
423 &layer->drawProperties().content_bounds); | |
424 | 452 |
425 Layer* maskLayer = layer->maskLayer(); | 453 calculateContentsScale(layer, contentsScale); |
426 if (maskLayer) | |
427 { | |
428 maskLayer->calculateContentsScale( | |
429 contentsScale, | |
430 &maskLayer->drawProperties().contents_scale_x, | |
431 &maskLayer->drawProperties().contents_scale_y, | |
432 &maskLayer->drawProperties().content_bounds); | |
433 } | |
434 | |
435 Layer* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLayer()->mas
kLayer() : 0; | |
436 if (replicaMaskLayer) | |
437 { | |
438 replicaMaskLayer->calculateContentsScale( | |
439 contentsScale, | |
440 &replicaMaskLayer->drawProperties().contents_scale_x, | |
441 &replicaMaskLayer->drawProperties().contents_scale_y, | |
442 &replicaMaskLayer->drawProperties().content_bounds); | |
443 } | |
444 } | 454 } |
445 | 455 |
446 template<typename LayerType, typename LayerList> | 456 template<typename LayerType, typename LayerList> |
447 static inline void removeSurfaceForEarlyExit(LayerType* layerToRemove, LayerList
& renderSurfaceLayerList) | 457 static inline void removeSurfaceForEarlyExit(LayerType* layerToRemove, LayerList
& renderSurfaceLayerList) |
448 { | 458 { |
449 DCHECK(layerToRemove->renderSurface()); | 459 DCHECK(layerToRemove->renderSurface()); |
450 // Technically, we know that the layer we want to remove should be | 460 // Technically, we know that the layer we want to remove should be |
451 // at the back of the renderSurfaceLayerList. However, we have had | 461 // at the back of the renderSurfaceLayerList. However, we have had |
452 // bugs before that added unnecessary layers here | 462 // bugs before that added unnecessary layers here |
453 // (https://bugs.webkit.org/show_bug.cgi?id=74147), but that causes | 463 // (https://bugs.webkit.org/show_bug.cgi?id=74147), but that causes |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 | 1138 |
1129 // At this point, we think the point does hit the touch event handler region o
n the layer, but we need to walk up | 1139 // At this point, we think the point does hit the touch event handler region o
n the layer, but we need to walk up |
1130 // the parents to ensure that the layer was not clipped in such a way that the | 1140 // the parents to ensure that the layer was not clipped in such a way that the |
1131 // hit point actually should not hit the layer. | 1141 // hit point actually should not hit the layer. |
1132 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) | 1142 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) |
1133 return false; | 1143 return false; |
1134 | 1144 |
1135 return true; | 1145 return true; |
1136 } | 1146 } |
1137 } // namespace cc | 1147 } // namespace cc |
OLD | NEW |