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 | 5 |
6 #include "config.h" | 6 #include "config.h" |
7 | 7 |
8 #include "CCLayerTreeHostCommon.h" | 8 #include "CCLayerTreeHostCommon.h" |
9 | 9 |
10 #include "CCLayerImpl.h" | 10 #include "CCLayerImpl.h" |
11 #include "CCLayerIterator.h" | 11 #include "CCLayerIterator.h" |
12 #include "CCLayerSorter.h" | 12 #include "CCLayerSorter.h" |
13 #include "CCMathUtil.h" | 13 #include "CCMathUtil.h" |
14 #include "CCRenderSurface.h" | 14 #include "CCRenderSurface.h" |
15 #include "FloatQuad.h" | 15 #include "FloatQuad.h" |
16 #include "IntRect.h" | 16 #include "IntRect.h" |
17 #include "LayerChromium.h" | 17 #include "LayerChromium.h" |
18 #include "RenderSurfaceChromium.h" | 18 #include "RenderSurfaceChromium.h" |
| 19 #include <algorithm> |
19 #include <public/WebTransformationMatrix.h> | 20 #include <public/WebTransformationMatrix.h> |
20 | 21 |
21 using WebKit::WebTransformationMatrix; | 22 using WebKit::WebTransformationMatrix; |
22 | 23 |
23 namespace cc { | 24 namespace cc { |
24 | 25 |
25 CCScrollAndScaleSet::CCScrollAndScaleSet() | 26 CCScrollAndScaleSet::CCScrollAndScaleSet() |
26 { | 27 { |
27 } | 28 } |
28 | 29 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 // The adjustment allows us to continue using the scrollCompensation on the
next surface. | 338 // The adjustment allows us to continue using the scrollCompensation on the
next surface. |
338 // Step 1 (right-most in the math): transform from the new surface to the o
riginal ancestor surface | 339 // Step 1 (right-most in the math): transform from the new surface to the o
riginal ancestor surface |
339 // Step 2: apply the scroll compensation | 340 // Step 2: apply the scroll compensation |
340 // Step 3: transform back to the new surface. | 341 // Step 3: transform back to the new surface. |
341 if (layer->renderSurface() && !nextScrollCompensationMatrix.isIdentity()) | 342 if (layer->renderSurface() && !nextScrollCompensationMatrix.isIdentity()) |
342 nextScrollCompensationMatrix = layer->renderSurface()->drawTransform().i
nverse() * nextScrollCompensationMatrix * layer->renderSurface()->drawTransform(
); | 343 nextScrollCompensationMatrix = layer->renderSurface()->drawTransform().i
nverse() * nextScrollCompensationMatrix * layer->renderSurface()->drawTransform(
); |
343 | 344 |
344 return nextScrollCompensationMatrix; | 345 return nextScrollCompensationMatrix; |
345 } | 346 } |
346 | 347 |
| 348 // There is no contentsScale on impl thread. |
| 349 static inline void updateLayerContentsScale(CCLayerImpl*, const WebTransformatio
nMatrix&, float, float) { } |
| 350 |
| 351 static inline void updateLayerContentsScale(LayerChromium* layer, const WebTrans
formationMatrix& combinedTransform, float deviceScaleFactor, float pageScaleFact
or) |
| 352 { |
| 353 float cssScale = layer->initialCssScale(); |
| 354 if (!cssScale) { |
| 355 FloatPoint transformScale = CCMathUtil::computeTransform2dScaleComponent
s(combinedTransform); |
| 356 float combinedScale = std::max(transformScale.x(), transformScale.y()); |
| 357 cssScale = combinedScale / deviceScaleFactor; |
| 358 if (!layer->boundsContainPageScale()) |
| 359 cssScale /= pageScaleFactor; |
| 360 layer->setInitialCssScale(cssScale); |
| 361 } |
| 362 |
| 363 float contentsScale = cssScale * deviceScaleFactor; |
| 364 if (!layer->boundsContainPageScale()) |
| 365 contentsScale *= pageScaleFactor; |
| 366 layer->setContentsScale(contentsScale); |
| 367 |
| 368 LayerChromium* maskLayer = layer->maskLayer(); |
| 369 if (maskLayer) |
| 370 maskLayer->setContentsScale(contentsScale); |
| 371 |
| 372 LayerChromium* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLaye
r()->maskLayer() : 0; |
| 373 if (replicaMaskLayer) |
| 374 replicaMaskLayer->setContentsScale(contentsScale); |
| 375 } |
| 376 |
347 // Should be called just before the recursive calculateDrawTransformsInternal(). | 377 // Should be called just before the recursive calculateDrawTransformsInternal(). |
348 template<typename LayerType, typename LayerList> | 378 template<typename LayerType, typename LayerList> |
349 void setupRootLayerAndSurfaceForRecursion(LayerType* rootLayer, LayerList& rende
rSurfaceLayerList, const IntSize& deviceViewportSize) | 379 void setupRootLayerAndSurfaceForRecursion(LayerType* rootLayer, LayerList& rende
rSurfaceLayerList, const IntSize& deviceViewportSize) |
350 { | 380 { |
351 if (!rootLayer->renderSurface()) | 381 if (!rootLayer->renderSurface()) |
352 rootLayer->createRenderSurface(); | 382 rootLayer->createRenderSurface(); |
353 | 383 |
354 rootLayer->renderSurface()->setContentRect(IntRect(IntPoint::zero(), deviceV
iewportSize)); | 384 rootLayer->renderSurface()->setContentRect(IntRect(IntPoint::zero(), deviceV
iewportSize)); |
355 rootLayer->renderSurface()->clearLayerLists(); | 385 rootLayer->renderSurface()->clearLayerLists(); |
356 | 386 |
357 ASSERT(renderSurfaceLayerList.empty()); | 387 ASSERT(renderSurfaceLayerList.empty()); |
358 renderSurfaceLayerList.push_back(rootLayer); | 388 renderSurfaceLayerList.push_back(rootLayer); |
359 } | 389 } |
360 | 390 |
361 // Recursively walks the layer tree starting at the given node and computes all
the | 391 // Recursively walks the layer tree starting at the given node and computes all
the |
362 // necessary transformations, clipRects, render surfaces, etc. | 392 // necessary transformations, clipRects, render surfaces, etc. |
363 template<typename LayerType, typename LayerList, typename RenderSurfaceType, typ
ename LayerSorter> | 393 template<typename LayerType, typename LayerList, typename RenderSurfaceType, typ
ename LayerSorter> |
364 static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
er, const WebTransformationMatrix& parentMatrix, | 394 static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
er, const WebTransformationMatrix& parentMatrix, |
365 const WebTransformationMatrix& fullHierarchyMatrix, const WebTransformationM
atrix& currentScrollCompensationMatrix, | 395 const WebTransformationMatrix& fullHierarchyMatrix, const WebTransformationM
atrix& currentScrollCompensationMatrix, |
366 const IntRect& clipRectFromAncestor, bool ancestorClipsSubtree, | 396 const IntRect& clipRectFromAncestor, bool ancestorClipsSubtree, |
367 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL
ayerList, LayerList& layerList, | 397 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL
ayerList, LayerList& layerList, |
368 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, IntRe
ct& drawableContentRectOfSubtree) | 398 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float
pageScaleFactor, IntRect& drawableContentRectOfSubtree) |
369 { | 399 { |
370 // This function computes the new matrix transformations recursively for thi
s | 400 // This function computes the new matrix transformations recursively for thi
s |
371 // layer and all its descendants. It also computes the appropriate render su
rfaces. | 401 // layer and all its descendants. It also computes the appropriate render su
rfaces. |
372 // Some important points to remember: | 402 // Some important points to remember: |
373 // | 403 // |
374 // 0. Here, transforms are notated in Matrix x Vector order, and in words we
describe what | 404 // 0. Here, transforms are notated in Matrix x Vector order, and in words we
describe what |
375 // the transform does from left to right. | 405 // the transform does from left to right. |
376 // | 406 // |
377 // 1. In our terminology, the "layer origin" refers to the top-left corner o
f a layer, and the | 407 // 1. In our terminology, the "layer origin" refers to the top-left corner o
f a layer, and the |
378 // positive Y-axis points downwards. This interpretation is valid because
the orthographic | 408 // positive Y-axis points downwards. This interpretation is valid because
the orthographic |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 if (layer->parent() && layer->parent()->preserves3D()) { | 493 if (layer->parent() && layer->parent()->preserves3D()) { |
464 drawOpacity *= layer->parent()->drawOpacity(); | 494 drawOpacity *= layer->parent()->drawOpacity(); |
465 drawOpacityIsAnimating |= layer->parent()->drawOpacityIsAnimating(); | 495 drawOpacityIsAnimating |= layer->parent()->drawOpacityIsAnimating(); |
466 } | 496 } |
467 | 497 |
468 IntSize bounds = layer->bounds(); | 498 IntSize bounds = layer->bounds(); |
469 FloatPoint anchorPoint = layer->anchorPoint(); | 499 FloatPoint anchorPoint = layer->anchorPoint(); |
470 FloatPoint position = layer->position() - layer->scrollDelta(); | 500 FloatPoint position = layer->position() - layer->scrollDelta(); |
471 | 501 |
472 WebTransformationMatrix layerLocalTransform; | 502 WebTransformationMatrix layerLocalTransform; |
473 // LT = M[impl transformation] | 503 // LT = Tr[origin] * Tr[origin2anchor] |
474 layerLocalTransform.multiply(layer->implTransform()); | |
475 // LT = M[impl transformation] * Tr[origin] * Tr[origin2anchor] | |
476 layerLocalTransform.translate3d(position.x() + anchorPoint.x() * bounds.widt
h(), position.y() + anchorPoint.y() * bounds.height(), layer->anchorPointZ()); | 504 layerLocalTransform.translate3d(position.x() + anchorPoint.x() * bounds.widt
h(), position.y() + anchorPoint.y() * bounds.height(), layer->anchorPointZ()); |
477 // LT = M[impl transformation] * Tr[origin] * Tr[origin2anchor] * M[layer] | 505 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] |
478 layerLocalTransform.multiply(layer->transform()); | 506 layerLocalTransform.multiply(layer->transform()); |
479 // LT = S[impl transformation] * Tr[origin] * Tr[origin2anchor] * M[layer] *
Tr[anchor2origin] | 507 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2origin] |
480 layerLocalTransform.translate3d(-anchorPoint.x() * bounds.width(), -anchorPo
int.y() * bounds.height(), -layer->anchorPointZ()); | 508 layerLocalTransform.translate3d(-anchorPoint.x() * bounds.width(), -anchorPo
int.y() * bounds.height(), -layer->anchorPointZ()); |
481 | 509 |
482 WebTransformationMatrix combinedTransform = parentMatrix; | 510 WebTransformationMatrix combinedTransform = parentMatrix; |
483 combinedTransform.multiply(layerLocalTransform); | 511 combinedTransform.multiply(layerLocalTransform); |
484 | 512 |
| 513 // The layer's contentsSize is determined from the combinedTransform, which
then informs the |
| 514 // layer's drawTransform. |
| 515 updateLayerContentsScale(layer, combinedTransform, deviceScaleFactor, pageSc
aleFactor); |
| 516 |
| 517 // If there is a tranformation from the impl thread then it should be at the |
| 518 // start of the combinedTransform, but we don't want it to affect the conten
tsScale. |
| 519 combinedTransform = layer->implTransform() * combinedTransform; |
| 520 |
485 if (layer->fixedToContainerLayer()) { | 521 if (layer->fixedToContainerLayer()) { |
486 // Special case: this layer is a composited fixed-position layer; we nee
d to | 522 // Special case: this layer is a composited fixed-position layer; we nee
d to |
487 // explicitly compensate for all ancestors' nonzero scrollDeltas to keep
this layer | 523 // explicitly compensate for all ancestors' nonzero scrollDeltas to keep
this layer |
488 // fixed correctly. | 524 // fixed correctly. |
489 combinedTransform = currentScrollCompensationMatrix * combinedTransform; | 525 combinedTransform = currentScrollCompensationMatrix * combinedTransform; |
490 } | 526 } |
491 | 527 |
492 // The drawTransform that gets computed below is effectively the layer's dra
wTransform, unless | 528 // The drawTransform that gets computed below is effectively the layer's dra
wTransform, unless |
493 // the layer itself creates a renderSurface. In that case, the renderSurface
re-parents the transforms. | 529 // the layer itself creates a renderSurface. In that case, the renderSurface
re-parents the transforms. |
494 WebTransformationMatrix drawTransform = combinedTransform; | 530 WebTransformationMatrix drawTransform = combinedTransform; |
(...skipping 17 matching lines...) Expand all Loading... |
512 animatingTransformToScreen |= layer->parent()->screenSpaceTransformIsAni
mating(); | 548 animatingTransformToScreen |= layer->parent()->screenSpaceTransformIsAni
mating(); |
513 } | 549 } |
514 | 550 |
515 FloatRect contentRect(FloatPoint(), layer->contentBounds()); | 551 FloatRect contentRect(FloatPoint(), layer->contentBounds()); |
516 | 552 |
517 // fullHierarchyMatrix is the matrix that transforms objects between screen
space (except projection matrix) and the most recent RenderSurface's space. | 553 // fullHierarchyMatrix is the matrix that transforms objects between screen
space (except projection matrix) and the most recent RenderSurface's space. |
518 // nextHierarchyMatrix will only change if this layer uses a new RenderSurfa
ce, otherwise remains the same. | 554 // nextHierarchyMatrix will only change if this layer uses a new RenderSurfa
ce, otherwise remains the same. |
519 WebTransformationMatrix nextHierarchyMatrix = fullHierarchyMatrix; | 555 WebTransformationMatrix nextHierarchyMatrix = fullHierarchyMatrix; |
520 WebTransformationMatrix sublayerMatrix; | 556 WebTransformationMatrix sublayerMatrix; |
521 | 557 |
| 558 FloatPoint renderSurfaceSublayerScale = CCMathUtil::computeTransform2dScaleC
omponents(combinedTransform); |
| 559 |
522 if (subtreeShouldRenderToSeparateSurface(layer, isScaleOrTranslation(combine
dTransform))) { | 560 if (subtreeShouldRenderToSeparateSurface(layer, isScaleOrTranslation(combine
dTransform))) { |
523 // Check back-face visibility before continuing with this surface and it
s subtree | 561 // Check back-face visibility before continuing with this surface and it
s subtree |
524 if (!layer->doubleSided() && transformToParentIsKnown(layer) && isSurfac
eBackFaceVisible(layer, combinedTransform)) | 562 if (!layer->doubleSided() && transformToParentIsKnown(layer) && isSurfac
eBackFaceVisible(layer, combinedTransform)) |
525 return; | 563 return; |
526 | 564 |
527 if (!layer->renderSurface()) | 565 if (!layer->renderSurface()) |
528 layer->createRenderSurface(); | 566 layer->createRenderSurface(); |
529 | 567 |
530 RenderSurfaceType* renderSurface = layer->renderSurface(); | 568 RenderSurfaceType* renderSurface = layer->renderSurface(); |
531 renderSurface->clearLayerLists(); | 569 renderSurface->clearLayerLists(); |
532 | 570 |
| 571 // The owning layer's draw transform has a scale from content to layer s
pace which we need to undo and |
| 572 // replace with a scale from the surface's subtree into layer space. |
| 573 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
| 574 drawTransform.scaleNonUniform(layer->contentBounds().width() / stati
c_cast<double>(layer->bounds().width()), |
| 575 layer->contentBounds().height() / stat
ic_cast<double>(layer->bounds().height())); |
| 576 } |
| 577 drawTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / re
nderSurfaceSublayerScale.y()); |
| 578 renderSurface->setDrawTransform(drawTransform); |
| 579 |
533 // The origin of the new surface is the upper left corner of the layer. | 580 // The origin of the new surface is the upper left corner of the layer. |
534 renderSurface->setDrawTransform(drawTransform); | |
535 WebTransformationMatrix layerDrawTransform; | 581 WebTransformationMatrix layerDrawTransform; |
536 layerDrawTransform.scale(deviceScaleFactor); | 582 layerDrawTransform.scaleNonUniform(renderSurfaceSublayerScale.x(), rende
rSurfaceSublayerScale.y()); |
537 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { | 583 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
538 layerDrawTransform.scaleNonUniform(layer->bounds().width() / static_
cast<double>(layer->contentBounds().width()), | 584 layerDrawTransform.scaleNonUniform(layer->bounds().width() / static_
cast<double>(layer->contentBounds().width()), |
539 layer->bounds().height() / static
_cast<double>(layer->contentBounds().height())); | 585 layer->bounds().height() / static
_cast<double>(layer->contentBounds().height())); |
540 } | 586 } |
541 layer->setDrawTransform(layerDrawTransform); | 587 layer->setDrawTransform(layerDrawTransform); |
542 | 588 |
| 589 // Inside the surface's subtree, we scale everything to the owning layer
's scale. |
543 // The sublayer matrix transforms centered layer rects into target | 590 // The sublayer matrix transforms centered layer rects into target |
544 // surface content space. | 591 // surface content space. |
545 sublayerMatrix.makeIdentity(); | 592 sublayerMatrix.makeIdentity(); |
546 sublayerMatrix.scale(deviceScaleFactor); | 593 sublayerMatrix.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSur
faceSublayerScale.y()); |
547 | 594 |
548 // The opacity value is moved from the layer to its surface, so that the
entire subtree properly inherits opacity. | 595 // The opacity value is moved from the layer to its surface, so that the
entire subtree properly inherits opacity. |
549 renderSurface->setDrawOpacity(drawOpacity); | 596 renderSurface->setDrawOpacity(drawOpacity); |
550 renderSurface->setDrawOpacityIsAnimating(drawOpacityIsAnimating); | 597 renderSurface->setDrawOpacityIsAnimating(drawOpacityIsAnimating); |
551 layer->setDrawOpacity(1); | 598 layer->setDrawOpacity(1); |
552 layer->setDrawOpacityIsAnimating(false); | 599 layer->setDrawOpacityIsAnimating(false); |
553 | 600 |
554 renderSurface->setTargetSurfaceTransformsAreAnimating(animatingTransform
ToTarget); | 601 renderSurface->setTargetSurfaceTransformsAreAnimating(animatingTransform
ToTarget); |
555 renderSurface->setScreenSpaceTransformsAreAnimating(animatingTransformTo
Screen); | 602 renderSurface->setScreenSpaceTransformsAreAnimating(animatingTransformTo
Screen); |
556 animatingTransformToTarget = false; | 603 animatingTransformToTarget = false; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 descendants.push_back(layer); | 695 descendants.push_back(layer); |
649 | 696 |
650 WebTransformationMatrix nextScrollCompensationMatrix = computeScrollCompensa
tionMatrixForChildren(layer, parentMatrix, currentScrollCompensationMatrix);; | 697 WebTransformationMatrix nextScrollCompensationMatrix = computeScrollCompensa
tionMatrixForChildren(layer, parentMatrix, currentScrollCompensationMatrix);; |
651 | 698 |
652 IntRect accumulatedDrawableContentRectOfChildren; | 699 IntRect accumulatedDrawableContentRectOfChildren; |
653 for (size_t i = 0; i < layer->children().size(); ++i) { | 700 for (size_t i = 0; i < layer->children().size(); ++i) { |
654 LayerType* child = CCLayerTreeHostCommon::getChildAsRawPtr(layer->childr
en(), i); | 701 LayerType* child = CCLayerTreeHostCommon::getChildAsRawPtr(layer->childr
en(), i); |
655 IntRect drawableContentRectOfChildSubtree; | 702 IntRect drawableContentRectOfChildSubtree; |
656 calculateDrawTransformsInternal<LayerType, LayerList, RenderSurfaceType,
LayerSorter>(child, rootLayer, sublayerMatrix, nextHierarchyMatrix, nextScrollC
ompensationMatrix, | 703 calculateDrawTransformsInternal<LayerType, LayerList, RenderSurfaceType,
LayerSorter>(child, rootLayer, sublayerMatrix, nextHierarchyMatrix, nextScrollC
ompensationMatrix, |
657
clipRectForSubtree, subtreeShouldBeClipped, nearestAncestorThatMov
esPixels, | 704
clipRectForSubtree, subtreeShouldBeClipped, nearestAncestorThatMov
esPixels, |
658
renderSurfaceLayerList, descendants, layerSorter, maxTextureSize,
deviceScaleFactor, drawableContentRectOfChildSubtree); | 705
renderSurfaceLayerList, descendants, layerSorter, maxTextureSize,
deviceScaleFactor, pageScaleFactor, drawableContentRectOfChildSubtree); |
659 if (!drawableContentRectOfChildSubtree.isEmpty()) { | 706 if (!drawableContentRectOfChildSubtree.isEmpty()) { |
660 accumulatedDrawableContentRectOfChildren.unite(drawableContentRectOf
ChildSubtree); | 707 accumulatedDrawableContentRectOfChildren.unite(drawableContentRectOf
ChildSubtree); |
661 if (child->renderSurface()) | 708 if (child->renderSurface()) |
662 descendants.push_back(child); | 709 descendants.push_back(child); |
663 } | 710 } |
664 } | 711 } |
665 | 712 |
666 // Compute the total drawableContentRect for this subtree (the rect is in ta
rgetSurface space) | 713 // Compute the total drawableContentRect for this subtree (the rect is in ta
rgetSurface space) |
667 IntRect localDrawableContentRectOfSubtree = accumulatedDrawableContentRectOf
Children; | 714 IntRect localDrawableContentRectOfSubtree = accumulatedDrawableContentRectOf
Children; |
668 if (layer->drawsContent()) | 715 if (layer->drawsContent()) |
(...skipping 30 matching lines...) Expand all Loading... |
699 | 746 |
700 // The RenderSurface backing texture cannot exceed the maximum supported | 747 // The RenderSurface backing texture cannot exceed the maximum supported |
701 // texture size. | 748 // texture size. |
702 clippedContentRect.setWidth(std::min(clippedContentRect.width(), maxText
ureSize)); | 749 clippedContentRect.setWidth(std::min(clippedContentRect.width(), maxText
ureSize)); |
703 clippedContentRect.setHeight(std::min(clippedContentRect.height(), maxTe
xtureSize)); | 750 clippedContentRect.setHeight(std::min(clippedContentRect.height(), maxTe
xtureSize)); |
704 | 751 |
705 if (clippedContentRect.isEmpty()) | 752 if (clippedContentRect.isEmpty()) |
706 renderSurface->clearLayerLists(); | 753 renderSurface->clearLayerLists(); |
707 | 754 |
708 renderSurface->setContentRect(clippedContentRect); | 755 renderSurface->setContentRect(clippedContentRect); |
709 renderSurface->setScreenSpaceTransform(layer->screenSpaceTransform()); | 756 |
| 757 // The owning layer's screenSpaceTransform has a scale from content to l
ayer space which we need to undo and |
| 758 // replace with a scale from the surface's subtree into layer space. |
| 759 WebTransformationMatrix screenSpaceTransform = layer->screenSpaceTransfo
rm(); |
| 760 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
| 761 screenSpaceTransform.scaleNonUniform(layer->contentBounds().width()
/ static_cast<double>(layer->bounds().width()), |
| 762 layer->contentBounds().height() / stat
ic_cast<double>(layer->bounds().height())); |
| 763 } |
| 764 screenSpaceTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(),
1 / renderSurfaceSublayerScale.y()); |
| 765 renderSurface->setScreenSpaceTransform(screenSpaceTransform); |
710 | 766 |
711 if (layer->replicaLayer()) { | 767 if (layer->replicaLayer()) { |
712 WebTransformationMatrix surfaceOriginToReplicaOriginTransform; | 768 WebTransformationMatrix surfaceOriginToReplicaOriginTransform; |
713 surfaceOriginToReplicaOriginTransform.scale(deviceScaleFactor); | 769 surfaceOriginToReplicaOriginTransform.scaleNonUniform(renderSurfaceS
ublayerScale.x(), renderSurfaceSublayerScale.y()); |
714 surfaceOriginToReplicaOriginTransform.translate(layer->replicaLayer(
)->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(), | 770 surfaceOriginToReplicaOriginTransform.translate(layer->replicaLayer(
)->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(), |
715 layer->replicaLayer(
)->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height()); | 771 layer->replicaLayer(
)->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height()); |
716 surfaceOriginToReplicaOriginTransform.multiply(layer->replicaLayer()
->transform()); | 772 surfaceOriginToReplicaOriginTransform.multiply(layer->replicaLayer()
->transform()); |
717 surfaceOriginToReplicaOriginTransform.translate(-layer->replicaLayer
()->anchorPoint().x() * bounds.width(), -layer->replicaLayer()->anchorPoint().y(
) * bounds.height()); | 773 surfaceOriginToReplicaOriginTransform.translate(-layer->replicaLayer
()->anchorPoint().x() * bounds.width(), -layer->replicaLayer()->anchorPoint().y(
) * bounds.height()); |
718 surfaceOriginToReplicaOriginTransform.scale(1 / deviceScaleFactor); | 774 surfaceOriginToReplicaOriginTransform.scaleNonUniform(1 / renderSurf
aceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y()); |
719 | 775 |
720 // Compute the replica's "originTransform" that maps from the replic
a's origin space to the target surface origin space. | 776 // Compute the replica's "originTransform" that maps from the replic
a's origin space to the target surface origin space. |
721 WebTransformationMatrix replicaOriginTransform = layer->renderSurfac
e()->drawTransform() * surfaceOriginToReplicaOriginTransform; | 777 WebTransformationMatrix replicaOriginTransform = layer->renderSurfac
e()->drawTransform() * surfaceOriginToReplicaOriginTransform; |
722 renderSurface->setReplicaDrawTransform(replicaOriginTransform); | 778 renderSurface->setReplicaDrawTransform(replicaOriginTransform); |
723 | 779 |
724 // Compute the replica's "screenSpaceTransform" that maps from the r
eplica's origin space to the screen's origin space. | 780 // Compute the replica's "screenSpaceTransform" that maps from the r
eplica's origin space to the screen's origin space. |
725 WebTransformationMatrix replicaScreenSpaceTransform = layer->renderS
urface()->screenSpaceTransform() * surfaceOriginToReplicaOriginTransform; | 781 WebTransformationMatrix replicaScreenSpaceTransform = layer->renderS
urface()->screenSpaceTransform() * surfaceOriginToReplicaOriginTransform; |
726 renderSurface->setReplicaScreenSpaceTransform(replicaScreenSpaceTran
sform); | 782 renderSurface->setReplicaScreenSpaceTransform(replicaScreenSpaceTran
sform); |
727 } | 783 } |
728 | 784 |
(...skipping 27 matching lines...) Expand all Loading... |
756 | 812 |
757 if (layer->renderSurface()) | 813 if (layer->renderSurface()) |
758 drawableContentRectOfSubtree = enclosingIntRect(layer->renderSurface()->
drawableContentRect()); | 814 drawableContentRectOfSubtree = enclosingIntRect(layer->renderSurface()->
drawableContentRect()); |
759 else | 815 else |
760 drawableContentRectOfSubtree = localDrawableContentRectOfSubtree; | 816 drawableContentRectOfSubtree = localDrawableContentRectOfSubtree; |
761 | 817 |
762 if (layer->hasContributingDelegatedRenderPasses()) | 818 if (layer->hasContributingDelegatedRenderPasses()) |
763 layer->renderTarget()->renderSurface()->addContributingDelegatedRenderPa
ssLayer(layer); | 819 layer->renderTarget()->renderSurface()->addContributingDelegatedRenderPa
ssLayer(layer); |
764 } | 820 } |
765 | 821 |
766 void CCLayerTreeHostCommon::calculateDrawTransforms(LayerChromium* rootLayer, co
nst IntSize& deviceViewportSize, float deviceScaleFactor, int maxTextureSize, st
d::vector<scoped_refptr<LayerChromium> >& renderSurfaceLayerList) | 822 void CCLayerTreeHostCommon::calculateDrawTransforms(LayerChromium* rootLayer, co
nst IntSize& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor,
int maxTextureSize, std::vector<scoped_refptr<LayerChromium> >& renderSurfaceLa
yerList) |
767 { | 823 { |
768 IntRect totalDrawableContentRect; | 824 IntRect totalDrawableContentRect; |
769 WebTransformationMatrix identityMatrix; | 825 WebTransformationMatrix identityMatrix; |
770 WebTransformationMatrix deviceScaleTransform; | 826 WebTransformationMatrix deviceScaleTransform; |
771 deviceScaleTransform.scale(deviceScaleFactor); | 827 deviceScaleTransform.scale(deviceScaleFactor); |
772 | 828 |
773 setupRootLayerAndSurfaceForRecursion<LayerChromium, std::vector<scoped_refpt
r<LayerChromium> > >(rootLayer, renderSurfaceLayerList, deviceViewportSize); | 829 setupRootLayerAndSurfaceForRecursion<LayerChromium, std::vector<scoped_refpt
r<LayerChromium> > >(rootLayer, renderSurfaceLayerList, deviceViewportSize); |
774 | 830 |
775 cc::calculateDrawTransformsInternal<LayerChromium, std::vector<scoped_refptr
<LayerChromium> >, RenderSurfaceChromium, void>(rootLayer, rootLayer, deviceScal
eTransform, identityMatrix, identityMatrix, | 831 cc::calculateDrawTransformsInternal<LayerChromium, std::vector<scoped_refptr
<LayerChromium> >, RenderSurfaceChromium, void>( |
776
rootLayer->renderSurface()->contentRect
(), true, 0, renderSurfaceLayerList, | 832 rootLayer, rootLayer, deviceScaleTransform, identityMatrix, identityMatr
ix, |
777
rootLayer->renderSurface()->layerList()
, 0, maxTextureSize, deviceScaleFactor, totalDrawableContentRect); | 833 rootLayer->renderSurface()->contentRect(), true, 0, renderSurfaceLayerLi
st, |
| 834 rootLayer->renderSurface()->layerList(), 0, maxTextureSize, |
| 835 deviceScaleFactor, pageScaleFactor, totalDrawableContentRect); |
778 } | 836 } |
779 | 837 |
780 void CCLayerTreeHostCommon::calculateDrawTransforms(CCLayerImpl* rootLayer, cons
t IntSize& deviceViewportSize, float deviceScaleFactor, CCLayerSorter* layerSort
er, int maxTextureSize, std::vector<CCLayerImpl*>& renderSurfaceLayerList) | 838 void CCLayerTreeHostCommon::calculateDrawTransforms(CCLayerImpl* rootLayer, cons
t IntSize& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, C
CLayerSorter* layerSorter, int maxTextureSize, std::vector<CCLayerImpl*>& render
SurfaceLayerList) |
781 { | 839 { |
782 IntRect totalDrawableContentRect; | 840 IntRect totalDrawableContentRect; |
783 WebTransformationMatrix identityMatrix; | 841 WebTransformationMatrix identityMatrix; |
784 WebTransformationMatrix deviceScaleTransform; | 842 WebTransformationMatrix deviceScaleTransform; |
785 deviceScaleTransform.scale(deviceScaleFactor); | 843 deviceScaleTransform.scale(deviceScaleFactor); |
786 | 844 |
787 setupRootLayerAndSurfaceForRecursion<CCLayerImpl, std::vector<CCLayerImpl*>
>(rootLayer, renderSurfaceLayerList, deviceViewportSize); | 845 setupRootLayerAndSurfaceForRecursion<CCLayerImpl, std::vector<CCLayerImpl*>
>(rootLayer, renderSurfaceLayerList, deviceViewportSize); |
788 | 846 |
789 cc::calculateDrawTransformsInternal<CCLayerImpl, std::vector<CCLayerImpl*>,
CCRenderSurface, CCLayerSorter>(rootLayer, rootLayer, deviceScaleTransform, iden
tityMatrix, identityMatrix, | 847 cc::calculateDrawTransformsInternal<CCLayerImpl, std::vector<CCLayerImpl*>,
CCRenderSurface, CCLayerSorter>( |
790
rootLayer->renderSurface()->contentRect(), true,
0, renderSurfaceLayerList, | 848 rootLayer, rootLayer, deviceScaleTransform, identityMatrix, identityMatr
ix, |
791
rootLayer->renderSurface()->layerList(), layerSo
rter, maxTextureSize, deviceScaleFactor, totalDrawableContentRect); | 849 rootLayer->renderSurface()->contentRect(), true, 0, renderSurfaceLayerLi
st, |
| 850 rootLayer->renderSurface()->layerList(), layerSorter, maxTextureSize, |
| 851 deviceScaleFactor, pageScaleFactor, totalDrawableContentRect); |
792 } | 852 } |
793 | 853 |
794 static bool pointHitsRect(const IntPoint& viewportPoint, const WebTransformation
Matrix& localSpaceToScreenSpaceTransform, FloatRect localSpaceRect) | 854 static bool pointHitsRect(const IntPoint& viewportPoint, const WebTransformation
Matrix& localSpaceToScreenSpaceTransform, FloatRect localSpaceRect) |
795 { | 855 { |
796 // If the transform is not invertible, then assume that this point doesn't h
it this rect. | 856 // If the transform is not invertible, then assume that this point doesn't h
it this rect. |
797 if (!localSpaceToScreenSpaceTransform.isInvertible()) | 857 if (!localSpaceToScreenSpaceTransform.isInvertible()) |
798 return false; | 858 return false; |
799 | 859 |
800 // Transform the hit test point from screen space to the local space of the
given rect. | 860 // Transform the hit test point from screen space to the local space of the
given rect. |
801 bool clipped = false; | 861 bool clipped = false; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 | 916 |
857 foundLayer = currentLayer; | 917 foundLayer = currentLayer; |
858 break; | 918 break; |
859 } | 919 } |
860 | 920 |
861 // This can potentially return 0, which means the viewportPoint did not succ
essfully hit test any layers, not even the root layer. | 921 // This can potentially return 0, which means the viewportPoint did not succ
essfully hit test any layers, not even the root layer. |
862 return foundLayer; | 922 return foundLayer; |
863 } | 923 } |
864 | 924 |
865 } // namespace cc | 925 } // namespace cc |
OLD | NEW |