Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: cc/layer_tree_host_common.cc

Issue 11312226: cc: Layer that have empty bounds should still have their contentsScale applied in their transforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/layer.h" 7 #include "cc/layer.h"
8 #include "cc/layer_impl.h" 8 #include "cc/layer_impl.h"
9 #include "cc/layer_iterator.h" 9 #include "cc/layer_iterator.h"
10 #include "cc/layer_sorter.h" 10 #include "cc/layer_sorter.h"
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 if (layer->fixedToContainerLayer()) { 524 if (layer->fixedToContainerLayer()) {
525 // Special case: this layer is a composited fixed-position layer; we nee d to 525 // Special case: this layer is a composited fixed-position layer; we nee d to
526 // explicitly compensate for all ancestors' nonzero scrollDeltas to keep this layer 526 // explicitly compensate for all ancestors' nonzero scrollDeltas to keep this layer
527 // fixed correctly. 527 // fixed correctly.
528 combinedTransform = currentScrollCompensationMatrix * combinedTransform; 528 combinedTransform = currentScrollCompensationMatrix * combinedTransform;
529 } 529 }
530 530
531 // The drawTransform that gets computed below is effectively the layer's dra wTransform, unless 531 // The drawTransform that gets computed below is effectively the layer's dra wTransform, unless
532 // the layer itself creates a renderSurface. In that case, the renderSurface re-parents the transforms. 532 // the layer itself creates a renderSurface. In that case, the renderSurface re-parents the transforms.
533 WebTransformationMatrix drawTransform = combinedTransform; 533 WebTransformationMatrix drawTransform = combinedTransform;
534 if (!layer->contentBounds().IsEmpty() && !layer->bounds().IsEmpty()) { 534 // M[draw] = M[parent] * LT * S[layer2content]
535 // M[draw] = M[parent] * LT * S[layer2content] 535 drawTransform.scaleNonUniform(1.0 / layer->contentsScaleX(), 1.0 / layer->co ntentsScaleY());
536 drawTransform.scaleNonUniform(1.0 / layer->contentsScaleX(),
537 1.0 / layer->contentsScaleY());
538 }
539 536
540 // layerScreenSpaceTransform represents the transform between root layer's " screen space" and local content space. 537 // layerScreenSpaceTransform represents the transform between root layer's " screen space" and local content space.
541 WebTransformationMatrix layerScreenSpaceTransform = fullHierarchyMatrix; 538 WebTransformationMatrix layerScreenSpaceTransform = fullHierarchyMatrix;
542 if (!layer->preserves3D()) 539 if (!layer->preserves3D())
543 MathUtil::flattenTransformTo2d(layerScreenSpaceTransform); 540 MathUtil::flattenTransformTo2d(layerScreenSpaceTransform);
544 layerScreenSpaceTransform.multiply(drawTransform); 541 layerScreenSpaceTransform.multiply(drawTransform);
545 layer->setScreenSpaceTransform(layerScreenSpaceTransform); 542 layer->setScreenSpaceTransform(layerScreenSpaceTransform);
546 543
547 gfx::RectF contentRect(gfx::PointF(), layer->contentBounds()); 544 gfx::RectF contentRect(gfx::PointF(), layer->contentBounds());
548 545
(...skipping 10 matching lines...) Expand all
559 return; 556 return;
560 557
561 if (!layer->renderSurface()) 558 if (!layer->renderSurface())
562 layer->createRenderSurface(); 559 layer->createRenderSurface();
563 560
564 RenderSurfaceType* renderSurface = layer->renderSurface(); 561 RenderSurfaceType* renderSurface = layer->renderSurface();
565 renderSurface->clearLayerLists(); 562 renderSurface->clearLayerLists();
566 563
567 // The owning layer's draw transform has a scale from content to layer s pace which we need to undo and 564 // The owning layer's draw transform has a scale from content to layer s pace which we need to undo and
568 // replace with a scale from the surface's subtree into layer space. 565 // replace with a scale from the surface's subtree into layer space.
569 if (!layer->contentBounds().IsEmpty() && !layer->bounds().IsEmpty()) 566 drawTransform.scaleNonUniform(layer->contentsScaleX(), layer->contentsSc aleY());
570 drawTransform.scaleNonUniform(layer->contentsScaleX(), layer->conten tsScaleY());
571 drawTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / re nderSurfaceSublayerScale.y()); 567 drawTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / re nderSurfaceSublayerScale.y());
572 renderSurface->setDrawTransform(drawTransform); 568 renderSurface->setDrawTransform(drawTransform);
573 569
574 // The origin of the new surface is the upper left corner of the layer. 570 // The origin of the new surface is the upper left corner of the layer.
575 WebTransformationMatrix layerDrawTransform; 571 WebTransformationMatrix layerDrawTransform;
576 layerDrawTransform.scaleNonUniform(renderSurfaceSublayerScale.x(), rende rSurfaceSublayerScale.y()); 572 layerDrawTransform.scaleNonUniform(renderSurfaceSublayerScale.x(), rende rSurfaceSublayerScale.y());
577 if (!layer->contentBounds().IsEmpty() && !layer->bounds().IsEmpty()) 573 layerDrawTransform.scaleNonUniform(1.0 / layer->contentsScaleX(), 1.0 / layer->contentsScaleY());
578 layerDrawTransform.scaleNonUniform(1.0 / layer->contentsScaleX(), 1. 0 / layer->contentsScaleY());
579 layer->setDrawTransform(layerDrawTransform); 574 layer->setDrawTransform(layerDrawTransform);
580 575
581 // Inside the surface's subtree, we scale everything to the owning layer 's scale. 576 // Inside the surface's subtree, we scale everything to the owning layer 's scale.
582 // The sublayer matrix transforms centered layer rects into target 577 // The sublayer matrix transforms centered layer rects into target
583 // surface content space. 578 // surface content space.
584 sublayerMatrix.makeIdentity(); 579 sublayerMatrix.makeIdentity();
585 sublayerMatrix.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSur faceSublayerScale.y()); 580 sublayerMatrix.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSur faceSublayerScale.y());
586 581
587 // The opacity value is moved from the layer to its surface, so that the entire subtree properly inherits opacity. 582 // The opacity value is moved from the layer to its surface, so that the entire subtree properly inherits opacity.
588 renderSurface->setDrawOpacity(drawOpacity); 583 renderSurface->setDrawOpacity(drawOpacity);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 clippedContentRect.set_height(std::min(clippedContentRect.height(), maxT extureSize)); 735 clippedContentRect.set_height(std::min(clippedContentRect.height(), maxT extureSize));
741 736
742 if (clippedContentRect.IsEmpty()) 737 if (clippedContentRect.IsEmpty())
743 renderSurface->clearLayerLists(); 738 renderSurface->clearLayerLists();
744 739
745 renderSurface->setContentRect(clippedContentRect); 740 renderSurface->setContentRect(clippedContentRect);
746 741
747 // The owning layer's screenSpaceTransform has a scale from content to l ayer space which we need to undo and 742 // The owning layer's screenSpaceTransform has a scale from content to l ayer space which we need to undo and
748 // replace with a scale from the surface's subtree into layer space. 743 // replace with a scale from the surface's subtree into layer space.
749 WebTransformationMatrix screenSpaceTransform = layer->screenSpaceTransfo rm(); 744 WebTransformationMatrix screenSpaceTransform = layer->screenSpaceTransfo rm();
750 if (!layer->contentBounds().IsEmpty() && !layer->bounds().IsEmpty()) 745 screenSpaceTransform.scaleNonUniform(layer->contentsScaleX(), layer->con tentsScaleY());
751 screenSpaceTransform.scaleNonUniform(layer->contentsScaleX(), layer- >contentsScaleY());
752 screenSpaceTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y()); 746 screenSpaceTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
753 renderSurface->setScreenSpaceTransform(screenSpaceTransform); 747 renderSurface->setScreenSpaceTransform(screenSpaceTransform);
754 748
755 if (layer->replicaLayer()) { 749 if (layer->replicaLayer()) {
756 WebTransformationMatrix surfaceOriginToReplicaOriginTransform; 750 WebTransformationMatrix surfaceOriginToReplicaOriginTransform;
757 surfaceOriginToReplicaOriginTransform.scaleNonUniform(renderSurfaceS ublayerScale.x(), renderSurfaceSublayerScale.y()); 751 surfaceOriginToReplicaOriginTransform.scaleNonUniform(renderSurfaceS ublayerScale.x(), renderSurfaceSublayerScale.y());
758 surfaceOriginToReplicaOriginTransform.translate(layer->replicaLayer( )->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(), 752 surfaceOriginToReplicaOriginTransform.translate(layer->replicaLayer( )->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(),
759 layer->replicaLayer( )->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height()); 753 layer->replicaLayer( )->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height());
760 surfaceOriginToReplicaOriginTransform.multiply(layer->replicaLayer() ->transform()); 754 surfaceOriginToReplicaOriginTransform.multiply(layer->replicaLayer() ->transform());
761 surfaceOriginToReplicaOriginTransform.translate(-layer->replicaLayer ()->anchorPoint().x() * bounds.width(), -layer->replicaLayer()->anchorPoint().y( ) * bounds.height()); 755 surfaceOriginToReplicaOriginTransform.translate(-layer->replicaLayer ()->anchorPoint().x() * bounds.width(), -layer->replicaLayer()->anchorPoint().y( ) * bounds.height());
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 920
927 foundLayer = currentLayer; 921 foundLayer = currentLayer;
928 break; 922 break;
929 } 923 }
930 924
931 // This can potentially return 0, which means the screenSpacePoint did not s uccessfully hit test any layers, not even the root layer. 925 // This can potentially return 0, which means the screenSpacePoint did not s uccessfully hit test any layers, not even the root layer.
932 return foundLayer; 926 return foundLayer;
933 } 927 }
934 928
935 } // namespace cc 929 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698