Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / cc / test / render_pass_test_common.cc
blob98d085c0874a007b4ca3be3614b96bffcb811891
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_common.h"
7 #include "cc/quads/checkerboard_draw_quad.h"
8 #include "cc/quads/debug_border_draw_quad.h"
9 #include "cc/quads/io_surface_draw_quad.h"
10 #include "cc/quads/render_pass_draw_quad.h"
11 #include "cc/quads/shared_quad_state.h"
12 #include "cc/quads/solid_color_draw_quad.h"
13 #include "cc/quads/stream_video_draw_quad.h"
14 #include "cc/quads/texture_draw_quad.h"
15 #include "cc/quads/tile_draw_quad.h"
16 #include "cc/quads/yuv_video_draw_quad.h"
17 #include "cc/resources/resource_provider.h"
18 #include "ui/gfx/transform.h"
20 namespace cc {
22 void TestRenderPass::AppendOneOfEveryQuadType(
23 ResourceProvider* resource_provider,
24 RenderPass::Id child_pass) {
25 gfx::Rect rect(0, 0, 100, 100);
26 gfx::Rect opaque_rect(10, 10, 80, 80);
27 gfx::Rect visible_rect(0, 0, 100, 100);
28 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
29 ResourceProvider::ResourceId resource1 = resource_provider->CreateResource(
30 gfx::Size(45, 5),
31 GL_CLAMP_TO_EDGE,
32 ResourceProvider::TextureUsageAny,
33 resource_provider->best_texture_format());
34 resource_provider->AllocateForTesting(resource1);
35 ResourceProvider::ResourceId resource2 = resource_provider->CreateResource(
36 gfx::Size(346, 61),
37 GL_CLAMP_TO_EDGE,
38 ResourceProvider::TextureUsageAny,
39 resource_provider->best_texture_format());
40 resource_provider->AllocateForTesting(resource2);
41 ResourceProvider::ResourceId resource3 = resource_provider->CreateResource(
42 gfx::Size(12, 134),
43 GL_CLAMP_TO_EDGE,
44 ResourceProvider::TextureUsageAny,
45 resource_provider->best_texture_format());
46 resource_provider->AllocateForTesting(resource3);
47 ResourceProvider::ResourceId resource4 = resource_provider->CreateResource(
48 gfx::Size(56, 12),
49 GL_CLAMP_TO_EDGE,
50 ResourceProvider::TextureUsageAny,
51 resource_provider->best_texture_format());
52 resource_provider->AllocateForTesting(resource4);
53 ResourceProvider::ResourceId resource5 = resource_provider->CreateResource(
54 gfx::Size(73, 26),
55 GL_CLAMP_TO_EDGE,
56 ResourceProvider::TextureUsageAny,
57 resource_provider->best_texture_format());
58 resource_provider->AllocateForTesting(resource5);
59 ResourceProvider::ResourceId resource6 = resource_provider->CreateResource(
60 gfx::Size(64, 92),
61 GL_CLAMP_TO_EDGE,
62 ResourceProvider::TextureUsageAny,
63 resource_provider->best_texture_format());
64 resource_provider->AllocateForTesting(resource6);
65 ResourceProvider::ResourceId resource7 = resource_provider->CreateResource(
66 gfx::Size(9, 14),
67 GL_CLAMP_TO_EDGE,
68 ResourceProvider::TextureUsageAny,
69 resource_provider->best_texture_format());
70 resource_provider->AllocateForTesting(resource7);
72 SharedQuadState* shared_state = this->CreateAndAppendSharedQuadState();
73 shared_state->SetAll(gfx::Transform(),
74 rect.size(),
75 rect,
76 rect,
77 false,
79 SkXfermode::kSrcOver_Mode,
80 0);
82 CheckerboardDrawQuad* checkerboard_quad =
83 this->CreateAndAppendDrawQuad<CheckerboardDrawQuad>();
84 checkerboard_quad->SetNew(shared_state, rect, visible_rect, SK_ColorRED);
86 DebugBorderDrawQuad* debug_border_quad =
87 this->CreateAndAppendDrawQuad<DebugBorderDrawQuad>();
88 debug_border_quad->SetNew(shared_state, rect, visible_rect, SK_ColorRED, 1);
90 IOSurfaceDrawQuad* io_surface_quad =
91 this->CreateAndAppendDrawQuad<IOSurfaceDrawQuad>();
92 io_surface_quad->SetNew(shared_state,
93 rect,
94 opaque_rect,
95 visible_rect,
96 gfx::Size(50, 50),
97 resource7,
98 IOSurfaceDrawQuad::FLIPPED);
100 if (child_pass.layer_id) {
101 RenderPassDrawQuad* render_pass_quad =
102 this->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
103 render_pass_quad->SetNew(shared_state,
104 rect,
105 visible_rect,
106 child_pass,
107 false,
108 resource5,
109 rect,
110 gfx::RectF(),
111 FilterOperations(),
112 FilterOperations());
114 RenderPassDrawQuad* render_pass_replica_quad =
115 this->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
116 render_pass_replica_quad->SetNew(shared_state,
117 rect,
118 visible_rect,
119 child_pass,
120 true,
121 resource5,
122 rect,
123 gfx::RectF(),
124 FilterOperations(),
125 FilterOperations());
128 SolidColorDrawQuad* solid_color_quad =
129 this->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
130 solid_color_quad->SetNew(
131 shared_state, rect, visible_rect, SK_ColorRED, false);
133 StreamVideoDrawQuad* stream_video_quad =
134 this->CreateAndAppendDrawQuad<StreamVideoDrawQuad>();
135 stream_video_quad->SetNew(shared_state,
136 rect,
137 opaque_rect,
138 visible_rect,
139 resource6,
140 gfx::Transform());
142 TextureDrawQuad* texture_quad =
143 this->CreateAndAppendDrawQuad<TextureDrawQuad>();
144 texture_quad->SetNew(shared_state,
145 rect,
146 opaque_rect,
147 visible_rect,
148 resource1,
149 false,
150 gfx::PointF(0.f, 0.f),
151 gfx::PointF(1.f, 1.f),
152 SK_ColorTRANSPARENT,
153 vertex_opacity,
154 false);
156 TileDrawQuad* scaled_tile_quad =
157 this->CreateAndAppendDrawQuad<TileDrawQuad>();
158 scaled_tile_quad->SetNew(shared_state,
159 rect,
160 opaque_rect,
161 visible_rect,
162 resource2,
163 gfx::RectF(0, 0, 50, 50),
164 gfx::Size(50, 50),
165 false);
167 SharedQuadState* transformed_state = this->CreateAndAppendSharedQuadState();
168 transformed_state->CopyFrom(shared_state);
169 gfx::Transform rotation;
170 rotation.Rotate(45);
171 transformed_state->content_to_target_transform =
172 transformed_state->content_to_target_transform * rotation;
173 TileDrawQuad* transformed_tile_quad =
174 this->CreateAndAppendDrawQuad<TileDrawQuad>();
175 transformed_tile_quad->SetNew(transformed_state,
176 rect,
177 opaque_rect,
178 visible_rect,
179 resource3,
180 gfx::RectF(0, 0, 100, 100),
181 gfx::Size(100, 100),
182 false);
184 SharedQuadState* shared_state2 = this->CreateAndAppendSharedQuadState();
185 shared_state->SetAll(gfx::Transform(),
186 rect.size(),
187 rect,
188 rect,
189 false,
191 SkXfermode::kSrcOver_Mode,
194 TileDrawQuad* tile_quad = this->CreateAndAppendDrawQuad<TileDrawQuad>();
195 tile_quad->SetNew(shared_state2,
196 rect,
197 opaque_rect,
198 visible_rect,
199 resource4,
200 gfx::RectF(0, 0, 100, 100),
201 gfx::Size(100, 100),
202 false);
204 ResourceProvider::ResourceId plane_resources[4];
205 for (int i = 0; i < 4; ++i) {
206 plane_resources[i] =
207 resource_provider->CreateResource(
208 gfx::Size(20, 12),
209 GL_CLAMP_TO_EDGE,
210 ResourceProvider::TextureUsageAny,
211 resource_provider->best_texture_format());
212 resource_provider->AllocateForTesting(plane_resources[i]);
214 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601;
215 YUVVideoDrawQuad* yuv_quad =
216 this->CreateAndAppendDrawQuad<YUVVideoDrawQuad>();
217 yuv_quad->SetNew(shared_state2,
218 rect,
219 opaque_rect,
220 visible_rect,
221 gfx::RectF(0, 0, 100, 100),
222 plane_resources[0],
223 plane_resources[1],
224 plane_resources[2],
225 plane_resources[3],
226 color_space);
229 } // namespace cc