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