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" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 bool EnsureOutputSurfaceCreated() { | 62 bool EnsureOutputSurfaceCreated() { |
63 base::MessageLoop::current()->PostDelayedTask( | 63 base::MessageLoop::current()->PostDelayedTask( |
64 FROM_HERE, | 64 FROM_HERE, |
65 run_loop_.QuitClosure(), | 65 run_loop_.QuitClosure(), |
66 base::TimeDelta::FromSeconds(5)); | 66 base::TimeDelta::FromSeconds(5)); |
67 run_loop_.Run(); | 67 run_loop_.Run(); |
68 return output_surface_created_; | 68 return output_surface_created_; |
69 } | 69 } |
70 | 70 |
71 virtual void OnCreateAndInitializeOutputSurfaceAttempted( | 71 virtual void OnCreateAndInitializeOutputSurfaceAttempted( |
72 bool success) OVERRIDE { | 72 bool success) override { |
73 LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted(success); | 73 LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted(success); |
74 output_surface_created_ = success; | 74 output_surface_created_ = success; |
75 run_loop_.Quit(); | 75 run_loop_.Quit(); |
76 } | 76 } |
77 | 77 |
78 private: | 78 private: |
79 SynchronousOutputSurfaceLayerTreeHost( | 79 SynchronousOutputSurfaceLayerTreeHost( |
80 LayerTreeHostClient* client, | 80 LayerTreeHostClient* client, |
81 SharedBitmapManager* manager, | 81 SharedBitmapManager* manager, |
82 const LayerTreeSettings& settings, | 82 const LayerTreeSettings& settings, |
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1641 resource_provider_.get()); | 1641 resource_provider_.get()); |
1642 layer_tree_host_->SetRootLayer(NULL); | 1642 layer_tree_host_->SetRootLayer(NULL); |
1643 } | 1643 } |
1644 | 1644 |
1645 class TrackingLayerPainter : public LayerPainter { | 1645 class TrackingLayerPainter : public LayerPainter { |
1646 public: | 1646 public: |
1647 static scoped_ptr<TrackingLayerPainter> Create() { | 1647 static scoped_ptr<TrackingLayerPainter> Create() { |
1648 return make_scoped_ptr(new TrackingLayerPainter()); | 1648 return make_scoped_ptr(new TrackingLayerPainter()); |
1649 } | 1649 } |
1650 | 1650 |
1651 virtual void Paint(SkCanvas* canvas, const gfx::Rect& content_rect) OVERRIDE { | 1651 virtual void Paint(SkCanvas* canvas, const gfx::Rect& content_rect) override { |
1652 painted_rect_ = content_rect; | 1652 painted_rect_ = content_rect; |
1653 } | 1653 } |
1654 | 1654 |
1655 gfx::Rect PaintedRect() const { return painted_rect_; } | 1655 gfx::Rect PaintedRect() const { return painted_rect_; } |
1656 void ResetPaintedRect() { painted_rect_ = gfx::Rect(); } | 1656 void ResetPaintedRect() { painted_rect_ = gfx::Rect(); } |
1657 | 1657 |
1658 private: | 1658 private: |
1659 gfx::Rect painted_rect_; | 1659 gfx::Rect painted_rect_; |
1660 }; | 1660 }; |
1661 | 1661 |
1662 class UpdateTrackingTiledLayer : public FakeTiledLayer { | 1662 class UpdateTrackingTiledLayer : public FakeTiledLayer { |
1663 public: | 1663 public: |
1664 explicit UpdateTrackingTiledLayer(PrioritizedResourceManager* manager) | 1664 explicit UpdateTrackingTiledLayer(PrioritizedResourceManager* manager) |
1665 : FakeTiledLayer(manager) { | 1665 : FakeTiledLayer(manager) { |
1666 scoped_ptr<TrackingLayerPainter> painter(TrackingLayerPainter::Create()); | 1666 scoped_ptr<TrackingLayerPainter> painter(TrackingLayerPainter::Create()); |
1667 tracking_layer_painter_ = painter.get(); | 1667 tracking_layer_painter_ = painter.get(); |
1668 layer_updater_ = BitmapContentLayerUpdater::Create( | 1668 layer_updater_ = BitmapContentLayerUpdater::Create( |
1669 painter.Pass(), &stats_instrumentation_, 0); | 1669 painter.Pass(), &stats_instrumentation_, 0); |
1670 } | 1670 } |
1671 | 1671 |
1672 TrackingLayerPainter* tracking_layer_painter() const { | 1672 TrackingLayerPainter* tracking_layer_painter() const { |
1673 return tracking_layer_painter_; | 1673 return tracking_layer_painter_; |
1674 } | 1674 } |
1675 | 1675 |
1676 private: | 1676 private: |
1677 virtual LayerUpdater* Updater() const OVERRIDE { | 1677 virtual LayerUpdater* Updater() const override { |
1678 return layer_updater_.get(); | 1678 return layer_updater_.get(); |
1679 } | 1679 } |
1680 virtual ~UpdateTrackingTiledLayer() {} | 1680 virtual ~UpdateTrackingTiledLayer() {} |
1681 | 1681 |
1682 TrackingLayerPainter* tracking_layer_painter_; | 1682 TrackingLayerPainter* tracking_layer_painter_; |
1683 scoped_refptr<BitmapContentLayerUpdater> layer_updater_; | 1683 scoped_refptr<BitmapContentLayerUpdater> layer_updater_; |
1684 FakeRenderingStatsInstrumentation stats_instrumentation_; | 1684 FakeRenderingStatsInstrumentation stats_instrumentation_; |
1685 }; | 1685 }; |
1686 | 1686 |
1687 TEST_F(TiledLayerTest, NonIntegerContentsScaleIsNotDistortedDuringPaint) { | 1687 TEST_F(TiledLayerTest, NonIntegerContentsScaleIsNotDistortedDuringPaint) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 | 1757 |
1758 // Rounding leads to an extra pixel. | 1758 // Rounding leads to an extra pixel. |
1759 gfx::Rect expanded_layer_rect(layer_rect); | 1759 gfx::Rect expanded_layer_rect(layer_rect); |
1760 expanded_layer_rect.set_height(32); | 1760 expanded_layer_rect.set_height(32); |
1761 EXPECT_RECT_EQ(expanded_layer_rect, | 1761 EXPECT_RECT_EQ(expanded_layer_rect, |
1762 layer->tracking_layer_painter()->PaintedRect()); | 1762 layer->tracking_layer_painter()->PaintedRect()); |
1763 } | 1763 } |
1764 | 1764 |
1765 } // namespace | 1765 } // namespace |
1766 } // namespace cc | 1766 } // namespace cc |
OLD | NEW |