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

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

Issue 2537683002: cc: Add image decode queue functionality to image manager. (Closed)
Patch Set: update Created 3 years, 12 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 virtual bool CreateHostImplWithTaskRunnerProvider( 193 virtual bool CreateHostImplWithTaskRunnerProvider(
194 const LayerTreeSettings& settings, 194 const LayerTreeSettings& settings,
195 std::unique_ptr<CompositorFrameSink> compositor_frame_sink, 195 std::unique_ptr<CompositorFrameSink> compositor_frame_sink,
196 TaskRunnerProvider* task_runner_provider) { 196 TaskRunnerProvider* task_runner_provider) {
197 if (host_impl_) 197 if (host_impl_)
198 host_impl_->ReleaseCompositorFrameSink(); 198 host_impl_->ReleaseCompositorFrameSink();
199 host_impl_ = LayerTreeHostImpl::Create( 199 host_impl_ = LayerTreeHostImpl::Create(
200 settings, this, task_runner_provider, &stats_instrumentation_, 200 settings, this, task_runner_provider, &stats_instrumentation_,
201 &task_graph_runner_, 201 &task_graph_runner_,
202 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); 202 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0, nullptr);
203 compositor_frame_sink_ = std::move(compositor_frame_sink); 203 compositor_frame_sink_ = std::move(compositor_frame_sink);
204 host_impl_->SetVisible(true); 204 host_impl_->SetVisible(true);
205 bool init = host_impl_->InitializeRenderer(compositor_frame_sink_.get()); 205 bool init = host_impl_->InitializeRenderer(compositor_frame_sink_.get());
206 host_impl_->SetViewportSize(gfx::Size(10, 10)); 206 host_impl_->SetViewportSize(gfx::Size(10, 10));
207 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 207 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
208 // Set the BeginFrameArgs so that methods which use it are able to. 208 // Set the BeginFrameArgs so that methods which use it are able to.
209 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( 209 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting(
210 BEGINFRAME_FROM_HERE, 0, 1, 210 BEGINFRAME_FROM_HERE, 0, 1,
211 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); 211 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1)));
212 host_impl_->DidFinishImplFrame(); 212 host_impl_->DidFinishImplFrame();
(...skipping 2489 matching lines...) Expand 10 before | Expand all | Expand 10 after
2702 LayerTreeHostImplClient* client, 2702 LayerTreeHostImplClient* client,
2703 TaskRunnerProvider* task_runner_provider, 2703 TaskRunnerProvider* task_runner_provider,
2704 TaskGraphRunner* task_graph_runner, 2704 TaskGraphRunner* task_graph_runner,
2705 RenderingStatsInstrumentation* rendering_stats_instrumentation) 2705 RenderingStatsInstrumentation* rendering_stats_instrumentation)
2706 : LayerTreeHostImpl(settings, 2706 : LayerTreeHostImpl(settings,
2707 client, 2707 client,
2708 task_runner_provider, 2708 task_runner_provider,
2709 rendering_stats_instrumentation, 2709 rendering_stats_instrumentation,
2710 task_graph_runner, 2710 task_graph_runner,
2711 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 2711 AnimationHost::CreateForTesting(ThreadInstance::IMPL),
2712 0) {} 2712 0,
2713 nullptr) {}
2713 2714
2714 BeginFrameArgs CurrentBeginFrameArgs() const override { 2715 BeginFrameArgs CurrentBeginFrameArgs() const override {
2715 return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1, 2716 return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1,
2716 fake_current_physical_time_); 2717 fake_current_physical_time_);
2717 } 2718 }
2718 2719
2719 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { 2720 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) {
2720 fake_current_physical_time_ = fake_now; 2721 fake_current_physical_time_ = fake_now;
2721 } 2722 }
2722 2723
(...skipping 4849 matching lines...) Expand 10 before | Expand all | Expand 10 after
7572 compositor_frame_sink.get(); 7573 compositor_frame_sink.get();
7573 7574
7574 // This test creates its own LayerTreeHostImpl, so 7575 // This test creates its own LayerTreeHostImpl, so
7575 // that we can force partial swap enabled. 7576 // that we can force partial swap enabled.
7576 LayerTreeSettings settings = DefaultSettings(); 7577 LayerTreeSettings settings = DefaultSettings();
7577 settings.renderer_settings.partial_swap_enabled = true; 7578 settings.renderer_settings.partial_swap_enabled = true;
7578 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = 7579 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl =
7579 LayerTreeHostImpl::Create( 7580 LayerTreeHostImpl::Create(
7580 settings, this, &task_runner_provider_, &stats_instrumentation_, 7581 settings, this, &task_runner_provider_, &stats_instrumentation_,
7581 &task_graph_runner_, 7582 &task_graph_runner_,
7582 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); 7583 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0, nullptr);
7583 layer_tree_host_impl->SetVisible(true); 7584 layer_tree_host_impl->SetVisible(true);
7584 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get()); 7585 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get());
7585 layer_tree_host_impl->WillBeginImplFrame( 7586 layer_tree_host_impl->WillBeginImplFrame(
7586 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2)); 7587 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2));
7587 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); 7588 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500));
7588 7589
7589 std::unique_ptr<LayerImpl> root = 7590 std::unique_ptr<LayerImpl> root =
7590 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); 7591 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1);
7591 root->test_properties()->force_render_surface = true; 7592 root->test_properties()->force_render_surface = true;
7592 std::unique_ptr<LayerImpl> child = 7593 std::unique_ptr<LayerImpl> child =
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
7701 bool partial_swap, 7702 bool partial_swap,
7702 LayerTreeHostImplClient* client, 7703 LayerTreeHostImplClient* client,
7703 TaskRunnerProvider* task_runner_provider, 7704 TaskRunnerProvider* task_runner_provider,
7704 TaskGraphRunner* task_graph_runner, 7705 TaskGraphRunner* task_graph_runner,
7705 RenderingStatsInstrumentation* stats_instrumentation, 7706 RenderingStatsInstrumentation* stats_instrumentation,
7706 CompositorFrameSink* compositor_frame_sink) { 7707 CompositorFrameSink* compositor_frame_sink) {
7707 settings.renderer_settings.partial_swap_enabled = partial_swap; 7708 settings.renderer_settings.partial_swap_enabled = partial_swap;
7708 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( 7709 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create(
7709 settings, client, task_runner_provider, stats_instrumentation, 7710 settings, client, task_runner_provider, stats_instrumentation,
7710 task_graph_runner, AnimationHost::CreateForTesting(ThreadInstance::IMPL), 7711 task_graph_runner, AnimationHost::CreateForTesting(ThreadInstance::IMPL),
7711 0); 7712 0, nullptr);
7712 my_host_impl->SetVisible(true); 7713 my_host_impl->SetVisible(true);
7713 my_host_impl->InitializeRenderer(compositor_frame_sink); 7714 my_host_impl->InitializeRenderer(compositor_frame_sink);
7714 my_host_impl->WillBeginImplFrame( 7715 my_host_impl->WillBeginImplFrame(
7715 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2)); 7716 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2));
7716 my_host_impl->SetViewportSize(gfx::Size(100, 100)); 7717 my_host_impl->SetViewportSize(gfx::Size(100, 100));
7717 7718
7718 /* 7719 /*
7719 Layers are created as follows: 7720 Layers are created as follows:
7720 7721
7721 +--------------------+ 7722 +--------------------+
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
8169 EXPECT_NE(kSoftwareTileCutoff, kNothingTileCutoff); 8170 EXPECT_NE(kSoftwareTileCutoff, kNothingTileCutoff);
8170 8171
8171 LayerTreeSettings settings = DefaultSettings(); 8172 LayerTreeSettings settings = DefaultSettings();
8172 settings.gpu_memory_policy = 8173 settings.gpu_memory_policy =
8173 ManagedMemoryPolicy(kGpuByteLimit, kGpuCutoff, kGpuResourceLimit); 8174 ManagedMemoryPolicy(kGpuByteLimit, kGpuCutoff, kGpuResourceLimit);
8174 settings.software_memory_policy = ManagedMemoryPolicy( 8175 settings.software_memory_policy = ManagedMemoryPolicy(
8175 kSoftwareByteLimit, kSoftwareCutoff, kSoftwareResourceLimit); 8176 kSoftwareByteLimit, kSoftwareCutoff, kSoftwareResourceLimit);
8176 host_impl_ = LayerTreeHostImpl::Create( 8177 host_impl_ = LayerTreeHostImpl::Create(
8177 settings, this, &task_runner_provider_, &stats_instrumentation_, 8178 settings, this, &task_runner_provider_, &stats_instrumentation_,
8178 &task_graph_runner_, 8179 &task_graph_runner_,
8179 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); 8180 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0, nullptr);
8180 8181
8181 // Gpu compositing. 8182 // Gpu compositing.
8182 compositor_frame_sink_ = 8183 compositor_frame_sink_ =
8183 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); 8184 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create());
8184 host_impl_->SetVisible(true); 8185 host_impl_->SetVisible(true);
8185 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); 8186 host_impl_->InitializeRenderer(compositor_frame_sink_.get());
8186 { 8187 {
8187 const auto& state = host_impl_->global_tile_state(); 8188 const auto& state = host_impl_->global_tile_state();
8188 EXPECT_EQ(kGpuByteLimit, state.hard_memory_limit_in_bytes); 8189 EXPECT_EQ(kGpuByteLimit, state.hard_memory_limit_in_bytes);
8189 EXPECT_EQ(kGpuResourceLimit, state.num_resources_limit); 8190 EXPECT_EQ(kGpuResourceLimit, state.num_resources_limit);
(...skipping 3435 matching lines...) Expand 10 before | Expand all | Expand 10 after
11625 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnCompositorFrameSinkChange) { 11626 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnCompositorFrameSinkChange) {
11626 host_impl_->ReleaseCompositorFrameSink(); 11627 host_impl_->ReleaseCompositorFrameSink();
11627 host_impl_ = nullptr; 11628 host_impl_ = nullptr;
11628 11629
11629 LayerTreeSettings settings = DefaultSettings(); 11630 LayerTreeSettings settings = DefaultSettings();
11630 settings.gpu_rasterization_forced = true; 11631 settings.gpu_rasterization_forced = true;
11631 11632
11632 host_impl_ = LayerTreeHostImpl::Create( 11633 host_impl_ = LayerTreeHostImpl::Create(
11633 settings, this, &task_runner_provider_, &stats_instrumentation_, 11634 settings, this, &task_runner_provider_, &stats_instrumentation_,
11634 &task_graph_runner_, 11635 &task_graph_runner_,
11635 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); 11636 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0, nullptr);
11636 host_impl_->SetVisible(true); 11637 host_impl_->SetVisible(true);
11637 11638
11638 // InitializeRenderer with a gpu-raster enabled output surface. 11639 // InitializeRenderer with a gpu-raster enabled output surface.
11639 auto gpu_raster_compositor_frame_sink = 11640 auto gpu_raster_compositor_frame_sink =
11640 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); 11641 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create());
11641 host_impl_->InitializeRenderer(gpu_raster_compositor_frame_sink.get()); 11642 host_impl_->InitializeRenderer(gpu_raster_compositor_frame_sink.get());
11642 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 11643 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
11643 11644
11644 // Re-initialize with a software output surface. 11645 // Re-initialize with a software output surface.
11645 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); 11646 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
11767 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11768 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar());
11768 host_impl_->MouseMoveAt(gfx::Point(10, 150)); 11769 host_impl_->MouseMoveAt(gfx::Point(10, 150));
11769 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11770 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar());
11770 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11771 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar());
11771 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); 11772 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar());
11772 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11773 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar());
11773 } 11774 }
11774 11775
11775 } // namespace 11776 } // namespace
11776 } // namespace cc 11777 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698