| 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 ResourceProvider::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 ResourceProvider::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 ResourceProvider::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 ResourceProvider::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 ResourceProvider::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 = |
| 1372 !PlatformColor::SameComponentOrder(ResourceProvider::RGBA_8888); |
| 1370 | 1373 |
| 1371 RenderPass::Id id(1, 1); | 1374 RenderPass::Id id(1, 1); |
| 1372 gfx::Transform transform_to_root; | 1375 gfx::Transform transform_to_root; |
| 1373 scoped_ptr<RenderPass> pass = | 1376 scoped_ptr<RenderPass> pass = |
| 1374 CreateTestRenderPass(id, viewport, transform_to_root); | 1377 CreateTestRenderPass(id, viewport, transform_to_root); |
| 1375 | 1378 |
| 1376 // One clipped blue quad in the lower right corner. Outside the clip | 1379 // One clipped blue quad in the lower right corner. Outside the clip |
| 1377 // is red, which should not appear. | 1380 // is red, which should not appear. |
| 1378 gfx::Rect blue_rect(gfx::Size(100, 100)); | 1381 gfx::Rect blue_rect(gfx::Size(100, 100)); |
| 1379 gfx::Rect blue_clip_rect(gfx::Point(50, 50), gfx::Size(50, 50)); | 1382 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, | 1447 PixelTest::NoOffscreenContext, |
| 1445 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png")), | 1448 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png")), |
| 1446 ExactPixelComparator(true))); | 1449 ExactPixelComparator(true))); |
| 1447 } | 1450 } |
| 1448 | 1451 |
| 1449 // Not WithSkiaGPUBackend since that path currently requires tiles for opacity. | 1452 // Not WithSkiaGPUBackend since that path currently requires tiles for opacity. |
| 1450 TYPED_TEST(RendererPixelTest, PictureDrawQuadOpacity) { | 1453 TYPED_TEST(RendererPixelTest, PictureDrawQuadOpacity) { |
| 1451 gfx::Size pile_tile_size(1000, 1000); | 1454 gfx::Size pile_tile_size(1000, 1000); |
| 1452 gfx::Rect viewport(this->device_viewport_size_); | 1455 gfx::Rect viewport(this->device_viewport_size_); |
| 1453 bool use_skia_gpu_backend = this->UseSkiaGPUBackend(); | 1456 bool use_skia_gpu_backend = this->UseSkiaGPUBackend(); |
| 1454 bool contents_swizzled = !PlatformColor::SameComponentOrder(GL_RGBA); | 1457 bool contents_swizzled = |
| 1458 !PlatformColor::SameComponentOrder(ResourceProvider::RGBA_8888); |
| 1455 | 1459 |
| 1456 RenderPass::Id id(1, 1); | 1460 RenderPass::Id id(1, 1); |
| 1457 gfx::Transform transform_to_root; | 1461 gfx::Transform transform_to_root; |
| 1458 scoped_ptr<RenderPass> pass = | 1462 scoped_ptr<RenderPass> pass = |
| 1459 CreateTestRenderPass(id, viewport, transform_to_root); | 1463 CreateTestRenderPass(id, viewport, transform_to_root); |
| 1460 | 1464 |
| 1461 // One viewport-filling 0.5-opacity green quad. | 1465 // One viewport-filling 0.5-opacity green quad. |
| 1462 scoped_refptr<FakePicturePileImpl> green_pile = | 1466 scoped_refptr<FakePicturePileImpl> green_pile = |
| 1463 FakePicturePileImpl::CreateFilledPile(pile_tile_size, viewport.size()); | 1467 FakePicturePileImpl::CreateFilledPile(pile_tile_size, viewport.size()); |
| 1464 SkPaint green_paint; | 1468 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")), | 1522 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), |
| 1519 FuzzyPixelOffByOneComparator(true))); | 1523 FuzzyPixelOffByOneComparator(true))); |
| 1520 } | 1524 } |
| 1521 | 1525 |
| 1522 TYPED_TEST(RendererPixelTestWithSkiaGPUBackend, | 1526 TYPED_TEST(RendererPixelTestWithSkiaGPUBackend, |
| 1523 PictureDrawQuadNonIdentityScale) { | 1527 PictureDrawQuadNonIdentityScale) { |
| 1524 gfx::Size pile_tile_size(1000, 1000); | 1528 gfx::Size pile_tile_size(1000, 1000); |
| 1525 gfx::Rect viewport(this->device_viewport_size_); | 1529 gfx::Rect viewport(this->device_viewport_size_); |
| 1526 bool use_skia_gpu_backend = this->UseSkiaGPUBackend(); | 1530 bool use_skia_gpu_backend = this->UseSkiaGPUBackend(); |
| 1527 // TODO(enne): the renderer should figure this out on its own. | 1531 // TODO(enne): the renderer should figure this out on its own. |
| 1528 bool contents_swizzled = !PlatformColor::SameComponentOrder(GL_RGBA); | 1532 bool contents_swizzled = |
| 1533 !PlatformColor::SameComponentOrder(ResourceProvider::RGBA_8888); |
| 1529 | 1534 |
| 1530 RenderPass::Id id(1, 1); | 1535 RenderPass::Id id(1, 1); |
| 1531 gfx::Transform transform_to_root; | 1536 gfx::Transform transform_to_root; |
| 1532 scoped_ptr<RenderPass> pass = | 1537 scoped_ptr<RenderPass> pass = |
| 1533 CreateTestRenderPass(id, viewport, transform_to_root); | 1538 CreateTestRenderPass(id, viewport, transform_to_root); |
| 1534 | 1539 |
| 1535 // As scaling up the blue checkerboards will cause sampling on the GPU, | 1540 // 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 | 1541 // 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 | 1542 // to make the output image more clean. This will also test subrects |
| 1538 // of the layer. | 1543 // of the layer. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 EXPECT_TRUE(this->RunPixelTest( | 1673 EXPECT_TRUE(this->RunPixelTest( |
| 1669 &pass_list, | 1674 &pass_list, |
| 1670 PixelTest::NoOffscreenContext, | 1675 PixelTest::NoOffscreenContext, |
| 1671 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), | 1676 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), |
| 1672 ExactPixelComparator(true))); | 1677 ExactPixelComparator(true))); |
| 1673 } | 1678 } |
| 1674 #endif // !defined(OS_ANDROID) | 1679 #endif // !defined(OS_ANDROID) |
| 1675 | 1680 |
| 1676 } // namespace | 1681 } // namespace |
| 1677 } // namespace cc | 1682 } // namespace cc |
| OLD | NEW |