aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pipe
diff options
context:
space:
mode:
authorGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-08 18:30:46 +0000
committerGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-08 18:30:46 +0000
commit94e75ee46a569cbcdf61fb7f04ee3a69d3ca0896 (patch)
tree69459ed6333c977be86dd36e503593a44a067e94 /src/pipe
parent97caebc7462c202ab0ec5cce4eb26a616930813e (diff)
Rename the existing flatten(void*) methods.
This change avoids naminc confusion with the SkFlattenable flatten methods and also changes SkPath to use the void* model instead of taking a SkReader32. Review URL: https://codereview.appspot.com/6299062 git-svn-id: http://skia.googlecode.com/svn/trunk@4215 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pipe')
-rw-r--r--src/pipe/SkGPipeRead.cpp6
-rw-r--r--src/pipe/SkGPipeWrite.cpp36
2 files changed, 13 insertions, 29 deletions
diff --git a/src/pipe/SkGPipeRead.cpp b/src/pipe/SkGPipeRead.cpp
index ddc0cc41d9..85f46fd944 100644
--- a/src/pipe/SkGPipeRead.cpp
+++ b/src/pipe/SkGPipeRead.cpp
@@ -142,7 +142,7 @@ template <typename T> const T* skipAlign(SkReader32* reader, int count = 1) {
static void clipPath_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
SkGPipeState* state) {
SkPath path;
- path.unflatten(*reader);
+ reader->readPath(&path);
canvas->clipPath(path, (SkRegion::Op)DrawOp_unpackData(op32),
reader->readBool());
}
@@ -260,7 +260,7 @@ static void drawRect_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
static void drawPath_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
SkGPipeState* state) {
SkPath path;
- path.unflatten(*reader);
+ reader->readPath(&path);
canvas->drawPath(path, state->paint());
}
@@ -331,7 +331,7 @@ static void drawTextOnPath_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op3
const void* text = reader->skip(SkAlign4(len));
SkPath path;
- path.unflatten(*reader);
+ reader->readPath(&path);
SkMatrix matrixStorage;
const SkMatrix* matrix = NULL;
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index 5d359889a2..24ca0eac49 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -43,22 +43,6 @@ static SkFlattenable* get_paintflat(const SkPaint& paint, unsigned paintFlat) {
return NULL;
}
-static size_t estimateFlattenSize(const SkPath& path) {
- int n = path.countPoints();
- size_t bytes = 3 * sizeof(int32_t);
- bytes += n * sizeof(SkPoint);
- bytes += SkAlign4(n + 2); // verbs: add 2 for move/close extras
-
-#ifdef SK_DEBUG
- {
- SkWriter32 writer(1024);
- path.flatten(writer);
- SkASSERT(writer.size() <= bytes);
- }
-#endif
- return bytes;
-}
-
static size_t writeTypeface(SkWriter32* writer, SkTypeface* typeface) {
SkASSERT(typeface);
SkDynamicMemoryWStream stream;
@@ -449,7 +433,7 @@ bool SkGPipeCanvas::skew(SkScalar sx, SkScalar sy) {
bool SkGPipeCanvas::concat(const SkMatrix& matrix) {
if (!matrix.isIdentity()) {
NOTIFY_SETUP(this);
- if (this->needOpBytes(matrix.flatten(NULL))) {
+ if (this->needOpBytes(matrix.writeToMemory(NULL))) {
this->writeOp(kConcat_DrawOp);
fWriter.writeMatrix(matrix);
}
@@ -459,7 +443,7 @@ bool SkGPipeCanvas::concat(const SkMatrix& matrix) {
void SkGPipeCanvas::setMatrix(const SkMatrix& matrix) {
NOTIFY_SETUP(this);
- if (this->needOpBytes(matrix.flatten(NULL))) {
+ if (this->needOpBytes(matrix.writeToMemory(NULL))) {
this->writeOp(kSetMatrix_DrawOp);
fWriter.writeMatrix(matrix);
}
@@ -480,9 +464,9 @@ bool SkGPipeCanvas::clipRect(const SkRect& rect, SkRegion::Op rgnOp,
bool SkGPipeCanvas::clipPath(const SkPath& path, SkRegion::Op rgnOp,
bool doAntiAlias) {
NOTIFY_SETUP(this);
- if (this->needOpBytes(estimateFlattenSize(path)) + sizeof(bool)) {
+ if (this->needOpBytes(path.writeToMemory(NULL)) + sizeof(bool)) {
this->writeOp(kClipPath_DrawOp, 0, rgnOp);
- path.flatten(fWriter);
+ fWriter.writePath(path);
fWriter.writeBool(doAntiAlias);
}
// we just pass on the bounds of the path
@@ -491,7 +475,7 @@ bool SkGPipeCanvas::clipPath(const SkPath& path, SkRegion::Op rgnOp,
bool SkGPipeCanvas::clipRegion(const SkRegion& region, SkRegion::Op rgnOp) {
NOTIFY_SETUP(this);
- if (this->needOpBytes(region.flatten(NULL))) {
+ if (this->needOpBytes(region.writeToMemory(NULL))) {
this->writeOp(kClipRegion_DrawOp, 0, rgnOp);
fWriter.writeRegion(region);
}
@@ -547,9 +531,9 @@ void SkGPipeCanvas::drawRect(const SkRect& rect, const SkPaint& paint) {
void SkGPipeCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
NOTIFY_SETUP(this);
this->writePaint(paint);
- if (this->needOpBytes(estimateFlattenSize(path))) {
+ if (this->needOpBytes(path.writeToMemory(NULL))) {
this->writeOp(kDrawPath_DrawOp);
- path.flatten(fWriter);
+ fWriter.writePath(path);
}
}
@@ -696,10 +680,10 @@ void SkGPipeCanvas::drawTextOnPath(const void* text, size_t byteLength,
if (byteLength) {
NOTIFY_SETUP(this);
unsigned flags = 0;
- size_t size = 4 + SkAlign4(byteLength) + estimateFlattenSize(path);
+ size_t size = 4 + SkAlign4(byteLength) + path.writeToMemory(NULL);
if (matrix) {
flags |= kDrawTextOnPath_HasMatrix_DrawOpFlag;
- size += matrix->flatten(NULL);
+ size += matrix->writeToMemory(NULL);
}
this->writePaint(paint);
if (this->needOpBytes(size)) {
@@ -708,7 +692,7 @@ void SkGPipeCanvas::drawTextOnPath(const void* text, size_t byteLength,
fWriter.write32(byteLength);
fWriter.writePad(text, byteLength);
- path.flatten(fWriter);
+ fWriter.writePath(path);
if (matrix) {
fWriter.writeMatrix(*matrix);
}