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

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

Issue 2881483002: Always set damage rect to output rect if 3D context was reshaped. (Closed)
Patch Set: redesign Created 3 years, 7 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/direct_renderer.cc ('k') | no next file » | 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 "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 RendererSettings settings; 2039 RendererSettings settings;
2040 settings.partial_swap_enabled = partial_swap; 2040 settings.partial_swap_enabled = partial_swap;
2041 FakeRendererGL renderer(&settings, output_surface.get(), 2041 FakeRendererGL renderer(&settings, output_surface.get(),
2042 resource_provider.get()); 2042 resource_provider.get());
2043 renderer.Initialize(); 2043 renderer.Initialize();
2044 EXPECT_EQ(partial_swap, renderer.use_partial_swap()); 2044 EXPECT_EQ(partial_swap, renderer.use_partial_swap());
2045 renderer.SetVisible(true); 2045 renderer.SetVisible(true);
2046 2046
2047 gfx::Size viewport_size(100, 100); 2047 gfx::Size viewport_size(100, 100);
2048 2048
2049 { 2049 for (int i = 0; i < 2; ++i) {
2050 int root_pass_id = 1; 2050 int root_pass_id = 1;
2051 RenderPass* root_pass = AddRenderPass( 2051 RenderPass* root_pass = AddRenderPass(
2052 &render_passes_in_draw_order_, root_pass_id, gfx::Rect(viewport_size), 2052 &render_passes_in_draw_order_, root_pass_id, gfx::Rect(viewport_size),
2053 gfx::Transform(), FilterOperations()); 2053 gfx::Transform(), FilterOperations());
2054 AddQuad(root_pass, gfx::Rect(viewport_size), SK_ColorGREEN); 2054 AddQuad(root_pass, gfx::Rect(viewport_size), SK_ColorGREEN);
2055 2055
2056 testing::Sequence seq; 2056 testing::Sequence seq;
2057 // A bunch of initialization that happens. 2057 // A bunch of initialization that happens.
2058 EXPECT_CALL(*gl, Disable(GL_DEPTH_TEST)).InSequence(seq); 2058 EXPECT_CALL(*gl, Disable(GL_DEPTH_TEST)).InSequence(seq);
2059 EXPECT_CALL(*gl, Disable(GL_CULL_FACE)).InSequence(seq); 2059 EXPECT_CALL(*gl, Disable(GL_CULL_FACE)).InSequence(seq);
2060 EXPECT_CALL(*gl, Disable(GL_STENCIL_TEST)).InSequence(seq); 2060 EXPECT_CALL(*gl, Disable(GL_STENCIL_TEST)).InSequence(seq);
2061 EXPECT_CALL(*gl, Enable(GL_BLEND)).InSequence(seq); 2061 EXPECT_CALL(*gl, Enable(GL_BLEND)).InSequence(seq);
2062 EXPECT_CALL(*gl, Disable(GL_SCISSOR_TEST)).InSequence(seq); 2062 EXPECT_CALL(*gl, Disable(GL_SCISSOR_TEST)).InSequence(seq);
2063 EXPECT_CALL(*gl, Scissor(0, 0, 0, 0)).InSequence(seq); 2063 EXPECT_CALL(*gl, Scissor(0, 0, 0, 0)).InSequence(seq);
2064 2064
2065 // Partial frame, we should use a scissor to swap only that part when 2065 // Partial frame, we should use a scissor to swap only that part when
2066 // partial swap is enabled. 2066 // partial swap is enabled.
2067 root_pass->damage_rect = gfx::Rect(2, 2, 3, 3); 2067 root_pass->damage_rect = gfx::Rect(2, 2, 3, 3);
2068 gfx::Rect output_rectangle = 2068 // With SetDrawRectangle the first frame will have its damage expanded
2069 partial_swap ? root_pass->damage_rect : gfx::Rect(viewport_size); 2069 // to cover the entire output rect.
2070 bool frame_has_partial_damage =
2071 partial_swap && (!set_draw_rectangle || (i > 0));
2072 gfx::Rect output_rectangle = frame_has_partial_damage
2073 ? root_pass->damage_rect
2074 : gfx::Rect(viewport_size);
2070 2075
2071 if (partial_swap || set_draw_rectangle) { 2076 if (partial_swap || set_draw_rectangle) {
2072 EXPECT_CALL(*gl, Enable(GL_SCISSOR_TEST)).InSequence(seq); 2077 EXPECT_CALL(*gl, Enable(GL_SCISSOR_TEST)).InSequence(seq);
2073 // The scissor is flipped, so subtract the y coord and height from the 2078 // The scissor is flipped, so subtract the y coord and height from the
2074 // bottom of the GL viewport. 2079 // bottom of the GL viewport.
2075 EXPECT_CALL( 2080 EXPECT_CALL(
2076 *gl, 2081 *gl,
2077 Scissor(output_rectangle.x(), 2082 Scissor(output_rectangle.x(),
2078 viewport_size.height() - output_rectangle.y() - 2083 viewport_size.height() - output_rectangle.y() -
2079 output_rectangle.height(), 2084 output_rectangle.height(),
2080 output_rectangle.width(), output_rectangle.height())) 2085 output_rectangle.width(), output_rectangle.height()))
2081 .InSequence(seq); 2086 .InSequence(seq);
2082 } 2087 }
2083 2088
2084 // The quad doesn't need blending. 2089 // The quad doesn't need blending.
2085 EXPECT_CALL(*gl, Disable(GL_BLEND)).InSequence(seq); 2090 EXPECT_CALL(*gl, Disable(GL_BLEND)).InSequence(seq);
2086 2091
2087 // Blending is disabled at the end of the frame. 2092 // Blending is disabled at the end of the frame.
2088 EXPECT_CALL(*gl, Disable(GL_BLEND)).InSequence(seq); 2093 EXPECT_CALL(*gl, Disable(GL_BLEND)).InSequence(seq);
2089 2094
2090 renderer.DecideRenderPassAllocationsForFrame( 2095 renderer.DecideRenderPassAllocationsForFrame(
2091 render_passes_in_draw_order_); 2096 render_passes_in_draw_order_);
2092 DrawFrame(&renderer, viewport_size); 2097 DrawFrame(&renderer, viewport_size);
2093 if (set_draw_rectangle) { 2098 if (set_draw_rectangle) {
2094 EXPECT_EQ(output_rectangle, output_surface->last_set_draw_rectangle()); 2099 EXPECT_EQ(output_rectangle, output_surface->last_set_draw_rectangle());
2095 } 2100 }
2101 Mock::VerifyAndClearExpectations(gl);
2096 } 2102 }
2097 } 2103 }
2098 }; 2104 };
2099 2105
2100 TEST_F(GLRendererPartialSwapTest, PartialSwap) { 2106 TEST_F(GLRendererPartialSwapTest, PartialSwap) {
2101 RunTest(true, false); 2107 RunTest(true, false);
2102 } 2108 }
2103 2109
2104 TEST_F(GLRendererPartialSwapTest, NoPartialSwap) { 2110 TEST_F(GLRendererPartialSwapTest, NoPartialSwap) {
2105 RunTest(false, false); 2111 RunTest(false, false);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 2357
2352 TEST_F(GLRendererSwapWithBoundsTest, NonEmpty) { 2358 TEST_F(GLRendererSwapWithBoundsTest, NonEmpty) {
2353 std::vector<gfx::Rect> content_bounds; 2359 std::vector<gfx::Rect> content_bounds;
2354 content_bounds.push_back(gfx::Rect(0, 0, 10, 10)); 2360 content_bounds.push_back(gfx::Rect(0, 0, 10, 10));
2355 content_bounds.push_back(gfx::Rect(20, 20, 30, 30)); 2361 content_bounds.push_back(gfx::Rect(20, 20, 30, 30));
2356 RunTest(content_bounds); 2362 RunTest(content_bounds);
2357 } 2363 }
2358 2364
2359 } // namespace 2365 } // namespace
2360 } // namespace cc 2366 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/direct_renderer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698