| 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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
| 12 #include "base/containers/scoped_ptr_hash_map.h" | 12 #include "base/containers/scoped_ptr_hash_map.h" |
| 13 #include "cc/animation/scrollbar_animation_controller_thinning.h" | 13 #include "cc/animation/scrollbar_animation_controller_thinning.h" |
| 14 #include "cc/base/latency_info_swap_promise.h" | 14 #include "cc/base/latency_info_swap_promise.h" |
| 15 #include "cc/base/math_util.h" | 15 #include "cc/base/math_util.h" |
| 16 #include "cc/input/top_controls_manager.h" | 16 #include "cc/input/top_controls_manager.h" |
| 17 #include "cc/layers/append_quads_data.h" | 17 #include "cc/layers/append_quads_data.h" |
| 18 #include "cc/layers/delegated_renderer_layer_impl.h" | 18 #include "cc/layers/delegated_renderer_layer_impl.h" |
| 19 #include "cc/layers/heads_up_display_layer_impl.h" | 19 #include "cc/layers/heads_up_display_layer_impl.h" |
| 20 #include "cc/layers/io_surface_layer_impl.h" | 20 #include "cc/layers/io_surface_layer_impl.h" |
| 21 #include "cc/layers/layer_impl.h" | 21 #include "cc/layers/layer_impl.h" |
| 22 #include "cc/layers/painted_scrollbar_layer_impl.h" | 22 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| 23 #include "cc/layers/quad_sink.h" | |
| 24 #include "cc/layers/render_surface_impl.h" | 23 #include "cc/layers/render_surface_impl.h" |
| 25 #include "cc/layers/solid_color_layer_impl.h" | 24 #include "cc/layers/solid_color_layer_impl.h" |
| 26 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 25 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 27 #include "cc/layers/texture_layer_impl.h" | 26 #include "cc/layers/texture_layer_impl.h" |
| 28 #include "cc/layers/tiled_layer_impl.h" | 27 #include "cc/layers/tiled_layer_impl.h" |
| 29 #include "cc/layers/video_layer_impl.h" | 28 #include "cc/layers/video_layer_impl.h" |
| 30 #include "cc/output/begin_frame_args.h" | 29 #include "cc/output/begin_frame_args.h" |
| 31 #include "cc/output/compositor_frame_ack.h" | 30 #include "cc/output/compositor_frame_ack.h" |
| 32 #include "cc/output/compositor_frame_metadata.h" | 31 #include "cc/output/compositor_frame_metadata.h" |
| 33 #include "cc/output/copy_output_request.h" | 32 #include "cc/output/copy_output_request.h" |
| (...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 } | 1653 } |
| 1655 | 1654 |
| 1656 virtual bool WillDraw(DrawMode draw_mode, ResourceProvider* provider) | 1655 virtual bool WillDraw(DrawMode draw_mode, ResourceProvider* provider) |
| 1657 OVERRIDE { | 1656 OVERRIDE { |
| 1658 will_draw_called_ = true; | 1657 will_draw_called_ = true; |
| 1659 if (will_draw_returns_false_) | 1658 if (will_draw_returns_false_) |
| 1660 return false; | 1659 return false; |
| 1661 return TiledLayerImpl::WillDraw(draw_mode, provider); | 1660 return TiledLayerImpl::WillDraw(draw_mode, provider); |
| 1662 } | 1661 } |
| 1663 | 1662 |
| 1664 virtual void AppendQuads(QuadSink* quad_sink, | 1663 virtual void AppendQuads(RenderPass* render_pass, |
| 1664 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 1665 AppendQuadsData* append_quads_data) OVERRIDE { | 1665 AppendQuadsData* append_quads_data) OVERRIDE { |
| 1666 append_quads_called_ = true; | 1666 append_quads_called_ = true; |
| 1667 TiledLayerImpl::AppendQuads(quad_sink, append_quads_data); | 1667 TiledLayerImpl::AppendQuads( |
| 1668 render_pass, occlusion_tracker, append_quads_data); |
| 1668 } | 1669 } |
| 1669 | 1670 |
| 1670 virtual void DidDraw(ResourceProvider* provider) OVERRIDE { | 1671 virtual void DidDraw(ResourceProvider* provider) OVERRIDE { |
| 1671 did_draw_called_ = true; | 1672 did_draw_called_ = true; |
| 1672 TiledLayerImpl::DidDraw(provider); | 1673 TiledLayerImpl::DidDraw(provider); |
| 1673 } | 1674 } |
| 1674 | 1675 |
| 1675 bool will_draw_called() const { return will_draw_called_; } | 1676 bool will_draw_called() const { return will_draw_called_; } |
| 1676 bool append_quads_called() const { return append_quads_called_; } | 1677 bool append_quads_called() const { return append_quads_called_; } |
| 1677 bool did_draw_called() const { return did_draw_called_; } | 1678 bool did_draw_called() const { return did_draw_called_; } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1883 ResourceProvider* resource_provider) { | 1884 ResourceProvider* resource_provider) { |
| 1884 return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer( | 1885 return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer( |
| 1885 tree_impl, | 1886 tree_impl, |
| 1886 id, | 1887 id, |
| 1887 tile_missing, | 1888 tile_missing, |
| 1888 skips_draw, | 1889 skips_draw, |
| 1889 animating, | 1890 animating, |
| 1890 resource_provider)); | 1891 resource_provider)); |
| 1891 } | 1892 } |
| 1892 | 1893 |
| 1893 virtual void AppendQuads(QuadSink* quad_sink, | 1894 virtual void AppendQuads(RenderPass* render_pass, |
| 1895 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 1894 AppendQuadsData* append_quads_data) OVERRIDE { | 1896 AppendQuadsData* append_quads_data) OVERRIDE { |
| 1895 TiledLayerImpl::AppendQuads(quad_sink, append_quads_data); | 1897 TiledLayerImpl::AppendQuads( |
| 1898 render_pass, occlusion_tracker, append_quads_data); |
| 1896 if (tile_missing_) | 1899 if (tile_missing_) |
| 1897 append_quads_data->had_incomplete_tile = true; | 1900 append_quads_data->had_incomplete_tile = true; |
| 1898 } | 1901 } |
| 1899 | 1902 |
| 1900 private: | 1903 private: |
| 1901 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, | 1904 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, |
| 1902 int id, | 1905 int id, |
| 1903 bool tile_missing, | 1906 bool tile_missing, |
| 1904 bool skips_draw, | 1907 bool skips_draw, |
| 1905 bool animating, | 1908 bool animating, |
| (...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3429 class BlendStateCheckLayer : public LayerImpl { | 3432 class BlendStateCheckLayer : public LayerImpl { |
| 3430 public: | 3433 public: |
| 3431 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, | 3434 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, |
| 3432 int id, | 3435 int id, |
| 3433 ResourceProvider* resource_provider) { | 3436 ResourceProvider* resource_provider) { |
| 3434 return scoped_ptr<LayerImpl>(new BlendStateCheckLayer(tree_impl, | 3437 return scoped_ptr<LayerImpl>(new BlendStateCheckLayer(tree_impl, |
| 3435 id, | 3438 id, |
| 3436 resource_provider)); | 3439 resource_provider)); |
| 3437 } | 3440 } |
| 3438 | 3441 |
| 3439 virtual void AppendQuads(QuadSink* quad_sink, | 3442 virtual void AppendQuads(RenderPass* render_pass, |
| 3443 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 3440 AppendQuadsData* append_quads_data) OVERRIDE { | 3444 AppendQuadsData* append_quads_data) OVERRIDE { |
| 3441 quads_appended_ = true; | 3445 quads_appended_ = true; |
| 3442 | 3446 |
| 3443 gfx::Rect opaque_rect; | 3447 gfx::Rect opaque_rect; |
| 3444 if (contents_opaque()) | 3448 if (contents_opaque()) |
| 3445 opaque_rect = quad_rect_; | 3449 opaque_rect = quad_rect_; |
| 3446 else | 3450 else |
| 3447 opaque_rect = opaque_content_rect_; | 3451 opaque_rect = opaque_content_rect_; |
| 3448 gfx::Rect visible_quad_rect = quad_rect_; | 3452 gfx::Rect visible_quad_rect = quad_rect_; |
| 3449 | 3453 |
| 3450 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 3454 SharedQuadState* shared_quad_state = |
| 3455 render_pass->CreateAndAppendSharedQuadState(); |
| 3451 PopulateSharedQuadState(shared_quad_state); | 3456 PopulateSharedQuadState(shared_quad_state); |
| 3452 | 3457 |
| 3453 scoped_ptr<TileDrawQuad> test_blending_draw_quad = TileDrawQuad::Create(); | 3458 scoped_ptr<TileDrawQuad> test_blending_draw_quad = TileDrawQuad::Create(); |
| 3454 test_blending_draw_quad->SetNew(shared_quad_state, | 3459 test_blending_draw_quad->SetNew(shared_quad_state, |
| 3455 quad_rect_, | 3460 quad_rect_, |
| 3456 opaque_rect, | 3461 opaque_rect, |
| 3457 visible_quad_rect, | 3462 visible_quad_rect, |
| 3458 resource_id_, | 3463 resource_id_, |
| 3459 gfx::RectF(0.f, 0.f, 1.f, 1.f), | 3464 gfx::RectF(0.f, 0.f, 1.f, 1.f), |
| 3460 gfx::Size(1, 1), | 3465 gfx::Size(1, 1), |
| 3461 false); | 3466 false); |
| 3462 test_blending_draw_quad->visible_rect = quad_visible_rect_; | 3467 test_blending_draw_quad->visible_rect = quad_visible_rect_; |
| 3463 EXPECT_EQ(blend_, test_blending_draw_quad->ShouldDrawWithBlending()); | 3468 EXPECT_EQ(blend_, test_blending_draw_quad->ShouldDrawWithBlending()); |
| 3464 EXPECT_EQ(has_render_surface_, !!render_surface()); | 3469 EXPECT_EQ(has_render_surface_, !!render_surface()); |
| 3465 quad_sink->Append(test_blending_draw_quad.PassAs<DrawQuad>()); | 3470 render_pass->AppendDrawQuad(test_blending_draw_quad.PassAs<DrawQuad>()); |
| 3466 } | 3471 } |
| 3467 | 3472 |
| 3468 void SetExpectation(bool blend, bool has_render_surface) { | 3473 void SetExpectation(bool blend, bool has_render_surface) { |
| 3469 blend_ = blend; | 3474 blend_ = blend; |
| 3470 has_render_surface_ = has_render_surface; | 3475 has_render_surface_ = has_render_surface; |
| 3471 quads_appended_ = false; | 3476 quads_appended_ = false; |
| 3472 } | 3477 } |
| 3473 | 3478 |
| 3474 bool quads_appended() const { return quads_appended_; } | 3479 bool quads_appended() const { return quads_appended_; } |
| 3475 | 3480 |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4194 EXPECT_EQ(1u, frame.render_passes.size()); | 4199 EXPECT_EQ(1u, frame.render_passes.size()); |
| 4195 host_impl_->DidDrawAllLayers(frame); | 4200 host_impl_->DidDrawAllLayers(frame); |
| 4196 } | 4201 } |
| 4197 | 4202 |
| 4198 class FakeLayerWithQuads : public LayerImpl { | 4203 class FakeLayerWithQuads : public LayerImpl { |
| 4199 public: | 4204 public: |
| 4200 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 4205 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
| 4201 return scoped_ptr<LayerImpl>(new FakeLayerWithQuads(tree_impl, id)); | 4206 return scoped_ptr<LayerImpl>(new FakeLayerWithQuads(tree_impl, id)); |
| 4202 } | 4207 } |
| 4203 | 4208 |
| 4204 virtual void AppendQuads(QuadSink* quad_sink, | 4209 virtual void AppendQuads(RenderPass* render_pass, |
| 4210 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 4205 AppendQuadsData* append_quads_data) OVERRIDE { | 4211 AppendQuadsData* append_quads_data) OVERRIDE { |
| 4206 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 4212 SharedQuadState* shared_quad_state = |
| 4213 render_pass->CreateAndAppendSharedQuadState(); |
| 4207 PopulateSharedQuadState(shared_quad_state); | 4214 PopulateSharedQuadState(shared_quad_state); |
| 4208 | 4215 |
| 4209 SkColor gray = SkColorSetRGB(100, 100, 100); | 4216 SkColor gray = SkColorSetRGB(100, 100, 100); |
| 4210 gfx::Rect quad_rect(content_bounds()); | 4217 gfx::Rect quad_rect(content_bounds()); |
| 4211 gfx::Rect visible_quad_rect(quad_rect); | 4218 gfx::Rect visible_quad_rect(quad_rect); |
| 4212 scoped_ptr<SolidColorDrawQuad> my_quad = SolidColorDrawQuad::Create(); | 4219 scoped_ptr<SolidColorDrawQuad> my_quad = SolidColorDrawQuad::Create(); |
| 4213 my_quad->SetNew( | 4220 my_quad->SetNew( |
| 4214 shared_quad_state, quad_rect, visible_quad_rect, gray, false); | 4221 shared_quad_state, quad_rect, visible_quad_rect, gray, false); |
| 4215 quad_sink->Append(my_quad.PassAs<DrawQuad>()); | 4222 render_pass->AppendDrawQuad(my_quad.PassAs<DrawQuad>()); |
| 4216 } | 4223 } |
| 4217 | 4224 |
| 4218 private: | 4225 private: |
| 4219 FakeLayerWithQuads(LayerTreeImpl* tree_impl, int id) | 4226 FakeLayerWithQuads(LayerTreeImpl* tree_impl, int id) |
| 4220 : LayerImpl(tree_impl, id) {} | 4227 : LayerImpl(tree_impl, id) {} |
| 4221 }; | 4228 }; |
| 4222 | 4229 |
| 4223 class MockContext : public TestWebGraphicsContext3D { | 4230 class MockContext : public TestWebGraphicsContext3D { |
| 4224 public: | 4231 public: |
| 4225 MOCK_METHOD1(useProgram, void(GLuint program)); | 4232 MOCK_METHOD1(useProgram, void(GLuint program)); |
| (...skipping 2390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6616 FakePictureLayerImpl* active_mask_content = | 6623 FakePictureLayerImpl* active_mask_content = |
| 6617 static_cast<FakePictureLayerImpl*>( | 6624 static_cast<FakePictureLayerImpl*>( |
| 6618 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); | 6625 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); |
| 6619 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); | 6626 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); |
| 6620 | 6627 |
| 6621 ASSERT_TRUE(!r2.IsEmpty()); | 6628 ASSERT_TRUE(!r2.IsEmpty()); |
| 6622 } | 6629 } |
| 6623 | 6630 |
| 6624 } // namespace | 6631 } // namespace |
| 6625 } // namespace cc | 6632 } // namespace cc |
| OLD | NEW |