diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkCanvas.cpp | 81 | ||||
-rw-r--r-- | src/core/SkPictureFlat.h | 6 | ||||
-rw-r--r-- | src/core/SkPicturePlayback.cpp | 11 | ||||
-rw-r--r-- | src/core/SkPictureRecord.cpp | 33 | ||||
-rw-r--r-- | src/core/SkPictureRecord.h | 4 | ||||
-rw-r--r-- | src/core/SkRecordDraw.cpp | 2 | ||||
-rw-r--r-- | src/core/SkRecorder.cpp | 6 | ||||
-rw-r--r-- | src/core/SkRecorder.h | 2 | ||||
-rw-r--r-- | src/core/SkRemote.cpp | 19 | ||||
-rw-r--r-- | src/core/SkRemote.h | 2 | ||||
-rw-r--r-- | src/pipe/SkGPipeRead.cpp | 4 | ||||
-rw-r--r-- | src/pipe/SkGPipeWrite.cpp | 19 | ||||
-rw-r--r-- | src/utils/SkDumpCanvas.cpp | 12 | ||||
-rw-r--r-- | src/utils/SkLuaCanvas.cpp | 13 | ||||
-rw-r--r-- | src/utils/SkNWayCanvas.cpp | 7 | ||||
-rw-r--r-- | src/utils/debugger/SkDebugCanvas.cpp | 7 | ||||
-rw-r--r-- | src/utils/debugger/SkDebugCanvas.h | 2 | ||||
-rw-r--r-- | src/utils/debugger/SkDrawCommand.cpp | 29 | ||||
-rw-r--r-- | src/utils/debugger/SkDrawCommand.h | 13 | ||||
-rw-r--r-- | src/utils/debugger/SkObjectParser.cpp | 13 | ||||
-rw-r--r-- | src/utils/debugger/SkObjectParser.h | 6 |
21 files changed, 159 insertions, 132 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 414e94ed59..09fef0bbed 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -481,7 +481,7 @@ public: // Make rawBounds include all paint outsets except for those due to image filters. rawBounds = &apply_paint_to_bounds_sans_imagefilter(*fPaint, *rawBounds, &storage); } - (void)canvas->internalSaveLayer(rawBounds, &tmp, SkCanvas::kARGB_ClipLayer_SaveFlag, + (void)canvas->internalSaveLayer(SkCanvas::SaveLayerRec(rawBounds, &tmp, 0), SkCanvas::kFullLayer_SaveLayerStrategy); fTempLayerForImageFilter = true; // we remove the imagefilter/xfermode inside doNext() @@ -1053,15 +1053,15 @@ void SkCanvas::internalSave() { fClipStack->save(); } -static bool bounds_affects_clip(SkCanvas::SaveFlags flags) { +bool SkCanvas::BoundsAffectsClip(SaveLayerFlags saveLayerFlags) { #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG - return (flags & SkCanvas::kClipToLayer_SaveFlag) != 0; + return !(saveLayerFlags & SkCanvas::kDontClipToLayer_PrivateSaveLayerFlag); #else return true; #endif } -bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags, +bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveLayerFlags saveLayerFlags, SkIRect* intersection, const SkImageFilter* imageFilter) { SkIRect clipBounds; if (!this->getClipDeviceBounds(&clipBounds)) { @@ -1098,7 +1098,7 @@ bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags, r.roundOut(&ir); // early exit if the layer's bounds are clipped out if (!ir.intersect(clipBounds)) { - if (bounds_affects_clip(flags)) { + if (BoundsAffectsClip(saveLayerFlags)) { fCachedLocalClipBoundsDirty = true; fMCRec->fRasterClip.setEmpty(); } @@ -1109,7 +1109,7 @@ bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags, } SkASSERT(!ir.isEmpty()); - if (bounds_affects_clip(flags)) { + if (BoundsAffectsClip(saveLayerFlags)) { // Simplify the current clips since they will be applied properly during restore() fCachedLocalClipBoundsDirty = true; fClipStack->clipDevRect(ir, SkRegion::kReplace_Op); @@ -1122,31 +1122,55 @@ bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags, return true; } -int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) { - if (gIgnoreSaveLayerBounds) { - bounds = nullptr; +uint32_t SkCanvas::SaveFlagsToSaveLayerFlags(SaveFlags flags) { + uint32_t layerFlags = 0; + + if (0 == (flags & kClipToLayer_SaveFlag)) { + layerFlags |= kDontClipToLayer_PrivateSaveLayerFlag; } - SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, kARGB_ClipLayer_SaveFlag); - fSaveCount += 1; - this->internalSaveLayer(bounds, paint, kARGB_ClipLayer_SaveFlag, strategy); - return this->getSaveCount() - 1; + if (0 == (flags & kHasAlphaLayer_SaveFlag)) { + layerFlags |= kIsOpaque_SaveLayerFlag; + } + return layerFlags; +} + +#ifdef SK_SUPPORT_LEGACY_SAVELAYERPARAMS +SkCanvas::SaveLayerStrategy SkCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) { + uint32_t flags = 0; + + if (0 == (rec.fSaveLayerFlags & kDontClipToLayer_PrivateSaveLayerFlag)) { + flags |= kClipToLayer_SaveFlag; + } + if (0 == (rec.fSaveLayerFlags & kIsOpaque_SaveLayerFlag)) { + flags |= kHasAlphaLayer_SaveFlag; + } + return this->willSaveLayer(rec.fBounds, rec.fPaint, (SaveFlags)flags); +} +#endif + +int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) { + return this->saveLayer(SaveLayerRec(bounds, paint, 0)); } int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags) { + return this->saveLayer(SaveLayerRec(bounds, paint, SaveFlagsToSaveLayerFlags(flags))); +} + +int SkCanvas::saveLayerPreserveLCDTextRequests(const SkRect* bounds, const SkPaint* paint) { + return this->saveLayer(SaveLayerRec(bounds, paint, kPreserveLCDText_SaveLayerFlag)); +} + +int SkCanvas::saveLayer(const SaveLayerRec& origRec) { + SaveLayerRec rec(origRec); if (gIgnoreSaveLayerBounds) { - bounds = nullptr; + rec.fBounds = nullptr; } - SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags); + SaveLayerStrategy strategy = this->getSaveLayerStrategy(rec); fSaveCount += 1; - this->internalSaveLayer(bounds, paint, flags, strategy); + this->internalSaveLayer(rec, strategy); return this->getSaveCount() - 1; } -int SkCanvas::saveLayerPreserveLCDTextRequests(const SkRect* bounds, const SkPaint* paint) { - unsigned flags = kARGB_ClipLayer_SaveFlag | kPreserveLCDText_PrivateSaveFlag; - return this->saveLayer(bounds, paint, (SaveFlags)flags); -} - static void draw_filter_into_device(SkBaseDevice* src, SkImageFilter* filter, SkBaseDevice* dst) { SkBitmap srcBM; @@ -1177,10 +1201,13 @@ static void draw_filter_into_device(SkBaseDevice* src, SkImageFilter* filter, Sk c.drawBitmap(srcBM, 0, 0, &p); } -void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags, - SaveLayerStrategy strategy) { +void SkCanvas::internalSaveLayer(const SaveLayerRec& rec, SaveLayerStrategy strategy) { + const SkRect* bounds = rec.fBounds; + const SkPaint* paint = rec.fPaint; + SaveLayerFlags saveLayerFlags = rec.fSaveLayerFlags; + #ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG - flags |= kClipToLayer_SaveFlag; + saveLayerFlags &= ~kDontClipToLayer_PrivateSaveLayerFlag; #endif // do this before we create the layer. We don't call the public save() since @@ -1190,7 +1217,7 @@ void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav fDeviceCMDirty = true; SkIRect ir; - if (!this->clipRectBounds(bounds, flags, &ir, paint ? paint->getImageFilter() : nullptr)) { + if (!this->clipRectBounds(bounds, saveLayerFlags, &ir, paint ? paint->getImageFilter() : nullptr)) { return; } @@ -1200,7 +1227,7 @@ void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav return; } - bool isOpaque = !SkToBool(flags & kHasAlphaLayer_SaveFlag); + bool isOpaque = SkToBool(saveLayerFlags & kIsOpaque_SaveLayerFlag); SkPixelGeometry geo = fProps.pixelGeometry(); if (paint) { // TODO: perhaps add a query to filters so we might preserve opaqueness... @@ -1221,7 +1248,7 @@ void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav bool forceSpriteOnRestore = false; { const bool preserveLCDText = kOpaque_SkAlphaType == info.alphaType() || - SkToBool(flags & kPreserveLCDText_PrivateSaveFlag); + (saveLayerFlags & kPreserveLCDText_SaveLayerFlag); const SkBaseDevice::TileUsage usage = SkBaseDevice::kNever_TileUsage; const SkBaseDevice::CreateInfo createInfo = SkBaseDevice::CreateInfo(info, usage, geo, preserveLCDText, false); diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h index 8befca0538..cbacc8e664 100644 --- a/src/core/SkPictureFlat.h +++ b/src/core/SkPictureFlat.h @@ -51,7 +51,7 @@ enum DrawType { RESTORE, ROTATE, SAVE, - SAVE_LAYER, + SAVE_LAYER_SAVEFLAGS_DEPRECATED, SCALE, SET_MATRIX, SKEW, @@ -75,7 +75,9 @@ enum DrawType { DRAW_IMAGE_NINE, DRAW_IMAGE_RECT, - LAST_DRAWTYPE_ENUM = DRAW_IMAGE_RECT + SAVE_LAYER_SAVELAYERFLAGS, + + LAST_DRAWTYPE_ENUM = SAVE_LAYER_SAVELAYERFLAGS, }; // In the 'match' method, this constant will match any flavor of DRAW_BITMAP* diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp index 9b27a3d1e9..187eeb96e1 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPicturePlayback.cpp @@ -455,10 +455,17 @@ void SkPicturePlayback::handleOp(SkReader32* reader, } canvas->save(); break; - case SAVE_LAYER: { + case SAVE_LAYER_SAVEFLAGS_DEPRECATED: { const SkRect* boundsPtr = get_rect_ptr(reader); const SkPaint* paint = fPictureData->getPaint(reader); - canvas->saveLayer(boundsPtr, paint, (SkCanvas::SaveFlags) reader->readInt()); + const SkCanvas::SaveFlags flags = (SkCanvas::SaveFlags)reader->readInt(); + canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, + SkCanvas::SaveFlagsToSaveLayerFlags(flags))); + } break; + case SAVE_LAYER_SAVELAYERFLAGS: { + const SkRect* boundsPtr = get_rect_ptr(reader); + const SkPaint* paint = fPictureData->getPaint(reader); + canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, reader->readInt())); } break; case SCALE: { SkScalar sx = reader->readScalar(); diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index f9ab0c93c1..36b8d379f5 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -83,7 +83,7 @@ static inline size_t get_paint_offset(DrawType op, size_t opSize) { 0, // RESTORE - no paint 0, // ROTATE - no paint 0, // SAVE - no paint - 0, // SAVE_LAYER - see below - this paint's location varies + 0, // SAVE_LAYER_SAVEFLAGS_DEPRECATED - see below - this paint's location varies 0, // SCALE - no paint 0, // SET_MATRIX - no paint 0, // SKEW - no paint @@ -103,6 +103,7 @@ static inline size_t get_paint_offset(DrawType op, size_t opSize) { 1, // DRAW_ATLAS - right after op code 1, // DRAW_IMAGE_NINE - right after op code 1, // DRAW_IMAGE_RECT - right after op code + 0, // SAVE_LAYER_SAVELAYERFLAGS - see below - this paint's location varies }; static_assert(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1, "need_to_be_in_sync"); @@ -115,7 +116,8 @@ static inline size_t get_paint_offset(DrawType op, size_t opSize) { overflow = sizeof(uint32_t); } - if (SAVE_LAYER == op) { + SkASSERT(SAVE_LAYER_SAVEFLAGS_DEPRECATED != op); + if (SAVE_LAYER_SAVELAYERFLAGS == op) { static const uint32_t kSaveLayerNoBoundsPaintOffset = 2 * kUInt32Size; static const uint32_t kSaveLayerWithBoundsPaintOffset = 2 * kUInt32Size + sizeof(SkRect); @@ -151,14 +153,13 @@ void SkPictureRecord::recordSave() { this->validate(initialOffset, size); } -SkCanvas::SaveLayerStrategy SkPictureRecord::willSaveLayer(const SkRect* bounds, - const SkPaint* paint, SaveFlags flags) { +SkCanvas::SaveLayerStrategy SkPictureRecord::getSaveLayerStrategy(const SaveLayerRec& rec) { // record the offset to us, making it non-positive to distinguish a save // from a clip entry. fRestoreOffsetStack.push(-(int32_t)fWriter.bytesWritten()); - this->recordSaveLayer(bounds, paint, flags); + this->recordSaveLayer(rec); - this->INHERITED::willSaveLayer(bounds, paint, flags); + (void)this->INHERITED::getSaveLayerStrategy(rec); /* No need for a (potentially very big) layer which we don't actually need at this time (and may not be able to afford since during record our clip starts out the size of the picture, which is often much larger @@ -167,25 +168,24 @@ SkCanvas::SaveLayerStrategy SkPictureRecord::willSaveLayer(const SkRect* bounds, return kNoLayer_SaveLayerStrategy; } -void SkPictureRecord::recordSaveLayer(const SkRect* bounds, const SkPaint* paint, - SaveFlags flags) { +void SkPictureRecord::recordSaveLayer(const SaveLayerRec& rec) { fContentInfo.onSaveLayer(); // op + bool for 'bounds' size_t size = 2 * kUInt32Size; - if (bounds) { - size += sizeof(*bounds); // + rect + if (rec.fBounds) { + size += sizeof(*rec.fBounds); // + rect } // + paint index + flags size += 2 * kUInt32Size; SkASSERT(kSaveLayerNoBoundsSize == size || kSaveLayerWithBoundsSize == size); - size_t initialOffset = this->addDraw(SAVE_LAYER, &size); - this->addRectPtr(bounds); - SkASSERT(initialOffset+get_paint_offset(SAVE_LAYER, size) == fWriter.bytesWritten()); - this->addPaintPtr(paint); - this->addInt(flags); + size_t initialOffset = this->addDraw(SAVE_LAYER_SAVELAYERFLAGS, &size); + this->addRectPtr(rec.fBounds); + SkASSERT(initialOffset+get_paint_offset(SAVE_LAYER_SAVELAYERFLAGS, size) == fWriter.bytesWritten()); + this->addPaintPtr(rec.fPaint); + this->addInt(rec.fSaveLayerFlags); this->validate(initialOffset, size); } @@ -321,7 +321,8 @@ void SkPictureRecord::fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t // assert that the final offset value points to a save verb uint32_t opSize; DrawType drawOp = peek_op_and_size(&fWriter, -offset, &opSize); - SkASSERT(SAVE == drawOp || SAVE_LAYER == drawOp); + SkASSERT(SAVE_LAYER_SAVEFLAGS_DEPRECATED != drawOp); + SkASSERT(SAVE == drawOp || SAVE_LAYER_SAVELAYERFLAGS == drawOp); } #endif } diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h index 3dcaa6ce4c..2e1e62a021 100644 --- a/src/core/SkPictureRecord.h +++ b/src/core/SkPictureRecord.h @@ -153,7 +153,7 @@ protected: bool onPeekPixels(SkPixmap*) override { return false; } void willSave() override; - SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) override; + SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; void willRestore() override; void didConcat(const SkMatrix&) override; @@ -218,7 +218,7 @@ protected: size_t recordClipPath(int pathID, SkRegion::Op op, bool doAA); size_t recordClipRegion(const SkRegion& region, SkRegion::Op op); void recordSave(); - void recordSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags); + void recordSaveLayer(const SaveLayerRec&); void recordRestore(bool fillInSkips = true); private: diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp index f512ecf015..01846676b6 100644 --- a/src/core/SkRecordDraw.cpp +++ b/src/core/SkRecordDraw.cpp @@ -78,7 +78,7 @@ template <> void Draw::draw(const NoOp&) {} #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; } DRAW(Restore, restore()); DRAW(Save, save()); -DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags)); +DRAW(SaveLayer, saveLayer(SkCanvas::SaveLayerRec(r.bounds, r.paint, r.saveLayerFlags))); DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); DRAW(Concat, concat(r.matrix)); diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp index c7a826f463..67429a691e 100644 --- a/src/core/SkRecorder.cpp +++ b/src/core/SkRecorder.cpp @@ -336,10 +336,8 @@ void SkRecorder::willSave() { APPEND(Save); } -SkCanvas::SaveLayerStrategy SkRecorder::willSaveLayer(const SkRect* bounds, - const SkPaint* paint, - SkCanvas::SaveFlags flags) { - APPEND(SaveLayer, this->copy(bounds), this->copy(paint), flags); +SkCanvas::SaveLayerStrategy SkRecorder::getSaveLayerStrategy(const SaveLayerRec& rec) { + APPEND(SaveLayer, this->copy(rec.fBounds), this->copy(rec.fPaint), rec.fSaveLayerFlags); return SkCanvas::kNoLayer_SaveLayerStrategy; } diff --git a/src/core/SkRecorder.h b/src/core/SkRecorder.h index 6bde375db4..cd5bc8ad04 100644 --- a/src/core/SkRecorder.h +++ b/src/core/SkRecorder.h @@ -54,7 +54,7 @@ public: void forgetRecord(); void willSave() override; - SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SkCanvas::SaveFlags) override; + SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; void willRestore() override {} void didRestore() override; diff --git a/src/core/SkRemote.cpp b/src/core/SkRemote.cpp index 1209be014c..22185cddb0 100644 --- a/src/core/SkRemote.cpp +++ b/src/core/SkRemote.cpp @@ -163,18 +163,17 @@ namespace SkRemote { void willSave() override { fEncoder-> save(); } void didRestore() override { fEncoder->restore(); } - SaveLayerStrategy willSaveLayer(const SkRect* bounds, - const SkPaint* paint, - SaveFlags flags) override { + SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override { SkPath path; - if (bounds) { - path.addRect(*bounds); + if (rec.fBounds) { + path.addRect(*rec.fBounds); } const SkPaint defaultPaint; + const SkPaint* paint = rec.fPaint; if (!paint) { paint = &defaultPaint; } - fEncoder->saveLayer(this->id(path), this->commonIDs(*paint), flags); + fEncoder->saveLayer(this->id(path), this->commonIDs(*paint), rec.fSaveLayerFlags); return kNoLayer_SaveLayerStrategy; } @@ -500,11 +499,13 @@ namespace SkRemote { void save() override { fCanvas->save(); } void restore() override { fCanvas->restore(); } - void saveLayer(ID bounds, CommonIDs common, SkCanvas::SaveFlags flags) override { + void saveLayer(ID bounds, CommonIDs common, SkCanvas::SaveLayerFlags flags) override { SkPaint paint; this->applyCommon(common, &paint); SkRect rect; - fCanvas->saveLayer(fPath.find(bounds).isRect(&rect) ? &rect : nullptr, &paint, flags); + + fCanvas->saveLayer({ fPath.find(bounds).isRect(&rect) ? &rect : nullptr, + &paint, flags }); } void setMatrix(ID matrix) override { fCanvas->setMatrix(fMatrix.find(matrix)); } @@ -684,7 +685,7 @@ namespace SkRemote { void save() override { fWrapped-> save(); } void restore() override { fWrapped->restore(); } - void saveLayer(ID bounds, CommonIDs common, SkCanvas::SaveFlags flags) override { + void saveLayer(ID bounds, CommonIDs common, SkCanvas::SaveLayerFlags flags) override { fWrapped->saveLayer(bounds, common, flags); } diff --git a/src/core/SkRemote.h b/src/core/SkRemote.h index 924e63e220..a1b1405b21 100644 --- a/src/core/SkRemote.h +++ b/src/core/SkRemote.h @@ -91,7 +91,7 @@ namespace SkRemote { virtual void save() = 0; virtual void restore() = 0; - virtual void saveLayer(ID bounds, CommonIDs, SkCanvas::SaveFlags) = 0; + virtual void saveLayer(ID bounds, CommonIDs, uint32_t saveLayerFlags) = 0; virtual void setMatrix(ID matrix) = 0; diff --git a/src/pipe/SkGPipeRead.cpp b/src/pipe/SkGPipeRead.cpp index 24f3e2d1ea..b48389abea 100644 --- a/src/pipe/SkGPipeRead.cpp +++ b/src/pipe/SkGPipeRead.cpp @@ -335,7 +335,7 @@ static void save_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, static void saveLayer_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, SkGPipeState* state) { unsigned flags = DrawOp_unpackFlags(op32); - SkCanvas::SaveFlags saveFlags = (SkCanvas::SaveFlags)DrawOp_unpackData(op32); + SkCanvas::SaveLayerFlags saveLayerFlags = DrawOp_unpackData(op32); const SkRect* bounds = nullptr; if (flags & kSaveLayer_HasBounds_DrawOpFlag) { @@ -345,7 +345,7 @@ static void saveLayer_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, if (flags & kSaveLayer_HasPaint_DrawOpFlag) { paint = &state->paint(); } - canvas->saveLayer(bounds, paint, saveFlags); + canvas->saveLayer(SkCanvas::SaveLayerRec(bounds, paint, saveLayerFlags)); } static void restore_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp index 2cab09c9e1..5147cd688d 100644 --- a/src/pipe/SkGPipeWrite.cpp +++ b/src/pipe/SkGPipeWrite.cpp @@ -248,7 +248,7 @@ public: protected: void willSave() override; - SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) override; + SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; void willRestore() override; void didConcat(const SkMatrix&) override; @@ -542,29 +542,28 @@ void SkGPipeCanvas::willSave() { this->INHERITED::willSave(); } -SkCanvas::SaveLayerStrategy SkGPipeCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint, - SaveFlags saveFlags) { +SkCanvas::SaveLayerStrategy SkGPipeCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) { NOTIFY_SETUP(this); size_t size = 0; unsigned opFlags = 0; - if (bounds) { + if (rec.fBounds) { opFlags |= kSaveLayer_HasBounds_DrawOpFlag; size += sizeof(SkRect); } - if (paint) { + if (rec.fPaint) { opFlags |= kSaveLayer_HasPaint_DrawOpFlag; - this->writePaint(*paint); + this->writePaint(*rec.fPaint); } if (this->needOpBytes(size)) { - this->writeOp(kSaveLayer_DrawOp, opFlags, saveFlags); - if (bounds) { - fWriter.writeRect(*bounds); + this->writeOp(kSaveLayer_DrawOp, opFlags, rec.fSaveLayerFlags); + if (rec.fBounds) { + fWriter.writeRect(*rec.fBounds); } } - this->INHERITED::willSaveLayer(bounds, paint, saveFlags); + (void)this->INHERITED::getSaveLayerStrategy(rec); // we don't create a layer return kNoLayer_SaveLayerStrategy; } diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp index a5005610ae..916c32a655 100644 --- a/src/utils/SkDumpCanvas.cpp +++ b/src/utils/SkDumpCanvas.cpp @@ -199,14 +199,14 @@ void SkDumpCanvas::willSave() { this->INHERITED::willSave(); } -SkCanvas::SaveLayerStrategy SkDumpCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint, - SaveFlags flags) { +SkCanvas::SaveLayerStrategy SkDumpCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) { SkString str; - str.printf("saveLayer(0x%X)", flags); - if (bounds) { + str.printf("saveLayer(0x%X)", rec.fSaveLayerFlags); + if (rec.fBounds) { str.append(" bounds"); - toString(*bounds, &str); + toString(*rec.fBounds, &str); } + const SkPaint* paint = rec.fPaint; if (paint) { if (paint->getAlpha() != 0xFF) { str.appendf(" alpha:0x%02X", paint->getAlpha()); @@ -216,7 +216,7 @@ SkCanvas::SaveLayerStrategy SkDumpCanvas::willSaveLayer(const SkRect* bounds, co } } this->dump(kSave_Verb, paint, str.c_str()); - return this->INHERITED::willSaveLayer(bounds, paint, flags); + return this->INHERITED::getSaveLayerStrategy(rec); } void SkDumpCanvas::willRestore() { diff --git a/src/utils/SkLuaCanvas.cpp b/src/utils/SkLuaCanvas.cpp index 4916decccb..c51b0d8a7c 100644 --- a/src/utils/SkLuaCanvas.cpp +++ b/src/utils/SkLuaCanvas.cpp @@ -86,17 +86,16 @@ void SkLuaCanvas::willSave() { this->INHERITED::willSave(); } -SkCanvas::SaveLayerStrategy SkLuaCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint, - SaveFlags flags) { +SkCanvas::SaveLayerStrategy SkLuaCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) { AUTO_LUA("saveLayer"); - if (bounds) { - lua.pushRect(*bounds, "bounds"); + if (rec.fBounds) { + lua.pushRect(*rec.fBounds, "bounds"); } - if (paint) { - lua.pushPaint(*paint, "paint"); + if (rec.fPaint) { + lua.pushPaint(*rec.fPaint, "paint"); } - this->INHERITED::willSaveLayer(bounds, paint, flags); + (void)this->INHERITED::getSaveLayerStrategy(rec); // No need for a layer. return kNoLayer_SaveLayerStrategy; } diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp index 05909a33fa..4f60ca33cf 100644 --- a/src/utils/SkNWayCanvas.cpp +++ b/src/utils/SkNWayCanvas.cpp @@ -66,14 +66,13 @@ void SkNWayCanvas::willSave() { this->INHERITED::willSave(); } -SkCanvas::SaveLayerStrategy SkNWayCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint, - SaveFlags flags) { +SkCanvas::SaveLayerStrategy SkNWayCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) { Iter iter(fList); while (iter.next()) { - iter->saveLayer(bounds, paint, flags); + iter->saveLayer(rec); } - this->INHERITED::willSaveLayer(bounds, paint, flags); + this->INHERITED::getSaveLayerStrategy(rec); // No need for a layer. return kNoLayer_SaveLayerStrategy; } diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp index 86937392a6..560976cbb7 100644 --- a/src/utils/debugger/SkDebugCanvas.cpp +++ b/src/utils/debugger/SkDebugCanvas.cpp @@ -524,10 +524,9 @@ void SkDebugCanvas::willSave() { this->INHERITED::willSave(); } -SkCanvas::SaveLayerStrategy SkDebugCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint, - SaveFlags flags) { - this->addDrawCommand(new SkSaveLayerCommand(bounds, paint, flags)); - this->INHERITED::willSaveLayer(bounds, paint, flags); +SkCanvas::SaveLayerStrategy SkDebugCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) { + this->addDrawCommand(new SkSaveLayerCommand(rec)); + (void)this->INHERITED::getSaveLayerStrategy(rec); // No need for a full layer. return kNoLayer_SaveLayerStrategy; } diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h index 7de2b59437..217b52e3ce 100644 --- a/src/utils/debugger/SkDebugCanvas.h +++ b/src/utils/debugger/SkDebugCanvas.h @@ -165,7 +165,7 @@ public: protected: void willSave() override; - SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) override; + SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; void willRestore() override; void didConcat(const SkMatrix&) override; diff --git a/src/utils/debugger/SkDrawCommand.cpp b/src/utils/debugger/SkDrawCommand.cpp index 9ebb81e74a..bb9f2f831d 100644 --- a/src/utils/debugger/SkDrawCommand.cpp +++ b/src/utils/debugger/SkDrawCommand.cpp @@ -925,36 +925,35 @@ void SkSaveCommand::execute(SkCanvas* canvas) const { canvas->save(); } -SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint, - SkCanvas::SaveFlags flags) +SkSaveLayerCommand::SkSaveLayerCommand(const SkCanvas::SaveLayerRec& rec) : INHERITED(kSaveLayer_OpType) { - if (bounds) { - fBounds = *bounds; + if (rec.fBounds) { + fBounds = *rec.fBounds; } else { fBounds.setEmpty(); } - if (paint) { - fPaint = *paint; + if (rec.fPaint) { + fPaint = *rec.fPaint; fPaintPtr = &fPaint; } else { fPaintPtr = nullptr; } - fFlags = flags; + fSaveLayerFlags = rec.fSaveLayerFlags; - if (bounds) { - fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); + if (rec.fBounds) { + fInfo.push(SkObjectParser::RectToString(*rec.fBounds, "Bounds: ")); } - if (paint) { - fInfo.push(SkObjectParser::PaintToString(*paint)); + if (rec.fPaint) { + fInfo.push(SkObjectParser::PaintToString(*rec.fPaint)); } - fInfo.push(SkObjectParser::SaveFlagsToString(flags)); + fInfo.push(SkObjectParser::SaveLayerFlagsToString(fSaveLayerFlags)); } void SkSaveLayerCommand::execute(SkCanvas* canvas) const { - canvas->saveLayer(fBounds.isEmpty() ? nullptr : &fBounds, - fPaintPtr, - fFlags); + canvas->saveLayer(SkCanvas::SaveLayerRec(fBounds.isEmpty() ? nullptr : &fBounds, + fPaintPtr, + fSaveLayerFlags)); } void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const { diff --git a/src/utils/debugger/SkDrawCommand.h b/src/utils/debugger/SkDrawCommand.h index 9da05eeedb..f67df92de7 100644 --- a/src/utils/debugger/SkDrawCommand.h +++ b/src/utils/debugger/SkDrawCommand.h @@ -551,8 +551,7 @@ private: class SkSaveLayerCommand : public SkDrawCommand { public: - SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint, - SkCanvas::SaveFlags flags); + SkSaveLayerCommand(const SkCanvas::SaveLayerRec&); void execute(SkCanvas* canvas) const override; void vizExecute(SkCanvas* canvas) const override; Action action() const override{ return kPushLayer_Action; } @@ -562,12 +561,12 @@ public: const SkPaint* paint() const { return fPaintPtr; } private: - SkRect fBounds; - SkPaint fPaint; - SkPaint* fPaintPtr; - SkCanvas::SaveFlags fFlags; + SkRect fBounds; + SkPaint fPaint; + SkPaint* fPaintPtr; + uint32_t fSaveLayerFlags; - bool fActive; + bool fActive; typedef SkDrawCommand INHERITED; }; diff --git a/src/utils/debugger/SkObjectParser.cpp b/src/utils/debugger/SkObjectParser.cpp index 3dbc03901f..6d71a38b7b 100644 --- a/src/utils/debugger/SkObjectParser.cpp +++ b/src/utils/debugger/SkObjectParser.cpp @@ -338,16 +338,13 @@ SkString* SkObjectParser::RegionToString(const SkRegion& region) { return mRegion; } -SkString* SkObjectParser::SaveFlagsToString(SkCanvas::SaveFlags flags) { +SkString* SkObjectParser::SaveLayerFlagsToString(SkCanvas::SaveLayerFlags saveLayerFlags) { SkString* mFlags = new SkString("SkCanvas::SaveFlags: "); - if (flags & SkCanvas::kHasAlphaLayer_SaveFlag) { - mFlags->append("kHasAlphaLayer_SaveFlag "); + if (saveLayerFlags & SkCanvas::kIsOpaque_SaveLayerFlag) { + mFlags->append("kIsOpaque_SaveLayerFlag "); } - if (flags & SkCanvas::kFullColorLayer_SaveFlag) { - mFlags->append("kFullColorLayer_SaveFlag "); - } - if (flags & SkCanvas::kClipToLayer_SaveFlag) { - mFlags->append("kClipToLayer_SaveFlag "); + if (saveLayerFlags & SkCanvas::kPreserveLCDText_SaveLayerFlag) { + mFlags->append("kPreserveLCDText_SaveLayerFlag "); } return mFlags; } diff --git a/src/utils/debugger/SkObjectParser.h b/src/utils/debugger/SkObjectParser.h index 4c04935257..9bdfad5e79 100644 --- a/src/utils/debugger/SkObjectParser.h +++ b/src/utils/debugger/SkObjectParser.h @@ -110,10 +110,10 @@ public: static SkString* RegionToString(const SkRegion& region); /** - Returns a string representation of the SkCanvas::SaveFlags enum. - @param flags SkCanvas::SaveFlags enum + Returns a string representation of the SkCanvas::SaveLayerFlags enum. + @param flags SkCanvas::SaveLayerFlags enum */ - static SkString* SaveFlagsToString(SkCanvas::SaveFlags flags); + static SkString* SaveLayerFlagsToString(uint32_t saveLayerFlags); /** Returns a string representation of an SkScalar with the text parameter |