minor fixes to SkRRect

Move methods that are not publicly callable
to SkRRectPriv.h. Name params, add a trailing
comma to the enum list.

R=reed@google.com,bsalomon@google.com
Bug: skia:6898
Change-Id: If93f712656dde563567a647624e58ce9a9d74494
Reviewed-on: https://skia-review.googlesource.com/134423
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Cary Clark <caryclark@skia.org>
This commit is contained in:
Cary Clark 2018-06-12 16:49:49 -04:00 committed by Skia Commit-Bot
parent 4010c792c6
commit 1e447dfb77
4 changed files with 19 additions and 16 deletions

View File

@ -13,8 +13,6 @@
class SkPath;
class SkMatrix;
class SkRBuffer;
class SkWBuffer;
// Path forward:
// core work
@ -51,8 +49,8 @@ public:
/** Default initialized to a rrect at the origin with zero width and height. */
SkRRect() = default;
SkRRect(const SkRRect&) = default;
SkRRect& operator=(const SkRRect&) = default;
SkRRect(const SkRRect& rrect) = default;
SkRRect& operator=(const SkRRect& rrect) = default;
/**
* Enum to capture the various possible subtypes of RR. Accessed
@ -201,7 +199,7 @@ public:
kUpperLeft_Corner,
kUpperRight_Corner,
kLowerRight_Corner,
kLowerLeft_Corner
kLowerLeft_Corner,
};
const SkRect& rect() const { return fRect; }
@ -278,7 +276,6 @@ public:
* a multiple of 4. Return kSizeInMemory.
*/
size_t writeToMemory(void* buffer) const;
void writeToBuffer(SkWBuffer*) const;
/**
* Reads the rrect from the specified buffer
@ -292,7 +289,6 @@ public:
* 0 if there was not enough memory available
*/
size_t readFromMemory(const void* buffer, size_t length);
bool readFromBuffer(SkRBuffer*);
/**
* Transform by the specified matrix, and put the result in dst.

View File

@ -11,7 +11,7 @@
#include "SkMath.h"
#include "SkPathPriv.h"
#include "SkPathRef.h"
#include "SkRRect.h"
#include "SkRRectPriv.h"
#include "SkSafeMath.h"
enum SerializationOffsets {
@ -77,7 +77,7 @@ size_t SkPath::writeToMemoryAsRRect(void* storage) const {
SkWBuffer buffer(storage);
buffer.write32(packed);
rrect.writeToBuffer(&buffer);
SkRRectPriv::WriteToBuffer(rrect, &buffer);
buffer.write32(SkToS32(start));
buffer.padToAlign4();
SkASSERT(sizeNeeded == buffer.pos());
@ -177,7 +177,7 @@ size_t SkPath::readAsRRect(const void* storage, size_t length) {
default:
return 0;
}
if (!rrect.readFromBuffer(&buffer)) {
if (!SkRRectPriv::ReadFromBuffer(&buffer, &rrect)) {
return 0;
}
if (!buffer.readS32(&start) || start != SkTPin(start, 0, 7)) {

View File

@ -501,9 +501,9 @@ size_t SkRRect::writeToMemory(void* buffer) const {
return kSizeInMemory;
}
void SkRRect::writeToBuffer(SkWBuffer* buffer) const {
void SkRRectPriv::WriteToBuffer(const SkRRect& rr, SkWBuffer* buffer) {
// Serialize only the rect and corners, but not the derived type tag.
buffer->write(this, kSizeInMemory);
buffer->write(&rr, SkRRect::kSizeInMemory);
}
size_t SkRRect::readFromMemory(const void* buffer, size_t length) {
@ -517,13 +517,13 @@ size_t SkRRect::readFromMemory(const void* buffer, size_t length) {
return kSizeInMemory;
}
bool SkRRect::readFromBuffer(SkRBuffer* buffer) {
if (buffer->available() < kSizeInMemory) {
bool SkRRectPriv::ReadFromBuffer(SkRBuffer* buffer, SkRRect* rr) {
if (buffer->available() < SkRRect::kSizeInMemory) {
return false;
}
SkRRect storage;
return buffer->read(&storage, kSizeInMemory) &&
(this->readFromMemory(&storage, kSizeInMemory) == kSizeInMemory);
return buffer->read(&storage, SkRRect::kSizeInMemory) &&
(rr->readFromMemory(&storage, SkRRect::kSizeInMemory) == SkRRect::kSizeInMemory);
}
#include "SkString.h"

View File

@ -10,6 +10,9 @@
#include "SkRRect.h"
class SkRBuffer;
class SkWBuffer;
class SkRRectPriv {
public:
static bool IsCircle(const SkRRect& rr) {
@ -30,6 +33,10 @@ public:
}
static bool AllCornersCircular(const SkRRect& rr, SkScalar tolerance = SK_ScalarNearlyZero);
static bool ReadFromBuffer(SkRBuffer* buffer, SkRRect* rr);
static void WriteToBuffer(const SkRRect& rr, SkWBuffer* buffer);
};
#endif