Chromium Code Reviews| 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 TEST_F(GLRendererPixelTest, SimpleYUVRect) { | |
| 211 gfx::Rect rect(this->device_viewport_size_); | |
| 212 gfx::Rect opaque_rect(0, 0, 0, 0); | |
| 213 | |
| 214 RenderPass::Id id(1, 1); | |
| 215 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | |
| 216 | |
| 217 scoped_ptr<SharedQuadState> shared_state = | |
| 218 CreateTestSharedQuadState(gfx::Transform(), rect); | |
| 219 | |
| 220 ResourceProvider::ResourceId y_resource = | |
| 221 cc::PixelTest::resource_provider_->CreateResource( | |
|
enne (OOO)
2013/05/30 23:52:54
cc::PixelTest::resource_provider_ => this->resourc
vignesh
2013/05/31 19:49:37
Done.
| |
| 222 this->device_viewport_size_, | |
| 223 GL_RGBA, | |
| 224 ResourceProvider::TextureUsageAny); | |
| 225 ResourceProvider::ResourceId u_resource = | |
| 226 cc::PixelTest::resource_provider_->CreateResource( | |
| 227 this->device_viewport_size_, | |
| 228 GL_RGBA, | |
| 229 ResourceProvider::TextureUsageAny); | |
| 230 ResourceProvider::ResourceId v_resource = | |
| 231 cc::PixelTest::resource_provider_->CreateResource( | |
| 232 this->device_viewport_size_, | |
| 233 GL_RGBA, | |
| 234 ResourceProvider::TextureUsageAny); | |
| 235 | |
| 236 int w = this->device_viewport_size_.width(); | |
| 237 int h = this->device_viewport_size_.height(); | |
| 238 uint8_t* y_plane = new uint8_t[w * h]; | |
|
enne (OOO)
2013/05/30 23:52:54
Please use a scoped_ptr for any memory ownership:
vignesh
2013/05/31 19:49:37
Done.
| |
| 239 uint8_t* u_plane = new uint8_t[(w / 2) * (h / 2)]; | |
|
enne (OOO)
2013/05/30 23:52:54
Can you put this repeated expression in a temporar
vignesh
2013/05/31 19:49:37
Done.
| |
| 240 uint8_t* v_plane = new uint8_t[(w / 2) * (h / 2)]; | |
| 241 // YUV values representing Green. | |
| 242 memset(y_plane, 149, w * h); | |
| 243 memset(u_plane, 43, (w / 2) * (h / 2)); | |
| 244 memset(v_plane, 21, (w / 2) * (h / 2)); | |
| 245 | |
| 246 cc::PixelTest::resource_provider_->SetPixels(y_resource, y_plane, rect, rect, | |
| 247 gfx::Vector2d()); | |
| 248 cc::PixelTest::resource_provider_->SetPixels(u_resource, u_plane, rect, rect, | |
| 249 gfx::Vector2d()); | |
| 250 cc::PixelTest::resource_provider_->SetPixels(v_resource, v_plane, rect, rect, | |
| 251 gfx::Vector2d()); | |
| 252 | |
| 253 scoped_ptr<cc::YUVVideoDrawQuad> yuv_quad = cc::YUVVideoDrawQuad::Create(); | |
| 254 yuv_quad->SetNew(shared_state.get(), rect, opaque_rect, gfx::Size(0, 0), | |
|
enne (OOO)
2013/05/30 23:52:54
style nit: gfx::Size(), here and elsewhere
vignesh
2013/05/31 19:49:37
Done.
| |
| 255 y_resource, u_resource, v_resource, 0); | |
| 256 | |
| 257 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | |
| 258 | |
| 259 RenderPassList pass_list; | |
| 260 pass_list.push_back(pass.Pass()); | |
| 261 | |
| 262 delete[] y_plane; | |
| 263 delete[] u_plane; | |
| 264 delete[] v_plane; | |
| 265 | |
| 266 EXPECT_TRUE(this->RunPixelTest( | |
| 267 &pass_list, | |
| 268 base::FilePath(FILE_PATH_LITERAL("green.png")), | |
| 269 ExactPixelComparator(true))); | |
| 270 } | |
| 271 | |
| 272 TEST_F(GLRendererPixelTest, SimpleYUVARect) { | |
| 273 gfx::Rect rect(this->device_viewport_size_); | |
| 274 gfx::Rect opaque_rect(0, 0, 0, 0); | |
| 275 | |
| 276 RenderPass::Id id(1, 1); | |
| 277 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | |
| 278 | |
| 279 scoped_ptr<SharedQuadState> shared_state = | |
| 280 CreateTestSharedQuadState(gfx::Transform(), rect); | |
| 281 | |
| 282 ResourceProvider::ResourceId y_resource = | |
|
enne (OOO)
2013/05/30 23:52:54
There's a lot of repeated code between these two t
vignesh
2013/05/31 19:49:37
Done.
| |
| 283 cc::PixelTest::resource_provider_->CreateResource( | |
| 284 this->device_viewport_size_, | |
| 285 GL_RGBA, | |
| 286 ResourceProvider::TextureUsageAny); | |
| 287 ResourceProvider::ResourceId u_resource = | |
| 288 cc::PixelTest::resource_provider_->CreateResource( | |
| 289 this->device_viewport_size_, | |
| 290 GL_RGBA, | |
| 291 ResourceProvider::TextureUsageAny); | |
| 292 ResourceProvider::ResourceId v_resource = | |
| 293 cc::PixelTest::resource_provider_->CreateResource( | |
| 294 this->device_viewport_size_, | |
| 295 GL_RGBA, | |
| 296 ResourceProvider::TextureUsageAny); | |
| 297 ResourceProvider::ResourceId a_resource = | |
| 298 cc::PixelTest::resource_provider_->CreateResource( | |
| 299 this->device_viewport_size_, | |
| 300 GL_RGBA, | |
| 301 ResourceProvider::TextureUsageAny); | |
| 302 | |
| 303 int w = this->device_viewport_size_.width(); | |
| 304 int h = this->device_viewport_size_.height(); | |
| 305 uint8_t* y_plane = new uint8_t[w * h]; | |
| 306 uint8_t* u_plane = new uint8_t[(w / 2) * (h / 2)]; | |
| 307 uint8_t* v_plane = new uint8_t[(w / 2) * (h / 2)]; | |
| 308 uint8_t* a_plane = new uint8_t[w * h]; | |
| 309 // YUV values representing Green. | |
| 310 memset(y_plane, 149, w * h); | |
| 311 memset(u_plane, 43, (w / 2) * (h / 2)); | |
| 312 memset(v_plane, 21, (w / 2) * (h / 2)); | |
| 313 memset(a_plane, 128, (w / 2) * (h / 2)); | |
| 314 | |
| 315 cc::PixelTest::resource_provider_->SetPixels(y_resource, y_plane, rect, rect, | |
| 316 gfx::Vector2d()); | |
| 317 cc::PixelTest::resource_provider_->SetPixels(u_resource, u_plane, rect, rect, | |
| 318 gfx::Vector2d()); | |
| 319 cc::PixelTest::resource_provider_->SetPixels(v_resource, v_plane, rect, rect, | |
| 320 gfx::Vector2d()); | |
| 321 cc::PixelTest::resource_provider_->SetPixels(a_resource, a_plane, rect, rect, | |
| 322 gfx::Vector2d()); | |
| 323 | |
| 324 scoped_ptr<cc::YUVVideoDrawQuad> yuv_quad = cc::YUVVideoDrawQuad::Create(); | |
| 325 yuv_quad->SetNew(shared_state.get(), rect, opaque_rect, gfx::Size(0, 0), | |
| 326 y_resource, u_resource, v_resource, a_resource); | |
| 327 | |
| 328 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | |
| 329 | |
| 330 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); | |
| 331 color_quad->SetNew(shared_state.get(), rect, SK_ColorWHITE, false); | |
| 332 | |
| 333 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); | |
| 334 | |
| 335 RenderPassList pass_list; | |
| 336 pass_list.push_back(pass.Pass()); | |
| 337 | |
| 338 delete[] y_plane; | |
| 339 delete[] u_plane; | |
| 340 delete[] v_plane; | |
| 341 delete[] a_plane; | |
| 342 | |
| 343 EXPECT_TRUE(this->RunPixelTest( | |
| 344 &pass_list, | |
| 345 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), | |
| 346 ExactPixelComparator(true))); | |
| 347 } | |
| 348 | |
| 210 TYPED_TEST(RendererPixelTest, FastPassColorFilterAlpha) { | 349 TYPED_TEST(RendererPixelTest, FastPassColorFilterAlpha) { |
| 211 gfx::Rect viewport_rect(this->device_viewport_size_); | 350 gfx::Rect viewport_rect(this->device_viewport_size_); |
| 212 | 351 |
| 213 RenderPass::Id root_pass_id(1, 1); | 352 RenderPass::Id root_pass_id(1, 1); |
| 214 scoped_ptr<RenderPass> root_pass = | 353 scoped_ptr<RenderPass> root_pass = |
| 215 CreateTestRootRenderPass(root_pass_id, viewport_rect); | 354 CreateTestRootRenderPass(root_pass_id, viewport_rect); |
| 216 | 355 |
| 217 RenderPass::Id child_pass_id(2, 2); | 356 RenderPass::Id child_pass_id(2, 2); |
| 218 gfx::Rect pass_rect(this->device_viewport_size_); | 357 gfx::Rect pass_rect(this->device_viewport_size_); |
| 219 gfx::Transform transform_to_root; | 358 gfx::Transform transform_to_root; |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 973 | 1112 |
| 974 EXPECT_TRUE(this->RunPixelTest( | 1113 EXPECT_TRUE(this->RunPixelTest( |
| 975 &pass_list, | 1114 &pass_list, |
| 976 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), | 1115 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), |
| 977 ExactPixelComparator(true))); | 1116 ExactPixelComparator(true))); |
| 978 } | 1117 } |
| 979 #endif // !defined(OS_ANDROID) | 1118 #endif // !defined(OS_ANDROID) |
| 980 | 1119 |
| 981 } // namespace | 1120 } // namespace |
| 982 } // namespace cc | 1121 } // namespace cc |
| OLD | NEW |