diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkPictureFlat.h | 19 | ||||
-rw-r--r-- | src/core/SkPicturePlayback.cpp | 15 | ||||
-rw-r--r-- | src/core/SkPictureRecord.cpp | 6 |
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); |