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
This diff is collapsed.
...@@ -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