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

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

Issue 131683005: cc: Make PrepareToDraw return an enum for why it aborts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
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"
(...skipping 17 matching lines...) Expand all
28 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
29 #include "ui/gfx/frame_time.h" 29 #include "ui/gfx/frame_time.h"
30 #include "ui/gfx/size_conversions.h" 30 #include "ui/gfx/size_conversions.h"
31 31
32 namespace cc { 32 namespace cc {
33 33
34 TestHooks::TestHooks() {} 34 TestHooks::TestHooks() {}
35 35
36 TestHooks::~TestHooks() {} 36 TestHooks::~TestHooks() {}
37 37
38 bool TestHooks::PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 38 DrawSwapReadbackResult::DrawResult TestHooks::PrepareToDrawOnThread(
39 LayerTreeHostImpl::FrameData* frame_data, 39 LayerTreeHostImpl* host_impl,
40 bool result) { 40 LayerTreeHostImpl::FrameData* frame_data,
41 return true; 41 DrawSwapReadbackResult::DrawResult draw_result) {
42 return DrawSwapReadbackResult::DID_DRAW;
42 } 43 }
43 44
44 base::TimeDelta TestHooks::LowFrequencyAnimationInterval() const { 45 base::TimeDelta TestHooks::LowFrequencyAnimationInterval() const {
45 return base::TimeDelta::FromMilliseconds(16); 46 return base::TimeDelta::FromMilliseconds(16);
46 } 47 }
47 48
48 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. 49 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks.
49 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { 50 class LayerTreeHostImplForTesting : public LayerTreeHostImpl {
50 public: 51 public:
51 static scoped_ptr<LayerTreeHostImplForTesting> Create( 52 static scoped_ptr<LayerTreeHostImplForTesting> Create(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 virtual void CommitComplete() OVERRIDE { 95 virtual void CommitComplete() OVERRIDE {
95 LayerTreeHostImpl::CommitComplete(); 96 LayerTreeHostImpl::CommitComplete();
96 test_hooks_->CommitCompleteOnThread(this); 97 test_hooks_->CommitCompleteOnThread(this);
97 98
98 if (!settings().impl_side_painting) { 99 if (!settings().impl_side_painting) {
99 test_hooks_->WillActivateTreeOnThread(this); 100 test_hooks_->WillActivateTreeOnThread(this);
100 test_hooks_->DidActivateTreeOnThread(this); 101 test_hooks_->DidActivateTreeOnThread(this);
101 } 102 }
102 } 103 }
103 104
104 virtual bool PrepareToDraw(FrameData* frame, 105 virtual DrawSwapReadbackResult::DrawResult PrepareToDraw(
105 const gfx::Rect& damage_rect) OVERRIDE { 106 FrameData* frame,
106 bool result = LayerTreeHostImpl::PrepareToDraw(frame, damage_rect); 107 const gfx::Rect& damage_rect) OVERRIDE {
107 if (!test_hooks_->PrepareToDrawOnThread(this, frame, result)) 108 DrawSwapReadbackResult::DrawResult draw_result =
108 result = false; 109 LayerTreeHostImpl::PrepareToDraw(frame, damage_rect);
109 return result; 110 return test_hooks_->PrepareToDrawOnThread(this, frame, draw_result);
110 } 111 }
111 112
112 virtual void DrawLayers(FrameData* frame, 113 virtual void DrawLayers(FrameData* frame,
113 base::TimeTicks frame_begin_time) OVERRIDE { 114 base::TimeTicks frame_begin_time) OVERRIDE {
114 LayerTreeHostImpl::DrawLayers(frame, frame_begin_time); 115 LayerTreeHostImpl::DrawLayers(frame, frame_begin_time);
115 test_hooks_->DrawLayersOnThread(this); 116 test_hooks_->DrawLayersOnThread(this);
116 } 117 }
117 118
118 virtual bool SwapBuffers(const LayerTreeHostImpl::FrameData& frame) OVERRIDE { 119 virtual bool SwapBuffers(const LayerTreeHostImpl::FrameData& frame) OVERRIDE {
119 bool result = LayerTreeHostImpl::SwapBuffers(frame); 120 bool result = LayerTreeHostImpl::SwapBuffers(frame);
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 const { 706 const {
706 if (impl->pending_tree()) 707 if (impl->pending_tree())
707 return impl->pending_tree()->source_frame_number(); 708 return impl->pending_tree()->source_frame_number();
708 if (impl->active_tree()) 709 if (impl->active_tree())
709 return impl->active_tree()->source_frame_number(); 710 return impl->active_tree()->source_frame_number();
710 // Source frames start at 0, so this is invalid. 711 // Source frames start at 0, so this is invalid.
711 return -1; 712 return -1;
712 } 713 }
713 714
714 } // namespace cc 715 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698