OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/surface_aggregator_test_helpers.h" | 5 #include "cc/test/surface_aggregator_test_helpers.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 } | 46 } |
47 | 47 |
48 void AddRenderPassQuad(RenderPass* pass, int render_pass_id) { | 48 void AddRenderPassQuad(RenderPass* pass, int render_pass_id) { |
49 gfx::Rect output_rect = gfx::Rect(0, 0, 5, 5); | 49 gfx::Rect output_rect = gfx::Rect(0, 0, 5, 5); |
50 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); | 50 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); |
51 shared_state->SetAll(gfx::Transform(), output_rect.size(), output_rect, | 51 shared_state->SetAll(gfx::Transform(), output_rect.size(), output_rect, |
52 output_rect, false, 1, SkBlendMode::kSrcOver, 0); | 52 output_rect, false, 1, SkBlendMode::kSrcOver, 0); |
53 RenderPassDrawQuad* quad = | 53 RenderPassDrawQuad* quad = |
54 pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 54 pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
55 quad->SetNew(shared_state, output_rect, output_rect, render_pass_id, 0, | 55 quad->SetNew(shared_state, output_rect, output_rect, render_pass_id, 0, |
56 gfx::Vector2dF(), gfx::Size(), FilterOperations(), | 56 gfx::Vector2dF(), gfx::Size(), gfx::Vector2dF(), gfx::PointF()); |
57 gfx::Vector2dF(), gfx::PointF(), FilterOperations()); | |
58 } | 57 } |
59 | 58 |
60 void AddQuadInPass(RenderPass* pass, Quad desc) { | 59 void AddQuadInPass(RenderPass* pass, Quad desc) { |
61 switch (desc.material) { | 60 switch (desc.material) { |
62 case DrawQuad::SOLID_COLOR: | 61 case DrawQuad::SOLID_COLOR: |
63 AddQuad(pass, gfx::Rect(0, 0, 5, 5), desc.color); | 62 AddQuad(pass, gfx::Rect(0, 0, 5, 5), desc.color); |
64 break; | 63 break; |
65 case DrawQuad::SURFACE_CONTENT: | 64 case DrawQuad::SURFACE_CONTENT: |
66 AddSurfaceQuad(pass, gfx::Size(5, 5), desc.opacity, desc.surface_id); | 65 AddSurfaceQuad(pass, gfx::Size(5, 5), desc.opacity, desc.surface_id); |
67 break; | 66 break; |
68 case DrawQuad::RENDER_PASS: | 67 case DrawQuad::RENDER_PASS: |
69 AddRenderPassQuad(pass, desc.render_pass_id); | 68 AddRenderPassQuad(pass, desc.render_pass_id); |
70 break; | 69 break; |
71 default: | 70 default: |
72 NOTREACHED(); | 71 NOTREACHED(); |
73 } | 72 } |
74 } | 73 } |
75 | 74 |
76 void AddPasses(RenderPassList* pass_list, | 75 void AddPasses(RenderPassList* pass_list, |
77 const gfx::Rect& output_rect, | 76 const gfx::Rect& output_rect, |
78 Pass* passes, | 77 Pass* passes, |
79 size_t pass_count) { | 78 size_t pass_count) { |
80 gfx::Transform root_transform; | 79 gfx::Transform root_transform; |
81 for (size_t i = 0; i < pass_count; ++i) { | 80 for (size_t i = 0; i < pass_count; ++i) { |
82 Pass pass = passes[i]; | 81 Pass pass = passes[i]; |
83 RenderPass* test_pass = | 82 RenderPass* test_pass = AddRenderPass(pass_list, pass.id, output_rect, |
84 AddRenderPass(pass_list, pass.id, output_rect, root_transform); | 83 root_transform, FilterOperations()); |
85 for (size_t j = 0; j < pass.quad_count; ++j) { | 84 for (size_t j = 0; j < pass.quad_count; ++j) { |
86 AddQuadInPass(test_pass, pass.quads[j]); | 85 AddQuadInPass(test_pass, pass.quads[j]); |
87 } | 86 } |
88 } | 87 } |
89 } | 88 } |
90 | 89 |
91 void TestQuadMatchesExpectations(Quad expected_quad, const DrawQuad* quad) { | 90 void TestQuadMatchesExpectations(Quad expected_quad, const DrawQuad* quad) { |
92 switch (expected_quad.material) { | 91 switch (expected_quad.material) { |
93 case DrawQuad::SOLID_COLOR: { | 92 case DrawQuad::SOLID_COLOR: { |
94 ASSERT_EQ(DrawQuad::SOLID_COLOR, quad->material); | 93 ASSERT_EQ(DrawQuad::SOLID_COLOR, quad->material); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 129 |
131 for (size_t i = 0; i < passes->size(); ++i) { | 130 for (size_t i = 0; i < passes->size(); ++i) { |
132 SCOPED_TRACE(base::StringPrintf("Pass number %" PRIuS, i)); | 131 SCOPED_TRACE(base::StringPrintf("Pass number %" PRIuS, i)); |
133 RenderPass* pass = (*passes)[i].get(); | 132 RenderPass* pass = (*passes)[i].get(); |
134 TestPassMatchesExpectations(expected_passes[i], pass); | 133 TestPassMatchesExpectations(expected_passes[i], pass); |
135 } | 134 } |
136 } | 135 } |
137 | 136 |
138 } // namespace test | 137 } // namespace test |
139 } // namespace cc | 138 } // namespace cc |
OLD | NEW |