| 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 "cc/layers/tiled_layer.h" | 5 #include "cc/layers/tiled_layer.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "cc/resources/bitmap_content_layer_updater.h" | 11 #include "cc/resources/bitmap_content_layer_updater.h" |
| 12 #include "cc/resources/layer_painter.h" | 12 #include "cc/resources/content_layer_painter.h" |
| 13 #include "cc/resources/prioritized_resource_manager.h" | 13 #include "cc/resources/prioritized_resource_manager.h" |
| 14 #include "cc/resources/resource_update_controller.h" | 14 #include "cc/resources/resource_update_controller.h" |
| 15 #include "cc/test/animation_test_common.h" | 15 #include "cc/test/animation_test_common.h" |
| 16 #include "cc/test/fake_layer_tree_host_client.h" | 16 #include "cc/test/fake_layer_tree_host_client.h" |
| 17 #include "cc/test/fake_layer_tree_host_impl.h" | 17 #include "cc/test/fake_layer_tree_host_impl.h" |
| 18 #include "cc/test/fake_output_surface.h" | 18 #include "cc/test/fake_output_surface.h" |
| 19 #include "cc/test/fake_output_surface_client.h" | 19 #include "cc/test/fake_output_surface_client.h" |
| 20 #include "cc/test/fake_proxy.h" | 20 #include "cc/test/fake_proxy.h" |
| 21 #include "cc/test/fake_rendering_stats_instrumentation.h" | 21 #include "cc/test/fake_rendering_stats_instrumentation.h" |
| 22 #include "cc/test/geometry_test_utils.h" | 22 #include "cc/test/geometry_test_utils.h" |
| (...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 EXPECT_FALSE(child2_impl->HasResourceIdForTileAt(i, 0)); | 1697 EXPECT_FALSE(child2_impl->HasResourceIdForTileAt(i, 0)); |
| 1698 } | 1698 } |
| 1699 } | 1699 } |
| 1700 layer_tree_host_->CommitComplete(); | 1700 layer_tree_host_->CommitComplete(); |
| 1701 | 1701 |
| 1702 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(), | 1702 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(), |
| 1703 resource_provider_.get()); | 1703 resource_provider_.get()); |
| 1704 layer_tree_host_->SetRootLayer(NULL); | 1704 layer_tree_host_->SetRootLayer(NULL); |
| 1705 } | 1705 } |
| 1706 | 1706 |
| 1707 class TrackingLayerPainter : public LayerPainter { | 1707 class TrackingLayerPainter : public ContentLayerPainter { |
| 1708 public: | 1708 public: |
| 1709 static scoped_ptr<TrackingLayerPainter> Create() { | 1709 static scoped_ptr<TrackingLayerPainter> Create(ContentLayerClient* client) { |
| 1710 return make_scoped_ptr(new TrackingLayerPainter()); | 1710 return make_scoped_ptr(new TrackingLayerPainter(client)); |
| 1711 } | 1711 } |
| 1712 | 1712 |
| 1713 virtual void Paint(SkCanvas* canvas, | 1713 virtual void Paint(SkCanvas* canvas, |
| 1714 const gfx::Rect& content_rect, | 1714 const gfx::Rect& content_rect, |
| 1715 bool can_paint_lcd_text, |
| 1715 gfx::RectF* opaque) OVERRIDE { | 1716 gfx::RectF* opaque) OVERRIDE { |
| 1716 painted_rect_ = content_rect; | 1717 painted_rect_ = content_rect; |
| 1717 } | 1718 } |
| 1718 | 1719 |
| 1719 gfx::Rect PaintedRect() const { return painted_rect_; } | 1720 gfx::Rect PaintedRect() const { return painted_rect_; } |
| 1720 void ResetPaintedRect() { painted_rect_ = gfx::Rect(); } | 1721 void ResetPaintedRect() { painted_rect_ = gfx::Rect(); } |
| 1721 | 1722 |
| 1723 protected: |
| 1724 explicit TrackingLayerPainter(ContentLayerClient* client) |
| 1725 : ContentLayerPainter(client) {} |
| 1726 |
| 1722 private: | 1727 private: |
| 1723 gfx::Rect painted_rect_; | 1728 gfx::Rect painted_rect_; |
| 1724 }; | 1729 }; |
| 1725 | 1730 |
| 1726 class UpdateTrackingTiledLayer : public FakeTiledLayer { | 1731 class UpdateTrackingTiledLayer : public FakeTiledLayer { |
| 1727 public: | 1732 public: |
| 1728 explicit UpdateTrackingTiledLayer(PrioritizedResourceManager* manager) | 1733 explicit UpdateTrackingTiledLayer(PrioritizedResourceManager* manager) |
| 1729 : FakeTiledLayer(manager) { | 1734 : FakeTiledLayer(manager) { |
| 1730 scoped_ptr<TrackingLayerPainter> painter(TrackingLayerPainter::Create()); | 1735 scoped_ptr<TrackingLayerPainter> painter( |
| 1736 TrackingLayerPainter::Create(NULL)); |
| 1731 tracking_layer_painter_ = painter.get(); | 1737 tracking_layer_painter_ = painter.get(); |
| 1732 layer_updater_ = | 1738 layer_updater_ = BitmapContentLayerUpdater::Create( |
| 1733 BitmapContentLayerUpdater::Create(painter.PassAs<LayerPainter>(), | 1739 painter.PassAs<ContentLayerPainter>(), &stats_instrumentation_, 0); |
| 1734 &stats_instrumentation_, | |
| 1735 0); | |
| 1736 } | 1740 } |
| 1737 | 1741 |
| 1738 TrackingLayerPainter* tracking_layer_painter() const { | 1742 TrackingLayerPainter* tracking_layer_painter() const { |
| 1739 return tracking_layer_painter_; | 1743 return tracking_layer_painter_; |
| 1740 } | 1744 } |
| 1741 | 1745 |
| 1742 private: | 1746 private: |
| 1743 virtual LayerUpdater* Updater() const OVERRIDE { | 1747 virtual LayerUpdater* Updater() const OVERRIDE { |
| 1744 return layer_updater_.get(); | 1748 return layer_updater_.get(); |
| 1745 } | 1749 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1815 // Invalidate the entire layer in layer space. When painting, the rect given | 1819 // Invalidate the entire layer in layer space. When painting, the rect given |
| 1816 // to webkit should match the layer's bounds. | 1820 // to webkit should match the layer's bounds. |
| 1817 layer->SetNeedsDisplayRect(layer_rect); | 1821 layer->SetNeedsDisplayRect(layer_rect); |
| 1818 layer->Update(queue_.get(), NULL); | 1822 layer->Update(queue_.get(), NULL); |
| 1819 | 1823 |
| 1820 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); | 1824 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); |
| 1821 } | 1825 } |
| 1822 | 1826 |
| 1823 } // namespace | 1827 } // namespace |
| 1824 } // namespace cc | 1828 } // namespace cc |
| OLD | NEW |