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 2475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2486 | 2486 |
2487 RenderPassList pass_list; | 2487 RenderPassList pass_list; |
2488 pass_list.push_back(pass.Pass()); | 2488 pass_list.push_back(pass.Pass()); |
2489 | 2489 |
2490 EXPECT_TRUE(this->RunPixelTest( | 2490 EXPECT_TRUE(this->RunPixelTest( |
2491 &pass_list, | 2491 &pass_list, |
2492 base::FilePath(FILE_PATH_LITERAL("wrap_mode_repeat.png")), | 2492 base::FilePath(FILE_PATH_LITERAL("wrap_mode_repeat.png")), |
2493 FuzzyPixelOffByOneComparator(true))); | 2493 FuzzyPixelOffByOneComparator(true))); |
2494 } | 2494 } |
2495 | 2495 |
2496 TYPED_TEST(RendererPixelTest, Checkerboards) { | |
2497 gfx::Rect rect(this->device_viewport_size_); | |
2498 | |
2499 RenderPassId id(1, 1); | |
2500 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | |
2501 | |
2502 SharedQuadState* shared_state = | |
2503 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); | |
2504 | |
2505 // The color's alpha value is not used. | |
2506 SkColor color1 = SK_ColorGREEN; | |
2507 color1 = SkColorSetA(color1, 0); | |
2508 SkColor color2 = SK_ColorBLUE; | |
2509 color2 = SkColorSetA(color2, 0); | |
2510 | |
2511 gfx::Rect content_rect(rect); | |
2512 | |
2513 gfx::Rect top_left(content_rect); | |
2514 gfx::Rect top_right(content_rect); | |
2515 gfx::Rect bottom_left(content_rect); | |
2516 gfx::Rect bottom_right(content_rect); | |
2517 // The format is Inset(left, top, right, bottom). | |
2518 top_left.Inset(0, 0, content_rect.width() / 2, content_rect.height() / 2); | |
2519 top_right.Inset(content_rect.width() / 2, 0, 0, content_rect.height() / 2); | |
2520 bottom_left.Inset(0, content_rect.height() / 2, content_rect.width() / 2, 0); | |
2521 bottom_right.Inset(content_rect.width() / 2, content_rect.height() / 2, 0, 0); | |
2522 | |
2523 // Appends checkerboard quads with a scale of 1. | |
2524 CheckerboardDrawQuad* quad = | |
2525 pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); | |
2526 quad->SetNew(shared_state, top_left, top_left, color1, 1.f); | |
2527 quad = pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); | |
2528 quad->SetNew(shared_state, top_right, top_right, color2, 1.f); | |
2529 quad = pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); | |
2530 quad->SetNew(shared_state, bottom_left, bottom_left, color2, 1.f); | |
2531 quad = pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); | |
2532 quad->SetNew(shared_state, bottom_right, bottom_right, color1, 1.f); | |
2533 | |
2534 RenderPassList pass_list; | |
2535 pass_list.push_back(pass.Pass()); | |
2536 | |
2537 const char* path = IsSoftwareRenderer<TypeParam>() | |
2538 ? "four_blue_green_checkers.png" | |
vmpstr
2015/03/04 00:53:56
I don't see this file included in this patch, does
danakj
2015/03/04 17:06:57
It already exists yes.
| |
2539 : "checkers.png"; | |
2540 EXPECT_TRUE(this->RunPixelTest(&pass_list, | |
2541 base::FilePath(FILE_PATH_LITERAL(path)), | |
2542 ExactPixelComparator(true))); | |
2543 } | |
2544 | |
2545 TYPED_TEST(RendererPixelTest, CheckerboardsScaled) { | |
2546 gfx::Rect rect(this->device_viewport_size_); | |
2547 | |
2548 RenderPassId id(1, 1); | |
2549 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | |
2550 | |
2551 gfx::Transform scale; | |
2552 scale.Scale(2.f, 2.f); | |
2553 | |
2554 SharedQuadState* shared_state = | |
2555 CreateTestSharedQuadState(scale, rect, pass.get()); | |
2556 | |
2557 // The color's alpha value is not used. | |
2558 SkColor color1 = SK_ColorGREEN; | |
2559 color1 = SkColorSetA(color1, 0); | |
2560 SkColor color2 = SK_ColorBLUE; | |
2561 color2 = SkColorSetA(color2, 0); | |
2562 | |
2563 gfx::Rect content_rect(rect); | |
2564 content_rect.Inset(0, 0, rect.width() / 2, rect.height() / 2); | |
2565 | |
2566 gfx::Rect top_left(content_rect); | |
2567 gfx::Rect top_right(content_rect); | |
2568 gfx::Rect bottom_left(content_rect); | |
2569 gfx::Rect bottom_right(content_rect); | |
2570 // The format is Inset(left, top, right, bottom). | |
2571 top_left.Inset(0, 0, content_rect.width() / 2, content_rect.height() / 2); | |
2572 top_right.Inset(content_rect.width() / 2, 0, 0, content_rect.height() / 2); | |
2573 bottom_left.Inset(0, content_rect.height() / 2, content_rect.width() / 2, 0); | |
2574 bottom_right.Inset(content_rect.width() / 2, content_rect.height() / 2, 0, 0); | |
2575 | |
2576 // Appends checkerboard quads with a scale of 2, and a shared quad state | |
2577 // with a scale of 2. The checkers should be scaled by 2 * 2 = 4. | |
2578 CheckerboardDrawQuad* quad = | |
2579 pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); | |
2580 quad->SetNew(shared_state, top_left, top_left, color1, 2.f); | |
2581 quad = pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); | |
2582 quad->SetNew(shared_state, top_right, top_right, color2, 2.f); | |
2583 quad = pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); | |
2584 quad->SetNew(shared_state, bottom_left, bottom_left, color2, 2.f); | |
2585 quad = pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); | |
2586 quad->SetNew(shared_state, bottom_right, bottom_right, color1, 2.f); | |
2587 | |
2588 RenderPassList pass_list; | |
2589 pass_list.push_back(pass.Pass()); | |
2590 | |
2591 const char* path = IsSoftwareRenderer<TypeParam>() | |
2592 ? "four_blue_green_checkers.png" | |
2593 : "checkers_big.png"; | |
2594 EXPECT_TRUE(this->RunPixelTest(&pass_list, | |
2595 base::FilePath(FILE_PATH_LITERAL(path)), | |
2596 ExactPixelComparator(true))); | |
2597 } | |
2598 | |
2496 #endif // !defined(OS_ANDROID) | 2599 #endif // !defined(OS_ANDROID) |
2497 | 2600 |
2498 } // namespace | 2601 } // namespace |
2499 } // namespace cc | 2602 } // namespace cc |
OLD | NEW |