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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 300323005: Route selection bounds updates through the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6273 matching lines...) Expand 10 before | Expand all | Expand 10 after
6284 host_impl_->DidDrawAllLayers(frame); 6284 host_impl_->DidDrawAllLayers(frame);
6285 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); 6285 EXPECT_TRUE(host_impl_->SwapBuffers(frame));
6286 6286
6287 const std::vector<ui::LatencyInfo>& metadata_latency_after = 6287 const std::vector<ui::LatencyInfo>& metadata_latency_after =
6288 fake_output_surface->last_sent_frame().metadata.latency_info; 6288 fake_output_surface->last_sent_frame().metadata.latency_info;
6289 EXPECT_EQ(1u, metadata_latency_after.size()); 6289 EXPECT_EQ(1u, metadata_latency_after.size());
6290 EXPECT_TRUE(metadata_latency_after[0].FindLatency( 6290 EXPECT_TRUE(metadata_latency_after[0].FindLatency(
6291 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); 6291 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL));
6292 } 6292 }
6293 6293
6294 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) {
6295 int root_layer_id = 1;
6296 scoped_ptr<SolidColorLayerImpl> root =
6297 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id);
6298 root->SetPosition(gfx::PointF());
6299 root->SetBounds(gfx::Size(10, 10));
6300 root->SetContentBounds(gfx::Size(10, 10));
6301 root->SetDrawsContent(true);
6302
6303 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>());
6304
6305 // Ensure the default frame selection bounds are empty.
6306 FakeOutputSurface* fake_output_surface =
6307 static_cast<FakeOutputSurface*>(host_impl_->output_surface());
6308 const ViewportSelectionBound& selection_anchor_before =
6309 fake_output_surface->last_sent_frame().metadata.selection_anchor;
6310 const ViewportSelectionBound& selection_focus_before =
6311 fake_output_surface->last_sent_frame().metadata.selection_focus;
6312 EXPECT_EQ(ViewportSelectionBound(), selection_anchor_before);
6313 EXPECT_EQ(ViewportSelectionBound(), selection_focus_before);
6314
6315 // Plumb the layer-local selection bounds.
6316 gfx::Rect selection_rect(5, 0, 0, 5);
6317 LayerSelectionBound anchor, focus;
6318 anchor.type = SELECTION_BOUND_CENTER;
6319 anchor.layer_id = root_layer_id;
6320 anchor.layer_rect = selection_rect;
6321 focus = anchor;
6322 host_impl_->active_tree()->RegisterSelection(anchor, focus);
6323
6324 // Trigger a draw-swap sequence.
6325 host_impl_->SetNeedsRedraw();
6326
6327 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
6328 LayerTreeHostImpl::FrameData frame;
6329 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6330 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
6331 host_impl_->DidDrawAllLayers(frame);
6332 EXPECT_TRUE(host_impl_->SwapBuffers(frame));
6333
6334 // Ensure the selection bounds have propagated to the frame metadata.
6335 const ViewportSelectionBound& selection_anchor_after =
6336 fake_output_surface->last_sent_frame().metadata.selection_anchor;
6337 const ViewportSelectionBound& selection_focus_after =
6338 fake_output_surface->last_sent_frame().metadata.selection_focus;
6339 EXPECT_EQ(anchor.type, selection_anchor_after.type);
6340 EXPECT_EQ(focus.type, selection_focus_after.type);
6341 EXPECT_EQ(selection_rect, selection_anchor_after.viewport_rect);
6342 EXPECT_EQ(selection_rect, selection_anchor_after.viewport_rect);
6343 EXPECT_TRUE(selection_anchor_after.visible);
6344 EXPECT_TRUE(selection_anchor_after.visible);
6345 }
6346
6294 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { 6347 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor {
6295 public: 6348 public:
6296 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, 6349 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host,
6297 LayerTreeHostImpl* layer_tree_host_impl, 6350 LayerTreeHostImpl* layer_tree_host_impl,
6298 int* set_needs_commit_count, 6351 int* set_needs_commit_count,
6299 int* set_needs_redraw_count) 6352 int* set_needs_redraw_count)
6300 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), 6353 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl),
6301 set_needs_commit_count_(set_needs_commit_count), 6354 set_needs_commit_count_(set_needs_commit_count),
6302 set_needs_redraw_count_(set_needs_redraw_count) {} 6355 set_needs_redraw_count_(set_needs_redraw_count) {}
6303 6356
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
6597 external_viewport, 6650 external_viewport,
6598 external_clip, 6651 external_clip,
6599 valid_for_tile_management); 6652 valid_for_tile_management);
6600 DrawFrame(); 6653 DrawFrame();
6601 EXPECT_TRANSFORMATION_MATRIX_EQ( 6654 EXPECT_TRANSFORMATION_MATRIX_EQ(
6602 external_transform, layer->draw_properties().target_space_transform); 6655 external_transform, layer->draw_properties().target_space_transform);
6603 } 6656 }
6604 6657
6605 } // namespace 6658 } // namespace
6606 } // namespace cc 6659 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698