Add writePoint3() to SkWriteBuffer interface.
Change-Id: I900a661f346a10dbd8002bfe383d1705138feb50 Reviewed-on: https://skia-review.googlesource.com/c/146401 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
parent
574d6165e2
commit
ea24140dee
@ -93,6 +93,10 @@ void SkBinaryWriteBuffer::writePoint(const SkPoint& point) {
|
||||
fWriter.writeScalar(point.fY);
|
||||
}
|
||||
|
||||
void SkBinaryWriteBuffer::writePoint3(const SkPoint3& point) {
|
||||
this->writePad32(&point, sizeof(SkPoint3));
|
||||
}
|
||||
|
||||
void SkBinaryWriteBuffer::writePointArray(const SkPoint* point, uint32_t count) {
|
||||
fWriter.write32(count);
|
||||
fWriter.write(point, count * sizeof(SkPoint));
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
virtual void writeColor4fArray(const SkColor4f* color, uint32_t count) = 0;
|
||||
virtual void writePoint(const SkPoint& point) = 0;
|
||||
virtual void writePointArray(const SkPoint* point, uint32_t count) = 0;
|
||||
virtual void writePoint3(const SkPoint3& point) = 0;
|
||||
virtual void writeMatrix(const SkMatrix& matrix) = 0;
|
||||
virtual void writeIRect(const SkIRect& rect) = 0;
|
||||
virtual void writeRect(const SkRect& rect) = 0;
|
||||
@ -108,6 +109,7 @@ public:
|
||||
void writeColor4fArray(const SkColor4f* color, uint32_t count) override;
|
||||
void writePoint(const SkPoint& point) override;
|
||||
void writePointArray(const SkPoint* point, uint32_t count) override;
|
||||
void writePoint3(const SkPoint3& point) override;
|
||||
void writeMatrix(const SkMatrix& matrix) override;
|
||||
void writeIRect(const SkIRect& rect) override;
|
||||
void writeRect(const SkRect& rect) override;
|
||||
|
@ -140,6 +140,15 @@ template<> struct SerializationUtils<SkPoint> {
|
||||
}
|
||||
};
|
||||
|
||||
template<> struct SerializationUtils<SkPoint3> {
|
||||
static void Write(SkWriteBuffer& writer, const SkPoint3* data) {
|
||||
writer.writePoint3(*data);
|
||||
}
|
||||
static void Read(SkReadBuffer& reader, SkPoint3* data) {
|
||||
reader.readPoint3(data);
|
||||
}
|
||||
};
|
||||
|
||||
template<> struct SerializationUtils<SkScalar> {
|
||||
static void Write(SkWriteBuffer& writer, SkScalar* data, uint32_t arraySize) {
|
||||
writer.writeScalarArray(data, arraySize);
|
||||
@ -443,6 +452,12 @@ DEF_TEST(Serialization, reporter) {
|
||||
TestObjectSerialization(&matrix, reporter);
|
||||
}
|
||||
|
||||
// Test point3 serialization
|
||||
{
|
||||
SkPoint3 point;
|
||||
TestObjectSerializationNoAlign<SkPoint3, false>(&point, reporter);
|
||||
}
|
||||
|
||||
// Test path serialization
|
||||
{
|
||||
SkPath path;
|
||||
|
@ -108,6 +108,10 @@ void SkJsonWriteBuffer::writePoint(const SkPoint& point) {
|
||||
this->append("point", SkDrawCommand::MakeJsonPoint(point));
|
||||
}
|
||||
|
||||
void SkJsonWriteBuffer::writePoint3(const SkPoint3& point) {
|
||||
this->append("point3", SkDrawCommand::MakeJsonPoint3(point));
|
||||
}
|
||||
|
||||
void SkJsonWriteBuffer::writePointArray(const SkPoint* point, uint32_t count) {
|
||||
Json::Value jsonArray(Json::arrayValue);
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
void writeColor4fArray(const SkColor4f* color, uint32_t count) override;
|
||||
void writePoint(const SkPoint& point) override;
|
||||
void writePointArray(const SkPoint* point, uint32_t count) override;
|
||||
void writePoint3(const SkPoint3& point) override;
|
||||
void writeMatrix(const SkMatrix& matrix) override;
|
||||
void writeIRect(const SkIRect& rect) override;
|
||||
void writeRect(const SkRect& rect) override;
|
||||
|
Loading…
Reference in New Issue
Block a user