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

Side by Side Diff: cc/test/layer_tree_test.cc

Issue 12662021: cc: Don't draw and swap if the frame will not change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/trees/damage_tracker.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/test/layer_tree_test.h" 5 #include "cc/test/layer_tree_test.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "cc/animation/animation.h" 8 #include "cc/animation/animation.h"
9 #include "cc/animation/animation_registrar.h" 9 #include "cc/animation/animation_registrar.h"
10 #include "cc/animation/layer_animation_controller.h" 10 #include "cc/animation/layer_animation_controller.h"
11 #include "cc/animation/timing_function.h" 11 #include "cc/animation/timing_function.h"
12 #include "cc/base/thread_impl.h" 12 #include "cc/base/thread_impl.h"
13 #include "cc/input/input_handler.h" 13 #include "cc/input/input_handler.h"
14 #include "cc/layers/content_layer.h" 14 #include "cc/layers/content_layer.h"
15 #include "cc/layers/layer.h" 15 #include "cc/layers/layer.h"
16 #include "cc/layers/layer_impl.h" 16 #include "cc/layers/layer_impl.h"
17 #include "cc/test/animation_test_common.h" 17 #include "cc/test/animation_test_common.h"
18 #include "cc/test/fake_layer_tree_host_client.h" 18 #include "cc/test/fake_layer_tree_host_client.h"
19 #include "cc/test/fake_output_surface.h" 19 #include "cc/test/fake_output_surface.h"
20 #include "cc/test/occlusion_tracker_test_common.h" 20 #include "cc/test/occlusion_tracker_test_common.h"
21 #include "cc/test/tiled_layer_test_common.h" 21 #include "cc/test/tiled_layer_test_common.h"
22 #include "cc/trees/layer_tree_host_impl.h" 22 #include "cc/trees/layer_tree_host_impl.h"
23 #include "cc/trees/single_thread_proxy.h" 23 #include "cc/trees/single_thread_proxy.h"
24 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
25 #include "ui/gfx/size_conversions.h" 25 #include "ui/gfx/size_conversions.h"
26 26
27 namespace cc { 27 namespace cc {
28 28
29 TestHooks::TestHooks() { 29 TestHooks::TestHooks()
30 fake_client_.reset( 30 : fake_client_(
31 new FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)); 31 new FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)) {}
32 }
33 32
34 TestHooks::~TestHooks() {} 33 TestHooks::~TestHooks() {}
35 34
36 bool TestHooks::PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 35 bool TestHooks::PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
37 LayerTreeHostImpl::FrameData* frame_data, 36 LayerTreeHostImpl::FrameData* frame_data,
38 bool result) { 37 bool result) {
39 return true; 38 return true;
40 } 39 }
41 40
42 bool TestHooks::CanActivatePendingTree() { 41 bool TestHooks::CanActivatePendingTree() {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 92 }
94 93
95 virtual void CommitComplete() OVERRIDE { 94 virtual void CommitComplete() OVERRIDE {
96 LayerTreeHostImpl::CommitComplete(); 95 LayerTreeHostImpl::CommitComplete();
97 test_hooks_->CommitCompleteOnThread(this); 96 test_hooks_->CommitCompleteOnThread(this);
98 97
99 if (!settings().impl_side_painting) 98 if (!settings().impl_side_painting)
100 test_hooks_->TreeActivatedOnThread(this); 99 test_hooks_->TreeActivatedOnThread(this);
101 } 100 }
102 101
103 virtual bool PrepareToDraw(FrameData* frame) OVERRIDE { 102 virtual bool PrepareToDraw(FrameData* frame, gfx::Rect damage_rect) OVERRIDE {
104 bool result = LayerTreeHostImpl::PrepareToDraw(frame); 103 bool result = LayerTreeHostImpl::PrepareToDraw(frame, damage_rect);
105 if (!test_hooks_->PrepareToDrawOnThread(this, frame, result)) 104 if (!test_hooks_->PrepareToDrawOnThread(this, frame, result))
106 result = false; 105 result = false;
107 return result; 106 return result;
108 } 107 }
109 108
110 virtual void DrawLayers(FrameData* frame, 109 virtual void DrawLayers(FrameData* frame,
111 base::TimeTicks frame_begin_time) OVERRIDE { 110 base::TimeTicks frame_begin_time) OVERRIDE {
112 LayerTreeHostImpl::DrawLayers(frame, frame_begin_time); 111 LayerTreeHostImpl::DrawLayers(frame, frame_begin_time);
113 test_hooks_->DrawLayersOnThread(this); 112 test_hooks_->DrawLayersOnThread(this);
114 } 113 }
115 114
116 virtual bool SwapBuffers() OVERRIDE { 115 virtual bool SwapBuffers(const LayerTreeHostImpl::FrameData& frame) OVERRIDE {
117 bool result = LayerTreeHostImpl::SwapBuffers(); 116 bool result = LayerTreeHostImpl::SwapBuffers(frame);
118 test_hooks_->SwapBuffersOnThread(this, result); 117 test_hooks_->SwapBuffersOnThread(this, result);
119 return result; 118 return result;
120 } 119 }
121 120
122 virtual bool ActivatePendingTreeIfNeeded() OVERRIDE { 121 virtual bool ActivatePendingTreeIfNeeded() OVERRIDE {
123 if (!pending_tree()) 122 if (!pending_tree())
124 return false; 123 return false;
125 124
126 if (!test_hooks_->CanActivatePendingTree()) 125 if (!test_hooks_->CanActivatePendingTree())
127 return false; 126 return false;
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 // so that those tasks will happen before the first commit. 405 // so that those tasks will happen before the first commit.
407 if (layer_tree_host_) { 406 if (layer_tree_host_) {
408 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())-> 407 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())->
409 set_test_started(true); 408 set_test_started(true);
410 } 409 }
411 } 410 }
412 411
413 void LayerTreeTest::SetupTree() { 412 void LayerTreeTest::SetupTree() {
414 if (!layer_tree_host_->root_layer()) { 413 if (!layer_tree_host_->root_layer()) {
415 scoped_refptr<Layer> root_layer = Layer::Create(); 414 scoped_refptr<Layer> root_layer = Layer::Create();
415 root_layer->SetAnchorPoint(gfx::PointF());
416 root_layer->SetBounds(gfx::Size(1, 1)); 416 root_layer->SetBounds(gfx::Size(1, 1));
417 root_layer->SetIsDrawable(true);
417 layer_tree_host_->SetRootLayer(root_layer); 418 layer_tree_host_->SetRootLayer(root_layer);
418 } 419 }
419 420
420 gfx::Size root_bounds = layer_tree_host_->root_layer()->bounds(); 421 gfx::Size root_bounds = layer_tree_host_->root_layer()->bounds();
421 gfx::Size device_root_bounds = gfx::ToCeiledSize( 422 gfx::Size device_root_bounds = gfx::ToCeiledSize(
422 gfx::ScaleSize(root_bounds, layer_tree_host_->device_scale_factor())); 423 gfx::ScaleSize(root_bounds, layer_tree_host_->device_scale_factor()));
423 layer_tree_host_->SetViewportSize(root_bounds, device_root_bounds); 424 layer_tree_host_->SetViewportSize(root_bounds, device_root_bounds);
424 } 425 }
425 426
426 void LayerTreeTest::Timeout() { 427 void LayerTreeTest::Timeout() {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 ASSERT_FALSE(layer_tree_host_.get()); 558 ASSERT_FALSE(layer_tree_host_.get());
558 client_.reset(); 559 client_.reset();
559 if (timed_out_) { 560 if (timed_out_) {
560 FAIL() << "Test timed out"; 561 FAIL() << "Test timed out";
561 return; 562 return;
562 } 563 }
563 AfterTest(); 564 AfterTest();
564 } 565 }
565 566
566 } // namespace cc 567 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/trees/damage_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698