0

Fix ValueChangeShouldCauseRepaint

Bug: 347682178
Change-Id: Ia029b7db815bf9bd2d8ece973bc5955bdeba768f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5675535
Reviewed-by: Robert Flack <flackr@chromium.org>
Commit-Queue: Kevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1323382}
This commit is contained in:
Kevin Ellis
2024-07-04 15:55:59 +00:00
committed by Chromium LUCI CQ
parent 07228a1177
commit 229eadfafc
2 changed files with 20 additions and 1 deletions

@ -85,7 +85,7 @@ bool PaintWorkletInput::NeedsLayer() const {
bool PaintWorkletInput::ValueChangeShouldCauseRepaint(
const PropertyValue& val1,
const PropertyValue& val2) const {
return val1.color_value != val1.color_value ||
return val1.color_value != val2.color_value ||
val1.float_value != val2.float_value;
}

@ -5,6 +5,7 @@
#include "cc/paint/paint_worklet_input.h"
#include "base/containers/flat_set.h"
#include "cc/test/test_paint_worklet_input.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
@ -21,4 +22,22 @@ TEST(PaintWorkletInputTest, InsertPropertyKeyToFlatSet) {
EXPECT_EQ(property_keys.size(), 2u);
}
// crbug.com/347682178
TEST(PaintWorkletInputTest, ValueChangeShouldCauseRepaint) {
scoped_refptr<TestPaintWorkletInput> input =
base::MakeRefCounted<TestPaintWorkletInput>(gfx::SizeF(100, 100));
PaintWorkletInput::PropertyValue empty;
EXPECT_FALSE(empty.has_value());
PaintWorkletInput::PropertyValue float1(0.f);
PaintWorkletInput::PropertyValue float2(1.f);
EXPECT_FALSE(input->ValueChangeShouldCauseRepaint(float1, float1));
EXPECT_TRUE(input->ValueChangeShouldCauseRepaint(float1, float2));
PaintWorkletInput::PropertyValue color1(SkColors::kTransparent);
PaintWorkletInput::PropertyValue color2(SkColors::kBlack);
EXPECT_FALSE(input->ValueChangeShouldCauseRepaint(color1, color1));
EXPECT_TRUE(input->ValueChangeShouldCauseRepaint(color1, color2));
}
} // namespace cc