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

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

Issue 199523002: cc: Throttle swaps in Scheduler instead of OutputSurface (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Actually, unittests need CC_EXPORT. Created 6 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_delegated.cc » ('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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 102
103 virtual void SetUp() OVERRIDE { 103 virtual void SetUp() OVERRIDE {
104 CreateHostImpl(DefaultSettings(), CreateOutputSurface()); 104 CreateHostImpl(DefaultSettings(), CreateOutputSurface());
105 } 105 }
106 106
107 virtual void TearDown() OVERRIDE {} 107 virtual void TearDown() OVERRIDE {}
108 108
109 virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE {} 109 virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE {}
110 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE {} 110 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE {}
111 virtual void SetMaxSwapsPendingOnImplThread(int max) OVERRIDE {}
111 virtual void DidSwapBuffersOnImplThread() OVERRIDE {} 112 virtual void DidSwapBuffersOnImplThread() OVERRIDE {}
112 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE {} 113 virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE {}
113 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {} 114 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {}
114 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE { 115 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE {
115 on_can_draw_state_changed_called_ = true; 116 on_can_draw_state_changed_called_ = true;
116 } 117 }
117 virtual void NotifyReadyToActivate() OVERRIDE { 118 virtual void NotifyReadyToActivate() OVERRIDE {
118 did_notify_ready_to_activate_ = true; 119 did_notify_ready_to_activate_ = true;
119 host_impl_->ActivatePendingTree(); 120 host_impl_->ActivatePendingTree();
120 } 121 }
121 virtual void SetNeedsRedrawOnImplThread() OVERRIDE { 122 virtual void SetNeedsRedrawOnImplThread() OVERRIDE {
122 did_request_redraw_ = true; 123 did_request_redraw_ = true;
(...skipping 5224 matching lines...) Expand 10 before | Expand all | Expand 10 after
5347 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5348 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5348 host_impl_->DidDrawAllLayers(frame); 5349 host_impl_->DidDrawAllLayers(frame);
5349 } 5350 }
5350 5351
5351 5352
5352 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { 5353 class CompositorFrameMetadataTest : public LayerTreeHostImplTest {
5353 public: 5354 public:
5354 CompositorFrameMetadataTest() 5355 CompositorFrameMetadataTest()
5355 : swap_buffers_complete_(0) {} 5356 : swap_buffers_complete_(0) {}
5356 5357
5357 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE { 5358 virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE {
5358 swap_buffers_complete_++; 5359 swap_buffers_complete_++;
5359 } 5360 }
5360 5361
5361 int swap_buffers_complete_; 5362 int swap_buffers_complete_;
5362 }; 5363 };
5363 5364
5364 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { 5365 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) {
5365 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 5366 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
5366 { 5367 {
5367 LayerTreeHostImpl::FrameData frame; 5368 LayerTreeHostImpl::FrameData frame;
5368 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5369 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
5369 host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5370 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5370 host_impl_->DrawLayers(&frame, base::TimeTicks()); 5371 host_impl_->DrawLayers(&frame, base::TimeTicks());
5371 host_impl_->DidDrawAllLayers(frame); 5372 host_impl_->DidDrawAllLayers(frame);
5372 } 5373 }
5373 CompositorFrameAck ack; 5374 CompositorFrameAck ack;
5374 host_impl_->ReclaimResources(&ack); 5375 host_impl_->ReclaimResources(&ack);
5375 host_impl_->OnSwapBuffersComplete(); 5376 host_impl_->DidSwapBuffersComplete();
5376 EXPECT_EQ(swap_buffers_complete_, 1); 5377 EXPECT_EQ(swap_buffers_complete_, 1);
5377 } 5378 }
5378 5379
5379 class CountingSoftwareDevice : public SoftwareOutputDevice { 5380 class CountingSoftwareDevice : public SoftwareOutputDevice {
5380 public: 5381 public:
5381 CountingSoftwareDevice() : frames_began_(0), frames_ended_(0) {} 5382 CountingSoftwareDevice() : frames_began_(0), frames_ended_(0) {}
5382 5383
5383 virtual SkCanvas* BeginPaint(const gfx::Rect& damage_rect) OVERRIDE { 5384 virtual SkCanvas* BeginPaint(const gfx::Rect& damage_rect) OVERRIDE {
5384 ++frames_began_; 5385 ++frames_began_;
5385 return SoftwareOutputDevice::BeginPaint(damage_rect); 5386 return SoftwareOutputDevice::BeginPaint(damage_rect);
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
6272 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, 6273 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes,
6273 300u * 1024u * 1024u); 6274 300u * 1024u * 1024u);
6274 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, 6275 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes,
6275 150u * 1024u * 1024u); 6276 150u * 1024u * 1024u);
6276 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, 6277 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes,
6277 75u * 1024u * 1024u); 6278 75u * 1024u * 1024u);
6278 } 6279 }
6279 6280
6280 } // namespace 6281 } // namespace
6281 } // namespace cc 6282 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_delegated.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698