summaryrefslogtreecommitdiff
path: root/chromium/ui/compositor
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-10-26 13:57:00 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-11-02 11:31:01 +0000
commit1943b3c2a1dcee36c233724fc4ee7613d71b9cf6 (patch)
tree8c1b5f12357025c197da5427ae02cfdc2f3570d6 /chromium/ui/compositor
parent21ba0c5d4bf8fba15dddd97cd693bad2358b77fd (diff)
downloadqtwebengine-chromium-1943b3c2a1dcee36c233724fc4ee7613d71b9cf6.tar.gz
BASELINE: Update Chromium to 94.0.4606.111
Change-Id: I924781584def20fc800bedf6ff41fdb96c438193 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui/compositor')
-rw-r--r--chromium/ui/compositor/DEPS2
-rw-r--r--chromium/ui/compositor/OWNERS4
-rw-r--r--chromium/ui/compositor/compositor.cc28
-rw-r--r--chromium/ui/compositor/compositor.h13
-rw-r--r--chromium/ui/compositor/compositor_lock.cc2
-rw-r--r--chromium/ui/compositor/compositor_unittest.cc58
-rw-r--r--chromium/ui/compositor/layer.cc27
-rw-r--r--chromium/ui/compositor/layer.h22
-rw-r--r--chromium/ui/compositor/layer_animator.cc2
-rw-r--r--chromium/ui/compositor/layer_owner_unittest.cc1
-rw-r--r--chromium/ui/compositor/layer_unittest.cc80
-rw-r--r--chromium/ui/compositor/overscroll/scroll_input_handler.cc2
-rw-r--r--chromium/ui/compositor/overscroll/scroll_input_handler.h1
-rw-r--r--chromium/ui/compositor/paint_cache.h1
-rw-r--r--chromium/ui/compositor/test/test_compositor_host_ozone.cc3
-rw-r--r--chromium/ui/compositor/total_animation_throughput_reporter_unittest.cc63
16 files changed, 210 insertions, 99 deletions
diff --git a/chromium/ui/compositor/DEPS b/chromium/ui/compositor/DEPS
index f9dcc8346f9..22b765ec22f 100644
--- a/chromium/ui/compositor/DEPS
+++ b/chromium/ui/compositor/DEPS
@@ -5,7 +5,7 @@ include_rules = [
"+gpu/command_buffer/client/gles2_interface.h",
"+mojo/public/cpp/bindings/pending_remote.h",
"+services/viz/privileged/mojom/compositing",
- "+skia/ext/refptr.h",
+ "+skia/ext",
"+third_party/khronos/GLES2/gl2.h",
"+third_party/skia",
"+ui/base",
diff --git a/chromium/ui/compositor/OWNERS b/chromium/ui/compositor/OWNERS
index 012d9456785..495e4c0bb89 100644
--- a/chromium/ui/compositor/OWNERS
+++ b/chromium/ui/compositor/OWNERS
@@ -3,7 +3,3 @@ flackr@chromium.org
kylechar@chromium.org
smcgruer@chromium.org
vollick@chromium.org
-
-# Animation
-per-file *animat*=ajuma@chromium.org
-per-file *animat*=loyso@chromium.org
diff --git a/chromium/ui/compositor/compositor.cc b/chromium/ui/compositor/compositor.cc
index bc4437e99ca..b6027dc5b55 100644
--- a/chromium/ui/compositor/compositor.cc
+++ b/chromium/ui/compositor/compositor.cc
@@ -185,6 +185,14 @@ Compositor::Compositor(const viz::FrameSinkId& frame_sink_id,
settings.enable_elastic_overscroll = true;
#endif
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ // Rasterized tiles must be overlay candidates to be forwarded.
+ // This is very similar to the line above for Apple.
+ if (features::IsDelegatedCompositingEnabled()) {
+ settings.resource_settings.use_gpu_memory_buffer_resources = true;
+ }
+#endif
+
settings.memory_policy.bytes_limit_when_visible = 512 * 1024 * 1024;
// Used to configure ui compositor memory limit for chromeos devices.
@@ -206,16 +214,8 @@ Compositor::Compositor(const viz::FrameSinkId& frame_sink_id,
settings.disallow_non_exact_resource_reuse =
command_line->HasSwitch(switches::kDisallowNonExactResourceReuse);
- settings.enable_impl_latency_recovery =
- features::IsImplLatencyRecoveryEnabled();
- settings.enable_main_latency_recovery =
- features::IsMainLatencyRecoveryEnabled();
-
- if (command_line->HasSwitch(switches::kRunAllCompositorStagesBeforeDraw)) {
- settings.wait_for_all_pipeline_stages_before_draw = true;
- settings.enable_impl_latency_recovery = false;
- settings.enable_main_latency_recovery = false;
- }
+ settings.wait_for_all_pipeline_stages_before_draw =
+ command_line->HasSwitch(switches::kRunAllCompositorStagesBeforeDraw);
if (base::FeatureList::IsEnabled(
features::kCompositorThreadedScrollbarScrolling)) {
@@ -372,7 +372,7 @@ cc::AnimationTimeline* Compositor::GetAnimationTimeline() const {
return animation_timeline_.get();
}
-void Compositor::SetDisplayColorMatrix(const SkMatrix44& matrix) {
+void Compositor::SetDisplayColorMatrix(const skia::Matrix44& matrix) {
display_color_matrix_ = matrix;
if (display_private_)
display_private_->SetDisplayColorMatrix(gfx::Transform(matrix));
@@ -654,8 +654,10 @@ void Compositor::BeginMainFrameNotExpectedUntil(base::TimeTicks time) {}
static void SendDamagedRectsRecursive(ui::Layer* layer) {
layer->SendDamagedRects();
- for (auto* child : layer->children())
- SendDamagedRectsRecursive(child);
+ // Iterate using the size for the case of mutation during sending damaged
+ // regions. https://crbug.com/1242257.
+ for (size_t i = 0; i < layer->children().size(); ++i)
+ SendDamagedRectsRecursive(layer->children()[i]);
}
void Compositor::UpdateLayerTreeHost() {
diff --git a/chromium/ui/compositor/compositor.h b/chromium/ui/compositor/compositor.h
index fe4e33a6208..dfb0c89dc7b 100644
--- a/chromium/ui/compositor/compositor.h
+++ b/chromium/ui/compositor/compositor.h
@@ -8,7 +8,7 @@
#include <stdint.h>
#include <memory>
-#include <string>
+#include <unordered_set>
#include "base/callback_forward.h"
#include "base/containers/flat_map.h"
@@ -25,14 +25,15 @@
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_host_client.h"
#include "cc/trees/layer_tree_host_single_thread_client.h"
+#include "cc/trees/paint_holding_reason.h"
#include "components/viz/common/frame_sinks/begin_frame_args.h"
#include "components/viz/common/surfaces/frame_sink_id.h"
#include "components/viz/common/surfaces/subtree_capture_id.h"
#include "components/viz/host/host_frame_sink_client.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/viz/privileged/mojom/compositing/vsync_parameter_observer.mojom-forward.h"
+#include "skia/ext/skia_matrix_44.h"
#include "third_party/skia/include/core/SkColor.h"
-#include "third_party/skia/include/core/SkMatrix44.h"
#include "ui/compositor/compositor_animation_observer.h"
#include "ui/compositor/compositor_export.h"
#include "ui/compositor/compositor_lock.h"
@@ -188,10 +189,10 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
// Gets and sets the color matrix used to transform the output colors of what
// this compositor renders.
- const SkMatrix44& display_color_matrix() const {
+ const skia::Matrix44& display_color_matrix() const {
return display_color_matrix_;
}
- void SetDisplayColorMatrix(const SkMatrix44& matrix);
+ void SetDisplayColorMatrix(const skia::Matrix44& matrix);
// Where possible, draws are scissored to a damage region calculated from
// changes to layer properties. This bypasses that and indicates that
@@ -321,7 +322,7 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
void WillBeginMainFrame() override {}
void DidBeginMainFrame() override {}
void OnDeferMainFrameUpdatesChanged(bool) override {}
- void OnDeferCommitsChanged(bool) override {}
+ void OnDeferCommitsChanged(bool, cc::PaintHoldingReason) override {}
void WillUpdateLayers() override {}
void DidUpdateLayers() override;
void BeginMainFrame(const viz::BeginFrameArgs& args) override;
@@ -484,7 +485,7 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
scoped_refptr<cc::AnimationTimeline> animation_timeline_;
std::unique_ptr<ScopedAnimationDurationScaleMode> slow_animations_;
- SkMatrix44 display_color_matrix_;
+ skia::Matrix44 display_color_matrix_;
gfx::DisplayColorSpaces display_color_spaces_;
bool output_is_secure_ = false;
diff --git a/chromium/ui/compositor/compositor_lock.cc b/chromium/ui/compositor/compositor_lock.cc
index 58642890508..bd6f59a25be 100644
--- a/chromium/ui/compositor/compositor_lock.cc
+++ b/chromium/ui/compositor/compositor_lock.cc
@@ -5,7 +5,7 @@
#include "ui/compositor/compositor_lock.h"
#include "base/bind.h"
-#include "base/stl_util.h"
+#include "base/containers/cxx20_erase.h"
#include "cc/trees/layer_tree_host.h"
namespace ui {
diff --git a/chromium/ui/compositor/compositor_unittest.cc b/chromium/ui/compositor/compositor_unittest.cc
index 7e3faff7a9b..05d31d7498f 100644
--- a/chromium/ui/compositor/compositor_unittest.cc
+++ b/chromium/ui/compositor/compositor_unittest.cc
@@ -12,12 +12,14 @@
#include "base/test/test_mock_time_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
+#include "build/build_config.h"
#include "cc/metrics/frame_sequence_tracker.h"
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
+#include "ui/compositor/layer_delegate.h"
#include "ui/compositor/test/draw_waiter_for_test.h"
#include "ui/compositor/test/in_process_context_factory.h"
#include "ui/compositor/test/test_context_factories.h"
@@ -111,7 +113,7 @@ TEST_F(CompositorTestWithMessageLoop, ShouldUpdateDisplayProperties) {
// Set a non-identity color matrix, color space, sdr white level, vsync
// timebase and vsync interval, and expect it to be set on the context
// factory.
- SkMatrix44 color_matrix(SkMatrix44::kIdentity_Constructor);
+ skia::Matrix44 color_matrix(skia::Matrix44::kIdentity_Constructor);
color_matrix.set(1, 1, 0.7f);
color_matrix.set(2, 2, 0.4f);
gfx::DisplayColorSpaces display_color_spaces(
@@ -388,4 +390,58 @@ TEST_F(CompositorTestWithMessageLoop, MAYBE_CreateAndReleaseOutputSurface) {
compositor()->SetRootLayer(nullptr);
}
+class LayerDelegateThatAddsDuringUpdateVisualState : public LayerDelegate {
+ public:
+ explicit LayerDelegateThatAddsDuringUpdateVisualState(Layer* parent)
+ : parent_(parent) {}
+
+ bool update_visual_state_called() const {
+ return update_visual_state_called_;
+ }
+
+ // LayerDelegate:
+ void UpdateVisualState() override {
+ added_layers_.push_back(std::make_unique<Layer>(ui::LAYER_SOLID_COLOR));
+ parent_->Add(added_layers_.back().get());
+ update_visual_state_called_ = true;
+ }
+ void OnPaintLayer(const PaintContext& context) override {}
+ void OnDeviceScaleFactorChanged(float old_device_scale_factor,
+ float new_device_scale_factor) override {}
+
+ private:
+ Layer* parent_;
+ std::vector<std::unique_ptr<Layer>> added_layers_;
+ bool update_visual_state_called_ = false;
+};
+
+TEST_F(CompositorTestWithMessageLoop, AddLayerDuringUpdateVisualState) {
+ std::unique_ptr<Layer> root_layer =
+ std::make_unique<Layer>(ui::LAYER_SOLID_COLOR);
+ std::unique_ptr<Layer> child_layer =
+ std::make_unique<Layer>(ui::LAYER_TEXTURED);
+ std::unique_ptr<Layer> child_layer2 =
+ std::make_unique<Layer>(ui::LAYER_SOLID_COLOR);
+ LayerDelegateThatAddsDuringUpdateVisualState child_layer_delegate(
+ root_layer.get());
+ child_layer->set_delegate(&child_layer_delegate);
+ root_layer->Add(child_layer.get());
+ root_layer->Add(child_layer2.get());
+
+ viz::ParentLocalSurfaceIdAllocator allocator;
+ allocator.GenerateId();
+ root_layer->SetBounds(gfx::Rect(10, 10));
+ compositor()->SetRootLayer(root_layer.get());
+ compositor()->SetScaleAndSize(1.0f, gfx::Size(10, 10),
+ allocator.GetCurrentLocalSurfaceId());
+ ASSERT_TRUE(compositor()->IsVisible());
+ compositor()->ScheduleDraw();
+ DrawWaiterForTest::WaitForCompositingEnded(compositor());
+ EXPECT_TRUE(child_layer_delegate.update_visual_state_called());
+ compositor()->SetRootLayer(nullptr);
+ child_layer2.reset();
+ child_layer.reset();
+ root_layer.reset();
+}
+
} // namespace ui
diff --git a/chromium/ui/compositor/layer.cc b/chromium/ui/compositor/layer.cc
index a869508f757..ee9f8cdae90 100644
--- a/chromium/ui/compositor/layer.cc
+++ b/chromium/ui/compositor/layer.cc
@@ -15,7 +15,6 @@
#include "base/command_line.h"
#include "base/json/json_writer.h"
#include "base/memory/ptr_util.h"
-#include "base/numerics/ranges.h"
#include "base/trace_event/trace_event.h"
#include "cc/layers/mirror_layer.h"
#include "cc/layers/nine_patch_layer.h"
@@ -30,6 +29,7 @@
#include "components/viz/common/resources/transferable_resource.h"
#include "ui/compositor/compositor_switches.h"
#include "ui/compositor/layer_animator.h"
+#include "ui/compositor/layer_delegate.h"
#include "ui/compositor/layer_observer.h"
#include "ui/compositor/paint_context.h"
#include "ui/gfx/animation/animation.h"
@@ -38,8 +38,10 @@
#include "ui/gfx/geometry/point3_f.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/rect_conversions.h"
+#include "ui/gfx/geometry/rounded_corners_f.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/interpolated_transform.h"
+#include "ui/gfx/transform.h"
namespace ui {
namespace {
@@ -75,6 +77,9 @@ class Layer::LayerMirror : public LayerDelegate, LayerObserver {
dest->set_delegate(this);
}
+ LayerMirror(const LayerMirror&) = delete;
+ LayerMirror& operator=(const LayerMirror&) = delete;
+
~LayerMirror() override {
dest_->RemoveObserver(this);
dest_->set_delegate(nullptr);
@@ -99,8 +104,6 @@ class Layer::LayerMirror : public LayerDelegate, LayerObserver {
private:
Layer* const source_;
Layer* const dest_;
-
- DISALLOW_COPY_AND_ASSIGN(LayerMirror);
};
// Manages the subpixel offset data for a given set of parameters (device
@@ -108,6 +111,9 @@ class Layer::LayerMirror : public LayerDelegate, LayerObserver {
class Layer::SubpixelPositionOffsetCache {
public:
SubpixelPositionOffsetCache() = default;
+ SubpixelPositionOffsetCache(const SubpixelPositionOffsetCache&) = delete;
+ SubpixelPositionOffsetCache& operator=(const SubpixelPositionOffsetCache&) =
+ delete;
~SubpixelPositionOffsetCache() = default;
gfx::Vector2dF GetSubpixelOffset(float device_scale_factor,
@@ -173,8 +179,6 @@ class Layer::SubpixelPositionOffsetCache {
// True if the subpixel offset was computed and set by an external source.
bool has_explicit_subpixel_offset_ = false;
-
- DISALLOW_COPY_AND_ASSIGN(SubpixelPositionOffsetCache);
};
Layer::Layer(LayerType type)
@@ -391,7 +395,7 @@ void Layer::Remove(Layer* child) {
// Stop (and complete) an ongoing animation to update the bounds immediately.
LayerAnimator* child_animator = child->animator_.get();
if (child_animator)
- child_animator->StopAnimatingProperty(ui::LayerAnimationElement::BOUNDS);
+ child_animator->StopAnimatingProperty(LayerAnimationElement::BOUNDS);
// Do not proceed if |this| or |child| is released by an animation observer
// of |child|'s bounds animation.
@@ -836,7 +840,7 @@ bool Layer::SwitchCCLayerForTest() {
}
// Note: The code that sets this flag would be responsible to unset it on that
-// ui::Layer. We do not want to clone this flag to a cloned layer by accident,
+// Layer. We do not want to clone this flag to a cloned layer by accident,
// which could be a supprise. But we want to preserve it after switching to a
// new cc::Layer. There could be a whole subtree and the root changed, but does
// not mean we want to treat the cache all different.
@@ -879,7 +883,7 @@ void Layer::RemoveDeferredPaintRequest() {
}
// Note: The code that sets this flag would be responsible to unset it on that
-// ui::Layer. We do not want to clone this flag to a cloned layer by accident,
+// Layer. We do not want to clone this flag to a cloned layer by accident,
// which could be a supprise. But we want to preserve it after switching to a
// new cc::Layer. There could be a whole subtree and the root changed, but does
// not mean we want to treat the trilinear filtering all different.
@@ -1298,8 +1302,9 @@ void Layer::SetScrollOffset(const gfx::ScrollOffset& offset) {
if (!scrolled_on_impl_side)
cc_layer_->SetScrollOffset(offset);
- DCHECK_EQ(offset.x(), CurrentScrollOffset().x());
- DCHECK_EQ(offset.y(), CurrentScrollOffset().y());
+ // TODO(crbug.com/1219662): If this layer was also resized since the last
+ // commit synchronizing |cc_layer_| with the cc::LayerImpl backing
+ // |compositor|, the scroll might not be completed.
}
void Layer::RequestCopyOfOutput(
@@ -1582,7 +1587,7 @@ float Layer::GetRefreshRate() const {
return compositor ? compositor->refresh_rate() : 60.0;
}
-ui::Layer* Layer::GetLayer() {
+Layer* Layer::GetLayer() {
return this;
}
diff --git a/chromium/ui/compositor/layer.h b/chromium/ui/compositor/layer.h
index f572b6f720f..3711fd74a8d 100644
--- a/chromium/ui/compositor/layer.h
+++ b/chromium/ui/compositor/layer.h
@@ -12,10 +12,7 @@
#include <string>
#include <vector>
-#include "base/compiler_specific.h"
-#include "base/containers/flat_set.h"
-#include "base/macros.h"
-#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "cc/base/region.h"
@@ -27,12 +24,9 @@
#include "third_party/skia/include/core/SkColor.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer_animation_delegate.h"
-#include "ui/compositor/layer_delegate.h"
#include "ui/compositor/layer_type.h"
#include "ui/gfx/geometry/rect.h"
-#include "ui/gfx/geometry/rounded_corners_f.h"
#include "ui/gfx/image/image_skia.h"
-#include "ui/gfx/transform.h"
namespace cc {
class Layer;
@@ -43,6 +37,11 @@ class SurfaceLayer;
class TextureLayer;
}
+namespace gfx {
+class RoundedCornersF;
+class Transform;
+} // namespace gfx
+
namespace viz {
class CopyOutputRequest;
struct TransferableResource;
@@ -52,6 +51,7 @@ namespace ui {
class Compositor;
class LayerAnimator;
+class LayerDelegate;
class LayerObserver;
class LayerOwner;
class LayerThreadedAnimationDelegate;
@@ -72,6 +72,8 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimationDelegate,
public:
using ShapeRects = std::vector<gfx::Rect>;
explicit Layer(LayerType type = LAYER_TEXTURED);
+ Layer(const Layer&) = delete;
+ Layer& operator=(const Layer&) = delete;
~Layer() override;
// Note that only solid color and surface content is copied.
@@ -191,8 +193,6 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimationDelegate,
void SetTransform(const gfx::Transform& transform);
const gfx::Transform& transform() const { return cc_layer_->transform(); }
- gfx::PointF position() const { return cc_layer_->position(); }
-
// Return the target transform if animator is running, or the current
// transform otherwise.
gfx::Transform GetTargetTransform() const;
@@ -588,7 +588,7 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimationDelegate,
gfx::Rect GetClipRectForAnimation() const override;
gfx::RoundedCornersF GetRoundedCornersForAnimation() const override;
float GetDeviceScaleFactor() const override;
- ui::Layer* GetLayer() override;
+ Layer* GetLayer() override;
cc::Layer* GetCcLayer() const override;
LayerThreadedAnimationDelegate* GetThreadedAnimationDelegate() override;
LayerAnimatorCollection* GetLayerAnimatorCollection() override;
@@ -787,8 +787,6 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimationDelegate,
#endif
base::WeakPtrFactory<Layer> weak_ptr_factory_{this};
-
- DISALLOW_COPY_AND_ASSIGN(Layer);
};
} // namespace ui
diff --git a/chromium/ui/compositor/layer_animator.cc b/chromium/ui/compositor/layer_animator.cc
index a5795296ca1..0d78bab2802 100644
--- a/chromium/ui/compositor/layer_animator.cc
+++ b/chromium/ui/compositor/layer_animator.cc
@@ -9,7 +9,7 @@
#include <memory>
#include "base/check_op.h"
-#include "base/stl_util.h"
+#include "base/containers/cxx20_erase.h"
#include "base/trace_event/trace_event.h"
#include "cc/animation/animation.h"
#include "cc/animation/animation_host.h"
diff --git a/chromium/ui/compositor/layer_owner_unittest.cc b/chromium/ui/compositor/layer_owner_unittest.cc
index 65ec66814f7..feadd35d31a 100644
--- a/chromium/ui/compositor/layer_owner_unittest.cc
+++ b/chromium/ui/compositor/layer_owner_unittest.cc
@@ -14,6 +14,7 @@
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/layer_animator.h"
+#include "ui/compositor/layer_delegate.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/compositor/test/test_context_factories.h"
diff --git a/chromium/ui/compositor/layer_unittest.cc b/chromium/ui/compositor/layer_unittest.cc
index 4169b58ae4c..e4f3b926bfd 100644
--- a/chromium/ui/compositor/layer_unittest.cc
+++ b/chromium/ui/compositor/layer_unittest.cc
@@ -23,7 +23,9 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
+#include "base/test/scoped_run_loop_timeout.h"
#include "base/test/task_environment.h"
+#include "base/test/test_timeouts.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
@@ -49,6 +51,7 @@
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/layer_animation_sequence.h"
#include "ui/compositor/layer_animator.h"
+#include "ui/compositor/layer_delegate.h"
#include "ui/compositor/paint_context.h"
#include "ui/compositor/paint_recorder.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
@@ -105,8 +108,7 @@ class ColoredLayer : public Layer, public LayerDelegate {
SkColor color_;
};
-// Param specifies whether to use SkiaRenderer or not
-class LayerWithRealCompositorTest : public testing::TestWithParam<bool> {
+class LayerWithRealCompositorTest : public testing::Test {
public:
LayerWithRealCompositorTest()
: task_environment_(base::test::TaskEnvironment::MainThreadType::UI),
@@ -125,7 +127,7 @@ class LayerWithRealCompositorTest : public testing::TestWithParam<bool> {
const bool enable_pixel_output = true;
context_factories_ =
- std::make_unique<TestContextFactories>(enable_pixel_output, GetParam());
+ std::make_unique<TestContextFactories>(enable_pixel_output);
const gfx::Rect host_bounds(10, 10, 500, 500);
compositor_host_.reset(TestCompositorHost::Create(
@@ -175,7 +177,8 @@ class LayerWithRealCompositorTest : public testing::TestWithParam<bool> {
scoped_refptr<ReadbackHolder> holder(new ReadbackHolder);
std::unique_ptr<viz::CopyOutputRequest> request =
std::make_unique<viz::CopyOutputRequest>(
- viz::CopyOutputRequest::ResultFormat::RGBA_BITMAP,
+ viz::CopyOutputRequest::ResultFormat::RGBA,
+ viz::CopyOutputRequest::ResultDestination::kSystemMemory,
base::BindOnce(&ReadbackHolder::OutputRequestCallback, holder));
request->set_area(source_rect);
@@ -451,9 +454,7 @@ class TestCallbackAnimationObserver : public ImplicitAnimationObserver {
} // namespace
-INSTANTIATE_TEST_SUITE_P(All, LayerWithRealCompositorTest, ::testing::Bool());
-
-TEST_P(LayerWithRealCompositorTest, Draw) {
+TEST_F(LayerWithRealCompositorTest, Draw) {
std::unique_ptr<Layer> layer =
CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 50, 50));
DrawTree(layer.get());
@@ -465,7 +466,7 @@ TEST_P(LayerWithRealCompositorTest, Draw) {
// | +-- L3 - yellow
// +-- L4 - magenta
//
-TEST_P(LayerWithRealCompositorTest, Hierarchy) {
+TEST_F(LayerWithRealCompositorTest, Hierarchy) {
std::unique_ptr<Layer> l1 =
CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 400, 400));
std::unique_ptr<Layer> l2 =
@@ -627,7 +628,7 @@ TEST_F(LayerWithDelegateTest, ConvertPointToLayer_Medium) {
EXPECT_EQ(point2_in_l3_coords, point2_in_l1_coords);
}
-TEST_P(LayerWithRealCompositorTest, Delegate) {
+TEST_F(LayerWithRealCompositorTest, Delegate) {
// This test makes sure that whenever paint happens at a layer, its layer
// delegate gets the paint, which in this test update its color and
// |color_index|.
@@ -659,7 +660,7 @@ TEST_P(LayerWithRealCompositorTest, Delegate) {
EXPECT_EQ(0, delegate.color_index());
}
-TEST_P(LayerWithRealCompositorTest, DrawTree) {
+TEST_F(LayerWithRealCompositorTest, DrawTree) {
std::unique_ptr<Layer> l1 =
CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 400, 400));
std::unique_ptr<Layer> l2 =
@@ -687,7 +688,7 @@ TEST_P(LayerWithRealCompositorTest, DrawTree) {
}
// Tests that scheduling paint on a layer with a mask updates the mask.
-TEST_P(LayerWithRealCompositorTest, SchedulePaintUpdatesMask) {
+TEST_F(LayerWithRealCompositorTest, SchedulePaintUpdatesMask) {
std::unique_ptr<Layer> layer =
CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 400, 400));
std::unique_ptr<Layer> mask_layer = CreateLayer(ui::LAYER_TEXTURED);
@@ -715,7 +716,7 @@ TEST_P(LayerWithRealCompositorTest, SchedulePaintUpdatesMask) {
// | +-- L3 - yellow
// +-- L4 - magenta
//
-TEST_P(LayerWithRealCompositorTest, HierarchyNoTexture) {
+TEST_F(LayerWithRealCompositorTest, HierarchyNoTexture) {
std::unique_ptr<Layer> l1 =
CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 400, 400));
std::unique_ptr<Layer> l2 = CreateNoTextureLayer(gfx::Rect(10, 10, 350, 350));
@@ -1601,7 +1602,7 @@ void ExpectRgba(int x, int y, SkColor expected_color, SkColor actual_color) {
}
// Checks that pixels are actually drawn to the screen with a read back.
-TEST_P(LayerWithRealCompositorTest, DrawPixels) {
+TEST_F(LayerWithRealCompositorTest, DrawPixels) {
gfx::Size viewport_size = GetCompositor()->size();
// The window should be some non-trivial size but may not be exactly
@@ -1635,7 +1636,7 @@ TEST_P(LayerWithRealCompositorTest, DrawPixels) {
// Checks that drawing a layer with transparent pixels is blended correctly
// with the lower layer.
-TEST_P(LayerWithRealCompositorTest, DrawAlphaBlendedPixels) {
+TEST_F(LayerWithRealCompositorTest, DrawAlphaBlendedPixels) {
gfx::Size viewport_size = GetCompositor()->size();
int test_size = 200;
@@ -1671,7 +1672,7 @@ TEST_P(LayerWithRealCompositorTest, DrawAlphaBlendedPixels) {
// Checks that using the AlphaShape filter applied to a layer with
// transparency, alpha-blends properly with the layer below.
-TEST_P(LayerWithRealCompositorTest, DrawAlphaThresholdFilterPixels) {
+TEST_F(LayerWithRealCompositorTest, DrawAlphaThresholdFilterPixels) {
gfx::Size viewport_size = GetCompositor()->size();
int test_size = 200;
@@ -1711,7 +1712,7 @@ TEST_P(LayerWithRealCompositorTest, DrawAlphaThresholdFilterPixels) {
}
// Checks the logic around Compositor::SetRootLayer and Layer::SetCompositor.
-TEST_P(LayerWithRealCompositorTest, SetRootLayer) {
+TEST_F(LayerWithRealCompositorTest, SetRootLayer) {
Compositor* compositor = GetCompositor();
std::unique_ptr<Layer> l1 =
CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 400, 400));
@@ -1750,7 +1751,7 @@ TEST_P(LayerWithRealCompositorTest, SetRootLayer) {
#else
#define MAYBE_CompositorObservers CompositorObservers
#endif
-TEST_P(LayerWithRealCompositorTest, MAYBE_CompositorObservers) {
+TEST_F(LayerWithRealCompositorTest, MAYBE_CompositorObservers) {
std::unique_ptr<Layer> l1 =
CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 400, 400));
std::unique_ptr<Layer> l2 =
@@ -1815,7 +1816,7 @@ TEST_P(LayerWithRealCompositorTest, MAYBE_CompositorObservers) {
}
// Checks that modifying the hierarchy correctly affects final composite.
-TEST_P(LayerWithRealCompositorTest, ModifyHierarchy) {
+TEST_F(LayerWithRealCompositorTest, ModifyHierarchy) {
viz::ParentLocalSurfaceIdAllocator allocator;
allocator.GenerateId();
GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(50, 50),
@@ -1884,13 +1885,12 @@ TEST_P(LayerWithRealCompositorTest, ModifyHierarchy) {
}
// Checks that basic background blur is working.
-// TODO(crbug.com/1174372) Flaky on Windows
-#if defined(OS_WIN)
-#define MAYBE_BackgroundBlur DISABLED_BackgroundBlur
-#else
-#define MAYBE_BackgroundBlur BackgroundBlur
+TEST_F(LayerWithRealCompositorTest, BackgroundBlur) {
+#if defined(THREAD_SANITIZER)
+ const base::test::ScopedRunLoopTimeout increased_run_timeout(
+ FROM_HERE, TestTimeouts::action_max_timeout());
#endif
-TEST_P(LayerWithRealCompositorTest, MAYBE_BackgroundBlur) {
+
viz::ParentLocalSurfaceIdAllocator allocator;
allocator.GenerateId();
GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(200, 200),
@@ -1933,7 +1933,7 @@ TEST_P(LayerWithRealCompositorTest, MAYBE_BackgroundBlur) {
// Checks that background blur bounds rect gets properly updated when device
// scale changes.
-TEST_P(LayerWithRealCompositorTest, BackgroundBlurChangeDeviceScale) {
+TEST_F(LayerWithRealCompositorTest, BackgroundBlurChangeDeviceScale) {
viz::ParentLocalSurfaceIdAllocator allocator;
allocator.GenerateId();
GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(200, 200),
@@ -1981,7 +1981,7 @@ TEST_P(LayerWithRealCompositorTest, BackgroundBlurChangeDeviceScale) {
// Opacity is rendered correctly.
// Checks that modifying the hierarchy correctly affects final composite.
-TEST_P(LayerWithRealCompositorTest, Opacity) {
+TEST_F(LayerWithRealCompositorTest, Opacity) {
viz::ParentLocalSurfaceIdAllocator allocator;
allocator.GenerateId();
GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(50, 50),
@@ -2086,7 +2086,7 @@ TEST_F(LayerWithDelegateTest, SchedulePaintFromOnPaintLayer) {
gfx::Rect(10, 10, 30, 30)));
}
-TEST_P(LayerWithRealCompositorTest, ScaleUpDown) {
+TEST_F(LayerWithRealCompositorTest, ScaleUpDown) {
std::unique_ptr<Layer> root =
CreateColorLayer(SK_ColorWHITE, gfx::Rect(10, 20, 200, 220));
TestLayerDelegate root_delegate;
@@ -2163,7 +2163,7 @@ TEST_P(LayerWithRealCompositorTest, ScaleUpDown) {
EXPECT_EQ(0.0f, l1_delegate.device_scale_factor());
}
-TEST_P(LayerWithRealCompositorTest, ScaleReparent) {
+TEST_F(LayerWithRealCompositorTest, ScaleReparent) {
viz::ParentLocalSurfaceIdAllocator allocator;
allocator.GenerateId();
std::unique_ptr<Layer> root =
@@ -2389,7 +2389,7 @@ TEST_F(LayerWithDelegateTest, LayerFiltersSurvival) {
}
// Tests Layer::AddThreadedAnimation and Layer::RemoveThreadedAnimation.
-TEST_P(LayerWithRealCompositorTest, AddRemoveThreadedAnimations) {
+TEST_F(LayerWithRealCompositorTest, AddRemoveThreadedAnimations) {
std::unique_ptr<Layer> root = CreateLayer(LAYER_TEXTURED);
std::unique_ptr<Layer> l1 = CreateLayer(LAYER_TEXTURED);
std::unique_ptr<Layer> l2 = CreateLayer(LAYER_TEXTURED);
@@ -2438,7 +2438,7 @@ TEST_P(LayerWithRealCompositorTest, AddRemoveThreadedAnimations) {
// Tests that in-progress threaded animations complete when a Layer's
// cc::Layer changes.
-TEST_P(LayerWithRealCompositorTest, SwitchCCLayerAnimations) {
+TEST_F(LayerWithRealCompositorTest, SwitchCCLayerAnimations) {
std::unique_ptr<Layer> root = CreateLayer(LAYER_TEXTURED);
std::unique_ptr<Layer> l1 = CreateLayer(LAYER_TEXTURED);
GetCompositor()->SetRootLayer(root.get());
@@ -2460,7 +2460,7 @@ TEST_P(LayerWithRealCompositorTest, SwitchCCLayerAnimations) {
// Tests that when a LAYER_SOLID_COLOR has its CC layer switched, that
// opaqueness and color set while not animating, are maintained.
-TEST_P(LayerWithRealCompositorTest, SwitchCCLayerSolidColorNotAnimating) {
+TEST_F(LayerWithRealCompositorTest, SwitchCCLayerSolidColorNotAnimating) {
SkColor transparent = SK_ColorTRANSPARENT;
std::unique_ptr<Layer> root = CreateLayer(LAYER_SOLID_COLOR);
GetCompositor()->SetRootLayer(root.get());
@@ -2486,7 +2486,7 @@ TEST_P(LayerWithRealCompositorTest, SwitchCCLayerSolidColorNotAnimating) {
// Tests that when a LAYER_SOLID_COLOR has its CC layer switched during an
// animation of its opaquness and color, that both the current values, and the
// targets are maintained.
-TEST_P(LayerWithRealCompositorTest, SwitchCCLayerSolidColorWhileAnimating) {
+TEST_F(LayerWithRealCompositorTest, SwitchCCLayerSolidColorWhileAnimating) {
SkColor transparent = SK_ColorTRANSPARENT;
std::unique_ptr<Layer> root = CreateLayer(LAYER_SOLID_COLOR);
GetCompositor()->SetRootLayer(root.get());
@@ -2531,7 +2531,7 @@ TEST_P(LayerWithRealCompositorTest, SwitchCCLayerSolidColorWhileAnimating) {
// Tests that when a layer with cache_render_surface flag has its CC layer
// switched, that the cache_render_surface flag is maintained.
-TEST_P(LayerWithRealCompositorTest, SwitchCCLayerCacheRenderSurface) {
+TEST_F(LayerWithRealCompositorTest, SwitchCCLayerCacheRenderSurface) {
std::unique_ptr<Layer> root = CreateLayer(LAYER_TEXTURED);
std::unique_ptr<Layer> l1 = CreateLayer(LAYER_TEXTURED);
GetCompositor()->SetRootLayer(root.get());
@@ -2548,7 +2548,7 @@ TEST_P(LayerWithRealCompositorTest, SwitchCCLayerCacheRenderSurface) {
// Tests that when a layer with trilinear_filtering flag has its CC layer
// switched, that the trilinear_filtering flag is maintained.
-TEST_P(LayerWithRealCompositorTest, SwitchCCLayerTrilinearFiltering) {
+TEST_F(LayerWithRealCompositorTest, SwitchCCLayerTrilinearFiltering) {
std::unique_ptr<Layer> root = CreateLayer(LAYER_TEXTURED);
std::unique_ptr<Layer> l1 = CreateLayer(LAYER_TEXTURED);
GetCompositor()->SetRootLayer(root.get());
@@ -2565,7 +2565,7 @@ TEST_P(LayerWithRealCompositorTest, SwitchCCLayerTrilinearFiltering) {
// Tests that when a layer with masks_to_bounds flag has its CC layer switched,
// that the masks_to_bounds flag is maintained.
-TEST_P(LayerWithRealCompositorTest, SwitchCCLayerMasksToBounds) {
+TEST_F(LayerWithRealCompositorTest, SwitchCCLayerMasksToBounds) {
std::unique_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
std::unique_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED));
GetCompositor()->SetRootLayer(root.get());
@@ -2583,7 +2583,7 @@ TEST_P(LayerWithRealCompositorTest, SwitchCCLayerMasksToBounds) {
// Tests that no crash happens when switching cc layer with an animation
// observer that deletes the layer itself.
-TEST_P(LayerWithRealCompositorTest, SwitchCCLayerDeleteLayer) {
+TEST_F(LayerWithRealCompositorTest, SwitchCCLayerDeleteLayer) {
std::unique_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
std::unique_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED));
GetCompositor()->SetRootLayer(root.get());
@@ -2611,7 +2611,7 @@ TEST_P(LayerWithRealCompositorTest, SwitchCCLayerDeleteLayer) {
// transform animation, may cause a crash. This is because an animation observer
// may mutate the tree, e.g. deleting a layer, changing ancestor z-order etc,
// which breaks the tree traversal and might lead to a use-after-free seg fault.
-TEST_P(LayerWithRealCompositorTest, TreeMutationDuringScaleFactorChange) {
+TEST_F(LayerWithRealCompositorTest, TreeMutationDuringScaleFactorChange) {
TestCallbackAnimationObserver animation_observer;
std::unique_ptr<Layer> root = CreateLayer(LAYER_SOLID_COLOR);
@@ -2713,7 +2713,7 @@ TEST_P(LayerWithRealCompositorTest, TreeMutationDuringScaleFactorChange) {
// Tests that no crash when parent/child layer is released by an animation
// observer of the child layer bounds animation.
-TEST_P(LayerWithRealCompositorTest, ParentOrChildGoneDuringRemove) {
+TEST_F(LayerWithRealCompositorTest, ParentOrChildGoneDuringRemove) {
std::unique_ptr<Layer> root = CreateLayer(LAYER_SOLID_COLOR);
GetCompositor()->SetRootLayer(root.get());
root->SetBounds(gfx::Rect(0, 0, 100, 100));
@@ -2878,7 +2878,7 @@ std::string Vector2dFTo100thPrecisionString(const gfx::Vector2dF& vector) {
} // namespace
-TEST_P(LayerWithRealCompositorTest, SnapLayerToPixels) {
+TEST_F(LayerWithRealCompositorTest, SnapLayerToPixels) {
std::unique_ptr<Layer> root = CreateLayer(LAYER_TEXTURED);
std::unique_ptr<Layer> c1 = CreateLayer(LAYER_TEXTURED);
std::unique_ptr<Layer> c11 = CreateLayer(LAYER_TEXTURED);
@@ -3244,7 +3244,7 @@ TEST(LayerDelegateTest, OnLayerAlphaShapeChanged) {
testing::Mock::VerifyAndClear(&delegate);
}
-TEST_P(LayerWithRealCompositorTest, CompositorAnimationObserverTest) {
+TEST_F(LayerWithRealCompositorTest, CompositorAnimationObserverTest) {
std::unique_ptr<Layer> root = CreateLayer(LAYER_TEXTURED);
root->SetAnimator(LayerAnimator::CreateImplicitAnimator());
diff --git a/chromium/ui/compositor/overscroll/scroll_input_handler.cc b/chromium/ui/compositor/overscroll/scroll_input_handler.cc
index 15f1a6a0250..e5acb171682 100644
--- a/chromium/ui/compositor/overscroll/scroll_input_handler.cc
+++ b/chromium/ui/compositor/overscroll/scroll_input_handler.cc
@@ -88,6 +88,8 @@ void ScrollInputHandler::Animate(base::TimeTicks time) {}
void ScrollInputHandler::ReconcileElasticOverscrollAndRootScroll() {}
+void ScrollInputHandler::SetPrefersReducedMotion(bool prefers_reduced_motion) {}
+
void ScrollInputHandler::UpdateRootLayerStateForSynchronousInputHandler(
const gfx::ScrollOffset& total_scroll_offset,
const gfx::ScrollOffset& max_scroll_offset,
diff --git a/chromium/ui/compositor/overscroll/scroll_input_handler.h b/chromium/ui/compositor/overscroll/scroll_input_handler.h
index d5c750be480..57b84ec2d0b 100644
--- a/chromium/ui/compositor/overscroll/scroll_input_handler.h
+++ b/chromium/ui/compositor/overscroll/scroll_input_handler.h
@@ -29,6 +29,7 @@ class COMPOSITOR_EXPORT ScrollInputHandler : public cc::InputHandlerClient {
void WillShutdown() override;
void Animate(base::TimeTicks time) override;
void ReconcileElasticOverscrollAndRootScroll() override;
+ void SetPrefersReducedMotion(bool prefers_reduced_motion) override;
void UpdateRootLayerStateForSynchronousInputHandler(
const gfx::ScrollOffset& total_scroll_offset,
const gfx::ScrollOffset& max_scroll_offset,
diff --git a/chromium/ui/compositor/paint_cache.h b/chromium/ui/compositor/paint_cache.h
index 2d2fb14b577..feb73a42c9f 100644
--- a/chromium/ui/compositor/paint_cache.h
+++ b/chromium/ui/compositor/paint_cache.h
@@ -6,7 +6,6 @@
#define UI_COMPOSITOR_PAINT_CACHE_H_
#include "base/macros.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "ui/compositor/compositor_export.h"
#include "ui/gfx/geometry/rect.h"
diff --git a/chromium/ui/compositor/test/test_compositor_host_ozone.cc b/chromium/ui/compositor/test/test_compositor_host_ozone.cc
index ac0cbf92b78..54360911462 100644
--- a/chromium/ui/compositor/test/test_compositor_host_ozone.cc
+++ b/chromium/ui/compositor/test/test_compositor_host_ozone.cc
@@ -41,7 +41,8 @@ class TestCompositorHostOzone::StubPlatformWindowDelegate
void DispatchEvent(Event* event) override {}
void OnCloseRequest() override {}
void OnClosed() override {}
- void OnWindowStateChanged(PlatformWindowState new_state) override {}
+ void OnWindowStateChanged(PlatformWindowState old_state,
+ PlatformWindowState new_state) override {}
void OnLostCapture() override {}
void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override {
widget_ = widget;
diff --git a/chromium/ui/compositor/total_animation_throughput_reporter_unittest.cc b/chromium/ui/compositor/total_animation_throughput_reporter_unittest.cc
index f801150e03e..769cfcc4273 100644
--- a/chromium/ui/compositor/total_animation_throughput_reporter_unittest.cc
+++ b/chromium/ui/compositor/total_animation_throughput_reporter_unittest.cc
@@ -19,7 +19,27 @@
#include "ui/compositor/test/animation_throughput_reporter_test_base.h"
#include "ui/compositor/test/throughput_report_checker.h"
+#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
+ defined(THREAD_SANITIZER) || defined(LEAK_SANITIZER) || \
+ defined(UNDEFINED_SANITIZER)
+#define SANITIZER_ENABLED
+#endif
+
namespace ui {
+namespace {
+
+#if !defined(SANITIZER_ENABLED)
+// Returns the delta from current time to the (start + duration) time.
+// This is used to compute how long it should wait from now to reach
+// the `start + duration` time.
+base::TimeDelta DeltaFromNowToTarget(const base::TimeTicks start,
+ int duration) {
+ return start + base::TimeDelta::FromMilliseconds(duration) -
+ base::TimeTicks::Now();
+}
+#endif
+
+} // namespace
using TotalAnimationThroughputReporterTest =
AnimationThroughputReporterTestBase;
@@ -66,7 +86,13 @@ TEST_F(TotalAnimationThroughputReporterTest, StopAnimation) {
}
// Tests the longest animation will trigger the report.
-TEST_F(TotalAnimationThroughputReporterTest, MultipleAnimations) {
+// TODO(crbug.com/1217783): Test is flaky on fuchia and lacros.
+#if defined(OS_FUCHSIA) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_LINUX)
+#define MAYBE_MultipleAnimations DISABLED_MultipleAnimations
+#else
+#define MAYBE_MultipleAnimations MultipleAnimations
+#endif
+TEST_F(TotalAnimationThroughputReporterTest, MAYBE_MultipleAnimations) {
Layer layer1;
layer1.SetOpacity(0.5f);
root_layer()->Add(&layer1);
@@ -92,11 +118,20 @@ TEST_F(TotalAnimationThroughputReporterTest, MultipleAnimations) {
settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(96));
layer2.SetOpacity(1.0f);
}
-
+#if !defined(SANITIZER_ENABLED)
+ auto start = base::TimeTicks::Now();
+#endif
Advance(base::TimeDelta::FromMilliseconds(32));
EXPECT_FALSE(checker.reported());
- Advance(base::TimeDelta::FromMilliseconds(32));
+
+ // The following check may fail on sanitizer builds which
+ // runs slwer.
+#if !defined(SANITIZER_ENABLED)
+ auto sixty_four_ms_from_start = DeltaFromNowToTarget(start, 64);
+ ASSERT_TRUE(sixty_four_ms_from_start > base::TimeDelta());
+ Advance(sixty_four_ms_from_start);
EXPECT_FALSE(checker.reported());
+#endif
EXPECT_TRUE(checker.WaitUntilReported());
}
@@ -131,7 +166,13 @@ TEST_F(TotalAnimationThroughputReporterTest, MultipleAnimationsOnSingleLayer) {
}
// Tests adding new animation will extends the duration.
-TEST_F(TotalAnimationThroughputReporterTest, AddAnimationWhileAnimating) {
+// TODO(crbug.com/1216715): Test is flaky on fuchia and lacros.
+#if defined(OS_FUCHSIA) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_LINUX)
+#define MAYBE_AddAnimationWhileAnimating DISABLED_AddAnimationWhileAnimating
+#else
+#define MAYBE_AddAnimationWhileAnimating AddAnimationWhileAnimating
+#endif
+TEST_F(TotalAnimationThroughputReporterTest, MAYBE_AddAnimationWhileAnimating) {
Layer layer1;
layer1.SetOpacity(0.5f);
root_layer()->Add(&layer1);
@@ -146,7 +187,9 @@ TEST_F(TotalAnimationThroughputReporterTest, AddAnimationWhileAnimating) {
settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(48));
layer1.SetOpacity(1.0f);
}
-
+#if !defined(SANITIZER_ENABLED)
+ base::TimeTicks start = base::TimeTicks::Now();
+#endif
Advance(base::TimeDelta::FromMilliseconds(32));
EXPECT_FALSE(checker.reported());
@@ -163,9 +206,15 @@ TEST_F(TotalAnimationThroughputReporterTest, AddAnimationWhileAnimating) {
layer2.SetOpacity(1.0f);
}
- // The animation time is extended.
- Advance(base::TimeDelta::FromMilliseconds(32));
+ // The following check may fail on sanitizer builds which
+ // runs slwer.
+#if !defined(SANITIZER_ENABLED)
+ // The animation time is extended by 32ms.
+ auto sixty_four_ms_from_start = DeltaFromNowToTarget(start, 64);
+ ASSERT_TRUE(sixty_four_ms_from_start > base::TimeDelta());
+ Advance(sixty_four_ms_from_start);
EXPECT_FALSE(checker.reported());
+#endif
EXPECT_TRUE(checker.WaitUntilReported());
}