Commit 31a5f14b authored by Caleb Raitto's avatar Caleb Raitto Committed by Commit Bot

Remove SimpleSerialize() and SimpleDeserialize().

By handling serialization of each type explicitly, we avoid serializing
padding bytes.

Bug: 973801,1106091
Change-Id: I9f4e6b82fb484b9256b25b531cc2d51c800425bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2309004
Commit-Queue: Khushal <khushalsagar@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791110}
parent 25380230
...@@ -306,14 +306,6 @@ std::ostream& operator<<(std::ostream& os, PaintOpType type) { ...@@ -306,14 +306,6 @@ std::ostream& operator<<(std::ostream& os, PaintOpType type) {
return os << PaintOpTypeToString(type); return os << PaintOpTypeToString(type);
} }
template <typename T>
size_t SimpleSerialize(const PaintOp* op, void* memory, size_t size) {
if (sizeof(T) > size)
return 0;
memcpy(memory, op, sizeof(T));
return sizeof(T);
}
PlaybackParams::PlaybackParams(ImageProvider* image_provider) PlaybackParams::PlaybackParams(ImageProvider* image_provider)
: PlaybackParams(image_provider, SkMatrix::I()) {} : PlaybackParams(image_provider, SkMatrix::I()) {}
...@@ -400,39 +392,59 @@ size_t ClipPathOp::Serialize(const PaintOp* base_op, ...@@ -400,39 +392,59 @@ size_t ClipPathOp::Serialize(const PaintOp* base_op,
return helper.size(); return helper.size();
} }
size_t ClipRectOp::Serialize(const PaintOp* op, size_t ClipRectOp::Serialize(const PaintOp* base_op,
void* memory, void* memory,
size_t size, size_t size,
const SerializeOptions& options) { const SerializeOptions& options) {
return SimpleSerialize<ClipRectOp>(op, memory, size); auto* op = static_cast<const ClipRectOp*>(base_op);
PaintOpWriter helper(memory, size, options);
helper.Write(op->rect);
helper.Write(op->op);
helper.Write(op->antialias);
return helper.size();
} }
size_t ClipRRectOp::Serialize(const PaintOp* op, size_t ClipRRectOp::Serialize(const PaintOp* base_op,
void* memory, void* memory,
size_t size, size_t size,
const SerializeOptions& options) { const SerializeOptions& options) {
return SimpleSerialize<ClipRRectOp>(op, memory, size); auto* op = static_cast<const ClipRRectOp*>(base_op);
PaintOpWriter helper(memory, size, options);
helper.Write(op->rrect);
helper.Write(op->op);
helper.Write(op->antialias);
return helper.size();
} }
size_t ConcatOp::Serialize(const PaintOp* op, size_t ConcatOp::Serialize(const PaintOp* base_op,
void* memory, void* memory,
size_t size, size_t size,
const SerializeOptions& options) { const SerializeOptions& options) {
return SimpleSerialize<ConcatOp>(op, memory, size); auto* op = static_cast<const ConcatOp*>(base_op);
PaintOpWriter helper(memory, size, options);
helper.Write(op->matrix);
return helper.size();
} }
size_t CustomDataOp::Serialize(const PaintOp* op, size_t CustomDataOp::Serialize(const PaintOp* base_op,
void* memory, void* memory,
size_t size, size_t size,
const SerializeOptions& options) { const SerializeOptions& options) {
return SimpleSerialize<CustomDataOp>(op, memory, size); auto* op = static_cast<const CustomDataOp*>(base_op);
PaintOpWriter helper(memory, size, options);
helper.Write(op->id);
return helper.size();
} }
size_t DrawColorOp::Serialize(const PaintOp* op, size_t DrawColorOp::Serialize(const PaintOp* base_op,
void* memory, void* memory,
size_t size, size_t size,
const SerializeOptions& options) { const SerializeOptions& options) {
return SimpleSerialize<DrawColorOp>(op, memory, size); auto* op = static_cast<const DrawColorOp*>(base_op);
PaintOpWriter helper(memory, size, options);
helper.Write(op->color);
helper.Write(op->mode);
return helper.size();
} }
size_t DrawDRRectOp::Serialize(const PaintOp* base_op, size_t DrawDRRectOp::Serialize(const PaintOp* base_op,
...@@ -638,32 +650,38 @@ size_t DrawTextBlobOp::Serialize(const PaintOp* base_op, ...@@ -638,32 +650,38 @@ size_t DrawTextBlobOp::Serialize(const PaintOp* base_op,
return helper.size(); return helper.size();
} }
size_t NoopOp::Serialize(const PaintOp* op, size_t NoopOp::Serialize(const PaintOp* base_op,
void* memory, void* memory,
size_t size, size_t size,
const SerializeOptions& options) { const SerializeOptions& options) {
return SimpleSerialize<NoopOp>(op, memory, size); PaintOpWriter helper(memory, size, options);
return helper.size();
} }
size_t RestoreOp::Serialize(const PaintOp* op, size_t RestoreOp::Serialize(const PaintOp* base_op,
void* memory, void* memory,
size_t size, size_t size,
const SerializeOptions& options) { const SerializeOptions& options) {
return SimpleSerialize<RestoreOp>(op, memory, size); PaintOpWriter helper(memory, size, options);
return helper.size();
} }
size_t RotateOp::Serialize(const PaintOp* op, size_t RotateOp::Serialize(const PaintOp* base_op,
void* memory, void* memory,
size_t size, size_t size,
const SerializeOptions& options) { const SerializeOptions& options) {
return SimpleSerialize<RotateOp>(op, memory, size); auto* op = static_cast<const RotateOp*>(base_op);
PaintOpWriter helper(memory, size, options);
helper.Write(op->degrees);
return helper.size();
} }
size_t SaveOp::Serialize(const PaintOp* op, size_t SaveOp::Serialize(const PaintOp* base_op,
void* memory, void* memory,
size_t size, size_t size,
const SerializeOptions& options) { const SerializeOptions& options) {
return SimpleSerialize<SaveOp>(op, memory, size); PaintOpWriter helper(memory, size, options);
return helper.size();
} }
size_t SaveLayerOp::Serialize(const PaintOp* base_op, size_t SaveLayerOp::Serialize(const PaintOp* base_op,
...@@ -680,44 +698,64 @@ size_t SaveLayerOp::Serialize(const PaintOp* base_op, ...@@ -680,44 +698,64 @@ size_t SaveLayerOp::Serialize(const PaintOp* base_op,
return helper.size(); return helper.size();
} }
size_t SaveLayerAlphaOp::Serialize(const PaintOp* op, size_t SaveLayerAlphaOp::Serialize(const PaintOp* base_op,
void* memory, void* memory,
size_t size, size_t size,
const SerializeOptions& options) { const SerializeOptions& options) {
return SimpleSerialize<SaveLayerAlphaOp>(op, memory, size); auto* op = static_cast<const SaveLayerAlphaOp*>(base_op);
PaintOpWriter helper(memory, size, options);
helper.Write(op->bounds);
helper.Write(op->alpha);
return helper.size();
} }
size_t ScaleOp::Serialize(const PaintOp* op, size_t ScaleOp::Serialize(const PaintOp* base_op,
void* memory, void* memory,
size_t size, size_t size,
const SerializeOptions& options) { const SerializeOptions& options) {
return SimpleSerialize<ScaleOp>(op, memory, size); auto* op = static_cast<const ScaleOp*>(base_op);
PaintOpWriter helper(memory, size, options);
helper.Write(op->sx);
helper.Write(op->sy);
return helper.size();
} }
size_t SetMatrixOp::Serialize(const PaintOp* op, size_t SetMatrixOp::Serialize(const PaintOp* base_op,
void* memory, void* memory,
size_t size, size_t size,
const SerializeOptions& options) { const SerializeOptions& options) {
if (options.original_ctm.isIdentity()) auto* op = static_cast<const SetMatrixOp*>(base_op);
return SimpleSerialize<SetMatrixOp>(op, memory, size); PaintOpWriter helper(memory, size, options);
SetMatrixOp transformed(*static_cast<const SetMatrixOp*>(op)); if (options.original_ctm.isIdentity()) {
transformed.matrix.postConcat(options.original_ctm); helper.Write(op->matrix);
return SimpleSerialize<SetMatrixOp>(&transformed, memory, size); } else {
SkMatrix transformed = op->matrix;
transformed.postConcat(options.original_ctm);
helper.Write(transformed);
}
return helper.size();
} }
size_t SetNodeIdOp::Serialize(const PaintOp* op, size_t SetNodeIdOp::Serialize(const PaintOp* base_op,
void* memory, void* memory,
size_t size, size_t size,
const SerializeOptions& options) { const SerializeOptions& options) {
return SimpleSerialize<SetNodeIdOp>(op, memory, size); auto* op = static_cast<const SetNodeIdOp*>(base_op);
PaintOpWriter helper(memory, size, options);
helper.Write(op->node_id);
return helper.size();
} }
size_t TranslateOp::Serialize(const PaintOp* op, size_t TranslateOp::Serialize(const PaintOp* base_op,
void* memory, void* memory,
size_t size, size_t size,
const SerializeOptions& options) { const SerializeOptions& options) {
return SimpleSerialize<TranslateOp>(op, memory, size); auto* op = static_cast<const TranslateOp*>(base_op);
PaintOpWriter helper(memory, size, options);
helper.Write(op->dx);
helper.Write(op->dy);
return helper.size();
} }
template <typename T> template <typename T>
...@@ -726,24 +764,6 @@ void UpdateTypeAndSkip(T* op) { ...@@ -726,24 +764,6 @@ void UpdateTypeAndSkip(T* op) {
op->skip = PaintOpBuffer::ComputeOpSkip(sizeof(T)); op->skip = PaintOpBuffer::ComputeOpSkip(sizeof(T));
} }
template <typename T>
T* SimpleDeserialize(const volatile void* input,
size_t input_size,
void* output,
size_t output_size) {
if (input_size < sizeof(T))
return nullptr;
memcpy(output, const_cast<void*>(input), sizeof(T));
T* op = reinterpret_cast<T*>(output);
if (!op->IsValid())
return nullptr;
// Type and skip were already read once, so could have been changed.
// Don't trust them and clobber them with something valid.
UpdateTypeAndSkip(op);
return op;
}
PaintOp* AnnotateOp::Deserialize(const volatile void* input, PaintOp* AnnotateOp::Deserialize(const volatile void* input,
size_t input_size, size_t input_size,
void* output, void* output,
...@@ -792,7 +812,19 @@ PaintOp* ClipRectOp::Deserialize(const volatile void* input, ...@@ -792,7 +812,19 @@ PaintOp* ClipRectOp::Deserialize(const volatile void* input,
size_t output_size, size_t output_size,
const DeserializeOptions& options) { const DeserializeOptions& options) {
DCHECK_GE(output_size, sizeof(ClipRectOp)); DCHECK_GE(output_size, sizeof(ClipRectOp));
return SimpleDeserialize<ClipRectOp>(input, input_size, output, output_size); ClipRectOp* op = new (output) ClipRectOp;
PaintOpReader helper(input, input_size, options);
helper.Read(&op->rect);
helper.Read(&op->op);
helper.Read(&op->antialias);
if (!helper.valid() || !op->IsValid()) {
op->~ClipRectOp();
return nullptr;
}
UpdateTypeAndSkip(op);
return op;
} }
PaintOp* ClipRRectOp::Deserialize(const volatile void* input, PaintOp* ClipRRectOp::Deserialize(const volatile void* input,
...@@ -801,7 +833,19 @@ PaintOp* ClipRRectOp::Deserialize(const volatile void* input, ...@@ -801,7 +833,19 @@ PaintOp* ClipRRectOp::Deserialize(const volatile void* input,
size_t output_size, size_t output_size,
const DeserializeOptions& options) { const DeserializeOptions& options) {
DCHECK_GE(output_size, sizeof(ClipRRectOp)); DCHECK_GE(output_size, sizeof(ClipRRectOp));
return SimpleDeserialize<ClipRRectOp>(input, input_size, output, output_size); ClipRRectOp* op = new (output) ClipRRectOp;
PaintOpReader helper(input, input_size, options);
helper.Read(&op->rrect);
helper.Read(&op->op);
helper.Read(&op->antialias);
if (!helper.valid() || !op->IsValid()) {
op->~ClipRRectOp();
return nullptr;
}
UpdateTypeAndSkip(op);
return op;
} }
PaintOp* ConcatOp::Deserialize(const volatile void* input, PaintOp* ConcatOp::Deserialize(const volatile void* input,
...@@ -810,10 +854,17 @@ PaintOp* ConcatOp::Deserialize(const volatile void* input, ...@@ -810,10 +854,17 @@ PaintOp* ConcatOp::Deserialize(const volatile void* input,
size_t output_size, size_t output_size,
const DeserializeOptions& options) { const DeserializeOptions& options) {
DCHECK_GE(output_size, sizeof(ConcatOp)); DCHECK_GE(output_size, sizeof(ConcatOp));
auto* op = ConcatOp* op = new (output) ConcatOp;
SimpleDeserialize<ConcatOp>(input, input_size, output, output_size);
if (op) PaintOpReader helper(input, input_size, options);
PaintOpReader::FixupMatrixPostSerialization(&op->matrix); helper.Read(&op->matrix);
if (!helper.valid() || !op->IsValid()) {
op->~ConcatOp();
return nullptr;
}
UpdateTypeAndSkip(op);
PaintOpReader::FixupMatrixPostSerialization(&op->matrix);
return op; return op;
} }
...@@ -823,8 +874,17 @@ PaintOp* CustomDataOp::Deserialize(const volatile void* input, ...@@ -823,8 +874,17 @@ PaintOp* CustomDataOp::Deserialize(const volatile void* input,
size_t output_size, size_t output_size,
const DeserializeOptions& options) { const DeserializeOptions& options) {
DCHECK_GE(output_size, sizeof(CustomDataOp)); DCHECK_GE(output_size, sizeof(CustomDataOp));
return SimpleDeserialize<CustomDataOp>(input, input_size, output, CustomDataOp* op = new (output) CustomDataOp;
output_size);
PaintOpReader helper(input, input_size, options);
helper.Read(&op->id);
if (!helper.valid() || !op->IsValid()) {
op->~CustomDataOp();
return nullptr;
}
UpdateTypeAndSkip(op);
return op;
} }
PaintOp* DrawColorOp::Deserialize(const volatile void* input, PaintOp* DrawColorOp::Deserialize(const volatile void* input,
...@@ -833,7 +893,18 @@ PaintOp* DrawColorOp::Deserialize(const volatile void* input, ...@@ -833,7 +893,18 @@ PaintOp* DrawColorOp::Deserialize(const volatile void* input,
size_t output_size, size_t output_size,
const DeserializeOptions& options) { const DeserializeOptions& options) {
DCHECK_GE(output_size, sizeof(DrawColorOp)); DCHECK_GE(output_size, sizeof(DrawColorOp));
return SimpleDeserialize<DrawColorOp>(input, input_size, output, output_size); DrawColorOp* op = new (output) DrawColorOp;
PaintOpReader helper(input, input_size, options);
helper.Read(&op->color);
helper.Read(&op->mode);
if (!helper.valid() || !op->IsValid()) {
op->~DrawColorOp();
return nullptr;
}
UpdateTypeAndSkip(op);
return op;
} }
PaintOp* DrawDRRectOp::Deserialize(const volatile void* input, PaintOp* DrawDRRectOp::Deserialize(const volatile void* input,
...@@ -1096,7 +1167,16 @@ PaintOp* NoopOp::Deserialize(const volatile void* input, ...@@ -1096,7 +1167,16 @@ PaintOp* NoopOp::Deserialize(const volatile void* input,
size_t output_size, size_t output_size,
const DeserializeOptions& options) { const DeserializeOptions& options) {
DCHECK_GE(output_size, sizeof(NoopOp)); DCHECK_GE(output_size, sizeof(NoopOp));
return SimpleDeserialize<NoopOp>(input, input_size, output, output_size); NoopOp* op = new (output) NoopOp;
PaintOpReader helper(input, input_size, options);
if (!helper.valid() || !op->IsValid()) {
op->~NoopOp();
return nullptr;
}
UpdateTypeAndSkip(op);
return op;
} }
PaintOp* RestoreOp::Deserialize(const volatile void* input, PaintOp* RestoreOp::Deserialize(const volatile void* input,
...@@ -1105,7 +1185,16 @@ PaintOp* RestoreOp::Deserialize(const volatile void* input, ...@@ -1105,7 +1185,16 @@ PaintOp* RestoreOp::Deserialize(const volatile void* input,
size_t output_size, size_t output_size,
const DeserializeOptions& options) { const DeserializeOptions& options) {
DCHECK_GE(output_size, sizeof(RestoreOp)); DCHECK_GE(output_size, sizeof(RestoreOp));
return SimpleDeserialize<RestoreOp>(input, input_size, output, output_size); RestoreOp* op = new (output) RestoreOp;
PaintOpReader helper(input, input_size, options);
if (!helper.valid() || !op->IsValid()) {
op->~RestoreOp();
return nullptr;
}
UpdateTypeAndSkip(op);
return op;
} }
PaintOp* RotateOp::Deserialize(const volatile void* input, PaintOp* RotateOp::Deserialize(const volatile void* input,
...@@ -1114,7 +1203,17 @@ PaintOp* RotateOp::Deserialize(const volatile void* input, ...@@ -1114,7 +1203,17 @@ PaintOp* RotateOp::Deserialize(const volatile void* input,
size_t output_size, size_t output_size,
const DeserializeOptions& options) { const DeserializeOptions& options) {
DCHECK_GE(output_size, sizeof(RotateOp)); DCHECK_GE(output_size, sizeof(RotateOp));
return SimpleDeserialize<RotateOp>(input, input_size, output, output_size); RotateOp* op = new (output) RotateOp;
PaintOpReader helper(input, input_size, options);
helper.Read(&op->degrees);
if (!helper.valid() || !op->IsValid()) {
op->~RotateOp();
return nullptr;
}
UpdateTypeAndSkip(op);
return op;
} }
PaintOp* SaveOp::Deserialize(const volatile void* input, PaintOp* SaveOp::Deserialize(const volatile void* input,
...@@ -1123,7 +1222,16 @@ PaintOp* SaveOp::Deserialize(const volatile void* input, ...@@ -1123,7 +1222,16 @@ PaintOp* SaveOp::Deserialize(const volatile void* input,
size_t output_size, size_t output_size,
const DeserializeOptions& options) { const DeserializeOptions& options) {
DCHECK_GE(output_size, sizeof(SaveOp)); DCHECK_GE(output_size, sizeof(SaveOp));
return SimpleDeserialize<SaveOp>(input, input_size, output, output_size); SaveOp* op = new (output) SaveOp;
PaintOpReader helper(input, input_size, options);
if (!helper.valid() || !op->IsValid()) {
op->~SaveOp();
return nullptr;
}
UpdateTypeAndSkip(op);
return op;
} }
PaintOp* SaveLayerOp::Deserialize(const volatile void* input, PaintOp* SaveLayerOp::Deserialize(const volatile void* input,
...@@ -1151,8 +1259,18 @@ PaintOp* SaveLayerAlphaOp::Deserialize(const volatile void* input, ...@@ -1151,8 +1259,18 @@ PaintOp* SaveLayerAlphaOp::Deserialize(const volatile void* input,
size_t output_size, size_t output_size,
const DeserializeOptions& options) { const DeserializeOptions& options) {
DCHECK_GE(output_size, sizeof(SaveLayerAlphaOp)); DCHECK_GE(output_size, sizeof(SaveLayerAlphaOp));
return SimpleDeserialize<SaveLayerAlphaOp>(input, input_size, output, SaveLayerAlphaOp* op = new (output) SaveLayerAlphaOp;
output_size);
PaintOpReader helper(input, input_size, options);
helper.Read(&op->bounds);
helper.Read(&op->alpha);
if (!helper.valid() || !op->IsValid()) {
op->~SaveLayerAlphaOp();
return nullptr;
}
UpdateTypeAndSkip(op);
return op;
} }
PaintOp* ScaleOp::Deserialize(const volatile void* input, PaintOp* ScaleOp::Deserialize(const volatile void* input,
...@@ -1161,8 +1279,18 @@ PaintOp* ScaleOp::Deserialize(const volatile void* input, ...@@ -1161,8 +1279,18 @@ PaintOp* ScaleOp::Deserialize(const volatile void* input,
size_t output_size, size_t output_size,
const DeserializeOptions& options) { const DeserializeOptions& options) {
DCHECK_GE(output_size, sizeof(ScaleOp)); DCHECK_GE(output_size, sizeof(ScaleOp));
ScaleOp* op = new (output) ScaleOp;
return SimpleDeserialize<ScaleOp>(input, input_size, output, output_size); PaintOpReader helper(input, input_size, options);
helper.Read(&op->sx);
helper.Read(&op->sy);
if (!helper.valid() || !op->IsValid()) {
op->~ScaleOp();
return nullptr;
}
UpdateTypeAndSkip(op);
return op;
} }
PaintOp* SetMatrixOp::Deserialize(const volatile void* input, PaintOp* SetMatrixOp::Deserialize(const volatile void* input,
...@@ -1171,10 +1299,17 @@ PaintOp* SetMatrixOp::Deserialize(const volatile void* input, ...@@ -1171,10 +1299,17 @@ PaintOp* SetMatrixOp::Deserialize(const volatile void* input,
size_t output_size, size_t output_size,
const DeserializeOptions& options) { const DeserializeOptions& options) {
DCHECK_GE(output_size, sizeof(SetMatrixOp)); DCHECK_GE(output_size, sizeof(SetMatrixOp));
auto* op = SetMatrixOp* op = new (output) SetMatrixOp;
SimpleDeserialize<SetMatrixOp>(input, input_size, output, output_size);
if (op) PaintOpReader helper(input, input_size, options);
PaintOpReader::FixupMatrixPostSerialization(&op->matrix); helper.Read(&op->matrix);
if (!helper.valid() || !op->IsValid()) {
op->~SetMatrixOp();
return nullptr;
}
UpdateTypeAndSkip(op);
PaintOpReader::FixupMatrixPostSerialization(&op->matrix);
return op; return op;
} }
...@@ -1184,7 +1319,17 @@ PaintOp* SetNodeIdOp::Deserialize(const volatile void* input, ...@@ -1184,7 +1319,17 @@ PaintOp* SetNodeIdOp::Deserialize(const volatile void* input,
size_t output_size, size_t output_size,
const DeserializeOptions& options) { const DeserializeOptions& options) {
DCHECK_GE(output_size, sizeof(SetNodeIdOp)); DCHECK_GE(output_size, sizeof(SetNodeIdOp));
return SimpleDeserialize<SetNodeIdOp>(input, input_size, output, output_size); SetNodeIdOp* op = new (output) SetNodeIdOp;
PaintOpReader helper(input, input_size, options);
helper.Read(&op->node_id);
if (!helper.valid() || !op->IsValid()) {
op->~SetNodeIdOp();
return nullptr;
}
UpdateTypeAndSkip(op);
return op;
} }
PaintOp* TranslateOp::Deserialize(const volatile void* input, PaintOp* TranslateOp::Deserialize(const volatile void* input,
...@@ -1193,7 +1338,18 @@ PaintOp* TranslateOp::Deserialize(const volatile void* input, ...@@ -1193,7 +1338,18 @@ PaintOp* TranslateOp::Deserialize(const volatile void* input,
size_t output_size, size_t output_size,
const DeserializeOptions& options) { const DeserializeOptions& options) {
DCHECK_GE(output_size, sizeof(TranslateOp)); DCHECK_GE(output_size, sizeof(TranslateOp));
return SimpleDeserialize<TranslateOp>(input, input_size, output, output_size); TranslateOp* op = new (output) TranslateOp;
PaintOpReader helper(input, input_size, options);
helper.Read(&op->dx);
helper.Read(&op->dy);
if (!helper.valid() || !op->IsValid()) {
op->~TranslateOp();
return nullptr;
}
UpdateTypeAndSkip(op);
return op;
} }
void AnnotateOp::Raster(const AnnotateOp* op, void AnnotateOp::Raster(const AnnotateOp* op,
......
...@@ -49,6 +49,7 @@ class CC_PAINT_EXPORT ThreadsafeMatrix : public SkMatrix { ...@@ -49,6 +49,7 @@ class CC_PAINT_EXPORT ThreadsafeMatrix : public SkMatrix {
explicit ThreadsafeMatrix(const SkMatrix& matrix) : SkMatrix(matrix) { explicit ThreadsafeMatrix(const SkMatrix& matrix) : SkMatrix(matrix) {
(void)getType(); (void)getType();
} }
ThreadsafeMatrix() { (void)getType(); }
}; };
class CC_PAINT_EXPORT ThreadsafePath : public SkPath { class CC_PAINT_EXPORT ThreadsafePath : public SkPath {
...@@ -418,6 +419,9 @@ class CC_PAINT_EXPORT ClipRectOp final : public PaintOp { ...@@ -418,6 +419,9 @@ class CC_PAINT_EXPORT ClipRectOp final : public PaintOp {
SkRect rect; SkRect rect;
SkClipOp op; SkClipOp op;
bool antialias; bool antialias;
private:
ClipRectOp() : PaintOp(kType) {}
}; };
class CC_PAINT_EXPORT ClipRRectOp final : public PaintOp { class CC_PAINT_EXPORT ClipRRectOp final : public PaintOp {
...@@ -436,6 +440,9 @@ class CC_PAINT_EXPORT ClipRRectOp final : public PaintOp { ...@@ -436,6 +440,9 @@ class CC_PAINT_EXPORT ClipRRectOp final : public PaintOp {
SkRRect rrect; SkRRect rrect;
SkClipOp op; SkClipOp op;
bool antialias; bool antialias;
private:
ClipRRectOp() : PaintOp(kType) {}
}; };
class CC_PAINT_EXPORT ConcatOp final : public PaintOp { class CC_PAINT_EXPORT ConcatOp final : public PaintOp {
...@@ -450,6 +457,9 @@ class CC_PAINT_EXPORT ConcatOp final : public PaintOp { ...@@ -450,6 +457,9 @@ class CC_PAINT_EXPORT ConcatOp final : public PaintOp {
HAS_SERIALIZATION_FUNCTIONS(); HAS_SERIALIZATION_FUNCTIONS();
ThreadsafeMatrix matrix; ThreadsafeMatrix matrix;
private:
ConcatOp() : PaintOp(kType) {}
}; };
class CC_PAINT_EXPORT CustomDataOp final : public PaintOp { class CC_PAINT_EXPORT CustomDataOp final : public PaintOp {
...@@ -465,6 +475,9 @@ class CC_PAINT_EXPORT CustomDataOp final : public PaintOp { ...@@ -465,6 +475,9 @@ class CC_PAINT_EXPORT CustomDataOp final : public PaintOp {
// Stores user defined id as a placeholder op. // Stores user defined id as a placeholder op.
uint32_t id; uint32_t id;
private:
CustomDataOp() : PaintOp(kType) {}
}; };
class CC_PAINT_EXPORT DrawColorOp final : public PaintOp { class CC_PAINT_EXPORT DrawColorOp final : public PaintOp {
...@@ -482,6 +495,9 @@ class CC_PAINT_EXPORT DrawColorOp final : public PaintOp { ...@@ -482,6 +495,9 @@ class CC_PAINT_EXPORT DrawColorOp final : public PaintOp {
SkColor color; SkColor color;
SkBlendMode mode; SkBlendMode mode;
private:
DrawColorOp() : PaintOp(kType) {}
}; };
class CC_PAINT_EXPORT DrawDRRectOp final : public PaintOpWithFlags { class CC_PAINT_EXPORT DrawDRRectOp final : public PaintOpWithFlags {
...@@ -829,6 +845,9 @@ class CC_PAINT_EXPORT RotateOp final : public PaintOp { ...@@ -829,6 +845,9 @@ class CC_PAINT_EXPORT RotateOp final : public PaintOp {
HAS_SERIALIZATION_FUNCTIONS(); HAS_SERIALIZATION_FUNCTIONS();
SkScalar degrees; SkScalar degrees;
private:
RotateOp() : PaintOp(kType) {}
}; };
class CC_PAINT_EXPORT SaveOp final : public PaintOp { class CC_PAINT_EXPORT SaveOp final : public PaintOp {
...@@ -883,6 +902,9 @@ class CC_PAINT_EXPORT SaveLayerAlphaOp final : public PaintOp { ...@@ -883,6 +902,9 @@ class CC_PAINT_EXPORT SaveLayerAlphaOp final : public PaintOp {
SkRect bounds; SkRect bounds;
uint8_t alpha; uint8_t alpha;
private:
SaveLayerAlphaOp() : PaintOp(kType) {}
}; };
class CC_PAINT_EXPORT ScaleOp final : public PaintOp { class CC_PAINT_EXPORT ScaleOp final : public PaintOp {
...@@ -922,6 +944,9 @@ class CC_PAINT_EXPORT SetMatrixOp final : public PaintOp { ...@@ -922,6 +944,9 @@ class CC_PAINT_EXPORT SetMatrixOp final : public PaintOp {
HAS_SERIALIZATION_FUNCTIONS(); HAS_SERIALIZATION_FUNCTIONS();
ThreadsafeMatrix matrix; ThreadsafeMatrix matrix;
private:
SetMatrixOp() : PaintOp(kType) {}
}; };
class CC_PAINT_EXPORT SetNodeIdOp final : public PaintOp { class CC_PAINT_EXPORT SetNodeIdOp final : public PaintOp {
...@@ -936,6 +961,9 @@ class CC_PAINT_EXPORT SetNodeIdOp final : public PaintOp { ...@@ -936,6 +961,9 @@ class CC_PAINT_EXPORT SetNodeIdOp final : public PaintOp {
HAS_SERIALIZATION_FUNCTIONS(); HAS_SERIALIZATION_FUNCTIONS();
int node_id; int node_id;
private:
SetNodeIdOp() : PaintOp(kType) {}
}; };
class CC_PAINT_EXPORT TranslateOp final : public PaintOp { class CC_PAINT_EXPORT TranslateOp final : public PaintOp {
...@@ -951,6 +979,9 @@ class CC_PAINT_EXPORT TranslateOp final : public PaintOp { ...@@ -951,6 +979,9 @@ class CC_PAINT_EXPORT TranslateOp final : public PaintOp {
SkScalar dx; SkScalar dx;
SkScalar dy; SkScalar dy;
private:
TranslateOp() : PaintOp(kType) {}
}; };
#undef HAS_SERIALIZATION_FUNCTIONS #undef HAS_SERIALIZATION_FUNCTIONS
......
...@@ -105,6 +105,15 @@ class CC_PAINT_EXPORT PaintOpReader { ...@@ -105,6 +105,15 @@ class CC_PAINT_EXPORT PaintOpReader {
} }
*quality = static_cast<SkFilterQuality>(value); *quality = static_cast<SkFilterQuality>(value);
} }
void Read(SkBlendMode* blend_mode) {
uint8_t value = 0u;
Read(&value);
if (value > static_cast<uint8_t>(SkBlendMode::kLastMode)) {
SetInvalid();
return;
}
*blend_mode = static_cast<SkBlendMode>(value);
}
void Read(bool* data) { void Read(bool* data) {
uint8_t value = 0u; uint8_t value = 0u;
Read(&value); Read(&value);
......
...@@ -81,6 +81,9 @@ class CC_PAINT_EXPORT PaintOpWriter { ...@@ -81,6 +81,9 @@ class CC_PAINT_EXPORT PaintOpWriter {
void Write(SkFilterQuality filter_quality) { void Write(SkFilterQuality filter_quality) {
Write(static_cast<uint8_t>(filter_quality)); Write(static_cast<uint8_t>(filter_quality));
} }
void Write(SkBlendMode blend_mode) {
Write(static_cast<uint8_t>(blend_mode));
}
void Write(bool data) { Write(static_cast<uint8_t>(data)); } void Write(bool data) { Write(static_cast<uint8_t>(data)); }
// Aligns the memory to the given alignment. // Aligns the memory to the given alignment.
......
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