| 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/trees/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "ui/gfx/quad_f.h" | 36 #include "ui/gfx/quad_f.h" |
| 37 #include "ui/gfx/transform.h" | 37 #include "ui/gfx/transform.h" |
| 38 | 38 |
| 39 namespace cc { | 39 namespace cc { |
| 40 namespace { | 40 namespace { |
| 41 | 41 |
| 42 class LayerWithForcedDrawsContent : public Layer { | 42 class LayerWithForcedDrawsContent : public Layer { |
| 43 public: | 43 public: |
| 44 LayerWithForcedDrawsContent() {} | 44 LayerWithForcedDrawsContent() {} |
| 45 | 45 |
| 46 virtual bool DrawsContent() const override; | 46 bool DrawsContent() const override; |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 virtual ~LayerWithForcedDrawsContent() {} | 49 ~LayerWithForcedDrawsContent() override {} |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 bool LayerWithForcedDrawsContent::DrawsContent() const { return true; } | 52 bool LayerWithForcedDrawsContent::DrawsContent() const { return true; } |
| 53 | 53 |
| 54 class MockContentLayerClient : public ContentLayerClient { | 54 class MockContentLayerClient : public ContentLayerClient { |
| 55 public: | 55 public: |
| 56 MockContentLayerClient() {} | 56 MockContentLayerClient() {} |
| 57 virtual ~MockContentLayerClient() {} | 57 ~MockContentLayerClient() override {} |
| 58 virtual void PaintContents( | 58 void PaintContents( |
| 59 SkCanvas* canvas, | 59 SkCanvas* canvas, |
| 60 const gfx::Rect& clip, | 60 const gfx::Rect& clip, |
| 61 ContentLayerClient::GraphicsContextStatus gc_status) override {} | 61 ContentLayerClient::GraphicsContextStatus gc_status) override {} |
| 62 virtual void DidChangeLayerCanUseLCDText() override {} | 62 void DidChangeLayerCanUseLCDText() override {} |
| 63 virtual bool FillsBoundsCompletely() const override { return false; } | 63 bool FillsBoundsCompletely() const override { return false; } |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 scoped_refptr<FakePictureLayer> CreateDrawablePictureLayer( | 66 scoped_refptr<FakePictureLayer> CreateDrawablePictureLayer( |
| 67 ContentLayerClient* delegate) { | 67 ContentLayerClient* delegate) { |
| 68 scoped_refptr<FakePictureLayer> to_return = | 68 scoped_refptr<FakePictureLayer> to_return = |
| 69 FakePictureLayer::Create(delegate); | 69 FakePictureLayer::Create(delegate); |
| 70 to_return->SetIsDrawable(true); | 70 to_return->SetIsDrawable(true); |
| 71 return to_return; | 71 return to_return; |
| 72 } | 72 } |
| 73 | 73 |
| (...skipping 3950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4024 render_surface_layer_list.at(1) | 4024 render_surface_layer_list.at(1) |
| 4025 ->render_surface()->layer_list().at(1)->id()); | 4025 ->render_surface()->layer_list().at(1)->id()); |
| 4026 } | 4026 } |
| 4027 | 4027 |
| 4028 class NoScaleContentLayer : public ContentLayer { | 4028 class NoScaleContentLayer : public ContentLayer { |
| 4029 public: | 4029 public: |
| 4030 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) { | 4030 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) { |
| 4031 return make_scoped_refptr(new NoScaleContentLayer(client)); | 4031 return make_scoped_refptr(new NoScaleContentLayer(client)); |
| 4032 } | 4032 } |
| 4033 | 4033 |
| 4034 virtual void CalculateContentsScale(float ideal_contents_scale, | 4034 void CalculateContentsScale(float ideal_contents_scale, |
| 4035 float* contents_scale_x, | 4035 float* contents_scale_x, |
| 4036 float* contents_scale_y, | 4036 float* contents_scale_y, |
| 4037 gfx::Size* content_bounds) override { | 4037 gfx::Size* content_bounds) override { |
| 4038 // Skip over the ContentLayer to the base Layer class. | 4038 // Skip over the ContentLayer to the base Layer class. |
| 4039 Layer::CalculateContentsScale(ideal_contents_scale, | 4039 Layer::CalculateContentsScale(ideal_contents_scale, |
| 4040 contents_scale_x, | 4040 contents_scale_x, |
| 4041 contents_scale_y, | 4041 contents_scale_y, |
| 4042 content_bounds); | 4042 content_bounds); |
| 4043 } | 4043 } |
| 4044 | 4044 |
| 4045 protected: | 4045 protected: |
| 4046 explicit NoScaleContentLayer(ContentLayerClient* client) | 4046 explicit NoScaleContentLayer(ContentLayerClient* client) |
| 4047 : ContentLayer(client) {} | 4047 : ContentLayer(client) {} |
| 4048 virtual ~NoScaleContentLayer() {} | 4048 ~NoScaleContentLayer() override {} |
| 4049 }; | 4049 }; |
| 4050 | 4050 |
| 4051 scoped_refptr<NoScaleContentLayer> CreateNoScaleDrawableContentLayer( | 4051 scoped_refptr<NoScaleContentLayer> CreateNoScaleDrawableContentLayer( |
| 4052 ContentLayerClient* delegate) { | 4052 ContentLayerClient* delegate) { |
| 4053 scoped_refptr<NoScaleContentLayer> to_return = | 4053 scoped_refptr<NoScaleContentLayer> to_return = |
| 4054 NoScaleContentLayer::Create(delegate); | 4054 NoScaleContentLayer::Create(delegate); |
| 4055 to_return->SetIsDrawable(true); | 4055 to_return->SetIsDrawable(true); |
| 4056 return to_return; | 4056 return to_return; |
| 4057 } | 4057 } |
| 4058 | 4058 |
| (...skipping 3705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7764 | 7764 |
| 7765 class AnimationScaleFactorTrackingLayerImpl : public LayerImpl { | 7765 class AnimationScaleFactorTrackingLayerImpl : public LayerImpl { |
| 7766 public: | 7766 public: |
| 7767 static scoped_ptr<AnimationScaleFactorTrackingLayerImpl> Create( | 7767 static scoped_ptr<AnimationScaleFactorTrackingLayerImpl> Create( |
| 7768 LayerTreeImpl* tree_impl, | 7768 LayerTreeImpl* tree_impl, |
| 7769 int id) { | 7769 int id) { |
| 7770 return make_scoped_ptr( | 7770 return make_scoped_ptr( |
| 7771 new AnimationScaleFactorTrackingLayerImpl(tree_impl, id)); | 7771 new AnimationScaleFactorTrackingLayerImpl(tree_impl, id)); |
| 7772 } | 7772 } |
| 7773 | 7773 |
| 7774 virtual ~AnimationScaleFactorTrackingLayerImpl() {} | 7774 ~AnimationScaleFactorTrackingLayerImpl() override {} |
| 7775 | 7775 |
| 7776 private: | 7776 private: |
| 7777 explicit AnimationScaleFactorTrackingLayerImpl(LayerTreeImpl* tree_impl, | 7777 explicit AnimationScaleFactorTrackingLayerImpl(LayerTreeImpl* tree_impl, |
| 7778 int id) | 7778 int id) |
| 7779 : LayerImpl(tree_impl, id) { | 7779 : LayerImpl(tree_impl, id) { |
| 7780 SetDrawsContent(true); | 7780 SetDrawsContent(true); |
| 7781 } | 7781 } |
| 7782 }; | 7782 }; |
| 7783 | 7783 |
| 7784 TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { | 7784 TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8557 // by the viewport. | 8557 // by the viewport. |
| 8558 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect()); | 8558 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect()); |
| 8559 | 8559 |
| 8560 // Layers drawing to a child render surface should still have their visible | 8560 // Layers drawing to a child render surface should still have their visible |
| 8561 // content rect clipped by the viewport. | 8561 // content rect clipped by the viewport. |
| 8562 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect()); | 8562 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect()); |
| 8563 } | 8563 } |
| 8564 | 8564 |
| 8565 } // namespace | 8565 } // namespace |
| 8566 } // namespace cc | 8566 } // namespace cc |
| OLD | NEW |