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 "cc/debug/overdraw_metrics.h" | 10 #include "cc/debug/overdraw_metrics.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/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_proxy.h" | 19 #include "cc/test/fake_proxy.h" |
| 20 #include "cc/test/fake_rendering_stats_instrumentation.h" |
20 #include "cc/test/geometry_test_utils.h" | 21 #include "cc/test/geometry_test_utils.h" |
21 #include "cc/test/tiled_layer_test_common.h" | 22 #include "cc/test/tiled_layer_test_common.h" |
22 #include "cc/trees/single_thread_proxy.h" | 23 #include "cc/trees/single_thread_proxy.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 #include "ui/gfx/rect_conversions.h" | 25 #include "ui/gfx/rect_conversions.h" |
25 #include "ui/gfx/transform.h" | 26 #include "ui/gfx/transform.h" |
26 | 27 |
27 namespace cc { | 28 namespace cc { |
28 namespace { | 29 namespace { |
29 | 30 |
(...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1712 gfx::Rect painted_rect_; | 1713 gfx::Rect painted_rect_; |
1713 }; | 1714 }; |
1714 | 1715 |
1715 class UpdateTrackingTiledLayer : public FakeTiledLayer { | 1716 class UpdateTrackingTiledLayer : public FakeTiledLayer { |
1716 public: | 1717 public: |
1717 explicit UpdateTrackingTiledLayer(PrioritizedResourceManager* manager) | 1718 explicit UpdateTrackingTiledLayer(PrioritizedResourceManager* manager) |
1718 : FakeTiledLayer(manager) { | 1719 : FakeTiledLayer(manager) { |
1719 scoped_ptr<TrackingLayerPainter> painter(TrackingLayerPainter::Create()); | 1720 scoped_ptr<TrackingLayerPainter> painter(TrackingLayerPainter::Create()); |
1720 tracking_layer_painter_ = painter.get(); | 1721 tracking_layer_painter_ = painter.get(); |
1721 layer_updater_ = | 1722 layer_updater_ = |
1722 BitmapContentLayerUpdater::Create(painter.PassAs<LayerPainter>()); | 1723 BitmapContentLayerUpdater::Create(painter.PassAs<LayerPainter>(), |
| 1724 &stats_instrumentation_); |
1723 } | 1725 } |
1724 | 1726 |
1725 TrackingLayerPainter* tracking_layer_painter() const { | 1727 TrackingLayerPainter* tracking_layer_painter() const { |
1726 return tracking_layer_painter_; | 1728 return tracking_layer_painter_; |
1727 } | 1729 } |
1728 | 1730 |
1729 private: | 1731 private: |
1730 virtual LayerUpdater* Updater() const OVERRIDE { | 1732 virtual LayerUpdater* Updater() const OVERRIDE { |
1731 return layer_updater_.get(); | 1733 return layer_updater_.get(); |
1732 } | 1734 } |
1733 virtual ~UpdateTrackingTiledLayer() {} | 1735 virtual ~UpdateTrackingTiledLayer() {} |
1734 | 1736 |
1735 TrackingLayerPainter* tracking_layer_painter_; | 1737 TrackingLayerPainter* tracking_layer_painter_; |
1736 scoped_refptr<BitmapContentLayerUpdater> layer_updater_; | 1738 scoped_refptr<BitmapContentLayerUpdater> layer_updater_; |
| 1739 FakeRenderingStatsInstrumentation stats_instrumentation_; |
1737 }; | 1740 }; |
1738 | 1741 |
1739 TEST_F(TiledLayerTest, NonIntegerContentsScaleIsNotDistortedDuringPaint) { | 1742 TEST_F(TiledLayerTest, NonIntegerContentsScaleIsNotDistortedDuringPaint) { |
1740 scoped_refptr<UpdateTrackingTiledLayer> layer = | 1743 scoped_refptr<UpdateTrackingTiledLayer> layer = |
1741 make_scoped_refptr(new UpdateTrackingTiledLayer(resource_manager_.get())); | 1744 make_scoped_refptr(new UpdateTrackingTiledLayer(resource_manager_.get())); |
1742 | 1745 |
1743 gfx::Rect layer_rect(0, 0, 30, 31); | 1746 gfx::Rect layer_rect(0, 0, 30, 31); |
1744 layer->SetPosition(layer_rect.origin()); | 1747 layer->SetPosition(layer_rect.origin()); |
1745 layer->SetBounds(layer_rect.size()); | 1748 layer->SetBounds(layer_rect.size()); |
1746 layer->UpdateContentsScale(1.5f); | 1749 layer->UpdateContentsScale(1.5f); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 // Invalidate the entire layer in layer space. When painting, the rect given | 1798 // Invalidate the entire layer in layer space. When painting, the rect given |
1796 // to webkit should match the layer's bounds. | 1799 // to webkit should match the layer's bounds. |
1797 layer->SetNeedsDisplayRect(layer_rect); | 1800 layer->SetNeedsDisplayRect(layer_rect); |
1798 layer->Update(queue_.get(), 0, NULL); | 1801 layer->Update(queue_.get(), 0, NULL); |
1799 | 1802 |
1800 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); | 1803 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); |
1801 } | 1804 } |
1802 | 1805 |
1803 } // namespace | 1806 } // namespace |
1804 } // namespace cc | 1807 } // namespace cc |
OLD | NEW |