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 "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 Loading... |
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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 228 } |
227 | 229 |
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 FloatRect& layerRect) const |
237 { | 239 { |
238 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi
dth(); | 240 FloatRect contentRect(layerRect); |
239 float heightScale = static_cast<float>(contentBounds().height()) / bounds().
height(); | 241 contentRect.scale(contentsScaleX(), contentsScaleY()); |
240 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h
eight); | 242 IntRect intContentRect = enclosingIntRect(contentRect); |
241 contentRect.scale(widthScale, heightScale); | 243 // Intersect with content rect to avoid the extra pixel because for some |
242 return enclosingIntRect(contentRect); | 244 // values x and y, ceil((x / y) * y) may be x + 1. |
| 245 intContentRect.intersect(IntRect(IntPoint(), contentBounds())); |
| 246 return intContentRect; |
243 } | 247 } |
244 | 248 |
245 std::string LayerImpl::indentString(int indent) | 249 std::string LayerImpl::indentString(int indent) |
246 { | 250 { |
247 std::string str; | 251 std::string str; |
248 for (int i = 0; i != indent; ++i) | 252 for (int i = 0; i != indent; ++i) |
249 str.append(" "); | 253 str.append(" "); |
250 return str; | 254 return str; |
251 } | 255 } |
252 | 256 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 | 606 |
603 void LayerImpl::setContentBounds(const IntSize& contentBounds) | 607 void LayerImpl::setContentBounds(const IntSize& contentBounds) |
604 { | 608 { |
605 if (m_contentBounds == contentBounds) | 609 if (m_contentBounds == contentBounds) |
606 return; | 610 return; |
607 | 611 |
608 m_contentBounds = contentBounds; | 612 m_contentBounds = contentBounds; |
609 m_layerPropertyChanged = true; | 613 m_layerPropertyChanged = true; |
610 } | 614 } |
611 | 615 |
| 616 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY) |
| 617 { |
| 618 if (m_contentsScaleX == contentsScaleX && m_contentsScaleY == contentsScaleY
) |
| 619 return; |
| 620 |
| 621 m_contentsScaleX = contentsScaleX; |
| 622 m_contentsScaleY = contentsScaleY; |
| 623 m_layerPropertyChanged = true; |
| 624 } |
| 625 |
612 void LayerImpl::setScrollPosition(const IntPoint& scrollPosition) | 626 void LayerImpl::setScrollPosition(const IntPoint& scrollPosition) |
613 { | 627 { |
614 if (m_scrollPosition == scrollPosition) | 628 if (m_scrollPosition == scrollPosition) |
615 return; | 629 return; |
616 | 630 |
617 m_scrollPosition = scrollPosition; | 631 m_scrollPosition = scrollPosition; |
618 noteLayerPropertyChangedForSubtree(); | 632 noteLayerPropertyChangedForSubtree(); |
619 } | 633 } |
620 | 634 |
621 void LayerImpl::setScrollDelta(const FloatSize& scrollDelta) | 635 void LayerImpl::setScrollDelta(const FloatSize& scrollDelta) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 | 699 |
686 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) | 700 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) |
687 { | 701 { |
688 if (!m_scrollbarAnimationController) | 702 if (!m_scrollbarAnimationController) |
689 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); | 703 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); |
690 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); | 704 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); |
691 m_scrollbarAnimationController->updateScrollOffset(this); | 705 m_scrollbarAnimationController->updateScrollOffset(this); |
692 } | 706 } |
693 | 707 |
694 } | 708 } |
OLD | NEW |