| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/test/render_pass_test_utils.h" | 5 #include "cc/test/render_pass_test_utils.h" |
| 6 | 6 |
| 7 #include "cc/layers/quad_sink.h" | 7 #include "cc/layers/quad_sink.h" |
| 8 #include "cc/quads/render_pass_draw_quad.h" | 8 #include "cc/quads/render_pass_draw_quad.h" |
| 9 #include "cc/quads/shared_quad_state.h" | 9 #include "cc/quads/shared_quad_state.h" |
| 10 #include "cc/quads/solid_color_draw_quad.h" | 10 #include "cc/quads/solid_color_draw_quad.h" |
| 11 #include "cc/resources/resource_provider.h" | 11 #include "cc/resources/resource_provider.h" |
| 12 #include "cc/test/mock_quad_culler.h" | |
| 13 #include "cc/test/render_pass_test_common.h" | 12 #include "cc/test/render_pass_test_common.h" |
| 14 #include "third_party/skia/include/core/SkColor.h" | 13 #include "third_party/skia/include/core/SkColor.h" |
| 15 #include "third_party/skia/include/core/SkImageFilter.h" | 14 #include "third_party/skia/include/core/SkImageFilter.h" |
| 16 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 17 | 16 |
| 18 namespace cc { | 17 namespace cc { |
| 19 | 18 |
| 20 TestRenderPass* AddRenderPass(RenderPassList* pass_list, | 19 TestRenderPass* AddRenderPass(RenderPassList* pass_list, |
| 21 RenderPass::Id id, | 20 RenderPass::Id id, |
| 22 const gfx::Rect& output_rect, | 21 const gfx::Rect& output_rect, |
| 23 const gfx::Transform& root_transform) { | 22 const gfx::Transform& root_transform) { |
| 24 scoped_ptr<TestRenderPass> pass(TestRenderPass::Create()); | 23 scoped_ptr<TestRenderPass> pass(TestRenderPass::Create()); |
| 25 pass->SetNew(id, output_rect, output_rect, root_transform); | 24 pass->SetNew(id, output_rect, output_rect, root_transform); |
| 26 TestRenderPass* saved = pass.get(); | 25 TestRenderPass* saved = pass.get(); |
| 27 pass_list->push_back(pass.PassAs<RenderPass>()); | 26 pass_list->push_back(pass.PassAs<RenderPass>()); |
| 28 return saved; | 27 return saved; |
| 29 } | 28 } |
| 30 | 29 |
| 31 SolidColorDrawQuad* AddQuad(TestRenderPass* pass, | 30 SolidColorDrawQuad* AddQuad(TestRenderPass* pass, |
| 32 const gfx::Rect& rect, | 31 const gfx::Rect& rect, |
| 33 SkColor color) { | 32 SkColor color) { |
| 34 MockQuadCuller quad_sink(pass); | 33 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); |
| 35 SharedQuadState* shared_state = quad_sink.CreateSharedQuadState(); | |
| 36 shared_state->SetAll(gfx::Transform(), | 34 shared_state->SetAll(gfx::Transform(), |
| 37 rect.size(), | 35 rect.size(), |
| 38 rect, | 36 rect, |
| 39 rect, | 37 rect, |
| 40 false, | 38 false, |
| 41 1, | 39 1, |
| 42 SkXfermode::kSrcOver_Mode); | 40 SkXfermode::kSrcOver_Mode); |
| 43 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 41 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 44 quad->SetNew(shared_state, rect, rect, color, false); | 42 quad->SetNew(shared_state, rect, rect, color, false); |
| 45 SolidColorDrawQuad* quad_ptr = quad.get(); | 43 SolidColorDrawQuad* quad_ptr = quad.get(); |
| 46 quad_sink.Append(quad.PassAs<DrawQuad>()); | 44 pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
| 47 return quad_ptr; | 45 return quad_ptr; |
| 48 } | 46 } |
| 49 | 47 |
| 50 SolidColorDrawQuad* AddClippedQuad(TestRenderPass* pass, | 48 SolidColorDrawQuad* AddClippedQuad(TestRenderPass* pass, |
| 51 const gfx::Rect& rect, | 49 const gfx::Rect& rect, |
| 52 SkColor color) { | 50 SkColor color) { |
| 53 MockQuadCuller quad_sink(pass); | 51 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); |
| 54 SharedQuadState* shared_state = quad_sink.CreateSharedQuadState(); | |
| 55 shared_state->SetAll(gfx::Transform(), | 52 shared_state->SetAll(gfx::Transform(), |
| 56 rect.size(), | 53 rect.size(), |
| 57 rect, | 54 rect, |
| 58 rect, | 55 rect, |
| 59 true, | 56 true, |
| 60 1, | 57 1, |
| 61 SkXfermode::kSrcOver_Mode); | 58 SkXfermode::kSrcOver_Mode); |
| 62 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 59 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 63 quad->SetNew(shared_state, rect, rect, color, false); | 60 quad->SetNew(shared_state, rect, rect, color, false); |
| 64 SolidColorDrawQuad* quad_ptr = quad.get(); | 61 SolidColorDrawQuad* quad_ptr = quad.get(); |
| 65 quad_sink.Append(quad.PassAs<DrawQuad>()); | 62 pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
| 66 return quad_ptr; | 63 return quad_ptr; |
| 67 } | 64 } |
| 68 | 65 |
| 69 SolidColorDrawQuad* AddTransformedQuad(TestRenderPass* pass, | 66 SolidColorDrawQuad* AddTransformedQuad(TestRenderPass* pass, |
| 70 const gfx::Rect& rect, | 67 const gfx::Rect& rect, |
| 71 SkColor color, | 68 SkColor color, |
| 72 const gfx::Transform& transform) { | 69 const gfx::Transform& transform) { |
| 73 MockQuadCuller quad_sink(pass); | 70 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); |
| 74 SharedQuadState* shared_state = quad_sink.CreateSharedQuadState(); | |
| 75 shared_state->SetAll( | 71 shared_state->SetAll( |
| 76 transform, rect.size(), rect, rect, false, 1, SkXfermode::kSrcOver_Mode); | 72 transform, rect.size(), rect, rect, false, 1, SkXfermode::kSrcOver_Mode); |
| 77 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 73 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 78 quad->SetNew(shared_state, rect, rect, color, false); | 74 quad->SetNew(shared_state, rect, rect, color, false); |
| 79 SolidColorDrawQuad* quad_ptr = quad.get(); | 75 SolidColorDrawQuad* quad_ptr = quad.get(); |
| 80 quad_sink.Append(quad.PassAs<DrawQuad>()); | 76 pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
| 81 return quad_ptr; | 77 return quad_ptr; |
| 82 } | 78 } |
| 83 | 79 |
| 84 void AddRenderPassQuad(TestRenderPass* to_pass, | 80 void AddRenderPassQuad(TestRenderPass* to_pass, |
| 85 TestRenderPass* contributing_pass) { | 81 TestRenderPass* contributing_pass) { |
| 86 MockQuadCuller quad_sink(to_pass); | |
| 87 gfx::Rect output_rect = contributing_pass->output_rect; | 82 gfx::Rect output_rect = contributing_pass->output_rect; |
| 88 SharedQuadState* shared_state = quad_sink.CreateSharedQuadState(); | 83 SharedQuadState* shared_state = to_pass->CreateAndAppendSharedQuadState(); |
| 89 shared_state->SetAll(gfx::Transform(), | 84 shared_state->SetAll(gfx::Transform(), |
| 90 output_rect.size(), | 85 output_rect.size(), |
| 91 output_rect, | 86 output_rect, |
| 92 output_rect, | 87 output_rect, |
| 93 false, | 88 false, |
| 94 1, | 89 1, |
| 95 SkXfermode::kSrcOver_Mode); | 90 SkXfermode::kSrcOver_Mode); |
| 96 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); | 91 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); |
| 97 quad->SetNew(shared_state, | 92 quad->SetNew(shared_state, |
| 98 output_rect, | 93 output_rect, |
| 99 output_rect, | 94 output_rect, |
| 100 contributing_pass->id, | 95 contributing_pass->id, |
| 101 false, | 96 false, |
| 102 0, | 97 0, |
| 103 output_rect, | 98 output_rect, |
| 104 gfx::RectF(), | 99 gfx::RectF(), |
| 105 FilterOperations(), | 100 FilterOperations(), |
| 106 FilterOperations()); | 101 FilterOperations()); |
| 107 quad_sink.Append(quad.PassAs<DrawQuad>()); | 102 to_pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
| 108 } | 103 } |
| 109 | 104 |
| 110 void AddRenderPassQuad(TestRenderPass* to_pass, | 105 void AddRenderPassQuad(TestRenderPass* to_pass, |
| 111 TestRenderPass* contributing_pass, | 106 TestRenderPass* contributing_pass, |
| 112 ResourceProvider::ResourceId mask_resource_id, | 107 ResourceProvider::ResourceId mask_resource_id, |
| 113 const FilterOperations& filters, | 108 const FilterOperations& filters, |
| 114 gfx::Transform transform) { | 109 gfx::Transform transform) { |
| 115 MockQuadCuller quad_sink(to_pass); | |
| 116 gfx::Rect output_rect = contributing_pass->output_rect; | 110 gfx::Rect output_rect = contributing_pass->output_rect; |
| 117 SharedQuadState* shared_state = quad_sink.CreateSharedQuadState(); | 111 SharedQuadState* shared_state = to_pass->CreateAndAppendSharedQuadState(); |
| 118 shared_state->SetAll(transform, | 112 shared_state->SetAll(transform, |
| 119 output_rect.size(), | 113 output_rect.size(), |
| 120 output_rect, | 114 output_rect, |
| 121 output_rect, | 115 output_rect, |
| 122 false, | 116 false, |
| 123 1, | 117 1, |
| 124 SkXfermode::kSrcOver_Mode); | 118 SkXfermode::kSrcOver_Mode); |
| 125 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); | 119 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); |
| 126 quad->SetNew(shared_state, | 120 quad->SetNew(shared_state, |
| 127 output_rect, | 121 output_rect, |
| 128 output_rect, | 122 output_rect, |
| 129 contributing_pass->id, | 123 contributing_pass->id, |
| 130 false, | 124 false, |
| 131 mask_resource_id, | 125 mask_resource_id, |
| 132 output_rect, | 126 output_rect, |
| 133 gfx::RectF(), | 127 gfx::RectF(), |
| 134 filters, | 128 filters, |
| 135 FilterOperations()); | 129 FilterOperations()); |
| 136 quad_sink.Append(quad.PassAs<DrawQuad>()); | 130 to_pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
| 137 } | 131 } |
| 138 | 132 |
| 139 } // namespace cc | 133 } // namespace cc |
| OLD | NEW |