| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 bool premultiplied_alpha, | 117 bool premultiplied_alpha, |
| 118 const SharedQuadState* shared_state, | 118 const SharedQuadState* shared_state, |
| 119 ResourceProvider* resource_provider, | 119 ResourceProvider* resource_provider, |
| 120 RenderPass* render_pass) { | 120 RenderPass* render_pass) { |
| 121 SkPMColor pixel_color = premultiplied_alpha ? | 121 SkPMColor pixel_color = premultiplied_alpha ? |
| 122 SkPreMultiplyColor(texel_color) : | 122 SkPreMultiplyColor(texel_color) : |
| 123 SkPackARGB32NoCheck(SkColorGetA(texel_color), | 123 SkPackARGB32NoCheck(SkColorGetA(texel_color), |
| 124 SkColorGetR(texel_color), | 124 SkColorGetR(texel_color), |
| 125 SkColorGetG(texel_color), | 125 SkColorGetG(texel_color), |
| 126 SkColorGetB(texel_color)); | 126 SkColorGetB(texel_color)); |
| 127 std::vector<uint32_t> pixels(rect.size().GetArea(), pixel_color); | 127 size_t num_pixels = static_cast<size_t>(rect.width()) * rect.height(); |
| 128 std::vector<uint32_t> pixels(num_pixels, pixel_color); |
| 128 | 129 |
| 129 ResourceProvider::ResourceId resource = | 130 ResourceProvider::ResourceId resource = |
| 130 resource_provider->CreateResource(rect.size(), | 131 resource_provider->CreateResource(rect.size(), |
| 131 GL_CLAMP_TO_EDGE, | 132 GL_CLAMP_TO_EDGE, |
| 132 ResourceProvider::TextureHintImmutable, | 133 ResourceProvider::TextureHintImmutable, |
| 133 RGBA_8888); | 134 RGBA_8888); |
| 134 resource_provider->SetPixels( | 135 resource_provider->CopyToResource( |
| 135 resource, | 136 resource, reinterpret_cast<uint8_t*>(&pixels.front()), rect.size()); |
| 136 reinterpret_cast<uint8_t*>(&pixels.front()), | |
| 137 rect, | |
| 138 rect, | |
| 139 gfx::Vector2d()); | |
| 140 | 137 |
| 141 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; | 138 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 142 | 139 |
| 143 TextureDrawQuad* quad = | 140 TextureDrawQuad* quad = |
| 144 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 141 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 145 quad->SetNew(shared_state, | 142 quad->SetNew(shared_state, |
| 146 rect, | 143 rect, |
| 147 gfx::Rect(), | 144 gfx::Rect(), |
| 148 rect, | 145 rect, |
| 149 resource, | 146 resource, |
| (...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 } | 1316 } |
| 1320 | 1317 |
| 1321 ResourceProvider::ResourceId mask_resource_id = | 1318 ResourceProvider::ResourceId mask_resource_id = |
| 1322 this->resource_provider_->CreateResource( | 1319 this->resource_provider_->CreateResource( |
| 1323 mask_rect.size(), | 1320 mask_rect.size(), |
| 1324 GL_CLAMP_TO_EDGE, | 1321 GL_CLAMP_TO_EDGE, |
| 1325 ResourceProvider::TextureHintImmutable, | 1322 ResourceProvider::TextureHintImmutable, |
| 1326 RGBA_8888); | 1323 RGBA_8888); |
| 1327 { | 1324 { |
| 1328 SkAutoLockPixels lock(bitmap); | 1325 SkAutoLockPixels lock(bitmap); |
| 1329 this->resource_provider_->SetPixels( | 1326 this->resource_provider_->CopyToResource( |
| 1330 mask_resource_id, | 1327 mask_resource_id, reinterpret_cast<uint8_t*>(bitmap.getPixels()), |
| 1331 reinterpret_cast<uint8_t*>(bitmap.getPixels()), | 1328 mask_rect.size()); |
| 1332 mask_rect, | |
| 1333 mask_rect, | |
| 1334 gfx::Vector2d()); | |
| 1335 } | 1329 } |
| 1336 | 1330 |
| 1337 // This RenderPassDrawQuad does not include the full |viewport_rect| which is | 1331 // This RenderPassDrawQuad does not include the full |viewport_rect| which is |
| 1338 // the size of the child render pass. | 1332 // the size of the child render pass. |
| 1339 gfx::Rect sub_rect = gfx::Rect(50, 50, 200, 100); | 1333 gfx::Rect sub_rect = gfx::Rect(50, 50, 200, 100); |
| 1340 EXPECT_NE(sub_rect.x(), child_pass->output_rect.x()); | 1334 EXPECT_NE(sub_rect.x(), child_pass->output_rect.x()); |
| 1341 EXPECT_NE(sub_rect.y(), child_pass->output_rect.y()); | 1335 EXPECT_NE(sub_rect.y(), child_pass->output_rect.y()); |
| 1342 EXPECT_NE(sub_rect.right(), child_pass->output_rect.right()); | 1336 EXPECT_NE(sub_rect.right(), child_pass->output_rect.right()); |
| 1343 EXPECT_NE(sub_rect.bottom(), child_pass->output_rect.bottom()); | 1337 EXPECT_NE(sub_rect.bottom(), child_pass->output_rect.bottom()); |
| 1344 | 1338 |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2110 gfx::Size tile_size(2, 2); | 2104 gfx::Size tile_size(2, 2); |
| 2111 ResourceProvider::ResourceId resource = | 2105 ResourceProvider::ResourceId resource = |
| 2112 this->resource_provider_->CreateResource( | 2106 this->resource_provider_->CreateResource( |
| 2113 tile_size, | 2107 tile_size, |
| 2114 GL_CLAMP_TO_EDGE, | 2108 GL_CLAMP_TO_EDGE, |
| 2115 ResourceProvider::TextureHintImmutable, | 2109 ResourceProvider::TextureHintImmutable, |
| 2116 RGBA_8888); | 2110 RGBA_8888); |
| 2117 | 2111 |
| 2118 { | 2112 { |
| 2119 SkAutoLockPixels lock(bitmap); | 2113 SkAutoLockPixels lock(bitmap); |
| 2120 this->resource_provider_->SetPixels( | 2114 this->resource_provider_->CopyToResource( |
| 2121 resource, | 2115 resource, static_cast<uint8_t*>(bitmap.getPixels()), tile_size); |
| 2122 static_cast<uint8_t*>(bitmap.getPixels()), | |
| 2123 gfx::Rect(tile_size), | |
| 2124 gfx::Rect(tile_size), | |
| 2125 gfx::Vector2d()); | |
| 2126 } | 2116 } |
| 2127 | 2117 |
| 2128 RenderPassId id(1, 1); | 2118 RenderPassId id(1, 1); |
| 2129 gfx::Transform transform_to_root; | 2119 gfx::Transform transform_to_root; |
| 2130 scoped_ptr<RenderPass> pass = | 2120 scoped_ptr<RenderPass> pass = |
| 2131 CreateTestRenderPass(id, viewport, transform_to_root); | 2121 CreateTestRenderPass(id, viewport, transform_to_root); |
| 2132 | 2122 |
| 2133 gfx::Transform content_to_target_transform; | 2123 gfx::Transform content_to_target_transform; |
| 2134 SharedQuadState* shared_state = CreateTestSharedQuadState( | 2124 SharedQuadState* shared_state = CreateTestSharedQuadState( |
| 2135 content_to_target_transform, viewport, pass.get()); | 2125 content_to_target_transform, viewport, pass.get()); |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2490 | 2480 |
| 2491 TYPED_TEST(RendererPixelTest, WrapModeRepeat) { | 2481 TYPED_TEST(RendererPixelTest, WrapModeRepeat) { |
| 2492 gfx::Rect rect(this->device_viewport_size_); | 2482 gfx::Rect rect(this->device_viewport_size_); |
| 2493 | 2483 |
| 2494 RenderPassId id(1, 1); | 2484 RenderPassId id(1, 1); |
| 2495 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 2485 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 2496 | 2486 |
| 2497 SharedQuadState* shared_state = | 2487 SharedQuadState* shared_state = |
| 2498 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); | 2488 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); |
| 2499 | 2489 |
| 2500 gfx::Rect texture_rect(4, 4); | 2490 gfx::Size texture_size(4, 4); |
| 2501 SkPMColor colors[4] = { | 2491 SkPMColor colors[4] = { |
| 2502 SkPreMultiplyColor(SkColorSetARGB(255, 0, 255, 0)), | 2492 SkPreMultiplyColor(SkColorSetARGB(255, 0, 255, 0)), |
| 2503 SkPreMultiplyColor(SkColorSetARGB(255, 0, 128, 0)), | 2493 SkPreMultiplyColor(SkColorSetARGB(255, 0, 128, 0)), |
| 2504 SkPreMultiplyColor(SkColorSetARGB(255, 0, 64, 0)), | 2494 SkPreMultiplyColor(SkColorSetARGB(255, 0, 64, 0)), |
| 2505 SkPreMultiplyColor(SkColorSetARGB(255, 0, 0, 0)), | 2495 SkPreMultiplyColor(SkColorSetARGB(255, 0, 0, 0)), |
| 2506 }; | 2496 }; |
| 2507 uint32_t pixels[16] = { | 2497 uint32_t pixels[16] = { |
| 2508 colors[0], colors[0], colors[1], colors[1], | 2498 colors[0], colors[0], colors[1], colors[1], |
| 2509 colors[0], colors[0], colors[1], colors[1], | 2499 colors[0], colors[0], colors[1], colors[1], |
| 2510 colors[2], colors[2], colors[3], colors[3], | 2500 colors[2], colors[2], colors[3], colors[3], |
| 2511 colors[2], colors[2], colors[3], colors[3], | 2501 colors[2], colors[2], colors[3], colors[3], |
| 2512 }; | 2502 }; |
| 2513 ResourceProvider::ResourceId resource = | 2503 ResourceProvider::ResourceId resource = |
| 2514 this->resource_provider_->CreateResource( | 2504 this->resource_provider_->CreateResource( |
| 2515 texture_rect.size(), | 2505 texture_size, GL_REPEAT, ResourceProvider::TextureHintImmutable, |
| 2516 GL_REPEAT, | |
| 2517 ResourceProvider::TextureHintImmutable, | |
| 2518 RGBA_8888); | 2506 RGBA_8888); |
| 2519 this->resource_provider_->SetPixels( | 2507 this->resource_provider_->CopyToResource( |
| 2520 resource, | 2508 resource, reinterpret_cast<uint8_t*>(pixels), texture_size); |
| 2521 reinterpret_cast<uint8_t*>(pixels), | |
| 2522 texture_rect, | |
| 2523 texture_rect, | |
| 2524 gfx::Vector2d()); | |
| 2525 | 2509 |
| 2526 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; | 2510 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 2527 TextureDrawQuad* texture_quad = | 2511 TextureDrawQuad* texture_quad = |
| 2528 pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 2512 pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 2529 texture_quad->SetNew( | 2513 texture_quad->SetNew( |
| 2530 shared_state, | 2514 shared_state, gfx::Rect(this->device_viewport_size_), gfx::Rect(), |
| 2531 gfx::Rect(this->device_viewport_size_), | 2515 gfx::Rect(this->device_viewport_size_), resource, |
| 2532 gfx::Rect(), | |
| 2533 gfx::Rect(this->device_viewport_size_), | |
| 2534 resource, | |
| 2535 true, // premultiplied_alpha | 2516 true, // premultiplied_alpha |
| 2536 gfx::PointF(0.0f, 0.0f), // uv_top_left | 2517 gfx::PointF(0.0f, 0.0f), // uv_top_left |
| 2537 gfx::PointF( // uv_bottom_right | 2518 gfx::PointF( // uv_bottom_right |
| 2538 this->device_viewport_size_.width() / texture_rect.width(), | 2519 this->device_viewport_size_.width() / texture_size.width(), |
| 2539 this->device_viewport_size_.height() / texture_rect.height()), | 2520 this->device_viewport_size_.height() / texture_size.height()), |
| 2540 SK_ColorWHITE, | 2521 SK_ColorWHITE, vertex_opacity, |
| 2541 vertex_opacity, | |
| 2542 false, // flipped | 2522 false, // flipped |
| 2543 false); // nearest_neighbor | 2523 false); // nearest_neighbor |
| 2544 | 2524 |
| 2545 RenderPassList pass_list; | 2525 RenderPassList pass_list; |
| 2546 pass_list.push_back(pass.Pass()); | 2526 pass_list.push_back(pass.Pass()); |
| 2547 | 2527 |
| 2548 EXPECT_TRUE(this->RunPixelTest( | 2528 EXPECT_TRUE(this->RunPixelTest( |
| 2549 &pass_list, | 2529 &pass_list, |
| 2550 base::FilePath(FILE_PATH_LITERAL("wrap_mode_repeat.png")), | 2530 base::FilePath(FILE_PATH_LITERAL("wrap_mode_repeat.png")), |
| 2551 FuzzyPixelOffByOneComparator(true))); | 2531 FuzzyPixelOffByOneComparator(true))); |
| 2552 } | 2532 } |
| 2553 | 2533 |
| 2554 #endif // !defined(OS_ANDROID) | 2534 #endif // !defined(OS_ANDROID) |
| 2555 | 2535 |
| 2556 } // namespace | 2536 } // namespace |
| 2557 } // namespace cc | 2537 } // namespace cc |
| OLD | NEW |