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

Side by Side Diff: cc/layer_impl.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 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/layer_impl.h" 7 #include "cc/layer_impl.h"
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 11 matching lines...) Expand all
22 namespace cc { 22 namespace cc {
23 23
24 LayerImpl::LayerImpl(int id) 24 LayerImpl::LayerImpl(int id)
25 : m_parent(0) 25 : m_parent(0)
26 , m_maskLayerId(-1) 26 , m_maskLayerId(-1)
27 , m_replicaLayerId(-1) 27 , m_replicaLayerId(-1)
28 , m_layerId(id) 28 , m_layerId(id)
29 , m_layerTreeHostImpl(0) 29 , m_layerTreeHostImpl(0)
30 , m_anchorPoint(0.5, 0.5) 30 , m_anchorPoint(0.5, 0.5)
31 , m_anchorPointZ(0) 31 , m_anchorPointZ(0)
32 , m_contentsScaleX(1.0)
33 , m_contentsScaleY(1.0)
32 , m_scrollable(false) 34 , m_scrollable(false)
33 , m_shouldScrollOnMainThread(false) 35 , m_shouldScrollOnMainThread(false)
34 , m_haveWheelEventHandlers(false) 36 , m_haveWheelEventHandlers(false)
35 , m_backgroundColor(0) 37 , m_backgroundColor(0)
36 , m_doubleSided(true) 38 , m_doubleSided(true)
37 , m_layerPropertyChanged(false) 39 , m_layerPropertyChanged(false)
38 , m_layerSurfacePropertyChanged(false) 40 , m_layerSurfacePropertyChanged(false)
39 , m_masksToBounds(false) 41 , m_masksToBounds(false)
40 , m_contentsOpaque(false) 42 , m_contentsOpaque(false)
41 , m_opacity(1.0) 43 , m_opacity(1.0)
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 return InputHandlerClient::ScrollStarted; 230 return InputHandlerClient::ScrollStarted;
229 } 231 }
230 232
231 bool LayerImpl::drawCheckerboardForMissingTiles() const 233 bool LayerImpl::drawCheckerboardForMissingTiles() const
232 { 234 {
233 return m_drawCheckerboardForMissingTiles && !Settings::backgroundColorInstea dOfCheckerboard(); 235 return m_drawCheckerboardForMissingTiles && !Settings::backgroundColorInstea dOfCheckerboard();
234 } 236 }
235 237
236 IntRect LayerImpl::layerRectToContentRect(const WebKit::WebRect& layerRect) 238 IntRect LayerImpl::layerRectToContentRect(const WebKit::WebRect& layerRect)
237 { 239 {
238 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi dth();
239 float heightScale = static_cast<float>(contentBounds().height()) / bounds(). height();
240 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h eight); 240 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h eight);
241 contentRect.scale(widthScale, heightScale); 241 contentRect.scale(contentsScaleX(), contentsScaleY());
242 return enclosingIntRect(contentRect); 242 return enclosingIntRect(contentRect);
danakj 2012/10/29 20:06:51 Intersect+comment here too.
wangxianzhu 2012/10/30 02:14:21 Done.
243 } 243 }
244 244
245 std::string LayerImpl::indentString(int indent) 245 std::string LayerImpl::indentString(int indent)
246 { 246 {
247 std::string str; 247 std::string str;
248 for (int i = 0; i != indent; ++i) 248 for (int i = 0; i != indent; ++i)
249 str.append(" "); 249 str.append(" ");
250 return str; 250 return str;
251 } 251 }
252 252
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 return; 407 return;
408 408
409 m_bounds = bounds; 409 m_bounds = bounds;
410 410
411 if (masksToBounds()) 411 if (masksToBounds())
412 noteLayerPropertyChangedForSubtree(); 412 noteLayerPropertyChangedForSubtree();
413 else 413 else
414 m_layerPropertyChanged = true; 414 m_layerPropertyChanged = true;
415 } 415 }
416 416
417 IntSize LayerImpl::contentBounds() const
enne (OOO) 2012/10/29 19:19:41 I don't think this math works out correctly for im
danakj 2012/10/29 20:06:51 If contentBounds() is not always equal to ceil(bou
wangxianzhu 2012/10/30 02:14:21 Done.
wangxianzhu 2012/10/30 02:14:21 Done.
418 {
419 return IntSize(ceil(bounds().width() * contentsScaleX()),
420 ceil(bounds().height() * contentsScaleY()));
421 }
422
417 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer) 423 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer)
418 { 424 {
419 m_maskLayer = maskLayer.Pass(); 425 m_maskLayer = maskLayer.Pass();
420 426
421 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1; 427 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1;
422 if (newLayerId == m_maskLayerId) 428 if (newLayerId == m_maskLayerId)
423 return; 429 return;
424 430
425 m_maskLayerId = newLayerId; 431 m_maskLayerId = newLayerId;
426 noteLayerPropertyChangedForSubtree(); 432 noteLayerPropertyChangedForSubtree();
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 599
594 m_debugBorderWidth = debugBorderWidth; 600 m_debugBorderWidth = debugBorderWidth;
595 m_layerPropertyChanged = true; 601 m_layerPropertyChanged = true;
596 } 602 }
597 603
598 bool LayerImpl::hasDebugBorders() const 604 bool LayerImpl::hasDebugBorders() const
599 { 605 {
600 return SkColorGetA(m_debugBorderColor) && debugBorderWidth() > 0; 606 return SkColorGetA(m_debugBorderColor) && debugBorderWidth() > 0;
601 } 607 }
602 608
603 void LayerImpl::setContentBounds(const IntSize& contentBounds) 609 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY)
604 { 610 {
605 if (m_contentBounds == contentBounds) 611 if (m_contentsScaleX == contentsScaleX && m_contentsScaleY == contentsScaleY )
606 return; 612 return;
607 613
608 m_contentBounds = contentBounds; 614 m_contentsScaleX = contentsScaleX;
615 m_contentsScaleY = contentsScaleY;
609 m_layerPropertyChanged = true; 616 m_layerPropertyChanged = true;
610 } 617 }
611 618
612 void LayerImpl::setScrollPosition(const IntPoint& scrollPosition) 619 void LayerImpl::setScrollPosition(const IntPoint& scrollPosition)
613 { 620 {
614 if (m_scrollPosition == scrollPosition) 621 if (m_scrollPosition == scrollPosition)
615 return; 622 return;
616 623
617 m_scrollPosition = scrollPosition; 624 m_scrollPosition = scrollPosition;
618 noteLayerPropertyChangedForSubtree(); 625 noteLayerPropertyChangedForSubtree();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 692
686 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) 693 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
687 { 694 {
688 if (!m_scrollbarAnimationController) 695 if (!m_scrollbarAnimationController)
689 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is); 696 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is);
690 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); 697 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer);
691 m_scrollbarAnimationController->updateScrollOffset(this); 698 m_scrollbarAnimationController->updateScrollOffset(this);
692 } 699 }
693 700
694 } 701 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698