Commit 41c15724 authored by danakj's avatar danakj Committed by Commit Bot

Use cc::LayerTreeHost for StubChromeClientForSPv2

Currently its using WebLayerTreeViewImplForTesting but it only uses
the cc::LayerTreeHost, not the WebViewImpl things, so it just needs
a LayerTreeHost itself. This helps us toward removing the
WebLayerTreeView interface.

R=chrishtr@chromium.org

Bug: 838693
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ia60ea4128ed029f09ee4abe012ee62f315633c88
Reviewed-on: https://chromium-review.googlesource.com/1117656
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571152}
parent 4006fb70
......@@ -2041,6 +2041,8 @@ jumbo_source_set("unit_tests") {
"paint/first_meaningful_paint_detector_test.cc",
"paint/fragment_data_test.cc",
"paint/html_canvas_painter_test.cc",
"paint/layer_tree_host_for_paint_artifact_test.cc",
"paint/layer_tree_host_for_paint_artifact_test.h",
"paint/link_highlight_impl_test.cc",
"paint/ng/ng_paint_fragment_test.cc",
"paint/ng/ng_paint_fragment_traversal_test.cc",
......
// Copyright 2018 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 "third_party/blink/renderer/core/paint/layer_tree_host_for_paint_artifact_test.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_thread.h"
namespace blink {
LayerTreeHostForPaintArtifactTest::LayerTreeHostForPaintArtifactTest() {
cc::LayerTreeSettings settings;
settings.layer_transforms_should_scale_layer_contents = true;
animation_host_ = cc::AnimationHost::CreateMainInstance();
cc::LayerTreeHost::InitParams params;
params.client = &layer_tree_host_client_;
params.settings = &settings;
params.main_task_runner =
Platform::Current()->CurrentThread()->GetTaskRunner();
params.task_graph_runner = &task_graph_runner_;
params.mutator_host = animation_host_.get();
layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded(
&layer_tree_host_single_thread_client_, &params);
}
} // namespace blink
// Copyright 2018 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.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_LAYER_TREE_HOST_FOR_PAINT_ARTIFACT_TEST_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_LAYER_TREE_HOST_FOR_PAINT_ARTIFACT_TEST_H_
#include "cc/animation/animation_host.h"
#include "cc/test/stub_layer_tree_host_client.h"
#include "cc/test/stub_layer_tree_host_single_thread_client.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_settings.h"
namespace blink {
class LayerTreeHostForPaintArtifactTest {
public:
LayerTreeHostForPaintArtifactTest();
cc::LayerTreeHost* layer_tree_host() { return layer_tree_host_.get(); }
private:
cc::StubLayerTreeHostSingleThreadClient layer_tree_host_single_thread_client_;
cc::StubLayerTreeHostClient layer_tree_host_client_;
cc::TestTaskGraphRunner task_graph_runner_;
std::unique_ptr<cc::AnimationHost> animation_host_;
std::unique_ptr<cc::LayerTreeHost> layer_tree_host_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_LAYER_TREE_HOST_FOR_PAINT_ARTIFACT_TEST_H_
......@@ -5,13 +5,8 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_PAINT_AND_RASTER_INVALIDATION_TEST_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_PAINT_AND_RASTER_INVALIDATION_TEST_H_
#include "cc/animation/animation_host.h"
#include "cc/layers/picture_layer.h"
#include "cc/test/stub_layer_tree_host_client.h"
#include "cc/test/stub_layer_tree_host_single_thread_client.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_settings.h"
#include "third_party/blink/renderer/core/paint/layer_tree_host_for_paint_artifact_test.h"
#include "third_party/blink/renderer/core/paint/paint_controller_paint_test.h"
#include "third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.h"
#include "third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h"
......@@ -56,20 +51,8 @@ class PaintAndRasterInvalidationTest : public PaintControllerPaintTest {
PaintControllerPaintTest::SetUp();
if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) {
cc::LayerTreeSettings settings;
settings.layer_transforms_should_scale_layer_contents = true;
animation_host_ = cc::AnimationHost::CreateMainInstance();
cc::LayerTreeHost::InitParams params;
params.client = &layer_tree_host_client_;
params.settings = &settings;
params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
params.task_graph_runner = &task_graph_runner_;
params.mutator_host = animation_host_.get();
layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded(
&layer_tree_host_single_thread_client_, &params);
layer_tree_host_->SetRootLayer(
layer_tree_ = std::make_unique<LayerTreeHostForPaintArtifactTest>();
layer_tree_->layer_tree_host()->SetRootLayer(
GetDocument()
.View()
->GetPaintArtifactCompositorForTesting()
......@@ -82,11 +65,7 @@ class PaintAndRasterInvalidationTest : public PaintControllerPaintTest {
}
private:
cc::StubLayerTreeHostSingleThreadClient layer_tree_host_single_thread_client_;
cc::StubLayerTreeHostClient layer_tree_host_client_;
cc::TestTaskGraphRunner task_graph_runner_;
std::unique_ptr<cc::AnimationHost> animation_host_;
std::unique_ptr<cc::LayerTreeHost> layer_tree_host_;
std::unique_ptr<LayerTreeHostForPaintArtifactTest> layer_tree_;
};
} // namespace blink
......
......@@ -6,6 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_STUB_CHROME_CLIENT_FOR_SPV2_H_
#include "third_party/blink/renderer/core/loader/empty_clients.h"
#include "third_party/blink/renderer/core/paint/layer_tree_host_for_paint_artifact_test.h"
#include "third_party/blink/renderer/platform/testing/web_layer_tree_view_impl_for_testing.h"
namespace cc {
......@@ -15,23 +16,21 @@ class Layer;
namespace blink {
// A simple ChromeClient implementation which forwards painted artifacts to a
// PaintArtifactCompositor attached to a testing WebLayerTreeView, and permits
// PaintArtifactCompositor attached to a testing cc::LayerTreeHost, and permits
// simple analysis of the results.
class StubChromeClientForSPv2 : public EmptyChromeClient {
public:
StubChromeClientForSPv2() : layer_tree_view_() {}
bool HasLayer(const cc::Layer& layer) {
return layer_tree_view_.HasLayer(layer);
return layer.layer_tree_host() == layer_tree_.layer_tree_host();
}
void AttachRootLayer(scoped_refptr<cc::Layer> layer,
LocalFrame* local_root) override {
layer_tree_view_.SetRootLayer(std::move(layer));
layer_tree_.layer_tree_host()->SetRootLayer(std::move(layer));
}
private:
WebLayerTreeViewImplForTesting layer_tree_view_;
LayerTreeHostForPaintArtifactTest layer_tree_;
};
} // namespace blink
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment