Fix incorrect alpha value in DrawImageRect serialization
https://crrev.com/c/4177774 changed the type of the alpha parameter of SerializeOpWithFlags from uint8_t to float, but it appears one of the call site was not updated accordingly. Change-Id: Ib76eae4bafc360a2cee5d34a9d7bdb68b36ce025 Bug: 40219248 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5449416 Auto-Submit: Jean-Philippe Gravel <jpgravel@chromium.org> Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org> Commit-Queue: Jean-Philippe Gravel <jpgravel@chromium.org> Cr-Commit-Position: refs/heads/main@{#1286812}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
d3180ce852
commit
9f28e723f5
@ -191,10 +191,42 @@ void PaintOpBufferSerializer::SerializePreamble(SkCanvas* canvas,
|
||||
}
|
||||
}
|
||||
|
||||
bool PaintOpBufferSerializer::WillSerializeNextOp(const PaintOp& op,
|
||||
SkCanvas* canvas,
|
||||
const PlaybackParams& params,
|
||||
float alpha) {
|
||||
template<>
|
||||
bool PaintOpBufferSerializer::SerializeOpWithFlags<float>(
|
||||
SkCanvas* canvas,
|
||||
const PaintOpWithFlags& flags_op,
|
||||
const PlaybackParams& params,
|
||||
float alpha) {
|
||||
if (alpha == 1.0f && flags_op.flags.isAntiAlias()) {
|
||||
// There's no need to spend CPU time on copying and restoring the flags
|
||||
// struct below (verified by the DCHECK). Note that this if test depends
|
||||
// on the internal logic of ScopedRasterFlags not calling MutableFlags().
|
||||
DCHECK_EQ(
|
||||
&flags_op.flags,
|
||||
ScopedRasterFlags(&flags_op.flags, nullptr, canvas->getTotalMatrix(),
|
||||
options_.max_texture_size, alpha)
|
||||
.flags());
|
||||
return SerializeOp(canvas, flags_op, &flags_op.flags, params);
|
||||
}
|
||||
// We use a null |image_provider| here because images are decoded during
|
||||
// serialization.
|
||||
const ScopedRasterFlags scoped_flags(&flags_op.flags, nullptr,
|
||||
canvas->getTotalMatrix(),
|
||||
options_.max_texture_size, alpha);
|
||||
const PaintFlags* flags_to_serialize = scoped_flags.flags();
|
||||
if (!flags_to_serialize) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return SerializeOp(canvas, flags_op, flags_to_serialize, params);
|
||||
}
|
||||
|
||||
template <>
|
||||
bool PaintOpBufferSerializer::WillSerializeNextOp<float>(
|
||||
const PaintOp& op,
|
||||
SkCanvas* canvas,
|
||||
const PlaybackParams& params,
|
||||
float alpha) {
|
||||
// Skip ops outside the current clip if they have images. This saves
|
||||
// performing an unnecessary expensive decode.
|
||||
bool skip_op = PaintOp::OpHasDiscardableImages(op) &&
|
||||
@ -276,7 +308,7 @@ bool PaintOpBufferSerializer::WillSerializeNextOp(const PaintOp& op,
|
||||
// flags_to_serialize or default (PaintFlags()) flags. At this point in the
|
||||
// serialization, flags_to_serialize is always null as well.
|
||||
SaveLayerOp save_layer_op(draw_op.src, PaintFlags());
|
||||
success = SerializeOpWithFlags(canvas, save_layer_op, params, 255);
|
||||
success = SerializeOpWithFlags(canvas, save_layer_op, params, 1.0f);
|
||||
if (!success)
|
||||
return false;
|
||||
|
||||
@ -317,35 +349,6 @@ void PaintOpBufferSerializer::SerializeBufferWithParams(
|
||||
}
|
||||
}
|
||||
|
||||
bool PaintOpBufferSerializer::SerializeOpWithFlags(
|
||||
SkCanvas* canvas,
|
||||
const PaintOpWithFlags& flags_op,
|
||||
const PlaybackParams& params,
|
||||
float alpha) {
|
||||
if (alpha == 1.0f && flags_op.flags.isAntiAlias()) {
|
||||
// There's no need to spend CPU time on copying and restoring the flags
|
||||
// struct below (verified by the DCHECK). Note that this if test depends
|
||||
// on the internal logic of ScopedRasterFlags not calling MutableFlags().
|
||||
DCHECK_EQ(
|
||||
&flags_op.flags,
|
||||
ScopedRasterFlags(&flags_op.flags, nullptr, canvas->getTotalMatrix(),
|
||||
options_.max_texture_size, alpha)
|
||||
.flags());
|
||||
return SerializeOp(canvas, flags_op, &flags_op.flags, params);
|
||||
}
|
||||
// We use a null |image_provider| here because images are decoded during
|
||||
// serialization.
|
||||
const ScopedRasterFlags scoped_flags(&flags_op.flags, nullptr,
|
||||
canvas->getTotalMatrix(),
|
||||
options_.max_texture_size, alpha);
|
||||
const PaintFlags* flags_to_serialize = scoped_flags.flags();
|
||||
if (!flags_to_serialize) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return SerializeOp(canvas, flags_op, flags_to_serialize, params);
|
||||
}
|
||||
|
||||
bool PaintOpBufferSerializer::SerializeOp(SkCanvas* canvas,
|
||||
const PaintOp& op,
|
||||
const PaintFlags* flags_to_serialize,
|
||||
|
@ -5,6 +5,7 @@
|
||||
#ifndef CC_PAINT_PAINT_OP_BUFFER_SERIALIZER_H_
|
||||
#define CC_PAINT_PAINT_OP_BUFFER_SERIALIZER_H_
|
||||
|
||||
#include <concepts>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@ -93,14 +94,19 @@ class CC_PAINT_EXPORT PaintOpBufferSerializer {
|
||||
const std::vector<size_t>* offsets);
|
||||
// Returns whether serialization of |op| succeeded and we need to serialize
|
||||
// the next PaintOp in the PaintOpBuffer.
|
||||
template<typename F>
|
||||
requires std::same_as<F, float>
|
||||
bool WillSerializeNextOp(const PaintOp& op,
|
||||
SkCanvas* canvas,
|
||||
const PlaybackParams& params,
|
||||
float alpha);
|
||||
F alpha);
|
||||
template<typename F>
|
||||
requires std::same_as<F, float>
|
||||
bool SerializeOpWithFlags(SkCanvas* canvas,
|
||||
const PaintOpWithFlags& flags_op,
|
||||
const PlaybackParams& params,
|
||||
float alpha);
|
||||
F alpha);
|
||||
|
||||
ALWAYS_INLINE bool SerializeOp(SkCanvas* canvas,
|
||||
const PaintOp& op,
|
||||
const PaintFlags* flags_to_serialize,
|
||||
|
Reference in New Issue
Block a user