Adding Peter Thatcher to the owners file.
[chromium-blink-merge.git] / cc / test / render_pass_test_utils.cc
blobf9def0f79263d17dc754f0b3512a95d0cdd7f513
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.
5 #include "cc/test/render_pass_test_utils.h"
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"
16 namespace cc {
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;
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,
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;
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,
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;
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,
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;
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,
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,
103 gfx::Vector2dF(),
104 gfx::Size(),
105 FilterOperations(),
106 gfx::Vector2dF(),
107 FilterOperations());
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,
124 blend_mode,
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());
141 } // namespace cc