Chromium Code Reviews| 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/test/layer_tree_test.h" | 5 #include "cc/test/layer_tree_test.h" |
| 6 | 6 |
| 7 #include "cc/animation/animation.h" | 7 #include "cc/animation/animation.h" |
| 8 #include "cc/animation/animation_registrar.h" | 8 #include "cc/animation/animation_registrar.h" |
| 9 #include "cc/animation/layer_animation_controller.h" | 9 #include "cc/animation/layer_animation_controller.h" |
| 10 #include "cc/animation/timing_function.h" | 10 #include "cc/animation/timing_function.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "cc/trees/single_thread_proxy.h" | 22 #include "cc/trees/single_thread_proxy.h" |
| 23 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperation. h" | 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperation. h" |
| 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations .h" | 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations .h" |
| 26 #include "ui/gfx/size_conversions.h" | 26 #include "ui/gfx/size_conversions.h" |
| 27 | 27 |
| 28 using namespace WebKit; | 28 using namespace WebKit; |
| 29 | 29 |
| 30 namespace cc { | 30 namespace cc { |
| 31 | 31 |
| 32 TestHooks::TestHooks() { | 32 TestHooks::TestHooks() |
| 33 fake_client_.reset( | 33 : fake_client_( |
| 34 new FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)); | 34 new FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)) {} |
| 35 } | |
| 36 | 35 |
| 37 TestHooks::~TestHooks() {} | 36 TestHooks::~TestHooks() {} |
| 38 | 37 |
| 39 bool TestHooks::PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 38 bool TestHooks::PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 40 LayerTreeHostImpl::FrameData* frame_data, | 39 LayerTreeHostImpl::FrameData* frame_data, |
| 41 bool result) { | 40 bool result) { |
| 42 return true; | 41 return true; |
| 43 } | 42 } |
| 44 | 43 |
| 45 bool TestHooks::CanActivatePendingTree() { | 44 bool TestHooks::CanActivatePendingTree() { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 } | 97 } |
| 99 | 98 |
| 100 virtual void CommitComplete() OVERRIDE { | 99 virtual void CommitComplete() OVERRIDE { |
| 101 LayerTreeHostImpl::CommitComplete(); | 100 LayerTreeHostImpl::CommitComplete(); |
| 102 test_hooks_->CommitCompleteOnThread(this); | 101 test_hooks_->CommitCompleteOnThread(this); |
| 103 | 102 |
| 104 if (!settings().impl_side_painting) | 103 if (!settings().impl_side_painting) |
| 105 test_hooks_->TreeActivatedOnThread(this); | 104 test_hooks_->TreeActivatedOnThread(this); |
| 106 } | 105 } |
| 107 | 106 |
| 108 virtual bool PrepareToDraw(FrameData* frame) OVERRIDE { | 107 virtual bool PrepareToDraw(FrameData* frame, gfx::Rect damage_rect) OVERRIDE { |
| 109 bool result = LayerTreeHostImpl::PrepareToDraw(frame); | 108 bool result = LayerTreeHostImpl::PrepareToDraw(frame, damage_rect); |
| 110 if (!test_hooks_->PrepareToDrawOnThread(this, frame, result)) | 109 if (!test_hooks_->PrepareToDrawOnThread(this, frame, result)) |
| 111 result = false; | 110 result = false; |
| 112 return result; | 111 return result; |
| 113 } | 112 } |
| 114 | 113 |
| 115 virtual void DrawLayers(FrameData* frame, | 114 virtual void DrawLayers(FrameData* frame, |
| 116 base::TimeTicks frame_begin_time) OVERRIDE { | 115 base::TimeTicks frame_begin_time) OVERRIDE { |
| 117 LayerTreeHostImpl::DrawLayers(frame, frame_begin_time); | 116 LayerTreeHostImpl::DrawLayers(frame, frame_begin_time); |
| 118 test_hooks_->DrawLayersOnThread(this); | 117 test_hooks_->DrawLayersOnThread(this); |
| 119 } | 118 } |
| 120 | 119 |
| 121 virtual bool SwapBuffers() OVERRIDE { | 120 virtual bool SwapBuffers(const LayerTreeHostImpl::FrameData& frame) OVERRIDE { |
| 122 bool result = LayerTreeHostImpl::SwapBuffers(); | 121 bool result = LayerTreeHostImpl::SwapBuffers(frame); |
| 123 test_hooks_->SwapBuffersOnThread(this, result); | 122 test_hooks_->SwapBuffersOnThread(this, result); |
| 124 return result; | 123 return result; |
| 125 } | 124 } |
| 126 | 125 |
| 127 virtual bool ActivatePendingTreeIfNeeded() OVERRIDE { | 126 virtual bool ActivatePendingTreeIfNeeded() OVERRIDE { |
| 128 if (!pending_tree()) | 127 if (!pending_tree()) |
| 129 return false; | 128 return false; |
| 130 | 129 |
| 131 if (!test_hooks_->CanActivatePendingTree()) | 130 if (!test_hooks_->CanActivatePendingTree()) |
| 132 return false; | 131 return false; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 // so that those tasks will happen before the first commit. | 401 // so that those tasks will happen before the first commit. |
| 403 if (layer_tree_host_) { | 402 if (layer_tree_host_) { |
| 404 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())-> | 403 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())-> |
| 405 set_test_started(true); | 404 set_test_started(true); |
| 406 } | 405 } |
| 407 } | 406 } |
| 408 | 407 |
| 409 void LayerTreeTest::SetupTree() { | 408 void LayerTreeTest::SetupTree() { |
| 410 if (!layer_tree_host_->root_layer()) { | 409 if (!layer_tree_host_->root_layer()) { |
| 411 scoped_refptr<Layer> root_layer = Layer::Create(); | 410 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 411 root_layer->SetAnchorPoint(gfx::PointF()); | |
| 412 root_layer->SetBounds(gfx::Size(1, 1)); | 412 root_layer->SetBounds(gfx::Size(1, 1)); |
| 413 root_layer->SetIsDrawable(true); | |
| 413 layer_tree_host_->SetRootLayer(root_layer); | 414 layer_tree_host_->SetRootLayer(root_layer); |
| 414 } | 415 } |
| 415 | 416 |
| 416 gfx::Size root_bounds = layer_tree_host_->root_layer()->bounds(); | 417 gfx::Size root_bounds = layer_tree_host_->root_layer()->bounds(); |
| 417 gfx::Size device_root_bounds = gfx::ToCeiledSize( | 418 gfx::Size device_root_bounds = gfx::ToCeiledSize( |
| 418 gfx::ScaleSize(root_bounds, layer_tree_host_->device_scale_factor())); | 419 gfx::ScaleSize(root_bounds, layer_tree_host_->device_scale_factor())); |
| 419 layer_tree_host_->SetViewportSize(root_bounds, device_root_bounds); | 420 layer_tree_host_->SetViewportSize(root_bounds, device_root_bounds); |
| 420 } | 421 } |
| 421 | 422 |
| 422 void LayerTreeTest::Timeout() { | 423 void LayerTreeTest::Timeout() { |
| 424 return; | |
|
enne (OOO)
2013/03/26 01:42:07
ಠ_ృ
danakj
2013/03/26 02:00:10
Haha.. Oops, was gdbing. We need a command line fl
danakj
2013/03/26 02:26:06
2013/03/26 02:00:10, danakj wrote:
| |
| 423 timed_out_ = true; | 425 timed_out_ = true; |
| 424 EndTest(); | 426 EndTest(); |
| 425 } | 427 } |
| 426 | 428 |
| 427 void LayerTreeTest::ScheduleComposite() { | 429 void LayerTreeTest::ScheduleComposite() { |
| 428 if (!started_ || scheduled_) | 430 if (!started_ || scheduled_) |
| 429 return; | 431 return; |
| 430 scheduled_ = true; | 432 scheduled_ = true; |
| 431 proxy()->MainThread()->PostTask( | 433 proxy()->MainThread()->PostTask( |
| 432 base::Bind(&LayerTreeTest::DispatchComposite, main_thread_weak_ptr_)); | 434 base::Bind(&LayerTreeTest::DispatchComposite, main_thread_weak_ptr_)); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 ASSERT_FALSE(layer_tree_host_.get()); | 542 ASSERT_FALSE(layer_tree_host_.get()); |
| 541 client_.reset(); | 543 client_.reset(); |
| 542 if (timed_out_) { | 544 if (timed_out_) { |
| 543 FAIL() << "Test timed out"; | 545 FAIL() << "Test timed out"; |
| 544 return; | 546 return; |
| 545 } | 547 } |
| 546 AfterTest(); | 548 AfterTest(); |
| 547 } | 549 } |
| 548 | 550 |
| 549 } // namespace cc | 551 } // namespace cc |
| OLD | NEW |