Fix a parenthesis bug.
SkGPipeCanvas::needOpBytes was being called with the wrong value due to a misplaced
parens in clipRect and clipPath. This can cause a crash if clip is called at just
the right (wrong) time. Instead of writing a boolean to the stream, I have added a
flag, which helps to avoid the parens problem.
Also renamed some flags from _DrawOpsFlag to _DrawOpFlag for consistency.
Lastly, added an assert that the size provided by the SkGPipeController is a multiple
of four.
Review URL: https://codereview.appspot.com/6453126
git-svn-id: http://skia.googlecode.com/svn/trunk@5134 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index aad4c8a..42f82c9 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -465,6 +465,7 @@
fDone = true;
return false;
}
+ SkASSERT(SkIsAlign4(fBlockSize));
fWriter.reset(block, fBlockSize);
fBytesNotified = 0;
}
@@ -616,10 +617,10 @@
bool SkGPipeCanvas::clipRect(const SkRect& rect, SkRegion::Op rgnOp,
bool doAntiAlias) {
NOTIFY_SETUP(this);
- if (this->needOpBytes(sizeof(SkRect)) + sizeof(bool)) {
- this->writeOp(kClipRect_DrawOp, 0, rgnOp);
+ if (this->needOpBytes(sizeof(SkRect))) {
+ unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag;
+ this->writeOp(kClipRect_DrawOp, flags, rgnOp);
fWriter.writeRect(rect);
- fWriter.writeBool(doAntiAlias);
}
return this->INHERITED::clipRect(rect, rgnOp, doAntiAlias);
}
@@ -627,10 +628,10 @@
bool SkGPipeCanvas::clipPath(const SkPath& path, SkRegion::Op rgnOp,
bool doAntiAlias) {
NOTIFY_SETUP(this);
- if (this->needOpBytes(path.writeToMemory(NULL)) + sizeof(bool)) {
- this->writeOp(kClipPath_DrawOp, 0, rgnOp);
+ if (this->needOpBytes(path.writeToMemory(NULL))) {
+ unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag;
+ this->writeOp(kClipPath_DrawOp, flags, rgnOp);
fWriter.writePath(path);
- fWriter.writeBool(doAntiAlias);
}
// we just pass on the bounds of the path
return this->INHERITED::clipRect(path.getBounds(), rgnOp, doAntiAlias);
@@ -705,7 +706,7 @@
size_t opBytesNeeded,
const SkPaint* paint) {
if (paint != NULL) {
- flags |= kDrawBitmap_HasPaint_DrawOpsFlag;
+ flags |= kDrawBitmap_HasPaint_DrawOpFlag;
this->writePaint(*paint);
}
if (this->needOpBytes(opBytesNeeded)) {
@@ -738,7 +739,7 @@
bool hasSrc = src != NULL;
unsigned flags;
if (hasSrc) {
- flags = kDrawBitmap_HasSrcRect_DrawOpsFlag;
+ flags = kDrawBitmap_HasSrcRect_DrawOpFlag;
opBytesNeeded += sizeof(int32_t) * 4;
} else {
flags = 0;