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 6287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6298 root->SetPosition(gfx::PointF()); | 6298 root->SetPosition(gfx::PointF()); |
6299 root->SetBounds(gfx::Size(10, 10)); | 6299 root->SetBounds(gfx::Size(10, 10)); |
6300 root->SetContentBounds(gfx::Size(10, 10)); | 6300 root->SetContentBounds(gfx::Size(10, 10)); |
6301 root->SetDrawsContent(true); | 6301 root->SetDrawsContent(true); |
6302 | 6302 |
6303 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); | 6303 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); |
6304 | 6304 |
6305 // Ensure the default frame selection bounds are empty. | 6305 // Ensure the default frame selection bounds are empty. |
6306 FakeOutputSurface* fake_output_surface = | 6306 FakeOutputSurface* fake_output_surface = |
6307 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 6307 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
6308 const ViewportSelectionBound& selection_anchor_before = | 6308 const ViewportSelectionBound& selection_start_before = |
6309 fake_output_surface->last_sent_frame().metadata.selection_anchor; | 6309 fake_output_surface->last_sent_frame().metadata.selection_start; |
6310 const ViewportSelectionBound& selection_focus_before = | 6310 const ViewportSelectionBound& selection_end_before = |
6311 fake_output_surface->last_sent_frame().metadata.selection_focus; | 6311 fake_output_surface->last_sent_frame().metadata.selection_end; |
6312 EXPECT_EQ(ViewportSelectionBound(), selection_anchor_before); | 6312 EXPECT_EQ(ViewportSelectionBound(), selection_start_before); |
6313 EXPECT_EQ(ViewportSelectionBound(), selection_focus_before); | 6313 EXPECT_EQ(ViewportSelectionBound(), selection_end_before); |
6314 | 6314 |
6315 // Plumb the layer-local selection bounds. | 6315 // Plumb the layer-local selection bounds. |
6316 gfx::Rect selection_rect(5, 0, 0, 5); | 6316 gfx::Rect selection_rect(5, 0, 0, 5); |
6317 LayerSelectionBound anchor, focus; | 6317 LayerSelectionBound start, end; |
6318 anchor.type = SELECTION_BOUND_CENTER; | 6318 start.type = SELECTION_BOUND_CENTER; |
6319 anchor.layer_id = root_layer_id; | 6319 start.layer_id = root_layer_id; |
6320 anchor.layer_rect = selection_rect; | 6320 start.layer_rect = selection_rect; |
6321 focus = anchor; | 6321 end = start; |
6322 host_impl_->active_tree()->RegisterSelection(anchor, focus); | 6322 host_impl_->active_tree()->RegisterSelection(start, end); |
6323 | 6323 |
6324 // Trigger a draw-swap sequence. | 6324 // Trigger a draw-swap sequence. |
6325 host_impl_->SetNeedsRedraw(); | 6325 host_impl_->SetNeedsRedraw(); |
6326 | 6326 |
6327 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 6327 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
6328 LayerTreeHostImpl::FrameData frame; | 6328 LayerTreeHostImpl::FrameData frame; |
6329 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6329 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6330 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 6330 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
6331 host_impl_->DidDrawAllLayers(frame); | 6331 host_impl_->DidDrawAllLayers(frame); |
6332 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 6332 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
6333 | 6333 |
6334 // Ensure the selection bounds have propagated to the frame metadata. | 6334 // Ensure the selection bounds have propagated to the frame metadata. |
6335 const ViewportSelectionBound& selection_anchor_after = | 6335 const ViewportSelectionBound& selection_start_after = |
6336 fake_output_surface->last_sent_frame().metadata.selection_anchor; | 6336 fake_output_surface->last_sent_frame().metadata.selection_start; |
6337 const ViewportSelectionBound& selection_focus_after = | 6337 const ViewportSelectionBound& selection_end_after = |
6338 fake_output_surface->last_sent_frame().metadata.selection_focus; | 6338 fake_output_surface->last_sent_frame().metadata.selection_end; |
6339 EXPECT_EQ(anchor.type, selection_anchor_after.type); | 6339 EXPECT_EQ(start.type, selection_start_after.type); |
6340 EXPECT_EQ(focus.type, selection_focus_after.type); | 6340 EXPECT_EQ(end.type, selection_end_after.type); |
6341 EXPECT_EQ(selection_rect, selection_anchor_after.viewport_rect); | 6341 EXPECT_EQ(selection_rect, selection_start_after.viewport_rect); |
6342 EXPECT_EQ(selection_rect, selection_anchor_after.viewport_rect); | 6342 EXPECT_EQ(selection_rect, selection_start_after.viewport_rect); |
6343 EXPECT_TRUE(selection_anchor_after.visible); | 6343 EXPECT_TRUE(selection_start_after.visible); |
6344 EXPECT_TRUE(selection_anchor_after.visible); | 6344 EXPECT_TRUE(selection_start_after.visible); |
6345 } | 6345 } |
6346 | 6346 |
6347 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { | 6347 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { |
6348 public: | 6348 public: |
6349 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, | 6349 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, |
6350 LayerTreeHostImpl* layer_tree_host_impl, | 6350 LayerTreeHostImpl* layer_tree_host_impl, |
6351 int* set_needs_commit_count, | 6351 int* set_needs_commit_count, |
6352 int* set_needs_redraw_count) | 6352 int* set_needs_redraw_count) |
6353 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), | 6353 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), |
6354 set_needs_commit_count_(set_needs_commit_count), | 6354 set_needs_commit_count_(set_needs_commit_count), |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6650 external_viewport, | 6650 external_viewport, |
6651 external_clip, | 6651 external_clip, |
6652 valid_for_tile_management); | 6652 valid_for_tile_management); |
6653 DrawFrame(); | 6653 DrawFrame(); |
6654 EXPECT_TRANSFORMATION_MATRIX_EQ( | 6654 EXPECT_TRANSFORMATION_MATRIX_EQ( |
6655 external_transform, layer->draw_properties().target_space_transform); | 6655 external_transform, layer->draw_properties().target_space_transform); |
6656 } | 6656 } |
6657 | 6657 |
6658 } // namespace | 6658 } // namespace |
6659 } // namespace cc | 6659 } // namespace cc |
OLD | NEW |