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_RGBA, |
| 221 ResourceProvider::TextureUsageAny); |
| 222 ResourceProvider::ResourceId u_resource = |
| 223 resource_provider_->CreateResource( |
| 224 this->device_viewport_size_, |
| 225 GL_RGBA, |
| 226 ResourceProvider::TextureUsageAny); |
| 227 ResourceProvider::ResourceId v_resource = |
| 228 resource_provider_->CreateResource( |
| 229 this->device_viewport_size_, |
| 230 GL_RGBA, |
| 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_RGBA, |
| 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 resource_provider_->SetPixels(y_resource, y_plane.get(), rect, rect, |
| 258 gfx::Vector2d()); |
| 259 resource_provider_->SetPixels(u_resource, u_plane.get(), rect, rect, |
| 260 gfx::Vector2d()); |
| 261 resource_provider_->SetPixels(v_resource, v_plane.get(), rect, rect, |
| 262 gfx::Vector2d()); |
| 263 if (with_alpha) { |
| 264 resource_provider_->SetPixels(a_resource, a_plane.get(), rect, rect, |
| 265 gfx::Vector2d()); |
| 266 } |
| 267 |
| 268 scoped_ptr<YUVVideoDrawQuad> yuv_quad = cc::YUVVideoDrawQuad::Create(); |
| 269 yuv_quad->SetNew(shared_state, rect, opaque_rect, gfx::Size(), |
| 270 y_resource, u_resource, v_resource, a_resource); |
| 271 return yuv_quad.Pass(); |
| 272 } |
| 273 }; |
| 274 |
| 275 TEST_F(VideoGLRendererPixelTest, SimpleYUVRect) { |
| 276 gfx::Rect rect(this->device_viewport_size_); |
| 277 |
| 278 RenderPass::Id id(1, 1); |
| 279 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 280 |
| 281 scoped_ptr<SharedQuadState> shared_state = |
| 282 CreateTestSharedQuadState(gfx::Transform(), rect); |
| 283 |
| 284 scoped_ptr<YUVVideoDrawQuad> yuv_quad = |
| 285 CreateTestYUVVideoDrawQuad(shared_state.get(), false); |
| 286 |
| 287 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
| 288 |
| 289 RenderPassList pass_list; |
| 290 pass_list.push_back(pass.Pass()); |
| 291 |
| 292 EXPECT_TRUE(this->RunPixelTest( |
| 293 &pass_list, |
| 294 base::FilePath(FILE_PATH_LITERAL("green.png")), |
| 295 ExactPixelComparator(true))); |
| 296 } |
| 297 |
| 298 TEST_F(VideoGLRendererPixelTest, SimpleYUVARect) { |
| 299 gfx::Rect rect(this->device_viewport_size_); |
| 300 |
| 301 RenderPass::Id id(1, 1); |
| 302 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 303 |
| 304 scoped_ptr<SharedQuadState> shared_state = |
| 305 CreateTestSharedQuadState(gfx::Transform(), rect); |
| 306 |
| 307 scoped_ptr<YUVVideoDrawQuad> yuv_quad = |
| 308 CreateTestYUVVideoDrawQuad(shared_state.get(), true); |
| 309 |
| 310 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
| 311 |
| 312 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); |
| 313 color_quad->SetNew(shared_state.get(), rect, SK_ColorWHITE, false); |
| 314 |
| 315 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); |
| 316 |
| 317 RenderPassList pass_list; |
| 318 pass_list.push_back(pass.Pass()); |
| 319 |
| 320 EXPECT_TRUE(this->RunPixelTest( |
| 321 &pass_list, |
| 322 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), |
| 323 ExactPixelComparator(true))); |
| 324 } |
| 325 |
210 TYPED_TEST(RendererPixelTest, FastPassColorFilterAlpha) { | 326 TYPED_TEST(RendererPixelTest, FastPassColorFilterAlpha) { |
211 gfx::Rect viewport_rect(this->device_viewport_size_); | 327 gfx::Rect viewport_rect(this->device_viewport_size_); |
212 | 328 |
213 RenderPass::Id root_pass_id(1, 1); | 329 RenderPass::Id root_pass_id(1, 1); |
214 scoped_ptr<RenderPass> root_pass = | 330 scoped_ptr<RenderPass> root_pass = |
215 CreateTestRootRenderPass(root_pass_id, viewport_rect); | 331 CreateTestRootRenderPass(root_pass_id, viewport_rect); |
216 | 332 |
217 RenderPass::Id child_pass_id(2, 2); | 333 RenderPass::Id child_pass_id(2, 2); |
218 gfx::Rect pass_rect(this->device_viewport_size_); | 334 gfx::Rect pass_rect(this->device_viewport_size_); |
219 gfx::Transform transform_to_root; | 335 gfx::Transform transform_to_root; |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 | 1089 |
974 EXPECT_TRUE(this->RunPixelTest( | 1090 EXPECT_TRUE(this->RunPixelTest( |
975 &pass_list, | 1091 &pass_list, |
976 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), | 1092 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), |
977 ExactPixelComparator(true))); | 1093 ExactPixelComparator(true))); |
978 } | 1094 } |
979 #endif // !defined(OS_ANDROID) | 1095 #endif // !defined(OS_ANDROID) |
980 | 1096 |
981 } // namespace | 1097 } // namespace |
982 } // namespace cc | 1098 } // namespace cc |
OLD | NEW |