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