| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2188 &this->pass_list_, | 2188 &this->pass_list_, |
| 2189 base::FilePath(FILE_PATH_LITERAL("background_filter.png")), | 2189 base::FilePath(FILE_PATH_LITERAL("background_filter.png")), |
| 2190 ExactPixelComparator(true))); | 2190 ExactPixelComparator(true))); |
| 2191 } | 2191 } |
| 2192 | 2192 |
| 2193 class ExternalStencilPixelTest : public GLRendererPixelTest { | 2193 class ExternalStencilPixelTest : public GLRendererPixelTest { |
| 2194 protected: | 2194 protected: |
| 2195 void ClearBackgroundToGreen() { | 2195 void ClearBackgroundToGreen() { |
| 2196 GLES2Interface* gl = output_surface_->context_provider()->ContextGL(); | 2196 GLES2Interface* gl = output_surface_->context_provider()->ContextGL(); |
| 2197 output_surface_->EnsureBackbuffer(); | 2197 output_surface_->EnsureBackbuffer(); |
| 2198 output_surface_->Reshape(device_viewport_size_, 1, gfx::ColorSpace(), true); | 2198 output_surface_->Reshape(device_viewport_size_, 1, gfx::ColorSpace(), true, |
| 2199 false); |
| 2199 gl->ClearColor(0.f, 1.f, 0.f, 1.f); | 2200 gl->ClearColor(0.f, 1.f, 0.f, 1.f); |
| 2200 gl->Clear(GL_COLOR_BUFFER_BIT); | 2201 gl->Clear(GL_COLOR_BUFFER_BIT); |
| 2201 } | 2202 } |
| 2202 | 2203 |
| 2203 void PopulateStencilBuffer() { | 2204 void PopulateStencilBuffer() { |
| 2204 // Set two quadrants of the stencil buffer to 1. | 2205 // Set two quadrants of the stencil buffer to 1. |
| 2205 GLES2Interface* gl = output_surface_->context_provider()->ContextGL(); | 2206 GLES2Interface* gl = output_surface_->context_provider()->ContextGL(); |
| 2206 output_surface_->EnsureBackbuffer(); | 2207 output_surface_->EnsureBackbuffer(); |
| 2207 output_surface_->Reshape(device_viewport_size_, 1, gfx::ColorSpace(), true); | 2208 output_surface_->Reshape(device_viewport_size_, 1, gfx::ColorSpace(), true, |
| 2209 false); |
| 2208 gl->ClearStencil(0); | 2210 gl->ClearStencil(0); |
| 2209 gl->Clear(GL_STENCIL_BUFFER_BIT); | 2211 gl->Clear(GL_STENCIL_BUFFER_BIT); |
| 2210 gl->Enable(GL_SCISSOR_TEST); | 2212 gl->Enable(GL_SCISSOR_TEST); |
| 2211 gl->ClearStencil(1); | 2213 gl->ClearStencil(1); |
| 2212 gl->Scissor(0, | 2214 gl->Scissor(0, |
| 2213 0, | 2215 0, |
| 2214 device_viewport_size_.width() / 2, | 2216 device_viewport_size_.width() / 2, |
| 2215 device_viewport_size_.height() / 2); | 2217 device_viewport_size_.height() / 2); |
| 2216 gl->Clear(GL_STENCIL_BUFFER_BIT); | 2218 gl->Clear(GL_STENCIL_BUFFER_BIT); |
| 2217 gl->Scissor(device_viewport_size_.width() / 2, | 2219 gl->Scissor(device_viewport_size_.width() / 2, |
| (...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3260 } | 3262 } |
| 3261 | 3263 |
| 3262 RenderPassList pass_list; | 3264 RenderPassList pass_list; |
| 3263 pass_list.push_back(std::move(pass)); | 3265 pass_list.push_back(std::move(pass)); |
| 3264 | 3266 |
| 3265 EXPECT_TRUE(this->RunPixelTest( | 3267 EXPECT_TRUE(this->RunPixelTest( |
| 3266 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")), | 3268 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")), |
| 3267 FuzzyPixelOffByOneComparator(true))); | 3269 FuzzyPixelOffByOneComparator(true))); |
| 3268 } | 3270 } |
| 3269 | 3271 |
| 3272 class GLRendererPixelTestWithOverdrawFeedback : public GLRendererPixelTest { |
| 3273 protected: |
| 3274 void SetUp() override { |
| 3275 settings_.renderer_settings.show_overdraw_feedback = true; |
| 3276 GLRendererPixelTest::SetUp(); |
| 3277 } |
| 3278 }; |
| 3279 |
| 3280 TEST_F(GLRendererPixelTestWithOverdrawFeedback, TranslucentRectangles) { |
| 3281 gfx::Rect rect(this->device_viewport_size_); |
| 3282 |
| 3283 int id = 1; |
| 3284 gfx::Transform transform_to_root; |
| 3285 std::unique_ptr<RenderPass> pass = |
| 3286 CreateTestRenderPass(id, rect, transform_to_root); |
| 3287 |
| 3288 gfx::Transform dark_gray_quad_to_target_transform; |
| 3289 dark_gray_quad_to_target_transform.Translate(50, 50); |
| 3290 dark_gray_quad_to_target_transform.Scale( |
| 3291 0.5f + 1.0f / (rect.width() * 2.0f), |
| 3292 0.5f + 1.0f / (rect.height() * 2.0f)); |
| 3293 SharedQuadState* dark_gray_shared_state = CreateTestSharedQuadState( |
| 3294 dark_gray_quad_to_target_transform, rect, pass.get()); |
| 3295 |
| 3296 SolidColorDrawQuad* dark_gray = |
| 3297 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 3298 dark_gray->SetNew(dark_gray_shared_state, rect, rect, 0x10444444, false); |
| 3299 |
| 3300 gfx::Transform light_gray_quad_to_target_transform; |
| 3301 light_gray_quad_to_target_transform.Translate(25.5f, 25.5f); |
| 3302 light_gray_quad_to_target_transform.Scale(0.5f, 0.5f); |
| 3303 SharedQuadState* light_gray_shared_state = CreateTestSharedQuadState( |
| 3304 light_gray_quad_to_target_transform, rect, pass.get()); |
| 3305 |
| 3306 SolidColorDrawQuad* light_gray = |
| 3307 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 3308 light_gray->SetNew(light_gray_shared_state, rect, rect, 0x10CCCCCC, false); |
| 3309 |
| 3310 gfx::Transform bg_quad_to_target_transform; |
| 3311 SharedQuadState* bg_shared_state = |
| 3312 CreateTestSharedQuadState(bg_quad_to_target_transform, rect, pass.get()); |
| 3313 |
| 3314 SolidColorDrawQuad* bg = pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 3315 bg->SetNew(bg_shared_state, rect, rect, SK_ColorBLACK, false); |
| 3316 |
| 3317 RenderPassList pass_list; |
| 3318 pass_list.push_back(std::move(pass)); |
| 3319 |
| 3320 EXPECT_TRUE(this->RunPixelTest(&pass_list, base::FilePath(FILE_PATH_LITERAL( |
| 3321 "translucent_rectangles.png")), |
| 3322 ExactPixelComparator(true))); |
| 3323 } |
| 3324 |
| 3270 #endif // !defined(OS_ANDROID) | 3325 #endif // !defined(OS_ANDROID) |
| 3271 | 3326 |
| 3272 } // namespace | 3327 } // namespace |
| 3273 } // namespace cc | 3328 } // namespace cc |
| OLD | NEW |