Commit 96b11126 authored by Robert Flack's avatar Robert Flack Committed by Commit Bot

Fix CSSAnimationsTest unit tests when running with BGPT

A few changes were needed to get this to work in BGPT:
- Create a StubChromeClientForSPv2 so that we have a LayerTreeHost,
  without which BGPT does not create composited animations.
- Change StubChromeClientForSPv2 to tell the LayerTreeHostEmbedder to
  use layer lists when running with BGPT
- Check for filter animations as well as current filters when deciding
  if we need a filter on a given object.

Bug: 874253
Cq-Include-Trybots: luci.chromium.try:linux-blink-gen-property-trees;luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I7e057d8a225ead67728d68070e62ac62f7a33f19
Reviewed-on: https://chromium-review.googlesource.com/1230438
Commit-Queue: Robert Flack <flackr@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592144}
parent 7406241d
......@@ -7,6 +7,7 @@
#include "third_party/blink/renderer/core/animation/element_animations.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/paint/stub_chrome_client_for_spv2.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
#include "third_party/blink/renderer/platform/animation/compositor_animation_delegate.h"
......@@ -14,7 +15,7 @@ namespace blink {
class CSSAnimationsTest : public RenderingTest {
public:
CSSAnimationsTest() {
CSSAnimationsTest() : chrome_client_(new StubChromeClientForSPv2()) {
EnablePlatform();
platform()->SetThreadedAnimationEnabled(true);
}
......@@ -32,6 +33,8 @@ class CSSAnimationsTest : public RenderingTest {
platform()->RunUntilIdle();
}
ChromeClient& GetChromeClient() const override { return *chrome_client_; }
void StartAnimationOnCompositor(Animation* animation) {
static_cast<CompositorAnimationDelegate*>(animation)
->NotifyAnimationStarted(
......@@ -52,6 +55,9 @@ class CSSAnimationsTest : public RenderingTest {
return static_cast<const BasicComponentTransferFilterOperation*>(filter)
->Amount();
}
private:
Persistent<StubChromeClientForSPv2> chrome_client_;
};
// Verify that a composited animation is retargeted according to its composited
......
......@@ -888,7 +888,9 @@ void FragmentPaintPropertyTreeBuilder::UpdateLinkHighlightEffect() {
static bool NeedsFilter(const LayoutObject& object) {
// TODO(trchen): SVG caches filters in SVGResources. Implement it.
if (object.IsBoxModelObject() && ToLayoutBoxModelObject(object).Layer() &&
(object.StyleRef().HasFilter() || object.HasReflection()))
(object.StyleRef().HasFilter() || object.HasReflection() ||
CompositingReasonFinder::RequiresCompositingForFilterAnimation(
object.StyleRef())))
return true;
if (object.IsLayoutImage() && ToLayoutImage(object).ShouldInvertColor())
return true;
......
......@@ -85,8 +85,7 @@ class PaintArtifactCompositorTest : public testing::Test,
// the compositor to run and submit frames.
layer_tree_ = std::make_unique<LayerTreeHostEmbedder>(
&layer_tree_host_client_,
/*single_thread_client=*/nullptr,
/*use_layer_lists=*/true);
/*single_thread_client=*/nullptr);
layer_tree_host_client_.SetLayerTreeHost(layer_tree_->layer_tree_host());
layer_tree_->layer_tree_host()->SetRootLayer(
paint_artifact_compositor_->RootLayer());
......
......@@ -32,6 +32,7 @@ include_rules = [
"+third_party/blink/renderer/platform/network",
"+third_party/blink/renderer/platform/platform_export.h",
"+third_party/blink/renderer/platform/pod_arena.h",
"+third_party/blink/renderer/platform/runtime_enabled_features.h",
"+third_party/blink/renderer/platform/scheduler",
"+third_party/blink/renderer/platform/scroll",
"+third_party/blink/renderer/platform/shared_buffer.h",
......
......@@ -5,22 +5,23 @@
#include "third_party/blink/renderer/platform/testing/layer_tree_host_embedder.h"
#include "base/threading/thread_task_runner_handle.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink {
LayerTreeHostEmbedder::LayerTreeHostEmbedder()
: LayerTreeHostEmbedder(/*client=*/nullptr,
/*single_thread_client=*/nullptr,
/*use_layer_lists=*/false) {}
/*single_thread_client=*/nullptr) {}
LayerTreeHostEmbedder::LayerTreeHostEmbedder(
cc::LayerTreeHostClient* client,
cc::LayerTreeHostSingleThreadClient* single_thread_client,
bool use_layer_lists) {
cc::LayerTreeHostSingleThreadClient* single_thread_client) {
cc::LayerTreeSettings settings;
settings.layer_transforms_should_scale_layer_contents = true;
settings.single_thread_proxy_scheduler = false;
settings.use_layer_lists = use_layer_lists;
settings.use_layer_lists =
RuntimeEnabledFeatures::SlimmingPaintV2Enabled() ||
RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled();
animation_host_ = cc::AnimationHost::CreateMainInstance();
cc::LayerTreeHost::InitParams params;
......
......@@ -26,8 +26,7 @@ class LayerTreeHostEmbedder {
// overrides of LayerTreeSettings.
LayerTreeHostEmbedder(
cc::LayerTreeHostClient* client,
cc::LayerTreeHostSingleThreadClient* single_thread_client,
bool use_layer_lists);
cc::LayerTreeHostSingleThreadClient* single_thread_client);
cc::LayerTreeHost* layer_tree_host() { return layer_tree_host_.get(); }
cc::AnimationHost* animation_host() { return animation_host_.get(); }
......
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