| 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 <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 6289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6300 FakeOutputSurface* fake_output_surface = | 6300 FakeOutputSurface* fake_output_surface = |
| 6301 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 6301 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
| 6302 const ViewportSelectionBound& selection_start_before = | 6302 const ViewportSelectionBound& selection_start_before = |
| 6303 fake_output_surface->last_sent_frame().metadata.selection_start; | 6303 fake_output_surface->last_sent_frame().metadata.selection_start; |
| 6304 const ViewportSelectionBound& selection_end_before = | 6304 const ViewportSelectionBound& selection_end_before = |
| 6305 fake_output_surface->last_sent_frame().metadata.selection_end; | 6305 fake_output_surface->last_sent_frame().metadata.selection_end; |
| 6306 EXPECT_EQ(ViewportSelectionBound(), selection_start_before); | 6306 EXPECT_EQ(ViewportSelectionBound(), selection_start_before); |
| 6307 EXPECT_EQ(ViewportSelectionBound(), selection_end_before); | 6307 EXPECT_EQ(ViewportSelectionBound(), selection_end_before); |
| 6308 | 6308 |
| 6309 // Plumb the layer-local selection bounds. | 6309 // Plumb the layer-local selection bounds. |
| 6310 gfx::Rect selection_rect(5, 0, 0, 5); | 6310 gfx::PointF selection_top(5, 0); |
| 6311 gfx::PointF selection_bottom(5, 5); |
| 6311 LayerSelectionBound start, end; | 6312 LayerSelectionBound start, end; |
| 6312 start.type = SELECTION_BOUND_CENTER; | 6313 start.type = SELECTION_BOUND_CENTER; |
| 6313 start.layer_id = root_layer_id; | 6314 start.layer_id = root_layer_id; |
| 6314 start.layer_rect = selection_rect; | 6315 start.edge_bottom = selection_bottom; |
| 6316 start.edge_top = selection_top; |
| 6315 end = start; | 6317 end = start; |
| 6316 host_impl_->active_tree()->RegisterSelection(start, end); | 6318 host_impl_->active_tree()->RegisterSelection(start, end); |
| 6317 | 6319 |
| 6318 // Trigger a draw-swap sequence. | 6320 // Trigger a draw-swap sequence. |
| 6319 host_impl_->SetNeedsRedraw(); | 6321 host_impl_->SetNeedsRedraw(); |
| 6320 | 6322 |
| 6321 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 6323 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
| 6322 LayerTreeHostImpl::FrameData frame; | 6324 LayerTreeHostImpl::FrameData frame; |
| 6323 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6325 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6324 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 6326 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 6325 host_impl_->DidDrawAllLayers(frame); | 6327 host_impl_->DidDrawAllLayers(frame); |
| 6326 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 6328 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
| 6327 | 6329 |
| 6328 // Ensure the selection bounds have propagated to the frame metadata. | 6330 // Ensure the selection bounds have propagated to the frame metadata. |
| 6329 const ViewportSelectionBound& selection_start_after = | 6331 const ViewportSelectionBound& selection_start_after = |
| 6330 fake_output_surface->last_sent_frame().metadata.selection_start; | 6332 fake_output_surface->last_sent_frame().metadata.selection_start; |
| 6331 const ViewportSelectionBound& selection_end_after = | 6333 const ViewportSelectionBound& selection_end_after = |
| 6332 fake_output_surface->last_sent_frame().metadata.selection_end; | 6334 fake_output_surface->last_sent_frame().metadata.selection_end; |
| 6333 EXPECT_EQ(start.type, selection_start_after.type); | 6335 EXPECT_EQ(start.type, selection_start_after.type); |
| 6334 EXPECT_EQ(end.type, selection_end_after.type); | 6336 EXPECT_EQ(end.type, selection_end_after.type); |
| 6335 EXPECT_EQ(selection_rect, selection_start_after.viewport_rect); | 6337 EXPECT_EQ(selection_bottom, selection_start_after.edge_bottom); |
| 6336 EXPECT_EQ(selection_rect, selection_start_after.viewport_rect); | 6338 EXPECT_EQ(selection_top, selection_start_after.edge_top); |
| 6337 EXPECT_TRUE(selection_start_after.visible); | 6339 EXPECT_TRUE(selection_start_after.visible); |
| 6338 EXPECT_TRUE(selection_start_after.visible); | 6340 EXPECT_TRUE(selection_start_after.visible); |
| 6339 } | 6341 } |
| 6340 | 6342 |
| 6341 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { | 6343 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { |
| 6342 public: | 6344 public: |
| 6343 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, | 6345 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, |
| 6344 LayerTreeHostImpl* layer_tree_host_impl, | 6346 LayerTreeHostImpl* layer_tree_host_impl, |
| 6345 int* set_needs_commit_count, | 6347 int* set_needs_commit_count, |
| 6346 int* set_needs_redraw_count, | 6348 int* set_needs_redraw_count, |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6986 host_impl_->DidLoseOutputSurface(); | 6988 host_impl_->DidLoseOutputSurface(); |
| 6987 EXPECT_TRUE(host_impl_->IsContextLost()); | 6989 EXPECT_TRUE(host_impl_->IsContextLost()); |
| 6988 EXPECT_EQ(1, num_lost_surfaces_); | 6990 EXPECT_EQ(1, num_lost_surfaces_); |
| 6989 host_impl_->DidLoseOutputSurface(); | 6991 host_impl_->DidLoseOutputSurface(); |
| 6990 EXPECT_TRUE(host_impl_->IsContextLost()); | 6992 EXPECT_TRUE(host_impl_->IsContextLost()); |
| 6991 EXPECT_EQ(1, num_lost_surfaces_); | 6993 EXPECT_EQ(1, num_lost_surfaces_); |
| 6992 } | 6994 } |
| 6993 | 6995 |
| 6994 } // namespace | 6996 } // namespace |
| 6995 } // namespace cc | 6997 } // namespace cc |
| OLD | NEW |