OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "cc/layers/append_quads_data.h" | 6 #include "cc/layers/append_quads_data.h" |
7 #include "cc/output/gl_renderer.h" | 7 #include "cc/output/gl_renderer.h" |
8 #include "cc/quads/draw_quad.h" | 8 #include "cc/quads/draw_quad.h" |
9 #include "cc/quads/picture_draw_quad.h" | 9 #include "cc/quads/picture_draw_quad.h" |
10 #include "cc/resources/platform_color.h" | 10 #include "cc/resources/platform_color.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 pass_list.push_back(child_pass.Pass()); | 200 pass_list.push_back(child_pass.Pass()); |
201 pass_list.push_back(root_pass.Pass()); | 201 pass_list.push_back(root_pass.Pass()); |
202 | 202 |
203 EXPECT_TRUE(this->RunPixelTestWithReadbackTarget( | 203 EXPECT_TRUE(this->RunPixelTestWithReadbackTarget( |
204 &pass_list, | 204 &pass_list, |
205 child_pass_ptr, | 205 child_pass_ptr, |
206 base::FilePath(FILE_PATH_LITERAL("green_small.png")), | 206 base::FilePath(FILE_PATH_LITERAL("green_small.png")), |
207 ExactPixelComparator(true))); | 207 ExactPixelComparator(true))); |
208 } | 208 } |
209 | 209 |
210 class VideoGLRendererPixelTest : public GLRendererPixelTest { | |
211 protected: | |
212 scoped_ptr<YUVVideoDrawQuad> CreateTestYUVVideoDrawQuad( | |
213 SharedQuadState* shared_state, bool with_alpha) { | |
214 gfx::Rect rect(this->device_viewport_size_); | |
215 gfx::Rect opaque_rect(0, 0, 0, 0); | |
216 | |
217 ResourceProvider::ResourceId y_resource = | |
218 resource_provider_->CreateResource( | |
219 this->device_viewport_size_, | |
220 GL_LUMINANCE, | |
221 ResourceProvider::TextureUsageAny); | |
222 ResourceProvider::ResourceId u_resource = | |
223 resource_provider_->CreateResource( | |
224 this->device_viewport_size_, | |
225 GL_LUMINANCE, | |
226 ResourceProvider::TextureUsageAny); | |
227 ResourceProvider::ResourceId v_resource = | |
228 resource_provider_->CreateResource( | |
229 this->device_viewport_size_, | |
230 GL_LUMINANCE, | |
231 ResourceProvider::TextureUsageAny); | |
232 ResourceProvider::ResourceId a_resource = 0; | |
233 if (with_alpha) { | |
234 a_resource = resource_provider_->CreateResource( | |
235 this->device_viewport_size_, | |
236 GL_LUMINANCE, | |
237 ResourceProvider::TextureUsageAny); | |
238 } | |
239 | |
240 int w = this->device_viewport_size_.width(); | |
241 int h = this->device_viewport_size_.height(); | |
242 const int y_plane_size = w * h; | |
243 const int uv_plane_size = ((w + 1) / 2) * ((h + 1) / 2); | |
244 scoped_ptr<uint8_t[]> y_plane(new uint8_t[y_plane_size]); | |
245 scoped_ptr<uint8_t[]> u_plane(new uint8_t[uv_plane_size]); | |
246 scoped_ptr<uint8_t[]> v_plane(new uint8_t[uv_plane_size]); | |
247 scoped_ptr<uint8_t[]> a_plane; | |
248 if (with_alpha) | |
249 a_plane.reset(new uint8_t[y_plane_size]); | |
250 // YUV values representing Green. | |
251 memset(y_plane.get(), 149, y_plane_size); | |
252 memset(u_plane.get(), 43, uv_plane_size); | |
253 memset(v_plane.get(), 21, uv_plane_size); | |
254 if (with_alpha) | |
255 memset(a_plane.get(), 128, y_plane_size); | |
256 | |
257 gfx::Rect uv_rect((w + 1) / 2, (h + 1) / 2); | |
piman
2013/06/07 02:56:23
Can you move this before uv_plane_size, and make
enne (OOO)
2013/06/07 02:56:33
Consider moving uv_rect's declaration above uv_pla
vignesh
2013/06/07 04:17:03
Done. Doing this as piman@ suggested.
| |
258 resource_provider_->SetPixels(y_resource, y_plane.get(), rect, rect, | |
259 gfx::Vector2d()); | |
260 resource_provider_->SetPixels(u_resource, u_plane.get(), uv_rect, uv_rect, | |
261 gfx::Vector2d()); | |
262 resource_provider_->SetPixels(v_resource, v_plane.get(), uv_rect, uv_rect, | |
263 gfx::Vector2d()); | |
264 if (with_alpha) { | |
265 resource_provider_->SetPixels(a_resource, a_plane.get(), rect, rect, | |
266 gfx::Vector2d()); | |
267 } | |
268 | |
269 scoped_ptr<YUVVideoDrawQuad> yuv_quad = cc::YUVVideoDrawQuad::Create(); | |
270 yuv_quad->SetNew(shared_state, rect, opaque_rect, gfx::Size(), | |
271 y_resource, u_resource, v_resource, a_resource); | |
272 return yuv_quad.Pass(); | |
273 } | |
274 }; | |
275 | |
276 TEST_F(VideoGLRendererPixelTest, SimpleYUVRect) { | |
277 gfx::Rect rect(this->device_viewport_size_); | |
278 | |
279 RenderPass::Id id(1, 1); | |
280 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | |
281 | |
282 scoped_ptr<SharedQuadState> shared_state = | |
283 CreateTestSharedQuadState(gfx::Transform(), rect); | |
284 | |
285 scoped_ptr<YUVVideoDrawQuad> yuv_quad = | |
286 CreateTestYUVVideoDrawQuad(shared_state.get(), false); | |
287 | |
288 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | |
289 | |
290 RenderPassList pass_list; | |
291 pass_list.push_back(pass.Pass()); | |
292 | |
293 EXPECT_TRUE(this->RunPixelTest( | |
294 &pass_list, | |
295 base::FilePath(FILE_PATH_LITERAL("green.png")), | |
296 ExactPixelComparator(true))); | |
297 } | |
298 | |
299 TEST_F(VideoGLRendererPixelTest, SimpleYUVARect) { | |
300 gfx::Rect rect(this->device_viewport_size_); | |
301 | |
302 RenderPass::Id id(1, 1); | |
303 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | |
304 | |
305 scoped_ptr<SharedQuadState> shared_state = | |
306 CreateTestSharedQuadState(gfx::Transform(), rect); | |
307 | |
308 scoped_ptr<YUVVideoDrawQuad> yuv_quad = | |
309 CreateTestYUVVideoDrawQuad(shared_state.get(), true); | |
310 | |
311 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | |
312 | |
313 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); | |
314 color_quad->SetNew(shared_state.get(), rect, SK_ColorWHITE, false); | |
315 | |
316 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); | |
317 | |
318 RenderPassList pass_list; | |
319 pass_list.push_back(pass.Pass()); | |
320 | |
321 EXPECT_TRUE(this->RunPixelTest( | |
322 &pass_list, | |
323 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), | |
324 ExactPixelComparator(true))); | |
325 } | |
326 | |
210 TYPED_TEST(RendererPixelTest, FastPassColorFilterAlpha) { | 327 TYPED_TEST(RendererPixelTest, FastPassColorFilterAlpha) { |
211 gfx::Rect viewport_rect(this->device_viewport_size_); | 328 gfx::Rect viewport_rect(this->device_viewport_size_); |
212 | 329 |
213 RenderPass::Id root_pass_id(1, 1); | 330 RenderPass::Id root_pass_id(1, 1); |
214 scoped_ptr<RenderPass> root_pass = | 331 scoped_ptr<RenderPass> root_pass = |
215 CreateTestRootRenderPass(root_pass_id, viewport_rect); | 332 CreateTestRootRenderPass(root_pass_id, viewport_rect); |
216 | 333 |
217 RenderPass::Id child_pass_id(2, 2); | 334 RenderPass::Id child_pass_id(2, 2); |
218 gfx::Rect pass_rect(this->device_viewport_size_); | 335 gfx::Rect pass_rect(this->device_viewport_size_); |
219 gfx::Transform transform_to_root; | 336 gfx::Transform transform_to_root; |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
973 | 1090 |
974 EXPECT_TRUE(this->RunPixelTest( | 1091 EXPECT_TRUE(this->RunPixelTest( |
975 &pass_list, | 1092 &pass_list, |
976 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), | 1093 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), |
977 ExactPixelComparator(true))); | 1094 ExactPixelComparator(true))); |
978 } | 1095 } |
979 #endif // !defined(OS_ANDROID) | 1096 #endif // !defined(OS_ANDROID) |
980 | 1097 |
981 } // namespace | 1098 } // namespace |
982 } // namespace cc | 1099 } // namespace cc |
OLD | NEW |