| OLD | NEW |
| 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 Loading... |
| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 if (host && m_layerAnimationController->hasActiveAnimation()) | 112 if (host && m_layerAnimationController->hasActiveAnimation()) |
| 114 host->didAddAnimation(); | 113 host->didAddAnimation(); |
| 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 FloatRect& layerRect) const |
| 124 { | 123 { |
| 125 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi
dth(); | 124 FloatRect contentRect(layerRect); |
| 126 float heightScale = static_cast<float>(contentBounds().height()) / bounds().
height(); | 125 contentRect.scale(contentsScaleX(), contentsScaleY()); |
| 127 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h
eight); | 126 IntRect intContentRect = enclosingIntRect(contentRect); |
| 128 contentRect.scale(widthScale, heightScale); | 127 // Intersect with content rect to avoid the extra pixel because for some |
| 129 return enclosingIntRect(contentRect); | 128 // values x and y, ceil((x / y) * y) may be x + 1. |
| 129 intContentRect.intersect(IntRect(IntPoint(), contentBounds())); |
| 130 return intContentRect; |
| 130 } | 131 } |
| 131 | 132 |
| 132 void Layer::setParent(Layer* layer) | 133 void Layer::setParent(Layer* layer) |
| 133 { | 134 { |
| 134 DCHECK(!layer || !layer->hasAncestor(this)); | 135 DCHECK(!layer || !layer->hasAncestor(this)); |
| 135 m_parent = layer; | 136 m_parent = layer; |
| 136 setLayerTreeHost(m_parent ? m_parent->layerTreeHost() : 0); | 137 setLayerTreeHost(m_parent ? m_parent->layerTreeHost() : 0); |
| 137 | 138 |
| 138 forceAutomaticRasterScaleToBeRecomputed(); | 139 forceAutomaticRasterScaleToBeRecomputed(); |
| 139 } | 140 } |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 setNeedsCommit(); | 551 setNeedsCommit(); |
| 551 } | 552 } |
| 552 | 553 |
| 553 void Layer::pushPropertiesTo(LayerImpl* layer) | 554 void Layer::pushPropertiesTo(LayerImpl* layer) |
| 554 { | 555 { |
| 555 layer->setAnchorPoint(m_anchorPoint); | 556 layer->setAnchorPoint(m_anchorPoint); |
| 556 layer->setAnchorPointZ(m_anchorPointZ); | 557 layer->setAnchorPointZ(m_anchorPointZ); |
| 557 layer->setBackgroundColor(m_backgroundColor); | 558 layer->setBackgroundColor(m_backgroundColor); |
| 558 layer->setBounds(m_bounds); | 559 layer->setBounds(m_bounds); |
| 559 layer->setContentBounds(contentBounds()); | 560 layer->setContentBounds(contentBounds()); |
| 561 layer->setContentsScale(contentsScaleX(), contentsScaleY()); |
| 560 layer->setDebugBorderColor(m_debugBorderColor); | 562 layer->setDebugBorderColor(m_debugBorderColor); |
| 561 layer->setDebugBorderWidth(m_debugBorderWidth); | 563 layer->setDebugBorderWidth(m_debugBorderWidth); |
| 562 layer->setDebugName(m_debugName); | 564 layer->setDebugName(m_debugName); |
| 563 layer->setDoubleSided(m_doubleSided); | 565 layer->setDoubleSided(m_doubleSided); |
| 564 layer->setDrawCheckerboardForMissingTiles(m_drawCheckerboardForMissingTiles)
; | 566 layer->setDrawCheckerboardForMissingTiles(m_drawCheckerboardForMissingTiles)
; |
| 565 layer->setForceRenderSurface(m_forceRenderSurface); | 567 layer->setForceRenderSurface(m_forceRenderSurface); |
| 566 layer->setDrawsContent(drawsContent()); | 568 layer->setDrawsContent(drawsContent()); |
| 567 layer->setFilters(filters()); | 569 layer->setFilters(filters()); |
| 568 layer->setFilter(filter()); | 570 layer->setFilter(filter()); |
| 569 layer->setBackgroundFilters(backgroundFilters()); | 571 layer->setBackgroundFilters(backgroundFilters()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 bool Layer::drawsContent() const | 625 bool Layer::drawsContent() const |
| 624 { | 626 { |
| 625 return m_isDrawable; | 627 return m_isDrawable; |
| 626 } | 628 } |
| 627 | 629 |
| 628 bool Layer::needMoreUpdates() | 630 bool Layer::needMoreUpdates() |
| 629 { | 631 { |
| 630 return false; | 632 return false; |
| 631 } | 633 } |
| 632 | 634 |
| 633 bool Layer::needsContentsScale() const | |
| 634 { | |
| 635 return false; | |
| 636 } | |
| 637 | |
| 638 void Layer::setDebugBorderColor(SkColor color) | 635 void Layer::setDebugBorderColor(SkColor color) |
| 639 { | 636 { |
| 640 m_debugBorderColor = color; | 637 m_debugBorderColor = color; |
| 641 setNeedsCommit(); | 638 setNeedsCommit(); |
| 642 } | 639 } |
| 643 | 640 |
| 644 void Layer::setDebugBorderWidth(float width) | 641 void Layer::setDebugBorderWidth(float width) |
| 645 { | 642 { |
| 646 m_debugBorderWidth = width; | 643 m_debugBorderWidth = width; |
| 647 setNeedsCommit(); | 644 setNeedsCommit(); |
| 648 } | 645 } |
| 649 | 646 |
| 650 void Layer::setDebugName(const std::string& debugName) | 647 void Layer::setDebugName(const std::string& debugName) |
| 651 { | 648 { |
| 652 m_debugName = debugName; | 649 m_debugName = debugName; |
| 653 setNeedsCommit(); | 650 setNeedsCommit(); |
| 654 } | 651 } |
| 655 | 652 |
| 656 void Layer::setContentsScale(float contentsScale) | 653 float Layer::contentsScaleX() const |
| 657 { | 654 { |
| 658 if (!needsContentsScale() || m_contentsScale == contentsScale) | 655 return 1.0; |
| 659 return; | 656 } |
| 660 m_contentsScale = contentsScale; | |
| 661 | 657 |
| 662 setNeedsDisplay(); | 658 float Layer::contentsScaleY() const |
| 659 { |
| 660 return 1.0; |
| 663 } | 661 } |
| 664 | 662 |
| 665 void Layer::setRasterScale(float scale) | 663 void Layer::setRasterScale(float scale) |
| 666 { | 664 { |
| 667 if (m_rasterScale == scale) | 665 if (m_rasterScale == scale) |
| 668 return; | 666 return; |
| 669 m_rasterScale = scale; | 667 m_rasterScale = scale; |
| 670 | 668 |
| 671 if (!m_automaticallyComputeRasterScale) | 669 if (!m_automaticallyComputeRasterScale) |
| 672 return; | 670 return; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 { | 839 { |
| 842 return 0; | 840 return 0; |
| 843 } | 841 } |
| 844 | 842 |
| 845 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*) | 843 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*) |
| 846 { | 844 { |
| 847 // Currently we don't use z-order to decide what to paint, so there's no nee
d to actually sort Layers. | 845 // Currently we don't use z-order to decide what to paint, so there's no nee
d to actually sort Layers. |
| 848 } | 846 } |
| 849 | 847 |
| 850 } | 848 } |
| OLD | NEW |