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

Side by Side Diff: cc/layer.cc

Issue 11276060: Pass accurate contentsScale to LayerImpl. (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
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/layer.h" 7 #include "cc/layer.h"
8 8
9 #include "cc/active_animation.h" 9 #include "cc/active_animation.h"
10 #include "cc/animation_events.h" 10 #include "cc/animation_events.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 , m_preserves3D(false) 57 , m_preserves3D(false)
58 , m_useParentBackfaceVisibility(false) 58 , m_useParentBackfaceVisibility(false)
59 , m_drawCheckerboardForMissingTiles(false) 59 , m_drawCheckerboardForMissingTiles(false)
60 , m_forceRenderSurface(false) 60 , m_forceRenderSurface(false)
61 , m_replicaLayer(0) 61 , m_replicaLayer(0)
62 , m_drawOpacity(0) 62 , m_drawOpacity(0)
63 , m_drawOpacityIsAnimating(false) 63 , m_drawOpacityIsAnimating(false)
64 , m_renderTarget(0) 64 , m_renderTarget(0)
65 , m_drawTransformIsAnimating(false) 65 , m_drawTransformIsAnimating(false)
66 , m_screenSpaceTransformIsAnimating(false) 66 , m_screenSpaceTransformIsAnimating(false)
67 , m_contentsScale(1.0)
68 , m_rasterScale(1.0) 67 , m_rasterScale(1.0)
69 , m_automaticallyComputeRasterScale(false) 68 , m_automaticallyComputeRasterScale(false)
70 , m_boundsContainPageScale(false) 69 , m_boundsContainPageScale(false)
71 , m_layerAnimationDelegate(0) 70 , m_layerAnimationDelegate(0)
72 , m_layerScrollClient(0) 71 , m_layerScrollClient(0)
73 { 72 {
74 if (m_layerId < 0) { 73 if (m_layerId < 0) {
75 s_nextLayerId = 1; 74 s_nextLayerId = 1;
76 m_layerId = s_nextLayerId++; 75 m_layerId = s_nextLayerId++;
77 } 76 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 114 }
116 115
117 void Layer::setNeedsCommit() 116 void Layer::setNeedsCommit()
118 { 117 {
119 if (m_layerTreeHost) 118 if (m_layerTreeHost)
120 m_layerTreeHost->setNeedsCommit(); 119 m_layerTreeHost->setNeedsCommit();
121 } 120 }
122 121
123 IntRect Layer::layerRectToContentRect(const WebKit::WebRect& layerRect) 122 IntRect Layer::layerRectToContentRect(const WebKit::WebRect& layerRect)
124 { 123 {
125 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi dth();
126 float heightScale = static_cast<float>(contentBounds().height()) / bounds(). height();
127 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h eight); 124 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h eight);
128 contentRect.scale(widthScale, heightScale); 125 contentRect.scale(contentsScaleX(), contentsScaleY());
129 return enclosingIntRect(contentRect); 126 return enclosingIntRect(contentRect);
danakj 2012/10/29 20:06:51 Since this conversion is not exactly right for ima
wangxianzhu 2012/10/30 02:14:21 Done.
130 } 127 }
131 128
132 void Layer::setParent(Layer* layer) 129 void Layer::setParent(Layer* layer)
133 { 130 {
134 DCHECK(!layer || !layer->hasAncestor(this)); 131 DCHECK(!layer || !layer->hasAncestor(this));
135 m_parent = layer; 132 m_parent = layer;
136 setLayerTreeHost(m_parent ? m_parent->layerTreeHost() : 0); 133 setLayerTreeHost(m_parent ? m_parent->layerTreeHost() : 0);
137 134
138 forceAutomaticRasterScaleToBeRecomputed(); 135 forceAutomaticRasterScaleToBeRecomputed();
139 } 136 }
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 m_fixedToContainerLayer = fixedToContainerLayer; 546 m_fixedToContainerLayer = fixedToContainerLayer;
550 setNeedsCommit(); 547 setNeedsCommit();
551 } 548 }
552 549
553 void Layer::pushPropertiesTo(LayerImpl* layer) 550 void Layer::pushPropertiesTo(LayerImpl* layer)
554 { 551 {
555 layer->setAnchorPoint(m_anchorPoint); 552 layer->setAnchorPoint(m_anchorPoint);
556 layer->setAnchorPointZ(m_anchorPointZ); 553 layer->setAnchorPointZ(m_anchorPointZ);
557 layer->setBackgroundColor(m_backgroundColor); 554 layer->setBackgroundColor(m_backgroundColor);
558 layer->setBounds(m_bounds); 555 layer->setBounds(m_bounds);
559 layer->setContentBounds(contentBounds()); 556 layer->setContentsScale(contentsScaleX(), contentsScaleY());
560 layer->setDebugBorderColor(m_debugBorderColor); 557 layer->setDebugBorderColor(m_debugBorderColor);
561 layer->setDebugBorderWidth(m_debugBorderWidth); 558 layer->setDebugBorderWidth(m_debugBorderWidth);
562 layer->setDebugName(m_debugName); 559 layer->setDebugName(m_debugName);
563 layer->setDoubleSided(m_doubleSided); 560 layer->setDoubleSided(m_doubleSided);
564 layer->setDrawCheckerboardForMissingTiles(m_drawCheckerboardForMissingTiles) ; 561 layer->setDrawCheckerboardForMissingTiles(m_drawCheckerboardForMissingTiles) ;
565 layer->setForceRenderSurface(m_forceRenderSurface); 562 layer->setForceRenderSurface(m_forceRenderSurface);
566 layer->setDrawsContent(drawsContent()); 563 layer->setDrawsContent(drawsContent());
567 layer->setFilters(filters()); 564 layer->setFilters(filters());
568 layer->setFilter(filter()); 565 layer->setFilter(filter());
569 layer->setBackgroundFilters(backgroundFilters()); 566 layer->setBackgroundFilters(backgroundFilters());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 bool Layer::drawsContent() const 620 bool Layer::drawsContent() const
624 { 621 {
625 return m_isDrawable; 622 return m_isDrawable;
626 } 623 }
627 624
628 bool Layer::needMoreUpdates() 625 bool Layer::needMoreUpdates()
629 { 626 {
630 return false; 627 return false;
631 } 628 }
632 629
633 bool Layer::needsContentsScale() const
634 {
635 return false;
636 }
637
638 void Layer::setDebugBorderColor(SkColor color) 630 void Layer::setDebugBorderColor(SkColor color)
639 { 631 {
640 m_debugBorderColor = color; 632 m_debugBorderColor = color;
641 setNeedsCommit(); 633 setNeedsCommit();
642 } 634 }
643 635
644 void Layer::setDebugBorderWidth(float width) 636 void Layer::setDebugBorderWidth(float width)
645 { 637 {
646 m_debugBorderWidth = width; 638 m_debugBorderWidth = width;
647 setNeedsCommit(); 639 setNeedsCommit();
648 } 640 }
649 641
650 void Layer::setDebugName(const std::string& debugName) 642 void Layer::setDebugName(const std::string& debugName)
651 { 643 {
652 m_debugName = debugName; 644 m_debugName = debugName;
653 setNeedsCommit(); 645 setNeedsCommit();
654 } 646 }
655 647
656 void Layer::setContentsScale(float contentsScale)
657 {
658 if (!needsContentsScale() || m_contentsScale == contentsScale)
659 return;
660 m_contentsScale = contentsScale;
661
662 setNeedsDisplay();
663 }
664
665 void Layer::setRasterScale(float scale) 648 void Layer::setRasterScale(float scale)
666 { 649 {
667 if (m_rasterScale == scale) 650 if (m_rasterScale == scale)
668 return; 651 return;
669 m_rasterScale = scale; 652 m_rasterScale = scale;
670 653
671 if (!m_automaticallyComputeRasterScale) 654 if (!m_automaticallyComputeRasterScale)
672 return; 655 return;
673 setNeedsDisplay(); 656 setNeedsDisplay();
674 } 657 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 { 824 {
842 return 0; 825 return 0;
843 } 826 }
844 827
845 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*) 828 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*)
846 { 829 {
847 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers. 830 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers.
848 } 831 }
849 832
850 } 833 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698