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