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

Unified Diff: cc/test/test_layer_tree_host_base.cc

Issue 1988053002: Revert of cc: Refactor layer/tile manager unittest to extract common code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/test/test_layer_tree_host_base.h ('k') | cc/tiles/tile_manager_perftest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/test/test_layer_tree_host_base.cc
diff --git a/cc/test/test_layer_tree_host_base.cc b/cc/test/test_layer_tree_host_base.cc
deleted file mode 100644
index b79ad5f89a48c70c1a1b91e97354afa20034c4fd..0000000000000000000000000000000000000000
--- a/cc/test/test_layer_tree_host_base.cc
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "cc/test/test_layer_tree_host_base.h"
-
-#include "cc/test/fake_output_surface.h"
-#include "cc/test/fake_raster_source.h"
-#include "cc/trees/layer_tree_impl.h"
-
-namespace cc {
-
-TestLayerTreeHostBase::TestLayerTreeHostBase()
- : task_runner_provider_(base::ThreadTaskRunnerHandle::Get()),
- pending_layer_(nullptr),
- active_layer_(nullptr),
- old_pending_layer_(nullptr),
- root_id_(6),
- id_(7) {}
-
-TestLayerTreeHostBase::~TestLayerTreeHostBase() = default;
-
-void TestLayerTreeHostBase::SetUp() {
- output_surface_ = CreateOutputSurface();
- task_graph_runner_ = CreateTaskGraphRunner();
- host_impl_ = CreateHostImpl(CreateSettings(), &task_runner_provider_,
- &shared_bitmap_manager_, task_graph_runner_.get(),
- &gpu_memory_buffer_manager_);
- InitializeRenderer();
- SetInitialTreePriority();
-}
-
-LayerTreeSettings TestLayerTreeHostBase::CreateSettings() {
- return LayerTreeSettings();
-}
-
-std::unique_ptr<OutputSurface> TestLayerTreeHostBase::CreateOutputSurface() {
- return FakeOutputSurface::Create3d();
-}
-
-std::unique_ptr<FakeLayerTreeHostImpl> TestLayerTreeHostBase::CreateHostImpl(
- const LayerTreeSettings& settings,
- TaskRunnerProvider* task_runner_provider,
- SharedBitmapManager* shared_bitmap_manager,
- TaskGraphRunner* task_graph_runner,
- gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) {
- return base::WrapUnique(new FakeLayerTreeHostImpl(
- settings, task_runner_provider, shared_bitmap_manager, task_graph_runner,
- gpu_memory_buffer_manager));
-}
-
-std::unique_ptr<TaskGraphRunner>
-TestLayerTreeHostBase::CreateTaskGraphRunner() {
- return base::WrapUnique(new TestTaskGraphRunner);
-}
-
-void TestLayerTreeHostBase::InitializeRenderer() {
- host_impl_->SetVisible(true);
- host_impl_->InitializeRenderer(output_surface_.get());
-}
-
-void TestLayerTreeHostBase::ResetOutputSurface(
- std::unique_ptr<OutputSurface> output_surface) {
- host_impl()->DidLoseOutputSurface();
- host_impl()->SetVisible(true);
- host_impl()->InitializeRenderer(output_surface.get());
- output_surface_ = std::move(output_surface);
-}
-
-std::unique_ptr<FakeLayerTreeHostImpl> TestLayerTreeHostBase::TakeHostImpl() {
- return std::move(host_impl_);
-}
-
-void TestLayerTreeHostBase::SetupDefaultTrees(const gfx::Size& layer_bounds) {
- scoped_refptr<FakeRasterSource> pending_raster_source =
- FakeRasterSource::CreateFilled(layer_bounds);
- scoped_refptr<FakeRasterSource> active_raster_source =
- FakeRasterSource::CreateFilled(layer_bounds);
-
- SetupTrees(std::move(pending_raster_source), std::move(active_raster_source));
-}
-
-void TestLayerTreeHostBase::SetupTrees(
- scoped_refptr<RasterSource> pending_raster_source,
- scoped_refptr<RasterSource> active_raster_source) {
- SetupPendingTree(std::move(active_raster_source));
- ActivateTree();
- SetupPendingTree(std::move(pending_raster_source));
-}
-
-void TestLayerTreeHostBase::SetupPendingTree(
- scoped_refptr<RasterSource> raster_source) {
- SetupPendingTree(std::move(raster_source), gfx::Size(), Region());
-}
-
-void TestLayerTreeHostBase::SetupPendingTree(
- scoped_refptr<RasterSource> raster_source,
- const gfx::Size& tile_size,
- const Region& invalidation) {
- host_impl()->CreatePendingTree();
- host_impl()->pending_tree()->PushPageScaleFromMainThread(1.f, 0.00001f,
- 100000.f);
- LayerTreeImpl* pending_tree = host_impl()->pending_tree();
- pending_tree->SetDeviceScaleFactor(
- host_impl()->active_tree()->device_scale_factor());
-
- // Steal from the recycled tree if possible.
- LayerImpl* pending_root = pending_tree->root_layer();
- std::unique_ptr<FakePictureLayerImpl> pending_layer;
- DCHECK(!pending_root || pending_root->id() == root_id_);
- if (!pending_root) {
- std::unique_ptr<LayerImpl> new_pending_root =
- LayerImpl::Create(pending_tree, root_id_);
- pending_layer = FakePictureLayerImpl::Create(pending_tree, id_);
- if (!tile_size.IsEmpty())
- pending_layer->set_fixed_tile_size(tile_size);
- pending_layer->SetDrawsContent(true);
- pending_layer->SetScrollClipLayer(new_pending_root->id());
- pending_root = new_pending_root.get();
- pending_tree->SetRootLayer(std::move(new_pending_root));
- } else {
- pending_layer.reset(static_cast<FakePictureLayerImpl*>(
- pending_root->RemoveChildForTesting(pending_root->children()[0])
- .release()));
- if (!tile_size.IsEmpty())
- pending_layer->set_fixed_tile_size(tile_size);
- }
- pending_root->test_properties()->force_render_surface = true;
- // The bounds() just mirror the raster source size.
- pending_layer->SetBounds(raster_source->GetSize());
- pending_layer->SetRasterSourceOnPending(raster_source, invalidation);
-
- pending_root->AddChild(std::move(pending_layer));
- pending_tree->SetViewportLayersFromIds(Layer::INVALID_ID,
- pending_tree->root_layer()->id(),
- Layer::INVALID_ID, Layer::INVALID_ID);
-
- pending_layer_ = static_cast<FakePictureLayerImpl*>(
- host_impl()->pending_tree()->LayerById(id_));
-
- // Add tilings/tiles for the layer.
- bool update_lcd_text = false;
- RebuildPropertyTreesOnPendingTree();
- host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text);
-}
-
-void TestLayerTreeHostBase::ActivateTree() {
- RebuildPropertyTreesOnPendingTree();
- host_impl()->ActivateSyncTree();
- CHECK(!host_impl()->pending_tree());
- CHECK(host_impl()->recycle_tree());
- old_pending_layer_ = pending_layer_;
- pending_layer_ = nullptr;
- active_layer_ = static_cast<FakePictureLayerImpl*>(
- host_impl()->active_tree()->LayerById(id_));
-
- bool update_lcd_text = false;
- host_impl()->active_tree()->UpdateDrawProperties(update_lcd_text);
-}
-
-void TestLayerTreeHostBase::RebuildPropertyTreesOnPendingTree() {
- host_impl()->pending_tree()->property_trees()->needs_rebuild = true;
- host_impl()->pending_tree()->BuildPropertyTreesForTesting();
-}
-
-void TestLayerTreeHostBase::SetInitialTreePriority() {
- GlobalStateThatImpactsTilePriority state;
-
- state.soft_memory_limit_in_bytes = 100 * 1000 * 1000;
- state.num_resources_limit = 10000;
- state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes * 2;
- state.memory_limit_policy = ALLOW_ANYTHING;
- state.tree_priority = SAME_PRIORITY_FOR_BOTH_TREES;
-
- host_impl_->resource_pool()->SetResourceUsageLimits(
- state.soft_memory_limit_in_bytes, state.num_resources_limit);
- host_impl_->tile_manager()->SetGlobalStateForTesting(state);
-}
-
-} // namespace cc
« no previous file with comments | « cc/test/test_layer_tree_host_base.h ('k') | cc/tiles/tile_manager_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698