aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-11-11 21:34:54 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-11-11 21:34:54 +0000
commit83ab49556ffc83fd3b2c1142db264362d21e6b19 (patch)
tree984c4c0070c32201dee468f2fa7a34ce29c49fff /src/core
parent74b98715a375e5e4863115d681386c9f5ec194f5 (diff)
record doAA param for clipRect and clipPath in pictures
git-svn-id: http://skia.googlecode.com/svn/trunk@2669 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkPictureFlat.h19
-rw-r--r--src/core/SkPicturePlayback.cpp15
-rw-r--r--src/core/SkPictureRecord.cpp6
3 files changed, 32 insertions, 8 deletions
diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h
index e46a931e70..bd212b827f 100644
--- a/src/core/SkPictureFlat.h
+++ b/src/core/SkPictureFlat.h
@@ -57,6 +57,25 @@ enum DrawVertexFlags {
DRAW_VERTICES_HAS_INDICES = 0x04
};
+///////////////////////////////////////////////////////////////////////////////
+// clipparams are packed in 5 bits
+// doAA:1 | regionOp:4
+
+static inline uint32_t ClipParams_pack(SkRegion::Op op, bool doAA) {
+ unsigned doAABit = doAA ? 1 : 0;
+ return (doAABit << 4) | op;
+}
+
+static inline SkRegion::Op ClipParams_unpackRegionOp(uint32_t packed) {
+ return (SkRegion::Op)(packed & 0xF);
+}
+
+static inline bool ClipParams_unpackDoAA(uint32_t packed) {
+ return SkToBool((packed >> 4) & 1);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
class SkRefCntPlayback {
public:
SkRefCntPlayback();
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index b75ae40215..d922051e3f 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -509,9 +509,11 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
switch (fReader.readInt()) {
case CLIP_PATH: {
const SkPath& path = getPath();
- SkRegion::Op op = (SkRegion::Op) getInt();
+ uint32_t packed = getInt();
+ SkRegion::Op op = ClipParams_unpackRegionOp(packed);
+ bool doAA = ClipParams_unpackDoAA(packed);
size_t offsetToRestore = getInt();
- if (!canvas.clipPath(path, op) && offsetToRestore) {
+ if (!canvas.clipPath(path, op, doAA) && offsetToRestore) {
#ifdef SPEW_CLIP_SKIPPING
skipPath.recordSkip(offsetToRestore - fReader.offset());
#endif
@@ -520,7 +522,8 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
} break;
case CLIP_REGION: {
const SkRegion& region = getRegion();
- SkRegion::Op op = (SkRegion::Op) getInt();
+ uint32_t packed = getInt();
+ SkRegion::Op op = ClipParams_unpackRegionOp(packed);
size_t offsetToRestore = getInt();
if (!canvas.clipRegion(region, op) && offsetToRestore) {
#ifdef SPEW_CLIP_SKIPPING
@@ -531,9 +534,11 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
} break;
case CLIP_RECT: {
const SkRect& rect = fReader.skipT<SkRect>();
- SkRegion::Op op = (SkRegion::Op) getInt();
+ uint32_t packed = getInt();
+ SkRegion::Op op = ClipParams_unpackRegionOp(packed);
+ bool doAA = ClipParams_unpackDoAA(packed);
size_t offsetToRestore = getInt();
- if (!canvas.clipRect(rect, op) && offsetToRestore) {
+ if (!canvas.clipRect(rect, op, doAA) && offsetToRestore) {
#ifdef SPEW_CLIP_SKIPPING
skipRect.recordSkip(offsetToRestore - fReader.offset());
#endif
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index a8a4cb2623..7997b74b88 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -166,7 +166,7 @@ void SkPictureRecord::recordOffsetForRestore(SkRegion::Op op) {
bool SkPictureRecord::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
addDraw(CLIP_RECT);
addRect(rect);
- addInt(op);
+ addInt(ClipParams_pack(op, doAA));
this->recordOffsetForRestore(op);
@@ -177,7 +177,7 @@ bool SkPictureRecord::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
bool SkPictureRecord::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
addDraw(CLIP_PATH);
addPath(path);
- addInt(op);
+ addInt(ClipParams_pack(op, doAA));
this->recordOffsetForRestore(op);
@@ -193,7 +193,7 @@ bool SkPictureRecord::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
bool SkPictureRecord::clipRegion(const SkRegion& region, SkRegion::Op op) {
addDraw(CLIP_REGION);
addRegion(region);
- addInt(op);
+ addInt(ClipParams_pack(op, false));
this->recordOffsetForRestore(op);