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/message_loop.h" | 5 #include "base/message_loop/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/quads/texture_draw_quad.h" | 10 #include "cc/quads/texture_draw_quad.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 SharedQuadState* shared_state, | 104 SharedQuadState* shared_state, |
105 ResourceProvider* resource_provider) { | 105 ResourceProvider* resource_provider) { |
106 SkPMColor pixel_color = premultiplied_alpha ? | 106 SkPMColor pixel_color = premultiplied_alpha ? |
107 SkPreMultiplyColor(texel_color) : | 107 SkPreMultiplyColor(texel_color) : |
108 SkPackARGB32NoCheck(SkColorGetA(texel_color), | 108 SkPackARGB32NoCheck(SkColorGetA(texel_color), |
109 SkColorGetR(texel_color), | 109 SkColorGetR(texel_color), |
110 SkColorGetG(texel_color), | 110 SkColorGetG(texel_color), |
111 SkColorGetB(texel_color)); | 111 SkColorGetB(texel_color)); |
112 std::vector<uint32_t> pixels(rect.size().GetArea(), pixel_color); | 112 std::vector<uint32_t> pixels(rect.size().GetArea(), pixel_color); |
113 | 113 |
114 ResourceProvider::ResourceId resource = resource_provider->CreateResource( | 114 ResourceProvider::ResourceId resource = |
115 rect.size(), GL_RGBA, GL_CLAMP_TO_EDGE, | 115 resource_provider->CreateResource(rect.size(), |
116 ResourceProvider::TextureUsageAny); | 116 GL_CLAMP_TO_EDGE, |
| 117 ResourceProvider::TextureUsageAny, |
| 118 RGBA_8888); |
117 resource_provider->SetPixels( | 119 resource_provider->SetPixels( |
118 resource, | 120 resource, |
119 reinterpret_cast<uint8_t*>(&pixels.front()), | 121 reinterpret_cast<uint8_t*>(&pixels.front()), |
120 rect, | 122 rect, |
121 rect, | 123 rect, |
122 gfx::Vector2d()); | 124 gfx::Vector2d()); |
123 | 125 |
124 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; | 126 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; |
125 | 127 |
126 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 128 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 class VideoGLRendererPixelTest : public GLRendererPixelTest { | 404 class VideoGLRendererPixelTest : public GLRendererPixelTest { |
403 protected: | 405 protected: |
404 scoped_ptr<YUVVideoDrawQuad> CreateTestYUVVideoDrawQuad( | 406 scoped_ptr<YUVVideoDrawQuad> CreateTestYUVVideoDrawQuad( |
405 SharedQuadState* shared_state, bool with_alpha, bool is_transparent) { | 407 SharedQuadState* shared_state, bool with_alpha, bool is_transparent) { |
406 gfx::Rect rect(this->device_viewport_size_); | 408 gfx::Rect rect(this->device_viewport_size_); |
407 gfx::Rect opaque_rect(0, 0, 0, 0); | 409 gfx::Rect opaque_rect(0, 0, 0, 0); |
408 | 410 |
409 ResourceProvider::ResourceId y_resource = | 411 ResourceProvider::ResourceId y_resource = |
410 resource_provider_->CreateResource( | 412 resource_provider_->CreateResource( |
411 this->device_viewport_size_, | 413 this->device_viewport_size_, |
412 GL_LUMINANCE, | |
413 GL_CLAMP_TO_EDGE, | 414 GL_CLAMP_TO_EDGE, |
414 ResourceProvider::TextureUsageAny); | 415 ResourceProvider::TextureUsageAny, |
| 416 LUMINANCE_8); |
415 ResourceProvider::ResourceId u_resource = | 417 ResourceProvider::ResourceId u_resource = |
416 resource_provider_->CreateResource( | 418 resource_provider_->CreateResource( |
417 this->device_viewport_size_, | 419 this->device_viewport_size_, |
418 GL_LUMINANCE, | |
419 GL_CLAMP_TO_EDGE, | 420 GL_CLAMP_TO_EDGE, |
420 ResourceProvider::TextureUsageAny); | 421 ResourceProvider::TextureUsageAny, |
| 422 LUMINANCE_8); |
421 ResourceProvider::ResourceId v_resource = | 423 ResourceProvider::ResourceId v_resource = |
422 resource_provider_->CreateResource( | 424 resource_provider_->CreateResource( |
423 this->device_viewport_size_, | 425 this->device_viewport_size_, |
424 GL_LUMINANCE, | |
425 GL_CLAMP_TO_EDGE, | 426 GL_CLAMP_TO_EDGE, |
426 ResourceProvider::TextureUsageAny); | 427 ResourceProvider::TextureUsageAny, |
| 428 LUMINANCE_8); |
427 ResourceProvider::ResourceId a_resource = 0; | 429 ResourceProvider::ResourceId a_resource = 0; |
428 if (with_alpha) { | 430 if (with_alpha) { |
429 a_resource = resource_provider_->CreateResource( | 431 a_resource = resource_provider_->CreateResource( |
430 this->device_viewport_size_, | 432 this->device_viewport_size_, |
431 GL_LUMINANCE, | |
432 GL_CLAMP_TO_EDGE, | 433 GL_CLAMP_TO_EDGE, |
433 ResourceProvider::TextureUsageAny); | 434 ResourceProvider::TextureUsageAny, |
| 435 LUMINANCE_8); |
434 } | 436 } |
435 | 437 |
436 int w = this->device_viewport_size_.width(); | 438 int w = this->device_viewport_size_.width(); |
437 int h = this->device_viewport_size_.height(); | 439 int h = this->device_viewport_size_.height(); |
438 const int y_plane_size = w * h; | 440 const int y_plane_size = w * h; |
439 gfx::Rect uv_rect((w + 1) / 2, (h + 1) / 2); | 441 gfx::Rect uv_rect((w + 1) / 2, (h + 1) / 2); |
440 const int uv_plane_size = uv_rect.size().GetArea(); | 442 const int uv_plane_size = uv_rect.size().GetArea(); |
441 scoped_ptr<uint8_t[]> y_plane(new uint8_t[y_plane_size]); | 443 scoped_ptr<uint8_t[]> y_plane(new uint8_t[y_plane_size]); |
442 scoped_ptr<uint8_t[]> u_plane(new uint8_t[uv_plane_size]); | 444 scoped_ptr<uint8_t[]> u_plane(new uint8_t[uv_plane_size]); |
443 scoped_ptr<uint8_t[]> v_plane(new uint8_t[uv_plane_size]); | 445 scoped_ptr<uint8_t[]> v_plane(new uint8_t[uv_plane_size]); |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 PixelTest::NoOffscreenContext, | 1361 PixelTest::NoOffscreenContext, |
1360 base::FilePath(FILE_PATH_LITERAL("anti_aliasing_perspective.png")), | 1362 base::FilePath(FILE_PATH_LITERAL("anti_aliasing_perspective.png")), |
1361 FuzzyPixelOffByOneComparator(true))); | 1363 FuzzyPixelOffByOneComparator(true))); |
1362 } | 1364 } |
1363 | 1365 |
1364 TYPED_TEST(RendererPixelTestWithSkiaGPUBackend, PictureDrawQuadIdentityScale) { | 1366 TYPED_TEST(RendererPixelTestWithSkiaGPUBackend, PictureDrawQuadIdentityScale) { |
1365 gfx::Size pile_tile_size(1000, 1000); | 1367 gfx::Size pile_tile_size(1000, 1000); |
1366 gfx::Rect viewport(this->device_viewport_size_); | 1368 gfx::Rect viewport(this->device_viewport_size_); |
1367 bool use_skia_gpu_backend = this->UseSkiaGPUBackend(); | 1369 bool use_skia_gpu_backend = this->UseSkiaGPUBackend(); |
1368 // TODO(enne): the renderer should figure this out on its own. | 1370 // TODO(enne): the renderer should figure this out on its own. |
1369 bool contents_swizzled = !PlatformColor::SameComponentOrder(GL_RGBA); | 1371 bool contents_swizzled = !PlatformColor::SameComponentOrder(RGBA_8888); |
1370 | 1372 |
1371 RenderPass::Id id(1, 1); | 1373 RenderPass::Id id(1, 1); |
1372 gfx::Transform transform_to_root; | 1374 gfx::Transform transform_to_root; |
1373 scoped_ptr<RenderPass> pass = | 1375 scoped_ptr<RenderPass> pass = |
1374 CreateTestRenderPass(id, viewport, transform_to_root); | 1376 CreateTestRenderPass(id, viewport, transform_to_root); |
1375 | 1377 |
1376 // One clipped blue quad in the lower right corner. Outside the clip | 1378 // One clipped blue quad in the lower right corner. Outside the clip |
1377 // is red, which should not appear. | 1379 // is red, which should not appear. |
1378 gfx::Rect blue_rect(gfx::Size(100, 100)); | 1380 gfx::Rect blue_rect(gfx::Size(100, 100)); |
1379 gfx::Rect blue_clip_rect(gfx::Point(50, 50), gfx::Size(50, 50)); | 1381 gfx::Rect blue_clip_rect(gfx::Point(50, 50), gfx::Size(50, 50)); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 PixelTest::NoOffscreenContext, | 1446 PixelTest::NoOffscreenContext, |
1445 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png")), | 1447 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png")), |
1446 ExactPixelComparator(true))); | 1448 ExactPixelComparator(true))); |
1447 } | 1449 } |
1448 | 1450 |
1449 // Not WithSkiaGPUBackend since that path currently requires tiles for opacity. | 1451 // Not WithSkiaGPUBackend since that path currently requires tiles for opacity. |
1450 TYPED_TEST(RendererPixelTest, PictureDrawQuadOpacity) { | 1452 TYPED_TEST(RendererPixelTest, PictureDrawQuadOpacity) { |
1451 gfx::Size pile_tile_size(1000, 1000); | 1453 gfx::Size pile_tile_size(1000, 1000); |
1452 gfx::Rect viewport(this->device_viewport_size_); | 1454 gfx::Rect viewport(this->device_viewport_size_); |
1453 bool use_skia_gpu_backend = this->UseSkiaGPUBackend(); | 1455 bool use_skia_gpu_backend = this->UseSkiaGPUBackend(); |
1454 bool contents_swizzled = !PlatformColor::SameComponentOrder(GL_RGBA); | 1456 bool contents_swizzled = !PlatformColor::SameComponentOrder(RGBA_8888); |
1455 | 1457 |
1456 RenderPass::Id id(1, 1); | 1458 RenderPass::Id id(1, 1); |
1457 gfx::Transform transform_to_root; | 1459 gfx::Transform transform_to_root; |
1458 scoped_ptr<RenderPass> pass = | 1460 scoped_ptr<RenderPass> pass = |
1459 CreateTestRenderPass(id, viewport, transform_to_root); | 1461 CreateTestRenderPass(id, viewport, transform_to_root); |
1460 | 1462 |
1461 // One viewport-filling 0.5-opacity green quad. | 1463 // One viewport-filling 0.5-opacity green quad. |
1462 scoped_refptr<FakePicturePileImpl> green_pile = | 1464 scoped_refptr<FakePicturePileImpl> green_pile = |
1463 FakePicturePileImpl::CreateFilledPile(pile_tile_size, viewport.size()); | 1465 FakePicturePileImpl::CreateFilledPile(pile_tile_size, viewport.size()); |
1464 SkPaint green_paint; | 1466 SkPaint green_paint; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), | 1520 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), |
1519 FuzzyPixelOffByOneComparator(true))); | 1521 FuzzyPixelOffByOneComparator(true))); |
1520 } | 1522 } |
1521 | 1523 |
1522 TYPED_TEST(RendererPixelTestWithSkiaGPUBackend, | 1524 TYPED_TEST(RendererPixelTestWithSkiaGPUBackend, |
1523 PictureDrawQuadNonIdentityScale) { | 1525 PictureDrawQuadNonIdentityScale) { |
1524 gfx::Size pile_tile_size(1000, 1000); | 1526 gfx::Size pile_tile_size(1000, 1000); |
1525 gfx::Rect viewport(this->device_viewport_size_); | 1527 gfx::Rect viewport(this->device_viewport_size_); |
1526 bool use_skia_gpu_backend = this->UseSkiaGPUBackend(); | 1528 bool use_skia_gpu_backend = this->UseSkiaGPUBackend(); |
1527 // TODO(enne): the renderer should figure this out on its own. | 1529 // TODO(enne): the renderer should figure this out on its own. |
1528 bool contents_swizzled = !PlatformColor::SameComponentOrder(GL_RGBA); | 1530 bool contents_swizzled = !PlatformColor::SameComponentOrder(RGBA_8888); |
1529 | 1531 |
1530 RenderPass::Id id(1, 1); | 1532 RenderPass::Id id(1, 1); |
1531 gfx::Transform transform_to_root; | 1533 gfx::Transform transform_to_root; |
1532 scoped_ptr<RenderPass> pass = | 1534 scoped_ptr<RenderPass> pass = |
1533 CreateTestRenderPass(id, viewport, transform_to_root); | 1535 CreateTestRenderPass(id, viewport, transform_to_root); |
1534 | 1536 |
1535 // As scaling up the blue checkerboards will cause sampling on the GPU, | 1537 // As scaling up the blue checkerboards will cause sampling on the GPU, |
1536 // a few extra "cleanup rects" need to be added to clobber the blending | 1538 // a few extra "cleanup rects" need to be added to clobber the blending |
1537 // to make the output image more clean. This will also test subrects | 1539 // to make the output image more clean. This will also test subrects |
1538 // of the layer. | 1540 // of the layer. |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 EXPECT_TRUE(this->RunPixelTest( | 1670 EXPECT_TRUE(this->RunPixelTest( |
1669 &pass_list, | 1671 &pass_list, |
1670 PixelTest::NoOffscreenContext, | 1672 PixelTest::NoOffscreenContext, |
1671 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), | 1673 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), |
1672 ExactPixelComparator(true))); | 1674 ExactPixelComparator(true))); |
1673 } | 1675 } |
1674 #endif // !defined(OS_ANDROID) | 1676 #endif // !defined(OS_ANDROID) |
1675 | 1677 |
1676 } // namespace | 1678 } // namespace |
1677 } // namespace cc | 1679 } // namespace cc |
OLD | NEW |