Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: cc/output/renderer_pixeltest.cc

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/program_binding.h ('k') | cc/output/shader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 2038
2039 RenderPassList pass_list; 2039 RenderPassList pass_list;
2040 pass_list.push_back(pass.Pass()); 2040 pass_list.push_back(pass.Pass());
2041 2041
2042 EXPECT_TRUE(this->RunPixelTest( 2042 EXPECT_TRUE(this->RunPixelTest(
2043 &pass_list, 2043 &pass_list,
2044 base::FilePath(FILE_PATH_LITERAL("wrap_mode_repeat.png")), 2044 base::FilePath(FILE_PATH_LITERAL("wrap_mode_repeat.png")),
2045 FuzzyPixelOffByOneComparator(true))); 2045 FuzzyPixelOffByOneComparator(true)));
2046 } 2046 }
2047 2047
2048 TYPED_TEST(RendererPixelTest, Checkerboards) {
2049 gfx::Rect rect(this->device_viewport_size_);
2050
2051 RenderPassId id(1, 1);
2052 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect);
2053
2054 SharedQuadState* shared_state =
2055 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get());
2056
2057 // The color's alpha value is not used.
2058 SkColor color1 = SK_ColorGREEN;
2059 color1 = SkColorSetA(color1, 0);
2060 SkColor color2 = SK_ColorBLUE;
2061 color2 = SkColorSetA(color2, 0);
2062
2063 gfx::Rect content_rect(rect);
2064
2065 gfx::Rect top_left(content_rect);
2066 gfx::Rect top_right(content_rect);
2067 gfx::Rect bottom_left(content_rect);
2068 gfx::Rect bottom_right(content_rect);
2069 // The format is Inset(left, top, right, bottom).
2070 top_left.Inset(0, 0, content_rect.width() / 2, content_rect.height() / 2);
2071 top_right.Inset(content_rect.width() / 2, 0, 0, content_rect.height() / 2);
2072 bottom_left.Inset(0, content_rect.height() / 2, content_rect.width() / 2, 0);
2073 bottom_right.Inset(content_rect.width() / 2, content_rect.height() / 2, 0, 0);
2074
2075 // Appends checkerboard quads with a scale of 1.
2076 CheckerboardDrawQuad* quad =
2077 pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>();
2078 quad->SetNew(shared_state, top_left, top_left, color1, 1.f);
2079 quad = pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>();
2080 quad->SetNew(shared_state, top_right, top_right, color2, 1.f);
2081 quad = pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>();
2082 quad->SetNew(shared_state, bottom_left, bottom_left, color2, 1.f);
2083 quad = pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>();
2084 quad->SetNew(shared_state, bottom_right, bottom_right, color1, 1.f);
2085
2086 RenderPassList pass_list;
2087 pass_list.push_back(pass.Pass());
2088
2089 base::FilePath::StringType path =
2090 IsSoftwareRenderer<TypeParam>()
2091 ? FILE_PATH_LITERAL("four_blue_green_checkers.png")
2092 : FILE_PATH_LITERAL("checkers.png");
2093 EXPECT_TRUE(this->RunPixelTest(&pass_list, base::FilePath(path),
2094 ExactPixelComparator(true)));
2095 }
2096
2097 TYPED_TEST(RendererPixelTest, CheckerboardsScaled) {
2098 gfx::Rect rect(this->device_viewport_size_);
2099
2100 RenderPassId id(1, 1);
2101 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect);
2102
2103 gfx::Transform scale;
2104 scale.Scale(2.f, 2.f);
2105
2106 SharedQuadState* shared_state =
2107 CreateTestSharedQuadState(scale, rect, pass.get());
2108
2109 // The color's alpha value is not used.
2110 SkColor color1 = SK_ColorGREEN;
2111 color1 = SkColorSetA(color1, 0);
2112 SkColor color2 = SK_ColorBLUE;
2113 color2 = SkColorSetA(color2, 0);
2114
2115 gfx::Rect content_rect(rect);
2116 content_rect.Inset(0, 0, rect.width() / 2, rect.height() / 2);
2117
2118 gfx::Rect top_left(content_rect);
2119 gfx::Rect top_right(content_rect);
2120 gfx::Rect bottom_left(content_rect);
2121 gfx::Rect bottom_right(content_rect);
2122 // The format is Inset(left, top, right, bottom).
2123 top_left.Inset(0, 0, content_rect.width() / 2, content_rect.height() / 2);
2124 top_right.Inset(content_rect.width() / 2, 0, 0, content_rect.height() / 2);
2125 bottom_left.Inset(0, content_rect.height() / 2, content_rect.width() / 2, 0);
2126 bottom_right.Inset(content_rect.width() / 2, content_rect.height() / 2, 0, 0);
2127
2128 // Appends checkerboard quads with a scale of 2, and a shared quad state
2129 // with a scale of 2. The checkers should be scaled by 2 * 2 = 4.
2130 CheckerboardDrawQuad* quad =
2131 pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>();
2132 quad->SetNew(shared_state, top_left, top_left, color1, 2.f);
2133 quad = pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>();
2134 quad->SetNew(shared_state, top_right, top_right, color2, 2.f);
2135 quad = pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>();
2136 quad->SetNew(shared_state, bottom_left, bottom_left, color2, 2.f);
2137 quad = pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>();
2138 quad->SetNew(shared_state, bottom_right, bottom_right, color1, 2.f);
2139
2140 RenderPassList pass_list;
2141 pass_list.push_back(pass.Pass());
2142
2143 base::FilePath::StringType path =
2144 IsSoftwareRenderer<TypeParam>()
2145 ? FILE_PATH_LITERAL("four_blue_green_checkers.png")
2146 : FILE_PATH_LITERAL("checkers_big.png");
2147 EXPECT_TRUE(this->RunPixelTest(&pass_list, base::FilePath(path),
2148 ExactPixelComparator(true)));
2149 }
2150
2048 #endif // !defined(OS_ANDROID) 2151 #endif // !defined(OS_ANDROID)
2049 2152
2050 } // namespace 2153 } // namespace
2051 } // namespace cc 2154 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/program_binding.h ('k') | cc/output/shader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698