| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 layer->SetDrawsContent(true); | 317 layer->SetDrawsContent(true); |
| 318 layer->SetBounds(size); | 318 layer->SetBounds(size); |
| 319 layer->SetContentBounds(size); | 319 layer->SetContentBounds(size); |
| 320 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); | 320 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); |
| 321 return layer.Pass(); | 321 return layer.Pass(); |
| 322 } | 322 } |
| 323 | 323 |
| 324 void DrawFrame() { | 324 void DrawFrame() { |
| 325 LayerTreeHostImpl::FrameData frame; | 325 LayerTreeHostImpl::FrameData frame; |
| 326 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 326 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 327 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 327 host_impl_->DrawLayers(&frame); |
| 328 host_impl_->DidDrawAllLayers(frame); | 328 host_impl_->DidDrawAllLayers(frame); |
| 329 } | 329 } |
| 330 | 330 |
| 331 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); | 331 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); |
| 332 void pinch_zoom_pan_viewport_test(float device_scale_factor); | 332 void pinch_zoom_pan_viewport_test(float device_scale_factor); |
| 333 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); | 333 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); |
| 334 void pinch_zoom_pan_viewport_and_scroll_boundary_test( | 334 void pinch_zoom_pan_viewport_and_scroll_boundary_test( |
| 335 float device_scale_factor); | 335 float device_scale_factor); |
| 336 | 336 |
| 337 void CheckNotifyCalledIfCanDrawChanged(bool always_draw) { | 337 void CheckNotifyCalledIfCanDrawChanged(bool always_draw) { |
| (...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1998 host_impl_->active_tree()->root_layer()); | 1998 host_impl_->active_tree()->root_layer()); |
| 1999 | 1999 |
| 2000 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 2000 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 2001 root->SetHasRenderSurface(true); | 2001 root->SetHasRenderSurface(true); |
| 2002 DidDrawCheckLayer* layer = | 2002 DidDrawCheckLayer* layer = |
| 2003 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 2003 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 2004 | 2004 |
| 2005 { | 2005 { |
| 2006 LayerTreeHostImpl::FrameData frame; | 2006 LayerTreeHostImpl::FrameData frame; |
| 2007 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2007 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2008 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2008 host_impl_->DrawLayers(&frame); |
| 2009 host_impl_->DidDrawAllLayers(frame); | 2009 host_impl_->DidDrawAllLayers(frame); |
| 2010 | 2010 |
| 2011 EXPECT_TRUE(layer->will_draw_called()); | 2011 EXPECT_TRUE(layer->will_draw_called()); |
| 2012 EXPECT_TRUE(layer->append_quads_called()); | 2012 EXPECT_TRUE(layer->append_quads_called()); |
| 2013 EXPECT_TRUE(layer->did_draw_called()); | 2013 EXPECT_TRUE(layer->did_draw_called()); |
| 2014 } | 2014 } |
| 2015 | 2015 |
| 2016 host_impl_->SetViewportDamage(gfx::Rect(10, 10)); | 2016 host_impl_->SetViewportDamage(gfx::Rect(10, 10)); |
| 2017 | 2017 |
| 2018 { | 2018 { |
| 2019 LayerTreeHostImpl::FrameData frame; | 2019 LayerTreeHostImpl::FrameData frame; |
| 2020 | 2020 |
| 2021 layer->set_will_draw_returns_false(); | 2021 layer->set_will_draw_returns_false(); |
| 2022 layer->ClearDidDrawCheck(); | 2022 layer->ClearDidDrawCheck(); |
| 2023 | 2023 |
| 2024 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2024 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2025 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2025 host_impl_->DrawLayers(&frame); |
| 2026 host_impl_->DidDrawAllLayers(frame); | 2026 host_impl_->DidDrawAllLayers(frame); |
| 2027 | 2027 |
| 2028 EXPECT_TRUE(layer->will_draw_called()); | 2028 EXPECT_TRUE(layer->will_draw_called()); |
| 2029 EXPECT_FALSE(layer->append_quads_called()); | 2029 EXPECT_FALSE(layer->append_quads_called()); |
| 2030 EXPECT_FALSE(layer->did_draw_called()); | 2030 EXPECT_FALSE(layer->did_draw_called()); |
| 2031 } | 2031 } |
| 2032 } | 2032 } |
| 2033 | 2033 |
| 2034 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { | 2034 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { |
| 2035 // The root layer is always drawn, so run this test on a child layer that | 2035 // The root layer is always drawn, so run this test on a child layer that |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2047 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 2047 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
| 2048 layer->SetBounds(gfx::Size(10, 10)); | 2048 layer->SetBounds(gfx::Size(10, 10)); |
| 2049 layer->SetContentBounds(gfx::Size(10, 10)); | 2049 layer->SetContentBounds(gfx::Size(10, 10)); |
| 2050 | 2050 |
| 2051 LayerTreeHostImpl::FrameData frame; | 2051 LayerTreeHostImpl::FrameData frame; |
| 2052 | 2052 |
| 2053 EXPECT_FALSE(layer->will_draw_called()); | 2053 EXPECT_FALSE(layer->will_draw_called()); |
| 2054 EXPECT_FALSE(layer->did_draw_called()); | 2054 EXPECT_FALSE(layer->did_draw_called()); |
| 2055 | 2055 |
| 2056 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2056 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2057 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2057 host_impl_->DrawLayers(&frame); |
| 2058 host_impl_->DidDrawAllLayers(frame); | 2058 host_impl_->DidDrawAllLayers(frame); |
| 2059 | 2059 |
| 2060 EXPECT_FALSE(layer->will_draw_called()); | 2060 EXPECT_FALSE(layer->will_draw_called()); |
| 2061 EXPECT_FALSE(layer->did_draw_called()); | 2061 EXPECT_FALSE(layer->did_draw_called()); |
| 2062 | 2062 |
| 2063 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); | 2063 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); |
| 2064 | 2064 |
| 2065 // Ensure visible_content_rect for layer is not empty | 2065 // Ensure visible_content_rect for layer is not empty |
| 2066 layer->SetPosition(gfx::PointF()); | 2066 layer->SetPosition(gfx::PointF()); |
| 2067 | 2067 |
| 2068 EXPECT_FALSE(layer->will_draw_called()); | 2068 EXPECT_FALSE(layer->will_draw_called()); |
| 2069 EXPECT_FALSE(layer->did_draw_called()); | 2069 EXPECT_FALSE(layer->did_draw_called()); |
| 2070 | 2070 |
| 2071 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2071 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2072 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2072 host_impl_->DrawLayers(&frame); |
| 2073 host_impl_->DidDrawAllLayers(frame); | 2073 host_impl_->DidDrawAllLayers(frame); |
| 2074 | 2074 |
| 2075 EXPECT_TRUE(layer->will_draw_called()); | 2075 EXPECT_TRUE(layer->will_draw_called()); |
| 2076 EXPECT_TRUE(layer->did_draw_called()); | 2076 EXPECT_TRUE(layer->did_draw_called()); |
| 2077 | 2077 |
| 2078 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); | 2078 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); |
| 2079 } | 2079 } |
| 2080 | 2080 |
| 2081 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { | 2081 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { |
| 2082 gfx::Size big_size(1000, 1000); | 2082 gfx::Size big_size(1000, 1000); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2102 top_layer->SetContentsOpaque(true); | 2102 top_layer->SetContentsOpaque(true); |
| 2103 | 2103 |
| 2104 LayerTreeHostImpl::FrameData frame; | 2104 LayerTreeHostImpl::FrameData frame; |
| 2105 | 2105 |
| 2106 EXPECT_FALSE(occluded_layer->will_draw_called()); | 2106 EXPECT_FALSE(occluded_layer->will_draw_called()); |
| 2107 EXPECT_FALSE(occluded_layer->did_draw_called()); | 2107 EXPECT_FALSE(occluded_layer->did_draw_called()); |
| 2108 EXPECT_FALSE(top_layer->will_draw_called()); | 2108 EXPECT_FALSE(top_layer->will_draw_called()); |
| 2109 EXPECT_FALSE(top_layer->did_draw_called()); | 2109 EXPECT_FALSE(top_layer->did_draw_called()); |
| 2110 | 2110 |
| 2111 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2111 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2112 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2112 host_impl_->DrawLayers(&frame); |
| 2113 host_impl_->DidDrawAllLayers(frame); | 2113 host_impl_->DidDrawAllLayers(frame); |
| 2114 | 2114 |
| 2115 EXPECT_FALSE(occluded_layer->will_draw_called()); | 2115 EXPECT_FALSE(occluded_layer->will_draw_called()); |
| 2116 EXPECT_FALSE(occluded_layer->did_draw_called()); | 2116 EXPECT_FALSE(occluded_layer->did_draw_called()); |
| 2117 EXPECT_TRUE(top_layer->will_draw_called()); | 2117 EXPECT_TRUE(top_layer->will_draw_called()); |
| 2118 EXPECT_TRUE(top_layer->did_draw_called()); | 2118 EXPECT_TRUE(top_layer->did_draw_called()); |
| 2119 } | 2119 } |
| 2120 | 2120 |
| 2121 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 2121 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
| 2122 host_impl_->active_tree()->SetRootLayer( | 2122 host_impl_->active_tree()->SetRootLayer( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2137 layer1->SetShouldFlattenTransform(true); | 2137 layer1->SetShouldFlattenTransform(true); |
| 2138 | 2138 |
| 2139 EXPECT_FALSE(root->did_draw_called()); | 2139 EXPECT_FALSE(root->did_draw_called()); |
| 2140 EXPECT_FALSE(layer1->did_draw_called()); | 2140 EXPECT_FALSE(layer1->did_draw_called()); |
| 2141 EXPECT_FALSE(layer2->did_draw_called()); | 2141 EXPECT_FALSE(layer2->did_draw_called()); |
| 2142 | 2142 |
| 2143 LayerTreeHostImpl::FrameData frame; | 2143 LayerTreeHostImpl::FrameData frame; |
| 2144 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 2144 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
| 2145 host_impl_->active_tree()->root_layer()); | 2145 host_impl_->active_tree()->root_layer()); |
| 2146 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2146 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2147 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2147 host_impl_->DrawLayers(&frame); |
| 2148 host_impl_->DidDrawAllLayers(frame); | 2148 host_impl_->DidDrawAllLayers(frame); |
| 2149 | 2149 |
| 2150 EXPECT_TRUE(root->did_draw_called()); | 2150 EXPECT_TRUE(root->did_draw_called()); |
| 2151 EXPECT_TRUE(layer1->did_draw_called()); | 2151 EXPECT_TRUE(layer1->did_draw_called()); |
| 2152 EXPECT_TRUE(layer2->did_draw_called()); | 2152 EXPECT_TRUE(layer2->did_draw_called()); |
| 2153 | 2153 |
| 2154 EXPECT_NE(root->render_surface(), layer1->render_surface()); | 2154 EXPECT_NE(root->render_surface(), layer1->render_surface()); |
| 2155 EXPECT_TRUE(!!layer1->render_surface()); | 2155 EXPECT_TRUE(!!layer1->render_surface()); |
| 2156 } | 2156 } |
| 2157 | 2157 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2287 cases.back().layer_before.is_animating = true; | 2287 cases.back().layer_before.is_animating = true; |
| 2288 | 2288 |
| 2289 host_impl_->active_tree()->SetRootLayer( | 2289 host_impl_->active_tree()->SetRootLayer( |
| 2290 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 2290 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 2291 DidDrawCheckLayer* root = | 2291 DidDrawCheckLayer* root = |
| 2292 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2292 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2293 root->SetHasRenderSurface(true); | 2293 root->SetHasRenderSurface(true); |
| 2294 | 2294 |
| 2295 LayerTreeHostImpl::FrameData frame; | 2295 LayerTreeHostImpl::FrameData frame; |
| 2296 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2296 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2297 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2297 host_impl_->DrawLayers(&frame); |
| 2298 host_impl_->DidDrawAllLayers(frame); | 2298 host_impl_->DidDrawAllLayers(frame); |
| 2299 host_impl_->SwapBuffers(frame); | 2299 host_impl_->SwapBuffers(frame); |
| 2300 | 2300 |
| 2301 for (size_t i = 0; i < cases.size(); ++i) { | 2301 for (size_t i = 0; i < cases.size(); ++i) { |
| 2302 const auto& testcase = cases[i]; | 2302 const auto& testcase = cases[i]; |
| 2303 std::vector<LayerImpl*> to_remove; | 2303 std::vector<LayerImpl*> to_remove; |
| 2304 for (auto* child : root->children()) | 2304 for (auto* child : root->children()) |
| 2305 to_remove.push_back(child); | 2305 to_remove.push_back(child); |
| 2306 for (auto* child : to_remove) | 2306 for (auto* child : to_remove) |
| 2307 root->RemoveChild(child); | 2307 root->RemoveChild(child); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2335 DidDrawCheckLayer* after = | 2335 DidDrawCheckLayer* after = |
| 2336 static_cast<DidDrawCheckLayer*>(root->children().back()); | 2336 static_cast<DidDrawCheckLayer*>(root->children().back()); |
| 2337 if (testcase.layer_after.has_copy_request) | 2337 if (testcase.layer_after.has_copy_request) |
| 2338 after->AddCopyRequest(); | 2338 after->AddCopyRequest(); |
| 2339 | 2339 |
| 2340 if (testcase.high_res_required) | 2340 if (testcase.high_res_required) |
| 2341 host_impl_->SetRequiresHighResToDraw(); | 2341 host_impl_->SetRequiresHighResToDraw(); |
| 2342 | 2342 |
| 2343 LayerTreeHostImpl::FrameData frame; | 2343 LayerTreeHostImpl::FrameData frame; |
| 2344 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); | 2344 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); |
| 2345 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2345 host_impl_->DrawLayers(&frame); |
| 2346 host_impl_->DidDrawAllLayers(frame); | 2346 host_impl_->DidDrawAllLayers(frame); |
| 2347 host_impl_->SwapBuffers(frame); | 2347 host_impl_->SwapBuffers(frame); |
| 2348 } | 2348 } |
| 2349 } | 2349 } |
| 2350 | 2350 |
| 2351 TEST_F(LayerTreeHostImplTest, | 2351 TEST_F(LayerTreeHostImplTest, |
| 2352 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { | 2352 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { |
| 2353 CreateHostImpl(DefaultSettings(), | 2353 CreateHostImpl(DefaultSettings(), |
| 2354 FakeOutputSurface::CreateAlwaysDrawAndSwap3d()); | 2354 FakeOutputSurface::CreateAlwaysDrawAndSwap3d()); |
| 2355 EXPECT_TRUE(host_impl_->output_surface() | 2355 EXPECT_TRUE(host_impl_->output_surface() |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2374 cases.back().layer_between.has_missing_tile = true; | 2374 cases.back().layer_between.has_missing_tile = true; |
| 2375 | 2375 |
| 2376 host_impl_->active_tree()->SetRootLayer( | 2376 host_impl_->active_tree()->SetRootLayer( |
| 2377 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 2377 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 2378 DidDrawCheckLayer* root = | 2378 DidDrawCheckLayer* root = |
| 2379 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2379 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2380 root->SetHasRenderSurface(true); | 2380 root->SetHasRenderSurface(true); |
| 2381 | 2381 |
| 2382 LayerTreeHostImpl::FrameData frame; | 2382 LayerTreeHostImpl::FrameData frame; |
| 2383 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2383 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2384 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2384 host_impl_->DrawLayers(&frame); |
| 2385 host_impl_->DidDrawAllLayers(frame); | 2385 host_impl_->DidDrawAllLayers(frame); |
| 2386 host_impl_->SwapBuffers(frame); | 2386 host_impl_->SwapBuffers(frame); |
| 2387 | 2387 |
| 2388 for (size_t i = 0; i < cases.size(); ++i) { | 2388 for (size_t i = 0; i < cases.size(); ++i) { |
| 2389 const auto& testcase = cases[i]; | 2389 const auto& testcase = cases[i]; |
| 2390 std::vector<LayerImpl*> to_remove; | 2390 std::vector<LayerImpl*> to_remove; |
| 2391 for (auto* child : root->children()) | 2391 for (auto* child : root->children()) |
| 2392 to_remove.push_back(child); | 2392 to_remove.push_back(child); |
| 2393 for (auto* child : to_remove) | 2393 for (auto* child : to_remove) |
| 2394 root->RemoveChild(child); | 2394 root->RemoveChild(child); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2422 DidDrawCheckLayer* after = | 2422 DidDrawCheckLayer* after = |
| 2423 static_cast<DidDrawCheckLayer*>(root->children().back()); | 2423 static_cast<DidDrawCheckLayer*>(root->children().back()); |
| 2424 if (testcase.layer_after.has_copy_request) | 2424 if (testcase.layer_after.has_copy_request) |
| 2425 after->AddCopyRequest(); | 2425 after->AddCopyRequest(); |
| 2426 | 2426 |
| 2427 if (testcase.high_res_required) | 2427 if (testcase.high_res_required) |
| 2428 host_impl_->SetRequiresHighResToDraw(); | 2428 host_impl_->SetRequiresHighResToDraw(); |
| 2429 | 2429 |
| 2430 LayerTreeHostImpl::FrameData frame; | 2430 LayerTreeHostImpl::FrameData frame; |
| 2431 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); | 2431 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); |
| 2432 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2432 host_impl_->DrawLayers(&frame); |
| 2433 host_impl_->DidDrawAllLayers(frame); | 2433 host_impl_->DidDrawAllLayers(frame); |
| 2434 host_impl_->SwapBuffers(frame); | 2434 host_impl_->SwapBuffers(frame); |
| 2435 } | 2435 } |
| 2436 } | 2436 } |
| 2437 | 2437 |
| 2438 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 2438 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
| 2439 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2439 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2440 root->SetScrollClipLayer(Layer::INVALID_ID); | 2440 root->SetScrollClipLayer(Layer::INVALID_ID); |
| 2441 root->SetHasRenderSurface(true); | 2441 root->SetHasRenderSurface(true); |
| 2442 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2442 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3383 EXPECT_EQ(1.f, scroll->contents_scale_y()); | 3383 EXPECT_EQ(1.f, scroll->contents_scale_y()); |
| 3384 EXPECT_EQ(1.f, child->contents_scale_x()); | 3384 EXPECT_EQ(1.f, child->contents_scale_x()); |
| 3385 EXPECT_EQ(1.f, child->contents_scale_y()); | 3385 EXPECT_EQ(1.f, child->contents_scale_y()); |
| 3386 EXPECT_EQ(1.f, grand_child->contents_scale_x()); | 3386 EXPECT_EQ(1.f, grand_child->contents_scale_x()); |
| 3387 EXPECT_EQ(1.f, grand_child->contents_scale_y()); | 3387 EXPECT_EQ(1.f, grand_child->contents_scale_y()); |
| 3388 | 3388 |
| 3389 // Make sure all the layers are drawn with the page scale delta applied, i.e., | 3389 // Make sure all the layers are drawn with the page scale delta applied, i.e., |
| 3390 // the page scale delta on the root layer is applied hierarchically. | 3390 // the page scale delta on the root layer is applied hierarchically. |
| 3391 LayerTreeHostImpl::FrameData frame; | 3391 LayerTreeHostImpl::FrameData frame; |
| 3392 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3392 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3393 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3393 host_impl_->DrawLayers(&frame); |
| 3394 host_impl_->DidDrawAllLayers(frame); | 3394 host_impl_->DidDrawAllLayers(frame); |
| 3395 | 3395 |
| 3396 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0)); | 3396 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0)); |
| 3397 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1)); | 3397 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1)); |
| 3398 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0)); | 3398 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0)); |
| 3399 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1)); | 3399 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1)); |
| 3400 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0)); | 3400 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0)); |
| 3401 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1)); | 3401 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1)); |
| 3402 EXPECT_EQ(new_page_scale, | 3402 EXPECT_EQ(new_page_scale, |
| 3403 grand_child->draw_transform().matrix().getDouble(0, 0)); | 3403 grand_child->draw_transform().matrix().getDouble(0, 0)); |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4057 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); | 4057 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); |
| 4058 | 4058 |
| 4059 // Set external scroll delta on delegate and notify LayerTreeHost. | 4059 // Set external scroll delta on delegate and notify LayerTreeHost. |
| 4060 gfx::ScrollOffset scroll_offset(10.f, 10.f); | 4060 gfx::ScrollOffset scroll_offset(10.f, 10.f); |
| 4061 scroll_delegate.set_getter_return_value(scroll_offset); | 4061 scroll_delegate.set_getter_return_value(scroll_offset); |
| 4062 host_impl_->OnRootLayerDelegatedScrollOffsetChanged(); | 4062 host_impl_->OnRootLayerDelegatedScrollOffsetChanged(); |
| 4063 | 4063 |
| 4064 // Check scroll delta reflected in layer. | 4064 // Check scroll delta reflected in layer. |
| 4065 LayerTreeHostImpl::FrameData frame; | 4065 LayerTreeHostImpl::FrameData frame; |
| 4066 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4066 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4067 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4067 host_impl_->DrawLayers(&frame); |
| 4068 host_impl_->DidDrawAllLayers(frame); | 4068 host_impl_->DidDrawAllLayers(frame); |
| 4069 EXPECT_FALSE(frame.has_no_damage); | 4069 EXPECT_FALSE(frame.has_no_damage); |
| 4070 CheckLayerScrollDelta(scroll_layer, ScrollOffsetToVector2dF(scroll_offset)); | 4070 CheckLayerScrollDelta(scroll_layer, ScrollOffsetToVector2dF(scroll_offset)); |
| 4071 | 4071 |
| 4072 host_impl_->SetRootLayerScrollOffsetDelegate(NULL); | 4072 host_impl_->SetRootLayerScrollOffsetDelegate(NULL); |
| 4073 } | 4073 } |
| 4074 | 4074 |
| 4075 TEST_F(LayerTreeHostImplTest, OverscrollRoot) { | 4075 TEST_F(LayerTreeHostImplTest, OverscrollRoot) { |
| 4076 InputHandlerScrollResult scroll_result; | 4076 InputHandlerScrollResult scroll_result; |
| 4077 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 4077 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4516 static_cast<BlendStateCheckLayer*>(root->children()[0]); | 4516 static_cast<BlendStateCheckLayer*>(root->children()[0]); |
| 4517 layer1->SetPosition(gfx::PointF(2.f, 2.f)); | 4517 layer1->SetPosition(gfx::PointF(2.f, 2.f)); |
| 4518 | 4518 |
| 4519 LayerTreeHostImpl::FrameData frame; | 4519 LayerTreeHostImpl::FrameData frame; |
| 4520 | 4520 |
| 4521 // Opaque layer, drawn without blending. | 4521 // Opaque layer, drawn without blending. |
| 4522 layer1->SetContentsOpaque(true); | 4522 layer1->SetContentsOpaque(true); |
| 4523 layer1->SetExpectation(false, false); | 4523 layer1->SetExpectation(false, false); |
| 4524 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4524 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4525 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4525 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4526 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4526 host_impl_->DrawLayers(&frame); |
| 4527 EXPECT_TRUE(layer1->quads_appended()); | 4527 EXPECT_TRUE(layer1->quads_appended()); |
| 4528 host_impl_->DidDrawAllLayers(frame); | 4528 host_impl_->DidDrawAllLayers(frame); |
| 4529 | 4529 |
| 4530 // Layer with translucent content and painting, so drawn with blending. | 4530 // Layer with translucent content and painting, so drawn with blending. |
| 4531 layer1->SetContentsOpaque(false); | 4531 layer1->SetContentsOpaque(false); |
| 4532 layer1->SetExpectation(true, false); | 4532 layer1->SetExpectation(true, false); |
| 4533 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4533 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4534 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4534 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4535 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4535 host_impl_->DrawLayers(&frame); |
| 4536 EXPECT_TRUE(layer1->quads_appended()); | 4536 EXPECT_TRUE(layer1->quads_appended()); |
| 4537 host_impl_->DidDrawAllLayers(frame); | 4537 host_impl_->DidDrawAllLayers(frame); |
| 4538 | 4538 |
| 4539 // Layer with translucent opacity, drawn with blending. | 4539 // Layer with translucent opacity, drawn with blending. |
| 4540 layer1->SetContentsOpaque(true); | 4540 layer1->SetContentsOpaque(true); |
| 4541 layer1->SetOpacity(0.5f); | 4541 layer1->SetOpacity(0.5f); |
| 4542 layer1->SetExpectation(true, false); | 4542 layer1->SetExpectation(true, false); |
| 4543 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4543 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4544 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4544 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4545 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4545 host_impl_->DrawLayers(&frame); |
| 4546 EXPECT_TRUE(layer1->quads_appended()); | 4546 EXPECT_TRUE(layer1->quads_appended()); |
| 4547 host_impl_->DidDrawAllLayers(frame); | 4547 host_impl_->DidDrawAllLayers(frame); |
| 4548 | 4548 |
| 4549 // Layer with translucent opacity and painting, drawn with blending. | 4549 // Layer with translucent opacity and painting, drawn with blending. |
| 4550 layer1->SetContentsOpaque(true); | 4550 layer1->SetContentsOpaque(true); |
| 4551 layer1->SetOpacity(0.5f); | 4551 layer1->SetOpacity(0.5f); |
| 4552 layer1->SetExpectation(true, false); | 4552 layer1->SetExpectation(true, false); |
| 4553 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4553 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4554 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4554 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4555 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4555 host_impl_->DrawLayers(&frame); |
| 4556 EXPECT_TRUE(layer1->quads_appended()); | 4556 EXPECT_TRUE(layer1->quads_appended()); |
| 4557 host_impl_->DidDrawAllLayers(frame); | 4557 host_impl_->DidDrawAllLayers(frame); |
| 4558 | 4558 |
| 4559 layer1->AddChild( | 4559 layer1->AddChild( |
| 4560 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 4560 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 4561 3, | 4561 3, |
| 4562 host_impl_->resource_provider())); | 4562 host_impl_->resource_provider())); |
| 4563 BlendStateCheckLayer* layer2 = | 4563 BlendStateCheckLayer* layer2 = |
| 4564 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); | 4564 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); |
| 4565 layer2->SetPosition(gfx::PointF(4.f, 4.f)); | 4565 layer2->SetPosition(gfx::PointF(4.f, 4.f)); |
| 4566 | 4566 |
| 4567 // 2 opaque layers, drawn without blending. | 4567 // 2 opaque layers, drawn without blending. |
| 4568 layer1->SetContentsOpaque(true); | 4568 layer1->SetContentsOpaque(true); |
| 4569 layer1->SetOpacity(1.f); | 4569 layer1->SetOpacity(1.f); |
| 4570 layer1->SetExpectation(false, false); | 4570 layer1->SetExpectation(false, false); |
| 4571 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4571 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4572 layer2->SetContentsOpaque(true); | 4572 layer2->SetContentsOpaque(true); |
| 4573 layer2->SetOpacity(1.f); | 4573 layer2->SetOpacity(1.f); |
| 4574 layer2->SetExpectation(false, false); | 4574 layer2->SetExpectation(false, false); |
| 4575 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4575 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4576 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4576 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4577 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4577 host_impl_->DrawLayers(&frame); |
| 4578 EXPECT_TRUE(layer1->quads_appended()); | 4578 EXPECT_TRUE(layer1->quads_appended()); |
| 4579 EXPECT_TRUE(layer2->quads_appended()); | 4579 EXPECT_TRUE(layer2->quads_appended()); |
| 4580 host_impl_->DidDrawAllLayers(frame); | 4580 host_impl_->DidDrawAllLayers(frame); |
| 4581 | 4581 |
| 4582 // Parent layer with translucent content, drawn with blending. | 4582 // Parent layer with translucent content, drawn with blending. |
| 4583 // Child layer with opaque content, drawn without blending. | 4583 // Child layer with opaque content, drawn without blending. |
| 4584 layer1->SetContentsOpaque(false); | 4584 layer1->SetContentsOpaque(false); |
| 4585 layer1->SetExpectation(true, false); | 4585 layer1->SetExpectation(true, false); |
| 4586 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4586 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4587 layer2->SetExpectation(false, false); | 4587 layer2->SetExpectation(false, false); |
| 4588 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4588 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4589 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4589 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4590 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4590 host_impl_->DrawLayers(&frame); |
| 4591 EXPECT_TRUE(layer1->quads_appended()); | 4591 EXPECT_TRUE(layer1->quads_appended()); |
| 4592 EXPECT_TRUE(layer2->quads_appended()); | 4592 EXPECT_TRUE(layer2->quads_appended()); |
| 4593 host_impl_->DidDrawAllLayers(frame); | 4593 host_impl_->DidDrawAllLayers(frame); |
| 4594 | 4594 |
| 4595 // Parent layer with translucent content but opaque painting, drawn without | 4595 // Parent layer with translucent content but opaque painting, drawn without |
| 4596 // blending. | 4596 // blending. |
| 4597 // Child layer with opaque content, drawn without blending. | 4597 // Child layer with opaque content, drawn without blending. |
| 4598 layer1->SetContentsOpaque(true); | 4598 layer1->SetContentsOpaque(true); |
| 4599 layer1->SetExpectation(false, false); | 4599 layer1->SetExpectation(false, false); |
| 4600 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4600 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4601 layer2->SetExpectation(false, false); | 4601 layer2->SetExpectation(false, false); |
| 4602 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4602 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4603 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4603 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4604 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4604 host_impl_->DrawLayers(&frame); |
| 4605 EXPECT_TRUE(layer1->quads_appended()); | 4605 EXPECT_TRUE(layer1->quads_appended()); |
| 4606 EXPECT_TRUE(layer2->quads_appended()); | 4606 EXPECT_TRUE(layer2->quads_appended()); |
| 4607 host_impl_->DidDrawAllLayers(frame); | 4607 host_impl_->DidDrawAllLayers(frame); |
| 4608 | 4608 |
| 4609 // Parent layer with translucent opacity and opaque content. Since it has a | 4609 // Parent layer with translucent opacity and opaque content. Since it has a |
| 4610 // drawing child, it's drawn to a render surface which carries the opacity, | 4610 // drawing child, it's drawn to a render surface which carries the opacity, |
| 4611 // so it's itself drawn without blending. | 4611 // so it's itself drawn without blending. |
| 4612 // Child layer with opaque content, drawn without blending (parent surface | 4612 // Child layer with opaque content, drawn without blending (parent surface |
| 4613 // carries the inherited opacity). | 4613 // carries the inherited opacity). |
| 4614 layer1->SetContentsOpaque(true); | 4614 layer1->SetContentsOpaque(true); |
| 4615 layer1->SetOpacity(0.5f); | 4615 layer1->SetOpacity(0.5f); |
| 4616 layer1->SetHasRenderSurface(true); | 4616 layer1->SetHasRenderSurface(true); |
| 4617 layer1->SetExpectation(false, true); | 4617 layer1->SetExpectation(false, true); |
| 4618 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4618 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4619 layer2->SetExpectation(false, false); | 4619 layer2->SetExpectation(false, false); |
| 4620 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4620 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4621 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 4621 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
| 4622 host_impl_->active_tree()->root_layer()); | 4622 host_impl_->active_tree()->root_layer()); |
| 4623 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4623 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4624 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4624 host_impl_->DrawLayers(&frame); |
| 4625 EXPECT_TRUE(layer1->quads_appended()); | 4625 EXPECT_TRUE(layer1->quads_appended()); |
| 4626 EXPECT_TRUE(layer2->quads_appended()); | 4626 EXPECT_TRUE(layer2->quads_appended()); |
| 4627 host_impl_->DidDrawAllLayers(frame); | 4627 host_impl_->DidDrawAllLayers(frame); |
| 4628 layer1->SetHasRenderSurface(false); | 4628 layer1->SetHasRenderSurface(false); |
| 4629 | 4629 |
| 4630 // Draw again, but with child non-opaque, to make sure | 4630 // Draw again, but with child non-opaque, to make sure |
| 4631 // layer1 not culled. | 4631 // layer1 not culled. |
| 4632 layer1->SetContentsOpaque(true); | 4632 layer1->SetContentsOpaque(true); |
| 4633 layer1->SetOpacity(1.f); | 4633 layer1->SetOpacity(1.f); |
| 4634 layer1->SetExpectation(false, false); | 4634 layer1->SetExpectation(false, false); |
| 4635 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4635 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4636 layer2->SetContentsOpaque(true); | 4636 layer2->SetContentsOpaque(true); |
| 4637 layer2->SetOpacity(0.5f); | 4637 layer2->SetOpacity(0.5f); |
| 4638 layer2->SetExpectation(true, false); | 4638 layer2->SetExpectation(true, false); |
| 4639 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4639 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4640 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4640 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4641 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4641 host_impl_->DrawLayers(&frame); |
| 4642 EXPECT_TRUE(layer1->quads_appended()); | 4642 EXPECT_TRUE(layer1->quads_appended()); |
| 4643 EXPECT_TRUE(layer2->quads_appended()); | 4643 EXPECT_TRUE(layer2->quads_appended()); |
| 4644 host_impl_->DidDrawAllLayers(frame); | 4644 host_impl_->DidDrawAllLayers(frame); |
| 4645 | 4645 |
| 4646 // A second way of making the child non-opaque. | 4646 // A second way of making the child non-opaque. |
| 4647 layer1->SetContentsOpaque(true); | 4647 layer1->SetContentsOpaque(true); |
| 4648 layer1->SetOpacity(1.f); | 4648 layer1->SetOpacity(1.f); |
| 4649 layer1->SetExpectation(false, false); | 4649 layer1->SetExpectation(false, false); |
| 4650 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4650 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4651 layer2->SetContentsOpaque(false); | 4651 layer2->SetContentsOpaque(false); |
| 4652 layer2->SetOpacity(1.f); | 4652 layer2->SetOpacity(1.f); |
| 4653 layer2->SetExpectation(true, false); | 4653 layer2->SetExpectation(true, false); |
| 4654 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4654 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4655 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4655 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4656 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4656 host_impl_->DrawLayers(&frame); |
| 4657 EXPECT_TRUE(layer1->quads_appended()); | 4657 EXPECT_TRUE(layer1->quads_appended()); |
| 4658 EXPECT_TRUE(layer2->quads_appended()); | 4658 EXPECT_TRUE(layer2->quads_appended()); |
| 4659 host_impl_->DidDrawAllLayers(frame); | 4659 host_impl_->DidDrawAllLayers(frame); |
| 4660 | 4660 |
| 4661 // And when the layer says its not opaque but is painted opaque, it is not | 4661 // And when the layer says its not opaque but is painted opaque, it is not |
| 4662 // blended. | 4662 // blended. |
| 4663 layer1->SetContentsOpaque(true); | 4663 layer1->SetContentsOpaque(true); |
| 4664 layer1->SetOpacity(1.f); | 4664 layer1->SetOpacity(1.f); |
| 4665 layer1->SetExpectation(false, false); | 4665 layer1->SetExpectation(false, false); |
| 4666 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4666 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4667 layer2->SetContentsOpaque(true); | 4667 layer2->SetContentsOpaque(true); |
| 4668 layer2->SetOpacity(1.f); | 4668 layer2->SetOpacity(1.f); |
| 4669 layer2->SetExpectation(false, false); | 4669 layer2->SetExpectation(false, false); |
| 4670 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4670 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4671 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4671 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4672 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4672 host_impl_->DrawLayers(&frame); |
| 4673 EXPECT_TRUE(layer1->quads_appended()); | 4673 EXPECT_TRUE(layer1->quads_appended()); |
| 4674 EXPECT_TRUE(layer2->quads_appended()); | 4674 EXPECT_TRUE(layer2->quads_appended()); |
| 4675 host_impl_->DidDrawAllLayers(frame); | 4675 host_impl_->DidDrawAllLayers(frame); |
| 4676 | 4676 |
| 4677 // Layer with partially opaque contents, drawn with blending. | 4677 // Layer with partially opaque contents, drawn with blending. |
| 4678 layer1->SetContentsOpaque(false); | 4678 layer1->SetContentsOpaque(false); |
| 4679 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 4679 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 4680 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); | 4680 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); |
| 4681 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 4681 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 4682 layer1->SetExpectation(true, false); | 4682 layer1->SetExpectation(true, false); |
| 4683 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4683 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4684 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4684 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4685 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4685 host_impl_->DrawLayers(&frame); |
| 4686 EXPECT_TRUE(layer1->quads_appended()); | 4686 EXPECT_TRUE(layer1->quads_appended()); |
| 4687 host_impl_->DidDrawAllLayers(frame); | 4687 host_impl_->DidDrawAllLayers(frame); |
| 4688 | 4688 |
| 4689 // Layer with partially opaque contents partially culled, drawn with blending. | 4689 // Layer with partially opaque contents partially culled, drawn with blending. |
| 4690 layer1->SetContentsOpaque(false); | 4690 layer1->SetContentsOpaque(false); |
| 4691 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 4691 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 4692 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); | 4692 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); |
| 4693 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 4693 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 4694 layer1->SetExpectation(true, false); | 4694 layer1->SetExpectation(true, false); |
| 4695 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4695 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4696 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4696 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4697 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4697 host_impl_->DrawLayers(&frame); |
| 4698 EXPECT_TRUE(layer1->quads_appended()); | 4698 EXPECT_TRUE(layer1->quads_appended()); |
| 4699 host_impl_->DidDrawAllLayers(frame); | 4699 host_impl_->DidDrawAllLayers(frame); |
| 4700 | 4700 |
| 4701 // Layer with partially opaque contents culled, drawn with blending. | 4701 // Layer with partially opaque contents culled, drawn with blending. |
| 4702 layer1->SetContentsOpaque(false); | 4702 layer1->SetContentsOpaque(false); |
| 4703 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 4703 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 4704 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); | 4704 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); |
| 4705 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 4705 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 4706 layer1->SetExpectation(true, false); | 4706 layer1->SetExpectation(true, false); |
| 4707 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4707 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4708 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4708 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4709 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4709 host_impl_->DrawLayers(&frame); |
| 4710 EXPECT_TRUE(layer1->quads_appended()); | 4710 EXPECT_TRUE(layer1->quads_appended()); |
| 4711 host_impl_->DidDrawAllLayers(frame); | 4711 host_impl_->DidDrawAllLayers(frame); |
| 4712 | 4712 |
| 4713 // Layer with partially opaque contents and translucent contents culled, drawn | 4713 // Layer with partially opaque contents and translucent contents culled, drawn |
| 4714 // without blending. | 4714 // without blending. |
| 4715 layer1->SetContentsOpaque(false); | 4715 layer1->SetContentsOpaque(false); |
| 4716 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 4716 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 4717 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); | 4717 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); |
| 4718 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 4718 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 4719 layer1->SetExpectation(false, false); | 4719 layer1->SetExpectation(false, false); |
| 4720 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4720 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4721 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4721 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4722 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4722 host_impl_->DrawLayers(&frame); |
| 4723 EXPECT_TRUE(layer1->quads_appended()); | 4723 EXPECT_TRUE(layer1->quads_appended()); |
| 4724 host_impl_->DidDrawAllLayers(frame); | 4724 host_impl_->DidDrawAllLayers(frame); |
| 4725 } | 4725 } |
| 4726 | 4726 |
| 4727 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 4727 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
| 4728 protected: | 4728 protected: |
| 4729 LayerTreeHostImplViewportCoveredTest() : | 4729 LayerTreeHostImplViewportCoveredTest() : |
| 4730 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 4730 gutter_quad_material_(DrawQuad::SOLID_COLOR), |
| 4731 child_(NULL), | 4731 child_(NULL), |
| 4732 did_activate_pending_tree_(false) {} | 4732 did_activate_pending_tree_(false) {} |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4992 root->SetDrawsContent(true); | 4992 root->SetDrawsContent(true); |
| 4993 root->SetHasRenderSurface(true); | 4993 root->SetHasRenderSurface(true); |
| 4994 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4994 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 4995 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 4995 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
| 4996 provider->TestContext3d()->clear_reshape_called(); | 4996 provider->TestContext3d()->clear_reshape_called(); |
| 4997 | 4997 |
| 4998 LayerTreeHostImpl::FrameData frame; | 4998 LayerTreeHostImpl::FrameData frame; |
| 4999 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 4999 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 5000 host_impl_->SetDeviceScaleFactor(1.f); | 5000 host_impl_->SetDeviceScaleFactor(1.f); |
| 5001 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5001 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5002 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5002 host_impl_->DrawLayers(&frame); |
| 5003 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 5003 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| 5004 EXPECT_EQ(provider->TestContext3d()->width(), 10); | 5004 EXPECT_EQ(provider->TestContext3d()->width(), 10); |
| 5005 EXPECT_EQ(provider->TestContext3d()->height(), 10); | 5005 EXPECT_EQ(provider->TestContext3d()->height(), 10); |
| 5006 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); | 5006 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); |
| 5007 host_impl_->DidDrawAllLayers(frame); | 5007 host_impl_->DidDrawAllLayers(frame); |
| 5008 provider->TestContext3d()->clear_reshape_called(); | 5008 provider->TestContext3d()->clear_reshape_called(); |
| 5009 | 5009 |
| 5010 host_impl_->SetViewportSize(gfx::Size(20, 30)); | 5010 host_impl_->SetViewportSize(gfx::Size(20, 30)); |
| 5011 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5011 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5012 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5012 host_impl_->DrawLayers(&frame); |
| 5013 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 5013 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| 5014 EXPECT_EQ(provider->TestContext3d()->width(), 20); | 5014 EXPECT_EQ(provider->TestContext3d()->width(), 20); |
| 5015 EXPECT_EQ(provider->TestContext3d()->height(), 30); | 5015 EXPECT_EQ(provider->TestContext3d()->height(), 30); |
| 5016 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); | 5016 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); |
| 5017 host_impl_->DidDrawAllLayers(frame); | 5017 host_impl_->DidDrawAllLayers(frame); |
| 5018 provider->TestContext3d()->clear_reshape_called(); | 5018 provider->TestContext3d()->clear_reshape_called(); |
| 5019 | 5019 |
| 5020 host_impl_->SetDeviceScaleFactor(2.f); | 5020 host_impl_->SetDeviceScaleFactor(2.f); |
| 5021 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5021 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5022 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5022 host_impl_->DrawLayers(&frame); |
| 5023 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 5023 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| 5024 EXPECT_EQ(provider->TestContext3d()->width(), 20); | 5024 EXPECT_EQ(provider->TestContext3d()->width(), 20); |
| 5025 EXPECT_EQ(provider->TestContext3d()->height(), 30); | 5025 EXPECT_EQ(provider->TestContext3d()->height(), 30); |
| 5026 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); | 5026 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); |
| 5027 host_impl_->DidDrawAllLayers(frame); | 5027 host_impl_->DidDrawAllLayers(frame); |
| 5028 provider->TestContext3d()->clear_reshape_called(); | 5028 provider->TestContext3d()->clear_reshape_called(); |
| 5029 } | 5029 } |
| 5030 | 5030 |
| 5031 // Make sure damage tracking propagates all the way to the graphics context, | 5031 // Make sure damage tracking propagates all the way to the graphics context, |
| 5032 // where it should request to swap only the sub-buffer that is damaged. | 5032 // where it should request to swap only the sub-buffer that is damaged. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 5063 root->SetBounds(gfx::Size(500, 500)); | 5063 root->SetBounds(gfx::Size(500, 500)); |
| 5064 root->SetContentBounds(gfx::Size(500, 500)); | 5064 root->SetContentBounds(gfx::Size(500, 500)); |
| 5065 root->SetDrawsContent(true); | 5065 root->SetDrawsContent(true); |
| 5066 root->AddChild(child.Pass()); | 5066 root->AddChild(child.Pass()); |
| 5067 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); | 5067 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); |
| 5068 | 5068 |
| 5069 LayerTreeHostImpl::FrameData frame; | 5069 LayerTreeHostImpl::FrameData frame; |
| 5070 | 5070 |
| 5071 // First frame, the entire screen should get swapped. | 5071 // First frame, the entire screen should get swapped. |
| 5072 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 5072 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 5073 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); | 5073 layer_tree_host_impl->DrawLayers(&frame); |
| 5074 layer_tree_host_impl->DidDrawAllLayers(frame); | 5074 layer_tree_host_impl->DidDrawAllLayers(frame); |
| 5075 layer_tree_host_impl->SwapBuffers(frame); | 5075 layer_tree_host_impl->SwapBuffers(frame); |
| 5076 gfx::Rect expected_swap_rect(0, 0, 500, 500); | 5076 gfx::Rect expected_swap_rect(0, 0, 500, 500); |
| 5077 EXPECT_EQ(expected_swap_rect.ToString(), | 5077 EXPECT_EQ(expected_swap_rect.ToString(), |
| 5078 fake_output_surface->last_swap_rect().ToString()); | 5078 fake_output_surface->last_swap_rect().ToString()); |
| 5079 | 5079 |
| 5080 // Second frame, only the damaged area should get swapped. Damage should be | 5080 // Second frame, only the damaged area should get swapped. Damage should be |
| 5081 // the union of old and new child rects. | 5081 // the union of old and new child rects. |
| 5082 // expected damage rect: gfx::Rect(26, 28); | 5082 // expected damage rect: gfx::Rect(26, 28); |
| 5083 // expected swap rect: vertically flipped, with origin at bottom left corner. | 5083 // expected swap rect: vertically flipped, with origin at bottom left corner. |
| 5084 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( | 5084 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( |
| 5085 gfx::PointF()); | 5085 gfx::PointF()); |
| 5086 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 5086 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 5087 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); | 5087 layer_tree_host_impl->DrawLayers(&frame); |
| 5088 host_impl_->DidDrawAllLayers(frame); | 5088 host_impl_->DidDrawAllLayers(frame); |
| 5089 layer_tree_host_impl->SwapBuffers(frame); | 5089 layer_tree_host_impl->SwapBuffers(frame); |
| 5090 | 5090 |
| 5091 // Make sure that partial swap is constrained to the viewport dimensions | 5091 // Make sure that partial swap is constrained to the viewport dimensions |
| 5092 // expected damage rect: gfx::Rect(500, 500); | 5092 // expected damage rect: gfx::Rect(500, 500); |
| 5093 // expected swap rect: flipped damage rect, but also clamped to viewport | 5093 // expected swap rect: flipped damage rect, but also clamped to viewport |
| 5094 expected_swap_rect = gfx::Rect(0, 500-28, 26, 28); | 5094 expected_swap_rect = gfx::Rect(0, 500-28, 26, 28); |
| 5095 EXPECT_EQ(expected_swap_rect.ToString(), | 5095 EXPECT_EQ(expected_swap_rect.ToString(), |
| 5096 fake_output_surface->last_swap_rect().ToString()); | 5096 fake_output_surface->last_swap_rect().ToString()); |
| 5097 | 5097 |
| 5098 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); | 5098 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); |
| 5099 // This will damage everything. | 5099 // This will damage everything. |
| 5100 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( | 5100 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( |
| 5101 SK_ColorBLACK); | 5101 SK_ColorBLACK); |
| 5102 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 5102 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 5103 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); | 5103 layer_tree_host_impl->DrawLayers(&frame); |
| 5104 host_impl_->DidDrawAllLayers(frame); | 5104 host_impl_->DidDrawAllLayers(frame); |
| 5105 layer_tree_host_impl->SwapBuffers(frame); | 5105 layer_tree_host_impl->SwapBuffers(frame); |
| 5106 | 5106 |
| 5107 expected_swap_rect = gfx::Rect(0, 0, 10, 10); | 5107 expected_swap_rect = gfx::Rect(0, 0, 10, 10); |
| 5108 EXPECT_EQ(expected_swap_rect.ToString(), | 5108 EXPECT_EQ(expected_swap_rect.ToString(), |
| 5109 fake_output_surface->last_swap_rect().ToString()); | 5109 fake_output_surface->last_swap_rect().ToString()); |
| 5110 } | 5110 } |
| 5111 | 5111 |
| 5112 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { | 5112 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { |
| 5113 scoped_ptr<LayerImpl> root = | 5113 scoped_ptr<LayerImpl> root = |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5257 CreateHostImpl(settings, | 5257 CreateHostImpl(settings, |
| 5258 FakeOutputSurface::Create3d(mock_context_owned.Pass())); | 5258 FakeOutputSurface::Create3d(mock_context_owned.Pass())); |
| 5259 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 5259 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 5260 | 5260 |
| 5261 // Without partial swap, and no clipping, no scissor is set. | 5261 // Without partial swap, and no clipping, no scissor is set. |
| 5262 harness.MustDrawSolidQuad(); | 5262 harness.MustDrawSolidQuad(); |
| 5263 harness.MustSetNoScissor(); | 5263 harness.MustSetNoScissor(); |
| 5264 { | 5264 { |
| 5265 LayerTreeHostImpl::FrameData frame; | 5265 LayerTreeHostImpl::FrameData frame; |
| 5266 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5266 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5267 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5267 host_impl_->DrawLayers(&frame); |
| 5268 host_impl_->DidDrawAllLayers(frame); | 5268 host_impl_->DidDrawAllLayers(frame); |
| 5269 } | 5269 } |
| 5270 Mock::VerifyAndClearExpectations(&mock_context); | 5270 Mock::VerifyAndClearExpectations(&mock_context); |
| 5271 | 5271 |
| 5272 // Without partial swap, but a layer does clip its subtree, one scissor is | 5272 // Without partial swap, but a layer does clip its subtree, one scissor is |
| 5273 // set. | 5273 // set. |
| 5274 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true); | 5274 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true); |
| 5275 harness.MustDrawSolidQuad(); | 5275 harness.MustDrawSolidQuad(); |
| 5276 harness.MustSetScissor(0, 0, 10, 10); | 5276 harness.MustSetScissor(0, 0, 10, 10); |
| 5277 { | 5277 { |
| 5278 LayerTreeHostImpl::FrameData frame; | 5278 LayerTreeHostImpl::FrameData frame; |
| 5279 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5279 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5280 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5280 host_impl_->DrawLayers(&frame); |
| 5281 host_impl_->DidDrawAllLayers(frame); | 5281 host_impl_->DidDrawAllLayers(frame); |
| 5282 } | 5282 } |
| 5283 Mock::VerifyAndClearExpectations(&mock_context); | 5283 Mock::VerifyAndClearExpectations(&mock_context); |
| 5284 } | 5284 } |
| 5285 | 5285 |
| 5286 TEST_F(LayerTreeHostImplTest, PartialSwap) { | 5286 TEST_F(LayerTreeHostImplTest, PartialSwap) { |
| 5287 scoped_ptr<MockContext> context_owned(new MockContext); | 5287 scoped_ptr<MockContext> context_owned(new MockContext); |
| 5288 MockContext* mock_context = context_owned.get(); | 5288 MockContext* mock_context = context_owned.get(); |
| 5289 MockContextHarness harness(mock_context); | 5289 MockContextHarness harness(mock_context); |
| 5290 | 5290 |
| 5291 LayerTreeSettings settings = DefaultSettings(); | 5291 LayerTreeSettings settings = DefaultSettings(); |
| 5292 settings.renderer_settings.partial_swap_enabled = true; | 5292 settings.renderer_settings.partial_swap_enabled = true; |
| 5293 CreateHostImpl(settings, FakeOutputSurface::Create3d(context_owned.Pass())); | 5293 CreateHostImpl(settings, FakeOutputSurface::Create3d(context_owned.Pass())); |
| 5294 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 5294 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 5295 | 5295 |
| 5296 // The first frame is not a partially-swapped one. No scissor should be set. | 5296 // The first frame is not a partially-swapped one. No scissor should be set. |
| 5297 harness.MustSetNoScissor(); | 5297 harness.MustSetNoScissor(); |
| 5298 harness.MustDrawSolidQuad(); | 5298 harness.MustDrawSolidQuad(); |
| 5299 { | 5299 { |
| 5300 LayerTreeHostImpl::FrameData frame; | 5300 LayerTreeHostImpl::FrameData frame; |
| 5301 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5301 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5302 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5302 host_impl_->DrawLayers(&frame); |
| 5303 host_impl_->DidDrawAllLayers(frame); | 5303 host_impl_->DidDrawAllLayers(frame); |
| 5304 } | 5304 } |
| 5305 Mock::VerifyAndClearExpectations(&mock_context); | 5305 Mock::VerifyAndClearExpectations(&mock_context); |
| 5306 | 5306 |
| 5307 // Damage a portion of the frame. | 5307 // Damage a portion of the frame. |
| 5308 host_impl_->active_tree()->root_layer()->SetUpdateRect( | 5308 host_impl_->active_tree()->root_layer()->SetUpdateRect( |
| 5309 gfx::Rect(0, 0, 2, 3)); | 5309 gfx::Rect(0, 0, 2, 3)); |
| 5310 | 5310 |
| 5311 // The second frame will be partially-swapped (the y coordinates are flipped). | 5311 // The second frame will be partially-swapped (the y coordinates are flipped). |
| 5312 harness.MustSetScissor(0, 7, 2, 3); | 5312 harness.MustSetScissor(0, 7, 2, 3); |
| 5313 harness.MustDrawSolidQuad(); | 5313 harness.MustDrawSolidQuad(); |
| 5314 { | 5314 { |
| 5315 LayerTreeHostImpl::FrameData frame; | 5315 LayerTreeHostImpl::FrameData frame; |
| 5316 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5316 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5317 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5317 host_impl_->DrawLayers(&frame); |
| 5318 host_impl_->DidDrawAllLayers(frame); | 5318 host_impl_->DidDrawAllLayers(frame); |
| 5319 } | 5319 } |
| 5320 Mock::VerifyAndClearExpectations(&mock_context); | 5320 Mock::VerifyAndClearExpectations(&mock_context); |
| 5321 } | 5321 } |
| 5322 | 5322 |
| 5323 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 5323 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
| 5324 bool partial_swap, | 5324 bool partial_swap, |
| 5325 LayerTreeHostImplClient* client, | 5325 LayerTreeHostImplClient* client, |
| 5326 Proxy* proxy, | 5326 Proxy* proxy, |
| 5327 SharedBitmapManager* manager, | 5327 SharedBitmapManager* manager, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5412 | 5412 |
| 5413 // Verify all quads have been computed | 5413 // Verify all quads have been computed |
| 5414 ASSERT_EQ(2U, frame.render_passes.size()); | 5414 ASSERT_EQ(2U, frame.render_passes.size()); |
| 5415 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 5415 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
| 5416 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 5416 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
| 5417 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 5417 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
| 5418 frame.render_passes[0]->quad_list.front()->material); | 5418 frame.render_passes[0]->quad_list.front()->material); |
| 5419 EXPECT_EQ(DrawQuad::RENDER_PASS, | 5419 EXPECT_EQ(DrawQuad::RENDER_PASS, |
| 5420 frame.render_passes[1]->quad_list.front()->material); | 5420 frame.render_passes[1]->quad_list.front()->material); |
| 5421 | 5421 |
| 5422 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); | 5422 my_host_impl->DrawLayers(&frame); |
| 5423 my_host_impl->DidDrawAllLayers(frame); | 5423 my_host_impl->DidDrawAllLayers(frame); |
| 5424 } | 5424 } |
| 5425 } | 5425 } |
| 5426 | 5426 |
| 5427 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { | 5427 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { |
| 5428 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 5428 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 5429 new TestSharedBitmapManager()); | 5429 new TestSharedBitmapManager()); |
| 5430 scoped_ptr<LayerTreeHostImpl> my_host_impl = | 5430 scoped_ptr<LayerTreeHostImpl> my_host_impl = |
| 5431 SetupLayersForOpacity(false, | 5431 SetupLayersForOpacity(false, |
| 5432 this, | 5432 this, |
| 5433 &proxy_, | 5433 &proxy_, |
| 5434 shared_bitmap_manager.get(), | 5434 shared_bitmap_manager.get(), |
| 5435 &stats_instrumentation_); | 5435 &stats_instrumentation_); |
| 5436 { | 5436 { |
| 5437 LayerTreeHostImpl::FrameData frame; | 5437 LayerTreeHostImpl::FrameData frame; |
| 5438 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); | 5438 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); |
| 5439 | 5439 |
| 5440 // Verify all quads have been computed | 5440 // Verify all quads have been computed |
| 5441 ASSERT_EQ(2U, frame.render_passes.size()); | 5441 ASSERT_EQ(2U, frame.render_passes.size()); |
| 5442 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 5442 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
| 5443 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 5443 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
| 5444 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 5444 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
| 5445 frame.render_passes[0]->quad_list.front()->material); | 5445 frame.render_passes[0]->quad_list.front()->material); |
| 5446 EXPECT_EQ(DrawQuad::RENDER_PASS, | 5446 EXPECT_EQ(DrawQuad::RENDER_PASS, |
| 5447 frame.render_passes[1]->quad_list.front()->material); | 5447 frame.render_passes[1]->quad_list.front()->material); |
| 5448 | 5448 |
| 5449 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); | 5449 my_host_impl->DrawLayers(&frame); |
| 5450 my_host_impl->DidDrawAllLayers(frame); | 5450 my_host_impl->DidDrawAllLayers(frame); |
| 5451 } | 5451 } |
| 5452 } | 5452 } |
| 5453 | 5453 |
| 5454 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { | 5454 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { |
| 5455 scoped_ptr<TestWebGraphicsContext3D> context = | 5455 scoped_ptr<TestWebGraphicsContext3D> context = |
| 5456 TestWebGraphicsContext3D::Create(); | 5456 TestWebGraphicsContext3D::Create(); |
| 5457 TestWebGraphicsContext3D* context3d = context.get(); | 5457 TestWebGraphicsContext3D* context3d = context.get(); |
| 5458 scoped_ptr<OutputSurface> output_surface( | 5458 scoped_ptr<OutputSurface> output_surface( |
| 5459 FakeOutputSurface::Create3d(context.Pass())); | 5459 FakeOutputSurface::Create3d(context.Pass())); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 5483 io_surface_layer->SetDrawsContent(true); | 5483 io_surface_layer->SetDrawsContent(true); |
| 5484 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); | 5484 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); |
| 5485 root_layer->AddChild(io_surface_layer.Pass()); | 5485 root_layer->AddChild(io_surface_layer.Pass()); |
| 5486 | 5486 |
| 5487 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); | 5487 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); |
| 5488 | 5488 |
| 5489 EXPECT_EQ(0u, context3d->NumTextures()); | 5489 EXPECT_EQ(0u, context3d->NumTextures()); |
| 5490 | 5490 |
| 5491 LayerTreeHostImpl::FrameData frame; | 5491 LayerTreeHostImpl::FrameData frame; |
| 5492 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5492 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5493 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5493 host_impl_->DrawLayers(&frame); |
| 5494 host_impl_->DidDrawAllLayers(frame); | 5494 host_impl_->DidDrawAllLayers(frame); |
| 5495 host_impl_->SwapBuffers(frame); | 5495 host_impl_->SwapBuffers(frame); |
| 5496 | 5496 |
| 5497 EXPECT_GT(context3d->NumTextures(), 0u); | 5497 EXPECT_GT(context3d->NumTextures(), 0u); |
| 5498 | 5498 |
| 5499 // Kill the layer tree. | 5499 // Kill the layer tree. |
| 5500 host_impl_->active_tree()->SetRootLayer( | 5500 host_impl_->active_tree()->SetRootLayer( |
| 5501 LayerImpl::Create(host_impl_->active_tree(), 100)); | 5501 LayerImpl::Create(host_impl_->active_tree(), 100)); |
| 5502 // There should be no textures left in use after. | 5502 // There should be no textures left in use after. |
| 5503 EXPECT_EQ(0u, context3d->NumTextures()); | 5503 EXPECT_EQ(0u, context3d->NumTextures()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 5526 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); | 5526 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); |
| 5527 | 5527 |
| 5528 // Verify one quad is drawn when transparent background set is not set. | 5528 // Verify one quad is drawn when transparent background set is not set. |
| 5529 host_impl_->active_tree()->set_has_transparent_background(false); | 5529 host_impl_->active_tree()->set_has_transparent_background(false); |
| 5530 EXPECT_CALL(*mock_context, useProgram(_)) | 5530 EXPECT_CALL(*mock_context, useProgram(_)) |
| 5531 .Times(1); | 5531 .Times(1); |
| 5532 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) | 5532 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) |
| 5533 .Times(1); | 5533 .Times(1); |
| 5534 LayerTreeHostImpl::FrameData frame; | 5534 LayerTreeHostImpl::FrameData frame; |
| 5535 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5535 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5536 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5536 host_impl_->DrawLayers(&frame); |
| 5537 host_impl_->DidDrawAllLayers(frame); | 5537 host_impl_->DidDrawAllLayers(frame); |
| 5538 Mock::VerifyAndClearExpectations(&mock_context); | 5538 Mock::VerifyAndClearExpectations(&mock_context); |
| 5539 | 5539 |
| 5540 // Verify no quads are drawn when transparent background is set. | 5540 // Verify no quads are drawn when transparent background is set. |
| 5541 host_impl_->active_tree()->set_has_transparent_background(true); | 5541 host_impl_->active_tree()->set_has_transparent_background(true); |
| 5542 host_impl_->SetFullRootLayerDamage(); | 5542 host_impl_->SetFullRootLayerDamage(); |
| 5543 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5543 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5544 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5544 host_impl_->DrawLayers(&frame); |
| 5545 host_impl_->DidDrawAllLayers(frame); | 5545 host_impl_->DidDrawAllLayers(frame); |
| 5546 Mock::VerifyAndClearExpectations(&mock_context); | 5546 Mock::VerifyAndClearExpectations(&mock_context); |
| 5547 } | 5547 } |
| 5548 | 5548 |
| 5549 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) { | 5549 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) { |
| 5550 set_reduce_memory_result(false); | 5550 set_reduce_memory_result(false); |
| 5551 | 5551 |
| 5552 // If changing the memory limit wouldn't result in changing what was | 5552 // If changing the memory limit wouldn't result in changing what was |
| 5553 // committed, then no commit should be requested. | 5553 // committed, then no commit should be requested. |
| 5554 set_reduce_memory_result(false); | 5554 set_reduce_memory_result(false); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5617 gfx::RectF expected_child_visible_rect(child->content_bounds()); | 5617 gfx::RectF expected_child_visible_rect(child->content_bounds()); |
| 5618 EXPECT_EQ(expected_child_visible_rect, | 5618 EXPECT_EQ(expected_child_visible_rect, |
| 5619 root_render_pass->quad_list.front()->visible_rect); | 5619 root_render_pass->quad_list.front()->visible_rect); |
| 5620 | 5620 |
| 5621 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 5621 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 5622 gfx::RectF expected_root_visible_rect(root->content_bounds()); | 5622 gfx::RectF expected_root_visible_rect(root->content_bounds()); |
| 5623 EXPECT_EQ(expected_root_visible_rect, | 5623 EXPECT_EQ(expected_root_visible_rect, |
| 5624 root_render_pass->quad_list.ElementAt(1)->visible_rect); | 5624 root_render_pass->quad_list.ElementAt(1)->visible_rect); |
| 5625 } | 5625 } |
| 5626 | 5626 |
| 5627 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5627 host_impl_->DrawLayers(&frame); |
| 5628 host_impl_->DidDrawAllLayers(frame); | 5628 host_impl_->DidDrawAllLayers(frame); |
| 5629 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); | 5629 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); |
| 5630 } | 5630 } |
| 5631 }; | 5631 }; |
| 5632 | 5632 |
| 5633 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { | 5633 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { |
| 5634 scoped_ptr<SolidColorLayerImpl> root = | 5634 scoped_ptr<SolidColorLayerImpl> root = |
| 5635 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 5635 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 5636 root->SetPosition(gfx::PointF()); | 5636 root->SetPosition(gfx::PointF()); |
| 5637 root->SetBounds(gfx::Size(10, 10)); | 5637 root->SetBounds(gfx::Size(10, 10)); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5751 | 5751 |
| 5752 ASSERT_EQ(1u, frame.render_passes.size()); | 5752 ASSERT_EQ(1u, frame.render_passes.size()); |
| 5753 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); | 5753 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); |
| 5754 const DrawQuad* quad = frame.render_passes[0]->quad_list.front(); | 5754 const DrawQuad* quad = frame.render_passes[0]->quad_list.front(); |
| 5755 | 5755 |
| 5756 bool antialiased = | 5756 bool antialiased = |
| 5757 GLRendererWithSetupQuadForAntialiasing::ShouldAntialiasQuad( | 5757 GLRendererWithSetupQuadForAntialiasing::ShouldAntialiasQuad( |
| 5758 quad->quadTransform(), quad, false); | 5758 quad->quadTransform(), quad, false); |
| 5759 EXPECT_FALSE(antialiased); | 5759 EXPECT_FALSE(antialiased); |
| 5760 | 5760 |
| 5761 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5761 host_impl_->DrawLayers(&frame); |
| 5762 host_impl_->DidDrawAllLayers(frame); | 5762 host_impl_->DidDrawAllLayers(frame); |
| 5763 } | 5763 } |
| 5764 | 5764 |
| 5765 | 5765 |
| 5766 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { | 5766 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { |
| 5767 public: | 5767 public: |
| 5768 CompositorFrameMetadataTest() | 5768 CompositorFrameMetadataTest() |
| 5769 : swap_buffers_complete_(0) {} | 5769 : swap_buffers_complete_(0) {} |
| 5770 | 5770 |
| 5771 void DidSwapBuffersCompleteOnImplThread() override { | 5771 void DidSwapBuffersCompleteOnImplThread() override { |
| 5772 swap_buffers_complete_++; | 5772 swap_buffers_complete_++; |
| 5773 } | 5773 } |
| 5774 | 5774 |
| 5775 int swap_buffers_complete_; | 5775 int swap_buffers_complete_; |
| 5776 }; | 5776 }; |
| 5777 | 5777 |
| 5778 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { | 5778 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { |
| 5779 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 5779 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 5780 { | 5780 { |
| 5781 LayerTreeHostImpl::FrameData frame; | 5781 LayerTreeHostImpl::FrameData frame; |
| 5782 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5782 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5783 host_impl_->DrawLayers(&frame, base::TimeTicks()); | 5783 host_impl_->DrawLayers(&frame); |
| 5784 host_impl_->DidDrawAllLayers(frame); | 5784 host_impl_->DidDrawAllLayers(frame); |
| 5785 } | 5785 } |
| 5786 CompositorFrameAck ack; | 5786 CompositorFrameAck ack; |
| 5787 host_impl_->ReclaimResources(&ack); | 5787 host_impl_->ReclaimResources(&ack); |
| 5788 host_impl_->DidSwapBuffersComplete(); | 5788 host_impl_->DidSwapBuffersComplete(); |
| 5789 EXPECT_EQ(swap_buffers_complete_, 1); | 5789 EXPECT_EQ(swap_buffers_complete_, 1); |
| 5790 } | 5790 } |
| 5791 | 5791 |
| 5792 class CountingSoftwareDevice : public SoftwareOutputDevice { | 5792 class CountingSoftwareDevice : public SoftwareOutputDevice { |
| 5793 public: | 5793 public: |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5868 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 5868 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
| 5869 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); | 5869 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); |
| 5870 video_layer->SetBounds(gfx::Size(10, 10)); | 5870 video_layer->SetBounds(gfx::Size(10, 10)); |
| 5871 video_layer->SetContentBounds(gfx::Size(10, 10)); | 5871 video_layer->SetContentBounds(gfx::Size(10, 10)); |
| 5872 video_layer->SetDrawsContent(true); | 5872 video_layer->SetDrawsContent(true); |
| 5873 root_layer->AddChild(video_layer.Pass()); | 5873 root_layer->AddChild(video_layer.Pass()); |
| 5874 SetupRootLayerImpl(root_layer.Pass()); | 5874 SetupRootLayerImpl(root_layer.Pass()); |
| 5875 | 5875 |
| 5876 LayerTreeHostImpl::FrameData frame; | 5876 LayerTreeHostImpl::FrameData frame; |
| 5877 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5877 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5878 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5878 host_impl_->DrawLayers(&frame); |
| 5879 host_impl_->DidDrawAllLayers(frame); | 5879 host_impl_->DidDrawAllLayers(frame); |
| 5880 | 5880 |
| 5881 EXPECT_EQ(1u, frame.will_draw_layers.size()); | 5881 EXPECT_EQ(1u, frame.will_draw_layers.size()); |
| 5882 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); | 5882 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); |
| 5883 } | 5883 } |
| 5884 | 5884 |
| 5885 // Checks that we have a non-0 default allocation if we pass a context that | 5885 // Checks that we have a non-0 default allocation if we pass a context that |
| 5886 // doesn't support memory management extensions. | 5886 // doesn't support memory management extensions. |
| 5887 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { | 5887 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { |
| 5888 LayerTreeSettings settings; | 5888 LayerTreeSettings settings; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6095 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 6095 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 6096 | 6096 |
| 6097 ScopedPtrVector<CopyOutputRequest> requests; | 6097 ScopedPtrVector<CopyOutputRequest> requests; |
| 6098 requests.push_back(CopyOutputRequest::CreateRequest( | 6098 requests.push_back(CopyOutputRequest::CreateRequest( |
| 6099 base::Bind(&ShutdownReleasesContext_Callback))); | 6099 base::Bind(&ShutdownReleasesContext_Callback))); |
| 6100 | 6100 |
| 6101 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); | 6101 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); |
| 6102 | 6102 |
| 6103 LayerTreeHostImpl::FrameData frame; | 6103 LayerTreeHostImpl::FrameData frame; |
| 6104 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6104 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6105 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 6105 host_impl_->DrawLayers(&frame); |
| 6106 host_impl_->DidDrawAllLayers(frame); | 6106 host_impl_->DidDrawAllLayers(frame); |
| 6107 | 6107 |
| 6108 // The CopyOutputResult's callback has a ref on the ContextProvider and a | 6108 // The CopyOutputResult's callback has a ref on the ContextProvider and a |
| 6109 // texture in a texture mailbox. | 6109 // texture in a texture mailbox. |
| 6110 EXPECT_FALSE(context_provider->HasOneRef()); | 6110 EXPECT_FALSE(context_provider->HasOneRef()); |
| 6111 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); | 6111 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); |
| 6112 | 6112 |
| 6113 host_impl_ = nullptr; | 6113 host_impl_ = nullptr; |
| 6114 | 6114 |
| 6115 // The CopyOutputResult's callback was cancelled, the CopyOutputResult | 6115 // The CopyOutputResult's callback was cancelled, the CopyOutputResult |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6492 latency_info.AddLatencyNumber( | 6492 latency_info.AddLatencyNumber( |
| 6493 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); | 6493 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); |
| 6494 scoped_ptr<SwapPromise> swap_promise( | 6494 scoped_ptr<SwapPromise> swap_promise( |
| 6495 new LatencyInfoSwapPromise(latency_info)); | 6495 new LatencyInfoSwapPromise(latency_info)); |
| 6496 host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); | 6496 host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); |
| 6497 host_impl_->SetNeedsRedraw(); | 6497 host_impl_->SetNeedsRedraw(); |
| 6498 | 6498 |
| 6499 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 6499 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
| 6500 LayerTreeHostImpl::FrameData frame; | 6500 LayerTreeHostImpl::FrameData frame; |
| 6501 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6501 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6502 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 6502 host_impl_->DrawLayers(&frame); |
| 6503 host_impl_->DidDrawAllLayers(frame); | 6503 host_impl_->DidDrawAllLayers(frame); |
| 6504 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 6504 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
| 6505 | 6505 |
| 6506 const std::vector<ui::LatencyInfo>& metadata_latency_after = | 6506 const std::vector<ui::LatencyInfo>& metadata_latency_after = |
| 6507 fake_output_surface->last_sent_frame().metadata.latency_info; | 6507 fake_output_surface->last_sent_frame().metadata.latency_info; |
| 6508 EXPECT_EQ(1u, metadata_latency_after.size()); | 6508 EXPECT_EQ(1u, metadata_latency_after.size()); |
| 6509 EXPECT_TRUE(metadata_latency_after[0].FindLatency( | 6509 EXPECT_TRUE(metadata_latency_after[0].FindLatency( |
| 6510 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); | 6510 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); |
| 6511 } | 6511 } |
| 6512 | 6512 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 6540 selection.start.edge_top = selection_top; | 6540 selection.start.edge_top = selection_top; |
| 6541 selection.end = selection.start; | 6541 selection.end = selection.start; |
| 6542 host_impl_->active_tree()->RegisterSelection(selection); | 6542 host_impl_->active_tree()->RegisterSelection(selection); |
| 6543 | 6543 |
| 6544 // Trigger a draw-swap sequence. | 6544 // Trigger a draw-swap sequence. |
| 6545 host_impl_->SetNeedsRedraw(); | 6545 host_impl_->SetNeedsRedraw(); |
| 6546 | 6546 |
| 6547 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 6547 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
| 6548 LayerTreeHostImpl::FrameData frame; | 6548 LayerTreeHostImpl::FrameData frame; |
| 6549 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6549 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6550 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 6550 host_impl_->DrawLayers(&frame); |
| 6551 host_impl_->DidDrawAllLayers(frame); | 6551 host_impl_->DidDrawAllLayers(frame); |
| 6552 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 6552 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
| 6553 | 6553 |
| 6554 // Ensure the selection bounds have propagated to the frame metadata. | 6554 // Ensure the selection bounds have propagated to the frame metadata. |
| 6555 const ViewportSelection& selection_after = | 6555 const ViewportSelection& selection_after = |
| 6556 fake_output_surface->last_sent_frame().metadata.selection; | 6556 fake_output_surface->last_sent_frame().metadata.selection; |
| 6557 EXPECT_EQ(selection.start.type, selection_after.start.type); | 6557 EXPECT_EQ(selection.start.type, selection_after.start.type); |
| 6558 EXPECT_EQ(selection.end.type, selection_after.end.type); | 6558 EXPECT_EQ(selection.end.type, selection_after.end.type); |
| 6559 EXPECT_EQ(selection_bottom, selection_after.start.edge_bottom); | 6559 EXPECT_EQ(selection_bottom, selection_after.start.edge_bottom); |
| 6560 EXPECT_EQ(selection_top, selection_after.start.edge_top); | 6560 EXPECT_EQ(selection_top, selection_after.start.edge_top); |
| (...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7881 EXPECT_FALSE(frame.render_passes_by_id[RenderPassId(2, 0)]); | 7881 EXPECT_FALSE(frame.render_passes_by_id[RenderPassId(2, 0)]); |
| 7882 EXPECT_FALSE(frame.render_passes_by_id[RenderPassId(3, 0)]); | 7882 EXPECT_FALSE(frame.render_passes_by_id[RenderPassId(3, 0)]); |
| 7883 EXPECT_EQ(1u, frame.render_passes.size()); | 7883 EXPECT_EQ(1u, frame.render_passes.size()); |
| 7884 EXPECT_EQ(RenderPassId(1, 0), frame.render_passes[0]->id); | 7884 EXPECT_EQ(RenderPassId(1, 0), frame.render_passes[0]->id); |
| 7885 // The RenderPassDrawQuad should be removed from pass1. | 7885 // The RenderPassDrawQuad should be removed from pass1. |
| 7886 EXPECT_EQ(0u, pass1->quad_list.size()); | 7886 EXPECT_EQ(0u, pass1->quad_list.size()); |
| 7887 } | 7887 } |
| 7888 | 7888 |
| 7889 } // namespace | 7889 } // namespace |
| 7890 } // namespace cc | 7890 } // namespace cc |
| OLD | NEW |