history: break <label> relationship between time and delete checkbox.
[chromium-blink-merge.git] / cc / test / render_pass_test_common.cc
bloba667dce43e1ea1a90a262cab8b9179ee15445c84
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 "base/bind.h"
8 #include "cc/quads/checkerboard_draw_quad.h"
9 #include "cc/quads/debug_border_draw_quad.h"
10 #include "cc/quads/io_surface_draw_quad.h"
11 #include "cc/quads/render_pass_draw_quad.h"
12 #include "cc/quads/shared_quad_state.h"
13 #include "cc/quads/solid_color_draw_quad.h"
14 #include "cc/quads/stream_video_draw_quad.h"
15 #include "cc/quads/texture_draw_quad.h"
16 #include "cc/quads/tile_draw_quad.h"
17 #include "cc/quads/yuv_video_draw_quad.h"
18 #include "cc/resources/resource_provider.h"
19 #include "cc/trees/blocking_task_runner.h"
20 #include "ui/gfx/transform.h"
22 namespace cc {
24 static void EmptyReleaseCallback(uint32 sync_point,
25 bool lost_resource,
26 BlockingTaskRunner* main_thread_task_runner) {
29 void TestRenderPass::AppendOneOfEveryQuadType(
30 ResourceProvider* resource_provider,
31 RenderPassId child_pass) {
32 gfx::Rect rect(0, 0, 100, 100);
33 gfx::Rect opaque_rect(10, 10, 80, 80);
34 gfx::Rect visible_rect(0, 0, 100, 100);
35 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
37 ResourceProvider::ResourceId resource1 = resource_provider->CreateResource(
38 gfx::Size(45, 5),
39 GL_CLAMP_TO_EDGE,
40 ResourceProvider::TextureHintImmutable,
41 resource_provider->best_texture_format());
42 resource_provider->AllocateForTesting(resource1);
43 ResourceProvider::ResourceId resource2 = resource_provider->CreateResource(
44 gfx::Size(346, 61),
45 GL_CLAMP_TO_EDGE,
46 ResourceProvider::TextureHintImmutable,
47 resource_provider->best_texture_format());
48 resource_provider->AllocateForTesting(resource2);
49 ResourceProvider::ResourceId resource3 = resource_provider->CreateResource(
50 gfx::Size(12, 134),
51 GL_CLAMP_TO_EDGE,
52 ResourceProvider::TextureHintImmutable,
53 resource_provider->best_texture_format());
54 resource_provider->AllocateForTesting(resource3);
55 ResourceProvider::ResourceId resource4 = resource_provider->CreateResource(
56 gfx::Size(56, 12),
57 GL_CLAMP_TO_EDGE,
58 ResourceProvider::TextureHintImmutable,
59 resource_provider->best_texture_format());
60 resource_provider->AllocateForTesting(resource4);
61 gfx::Size resource5_size(73, 26);
62 ResourceProvider::ResourceId resource5 = resource_provider->CreateResource(
63 resource5_size,
64 GL_CLAMP_TO_EDGE,
65 ResourceProvider::TextureHintImmutable,
66 resource_provider->best_texture_format());
67 resource_provider->AllocateForTesting(resource5);
68 ResourceProvider::ResourceId resource6 = resource_provider->CreateResource(
69 gfx::Size(64, 92),
70 GL_CLAMP_TO_EDGE,
71 ResourceProvider::TextureHintImmutable,
72 resource_provider->best_texture_format());
73 resource_provider->AllocateForTesting(resource6);
74 ResourceProvider::ResourceId resource7 = resource_provider->CreateResource(
75 gfx::Size(9, 14),
76 GL_CLAMP_TO_EDGE,
77 ResourceProvider::TextureHintImmutable,
78 resource_provider->best_texture_format());
79 resource_provider->AllocateForTesting(resource7);
81 unsigned target = GL_TEXTURE_2D;
82 gpu::Mailbox gpu_mailbox;
83 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
84 scoped_ptr<SingleReleaseCallbackImpl> callback =
85 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
86 TextureMailbox mailbox(gpu_mailbox, target, kSyncPointForMailboxTextureQuad);
87 ResourceProvider::ResourceId resource8 =
88 resource_provider->CreateResourceFromTextureMailbox(mailbox,
89 callback.Pass());
90 resource_provider->AllocateForTesting(resource8);
92 SharedQuadState* shared_state = this->CreateAndAppendSharedQuadState();
93 shared_state->SetAll(gfx::Transform(),
94 rect.size(),
95 rect,
96 rect,
97 false,
99 SkXfermode::kSrcOver_Mode,
102 CheckerboardDrawQuad* checkerboard_quad =
103 this->CreateAndAppendDrawQuad<CheckerboardDrawQuad>();
104 checkerboard_quad->SetNew(shared_state, rect, visible_rect, SK_ColorRED);
106 DebugBorderDrawQuad* debug_border_quad =
107 this->CreateAndAppendDrawQuad<DebugBorderDrawQuad>();
108 debug_border_quad->SetNew(shared_state, rect, visible_rect, SK_ColorRED, 1);
110 IOSurfaceDrawQuad* io_surface_quad =
111 this->CreateAndAppendDrawQuad<IOSurfaceDrawQuad>();
112 io_surface_quad->SetNew(shared_state,
113 rect,
114 opaque_rect,
115 visible_rect,
116 gfx::Size(50, 50),
117 resource7,
118 IOSurfaceDrawQuad::FLIPPED);
120 if (child_pass.layer_id) {
121 RenderPassDrawQuad* render_pass_quad =
122 this->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
123 render_pass_quad->SetNew(shared_state,
124 rect,
125 visible_rect,
126 child_pass,
127 resource5,
128 gfx::Vector2dF(1.f, 1.f),
129 resource5_size,
130 FilterOperations(),
131 gfx::Vector2dF(),
132 FilterOperations());
134 RenderPassDrawQuad* render_pass_replica_quad =
135 this->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
136 render_pass_replica_quad->SetNew(shared_state,
137 rect,
138 visible_rect,
139 child_pass,
140 resource5,
141 gfx::Vector2dF(1.f, 1.f),
142 resource5_size,
143 FilterOperations(),
144 gfx::Vector2dF(),
145 FilterOperations());
148 SolidColorDrawQuad* solid_color_quad =
149 this->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
150 solid_color_quad->SetNew(
151 shared_state, rect, visible_rect, SK_ColorRED, false);
153 StreamVideoDrawQuad* stream_video_quad =
154 this->CreateAndAppendDrawQuad<StreamVideoDrawQuad>();
155 stream_video_quad->SetNew(shared_state,
156 rect,
157 opaque_rect,
158 visible_rect,
159 resource6,
160 gfx::Transform());
162 TextureDrawQuad* texture_quad =
163 this->CreateAndAppendDrawQuad<TextureDrawQuad>();
164 texture_quad->SetNew(shared_state,
165 rect,
166 opaque_rect,
167 visible_rect,
168 resource1,
169 false,
170 gfx::PointF(0.f, 0.f),
171 gfx::PointF(1.f, 1.f),
172 SK_ColorTRANSPARENT,
173 vertex_opacity,
174 false);
176 TextureDrawQuad* mailbox_texture_quad =
177 this->CreateAndAppendDrawQuad<TextureDrawQuad>();
178 mailbox_texture_quad->SetNew(shared_state,
179 rect,
180 opaque_rect,
181 visible_rect,
182 resource8,
183 false,
184 gfx::PointF(0.f, 0.f),
185 gfx::PointF(1.f, 1.f),
186 SK_ColorTRANSPARENT,
187 vertex_opacity,
188 false);
190 TileDrawQuad* scaled_tile_quad =
191 this->CreateAndAppendDrawQuad<TileDrawQuad>();
192 scaled_tile_quad->SetNew(shared_state,
193 rect,
194 opaque_rect,
195 visible_rect,
196 resource2,
197 gfx::RectF(0, 0, 50, 50),
198 gfx::Size(50, 50),
199 false);
201 SharedQuadState* transformed_state = this->CreateAndAppendSharedQuadState();
202 transformed_state->CopyFrom(shared_state);
203 gfx::Transform rotation;
204 rotation.Rotate(45);
205 transformed_state->content_to_target_transform =
206 transformed_state->content_to_target_transform * rotation;
207 TileDrawQuad* transformed_tile_quad =
208 this->CreateAndAppendDrawQuad<TileDrawQuad>();
209 transformed_tile_quad->SetNew(transformed_state,
210 rect,
211 opaque_rect,
212 visible_rect,
213 resource3,
214 gfx::RectF(0, 0, 100, 100),
215 gfx::Size(100, 100),
216 false);
218 SharedQuadState* shared_state2 = this->CreateAndAppendSharedQuadState();
219 shared_state->SetAll(gfx::Transform(),
220 rect.size(),
221 rect,
222 rect,
223 false,
225 SkXfermode::kSrcOver_Mode,
228 TileDrawQuad* tile_quad = this->CreateAndAppendDrawQuad<TileDrawQuad>();
229 tile_quad->SetNew(shared_state2,
230 rect,
231 opaque_rect,
232 visible_rect,
233 resource4,
234 gfx::RectF(0, 0, 100, 100),
235 gfx::Size(100, 100),
236 false);
238 ResourceProvider::ResourceId plane_resources[4];
239 for (int i = 0; i < 4; ++i) {
240 plane_resources[i] = resource_provider->CreateResource(
241 gfx::Size(20, 12),
242 GL_CLAMP_TO_EDGE,
243 ResourceProvider::TextureHintImmutable,
244 resource_provider->best_texture_format());
245 resource_provider->AllocateForTesting(plane_resources[i]);
247 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601;
248 YUVVideoDrawQuad* yuv_quad =
249 this->CreateAndAppendDrawQuad<YUVVideoDrawQuad>();
250 yuv_quad->SetNew(shared_state2,
251 rect,
252 opaque_rect,
253 visible_rect,
254 gfx::RectF(0, 0, 100, 100),
255 plane_resources[0],
256 plane_resources[1],
257 plane_resources[2],
258 plane_resources[3],
259 color_space);
262 } // namespace cc