| 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 base::MessageLoopProxy::current()), | 83 base::MessageLoopProxy::current()), |
| 84 always_impl_thread_(&proxy_), | 84 always_impl_thread_(&proxy_), |
| 85 always_main_thread_blocked_(&proxy_), | 85 always_main_thread_blocked_(&proxy_), |
| 86 shared_bitmap_manager_(new TestSharedBitmapManager), | 86 shared_bitmap_manager_(new TestSharedBitmapManager), |
| 87 gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager), | 87 gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager), |
| 88 on_can_draw_state_changed_called_(false), | 88 on_can_draw_state_changed_called_(false), |
| 89 did_notify_ready_to_activate_(false), | 89 did_notify_ready_to_activate_(false), |
| 90 did_request_commit_(false), | 90 did_request_commit_(false), |
| 91 did_request_redraw_(false), | 91 did_request_redraw_(false), |
| 92 did_request_animate_(false), | 92 did_request_animate_(false), |
| 93 did_request_manage_tiles_(false), | 93 did_request_prepare_tiles_(false), |
| 94 reduce_memory_result_(true), | 94 reduce_memory_result_(true), |
| 95 current_limit_bytes_(0), | 95 current_limit_bytes_(0), |
| 96 current_priority_cutoff_value_(0) { | 96 current_priority_cutoff_value_(0) { |
| 97 media::InitializeMediaLibraryForTesting(); | 97 media::InitializeMediaLibraryForTesting(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 LayerTreeSettings DefaultSettings() { | 100 LayerTreeSettings DefaultSettings() { |
| 101 LayerTreeSettings settings; | 101 LayerTreeSettings settings; |
| 102 settings.minimum_occlusion_tracking_size = gfx::Size(); | 102 settings.minimum_occlusion_tracking_size = gfx::Size(); |
| 103 settings.impl_side_painting = true; | 103 settings.impl_side_painting = true; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 127 void NotifyReadyToActivate() override { | 127 void NotifyReadyToActivate() override { |
| 128 did_notify_ready_to_activate_ = true; | 128 did_notify_ready_to_activate_ = true; |
| 129 host_impl_->ActivateSyncTree(); | 129 host_impl_->ActivateSyncTree(); |
| 130 } | 130 } |
| 131 void NotifyReadyToDraw() override {} | 131 void NotifyReadyToDraw() override {} |
| 132 void SetNeedsRedrawOnImplThread() override { did_request_redraw_ = true; } | 132 void SetNeedsRedrawOnImplThread() override { did_request_redraw_ = true; } |
| 133 void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) override { | 133 void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) override { |
| 134 did_request_redraw_ = true; | 134 did_request_redraw_ = true; |
| 135 } | 135 } |
| 136 void SetNeedsAnimateOnImplThread() override { did_request_animate_ = true; } | 136 void SetNeedsAnimateOnImplThread() override { did_request_animate_ = true; } |
| 137 void SetNeedsManageTilesOnImplThread() override { | 137 void SetNeedsPrepareTilesOnImplThread() override { |
| 138 did_request_manage_tiles_ = true; | 138 did_request_prepare_tiles_ = true; |
| 139 } | 139 } |
| 140 void SetNeedsCommitOnImplThread() override { did_request_commit_ = true; } | 140 void SetNeedsCommitOnImplThread() override { did_request_commit_ = true; } |
| 141 void PostAnimationEventsToMainThreadOnImplThread( | 141 void PostAnimationEventsToMainThreadOnImplThread( |
| 142 scoped_ptr<AnimationEventsVector> events) override {} | 142 scoped_ptr<AnimationEventsVector> events) override {} |
| 143 bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, | 143 bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, |
| 144 int priority_cutoff) override { | 144 int priority_cutoff) override { |
| 145 current_limit_bytes_ = limit_bytes; | 145 current_limit_bytes_ = limit_bytes; |
| 146 current_priority_cutoff_value_ = priority_cutoff; | 146 current_priority_cutoff_value_ = priority_cutoff; |
| 147 return reduce_memory_result_; | 147 return reduce_memory_result_; |
| 148 } | 148 } |
| 149 bool IsInsideDraw() override { return false; } | 149 bool IsInsideDraw() override { return false; } |
| 150 void RenewTreePriority() override {} | 150 void RenewTreePriority() override {} |
| 151 void PostDelayedScrollbarFadeOnImplThread(const base::Closure& start_fade, | 151 void PostDelayedScrollbarFadeOnImplThread(const base::Closure& start_fade, |
| 152 base::TimeDelta delay) override { | 152 base::TimeDelta delay) override { |
| 153 scrollbar_fade_start_ = start_fade; | 153 scrollbar_fade_start_ = start_fade; |
| 154 requested_scrollbar_animation_delay_ = delay; | 154 requested_scrollbar_animation_delay_ = delay; |
| 155 } | 155 } |
| 156 void DidActivateSyncTree() override {} | 156 void DidActivateSyncTree() override {} |
| 157 void DidManageTiles() override {} | 157 void DidPrepareTiles() override {} |
| 158 | 158 |
| 159 void set_reduce_memory_result(bool reduce_memory_result) { | 159 void set_reduce_memory_result(bool reduce_memory_result) { |
| 160 reduce_memory_result_ = reduce_memory_result; | 160 reduce_memory_result_ = reduce_memory_result; |
| 161 } | 161 } |
| 162 | 162 |
| 163 virtual bool CreateHostImpl(const LayerTreeSettings& settings, | 163 virtual bool CreateHostImpl(const LayerTreeSettings& settings, |
| 164 scoped_ptr<OutputSurface> output_surface) { | 164 scoped_ptr<OutputSurface> output_surface) { |
| 165 host_impl_ = LayerTreeHostImpl::Create(settings, | 165 host_impl_ = LayerTreeHostImpl::Create(settings, |
| 166 this, | 166 this, |
| 167 &proxy_, | 167 &proxy_, |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 388 |
| 389 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_; | 389 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_; |
| 390 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; | 390 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
| 391 scoped_ptr<LayerTreeHostImpl> host_impl_; | 391 scoped_ptr<LayerTreeHostImpl> host_impl_; |
| 392 FakeRenderingStatsInstrumentation stats_instrumentation_; | 392 FakeRenderingStatsInstrumentation stats_instrumentation_; |
| 393 bool on_can_draw_state_changed_called_; | 393 bool on_can_draw_state_changed_called_; |
| 394 bool did_notify_ready_to_activate_; | 394 bool did_notify_ready_to_activate_; |
| 395 bool did_request_commit_; | 395 bool did_request_commit_; |
| 396 bool did_request_redraw_; | 396 bool did_request_redraw_; |
| 397 bool did_request_animate_; | 397 bool did_request_animate_; |
| 398 bool did_request_manage_tiles_; | 398 bool did_request_prepare_tiles_; |
| 399 bool reduce_memory_result_; | 399 bool reduce_memory_result_; |
| 400 base::Closure scrollbar_fade_start_; | 400 base::Closure scrollbar_fade_start_; |
| 401 base::TimeDelta requested_scrollbar_animation_delay_; | 401 base::TimeDelta requested_scrollbar_animation_delay_; |
| 402 size_t current_limit_bytes_; | 402 size_t current_limit_bytes_; |
| 403 int current_priority_cutoff_value_; | 403 int current_priority_cutoff_value_; |
| 404 }; | 404 }; |
| 405 | 405 |
| 406 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { | 406 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { |
| 407 bool always_draw = false; | 407 bool always_draw = false; |
| 408 CheckNotifyCalledIfCanDrawChanged(always_draw); | 408 CheckNotifyCalledIfCanDrawChanged(always_draw); |
| (...skipping 6113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6522 host_impl_->SetUseGpuRasterization(false); | 6522 host_impl_->SetUseGpuRasterization(false); |
| 6523 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 6523 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
| 6524 | 6524 |
| 6525 host_impl_->ResetRequiresHighResToDraw(); | 6525 host_impl_->ResetRequiresHighResToDraw(); |
| 6526 | 6526 |
| 6527 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); | 6527 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); |
| 6528 host_impl_->SetUseGpuRasterization(true); | 6528 host_impl_->SetUseGpuRasterization(true); |
| 6529 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 6529 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
| 6530 } | 6530 } |
| 6531 | 6531 |
| 6532 class LayerTreeHostImplTestManageTiles : public LayerTreeHostImplTest { | 6532 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { |
| 6533 public: | 6533 public: |
| 6534 void SetUp() override { | 6534 void SetUp() override { |
| 6535 LayerTreeSettings settings; | 6535 LayerTreeSettings settings; |
| 6536 settings.impl_side_painting = true; | 6536 settings.impl_side_painting = true; |
| 6537 | 6537 |
| 6538 fake_host_impl_ = new FakeLayerTreeHostImpl( | 6538 fake_host_impl_ = new FakeLayerTreeHostImpl( |
| 6539 settings, &proxy_, shared_bitmap_manager_.get()); | 6539 settings, &proxy_, shared_bitmap_manager_.get()); |
| 6540 host_impl_.reset(fake_host_impl_); | 6540 host_impl_.reset(fake_host_impl_); |
| 6541 host_impl_->InitializeRenderer(CreateOutputSurface()); | 6541 host_impl_->InitializeRenderer(CreateOutputSurface()); |
| 6542 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 6542 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 6543 } | 6543 } |
| 6544 | 6544 |
| 6545 FakeLayerTreeHostImpl* fake_host_impl_; | 6545 FakeLayerTreeHostImpl* fake_host_impl_; |
| 6546 }; | 6546 }; |
| 6547 | 6547 |
| 6548 TEST_F(LayerTreeHostImplTestManageTiles, ManageTilesWhenInvisible) { | 6548 TEST_F(LayerTreeHostImplTestPrepareTiles, PrepareTilesWhenInvisible) { |
| 6549 fake_host_impl_->DidModifyTilePriorities(); | 6549 fake_host_impl_->DidModifyTilePriorities(); |
| 6550 EXPECT_TRUE(fake_host_impl_->manage_tiles_needed()); | 6550 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed()); |
| 6551 fake_host_impl_->SetVisible(false); | 6551 fake_host_impl_->SetVisible(false); |
| 6552 EXPECT_FALSE(fake_host_impl_->manage_tiles_needed()); | 6552 EXPECT_FALSE(fake_host_impl_->prepare_tiles_needed()); |
| 6553 } | 6553 } |
| 6554 | 6554 |
| 6555 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { | 6555 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { |
| 6556 scoped_ptr<TestWebGraphicsContext3D> context = | 6556 scoped_ptr<TestWebGraphicsContext3D> context = |
| 6557 TestWebGraphicsContext3D::Create(); | 6557 TestWebGraphicsContext3D::Create(); |
| 6558 TestWebGraphicsContext3D* context3d = context.get(); | 6558 TestWebGraphicsContext3D* context3d = context.get(); |
| 6559 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); | 6559 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); |
| 6560 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 6560 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
| 6561 | 6561 |
| 6562 EXPECT_EQ(0u, context3d->NumTextures()); | 6562 EXPECT_EQ(0u, context3d->NumTextures()); |
| (...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7955 // surface. | 7955 // surface. |
| 7956 EXPECT_EQ(0, num_lost_surfaces_); | 7956 EXPECT_EQ(0, num_lost_surfaces_); |
| 7957 host_impl_->DidLoseOutputSurface(); | 7957 host_impl_->DidLoseOutputSurface(); |
| 7958 EXPECT_EQ(1, num_lost_surfaces_); | 7958 EXPECT_EQ(1, num_lost_surfaces_); |
| 7959 host_impl_->DidLoseOutputSurface(); | 7959 host_impl_->DidLoseOutputSurface(); |
| 7960 EXPECT_LE(1, num_lost_surfaces_); | 7960 EXPECT_LE(1, num_lost_surfaces_); |
| 7961 } | 7961 } |
| 7962 | 7962 |
| 7963 } // namespace | 7963 } // namespace |
| 7964 } // namespace cc | 7964 } // namespace cc |
| OLD | NEW |