diff options
author | 2016-08-01 11:24:03 -0700 | |
---|---|---|
committer | 2016-08-01 11:24:03 -0700 | |
commit | da574d17f864ed70323a1c0fc6e4e969153a4c98 (patch) | |
tree | 1a45e595208f7b4ddb835a515f0609c2d66769e6 /src/core | |
parent | 2dad769dc9e6a2974c4a7de1ffa945706274fab8 (diff) |
Replace old SkRecords RefBox with sk_sp.
The main differences are that RefBox's constructor reffed and sk_sp's doesn't,
and that RefBox auto-casts to the underlying pointer while sk_sp doesn't.
I've added a bunch of sk_ref_sp() and .get() to compensate.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2197243003
Review-Url: https://codereview.chromium.org/2197243003
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkMiniRecorder.cpp | 2 | ||||
-rw-r--r-- | src/core/SkRecordDraw.cpp | 24 | ||||
-rw-r--r-- | src/core/SkRecorder.cpp | 28 |
3 files changed, 31 insertions, 23 deletions
diff --git a/src/core/SkMiniRecorder.cpp b/src/core/SkMiniRecorder.cpp index a5d676aed9..51ff5acbbc 100644 --- a/src/core/SkMiniRecorder.cpp +++ b/src/core/SkMiniRecorder.cpp @@ -79,7 +79,7 @@ bool SkMiniRecorder::drawPath(const SkPath& path, const SkPaint& paint) { } bool SkMiniRecorder::drawTextBlob(const SkTextBlob* b, SkScalar x, SkScalar y, const SkPaint& p) { - TRY_TO_STORE(DrawTextBlob, p, b, x, y); + TRY_TO_STORE(DrawTextBlob, p, sk_ref_sp(b), x, y); } #undef TRY_TO_STORE diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp index 6cb41efea8..8897e5fcf3 100644 --- a/src/core/SkRecordDraw.cpp +++ b/src/core/SkRecordDraw.cpp @@ -77,7 +77,10 @@ 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(SkCanvas::SaveLayerRec(r.bounds, r.paint, r.backdrop, r.saveLayerFlags))); +DRAW(SaveLayer, saveLayer(SkCanvas::SaveLayerRec(r.bounds, + r.paint, + r.backdrop.get(), + r.saveLayerFlags))); DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); DRAW(Concat, concat(r.matrix)); @@ -93,17 +96,17 @@ template <> void Draw::draw(const TranslateZ& r) { } #endif DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint)); -DRAW(DrawImage, drawImage(r.image, r.left, r.top, r.paint)); -DRAW(DrawImageRect, legacy_drawImageRect(r.image, r.src, r.dst, r.paint, r.constraint)); -DRAW(DrawImageNine, drawImageNine(r.image, r.center, r.dst, r.paint)); +DRAW(DrawImage, drawImage(r.image.get(), r.left, r.top, r.paint)); +DRAW(DrawImageRect, legacy_drawImageRect(r.image.get(), r.src, r.dst, r.paint, r.constraint)); +DRAW(DrawImageNine, drawImageNine(r.image.get(), r.center, r.dst, r.paint)); DRAW(DrawOval, drawOval(r.oval, r.paint)); DRAW(DrawPaint, drawPaint(r.paint)); DRAW(DrawPath, drawPath(r.path, r.paint)); DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.xmode, r.paint)); -DRAW(DrawPicture, drawPicture(r.picture, &r.matrix, r.paint)); +DRAW(DrawPicture, drawPicture(r.picture.get(), &r.matrix, r.paint)); #ifdef SK_EXPERIMENTAL_SHADOWING -DRAW(DrawShadowedPicture, drawShadowedPicture(r.picture, &r.matrix, r.paint)); +DRAW(DrawShadowedPicture, drawShadowedPicture(r.picture.get(), &r.matrix, r.paint)); #else template <> void Draw::draw(const DrawShadowedPicture& r) { } #endif @@ -114,13 +117,14 @@ DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint)); DRAW(DrawRRect, drawRRect(r.rrect, r.paint)); DRAW(DrawRect, drawRect(r.rect, r.paint)); DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint)); -DRAW(DrawTextBlob, drawTextBlob(r.blob, r.x, r.y, r.paint)); +DRAW(DrawTextBlob, drawTextBlob(r.blob.get(), r.x, r.y, r.paint)); DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, &r.matrix, r.paint)); DRAW(DrawTextRSXform, drawTextRSXform(r.text, r.byteLength, r.xforms, r.cull, r.paint)); -DRAW(DrawAtlas, drawAtlas(r.atlas, r.xforms, r.texs, r.colors, r.count, r.mode, r.cull, r.paint)); +DRAW(DrawAtlas, drawAtlas(r.atlas.get(), + r.xforms, r.texs, r.colors, r.count, r.mode, r.cull, r.paint)); DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors, r.xmode, r.indices, r.indexCount, r.paint)); -DRAW(DrawAnnotation, drawAnnotation(r.rect, r.key.c_str(), r.value)); +DRAW(DrawAnnotation, drawAnnotation(r.rect, r.key.c_str(), r.value.get())); #undef DRAW template <> void Draw::draw(const DrawDrawable& r) { @@ -403,7 +407,7 @@ private: return this->adjustAndMap(op.outer.rect(), &op.paint); } Bounds bounds(const DrawImage& op) const { - const SkImage* image = op.image; + const SkImage* image = op.image.get(); SkRect rect = SkRect::MakeXYWH(op.left, op.top, image->width(), image->height()); return this->adjustAndMap(rect, op.paint); diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp index 42fc510fe9..c822fdba87 100644 --- a/src/core/SkRecorder.cpp +++ b/src/core/SkRecorder.cpp @@ -208,17 +208,17 @@ void SkRecorder::onDrawBitmapNine(const SkBitmap& bitmap, void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint) { - APPEND(DrawImage, this->copy(paint), image, left, top); + APPEND(DrawImage, this->copy(paint), sk_ref_sp(image), left, top); } void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst, const SkPaint* paint, SrcRectConstraint constraint) { - APPEND(DrawImageRect, this->copy(paint), image, this->copy(src), dst, constraint); + APPEND(DrawImageRect, this->copy(paint), sk_ref_sp(image), this->copy(src), dst, constraint); } void SkRecorder::onDrawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst, const SkPaint* paint) { - APPEND(DrawImageNine, this->copy(paint), image, center, dst); + APPEND(DrawImageNine, this->copy(paint), sk_ref_sp(image), center, dst); } void SkRecorder::onDrawText(const void* text, size_t byteLength, @@ -271,13 +271,13 @@ void SkRecorder::onDrawTextRSXform(const void* text, size_t byteLength, const Sk void SkRecorder::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint) { TRY_MINIRECORDER(drawTextBlob, blob, x, y, paint); - APPEND(DrawTextBlob, paint, blob, x, y); + APPEND(DrawTextBlob, paint, sk_ref_sp(blob), x, y); } void SkRecorder::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, const SkPaint* paint) { if (fDrawPictureMode == Record_DrawPictureMode) { fApproxBytesUsedBySubPictures += SkPictureUtils::ApproximateBytesUsed(pic); - APPEND(DrawPicture, this->copy(paint), pic, matrix ? *matrix : SkMatrix::I()); + APPEND(DrawPicture, this->copy(paint), sk_ref_sp(pic), matrix ? *matrix : SkMatrix::I()); } else { SkASSERT(fDrawPictureMode == Playback_DrawPictureMode); SkAutoCanvasMatrixPaint acmp(this, matrix, paint, pic->cullRect()); @@ -290,7 +290,9 @@ void SkRecorder::onDrawShadowedPicture(const SkPicture* pic, const SkPaint* paint) { if (fDrawPictureMode == Record_DrawPictureMode) { fApproxBytesUsedBySubPictures += SkPictureUtils::ApproximateBytesUsed(pic); - APPEND(DrawShadowedPicture, this->copy(paint), pic, matrix ? *matrix : SkMatrix::I()); + APPEND(DrawShadowedPicture, this->copy(paint), + sk_ref_sp(pic), + matrix ? *matrix : SkMatrix::I()); } else { SkASSERT(fDrawPictureMode == Playback_DrawPictureMode); SkAutoCanvasMatrixPaint acmp(this, matrix, paint, pic->cullRect()); @@ -310,7 +312,7 @@ void SkRecorder::onDrawVertices(VertexMode vmode, this->copy(vertices, vertexCount), texs ? this->copy(texs, vertexCount) : nullptr, colors ? this->copy(colors, vertexCount) : nullptr, - xmode, + sk_ref_sp(xmode), this->copy(indices, indexCount), indexCount); } @@ -321,14 +323,14 @@ void SkRecorder::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], cubics ? this->copy(cubics, SkPatchUtils::kNumCtrlPts) : nullptr, colors ? this->copy(colors, SkPatchUtils::kNumCorners) : nullptr, texCoords ? this->copy(texCoords, SkPatchUtils::kNumCorners) : nullptr, - xmode); + sk_ref_sp(xmode)); } void SkRecorder::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, SkXfermode::Mode mode, const SkRect* cull, const SkPaint* paint) { APPEND(DrawAtlas, this->copy(paint), - atlas, + sk_ref_sp(atlas), this->copy(xform, count), this->copy(tex, count), this->copy(colors, count), @@ -338,7 +340,7 @@ void SkRecorder::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], cons } void SkRecorder::onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) { - APPEND(DrawAnnotation, rect, SkString(key), value); + APPEND(DrawAnnotation, rect, SkString(key), sk_ref_sp(value)); } void SkRecorder::willSave() { @@ -346,8 +348,10 @@ void SkRecorder::willSave() { } SkCanvas::SaveLayerStrategy SkRecorder::getSaveLayerStrategy(const SaveLayerRec& rec) { - APPEND(SaveLayer, - this->copy(rec.fBounds), this->copy(rec.fPaint), rec.fBackdrop, rec.fSaveLayerFlags); + APPEND(SaveLayer, this->copy(rec.fBounds) + , this->copy(rec.fPaint) + , sk_ref_sp(rec.fBackdrop) + , rec.fSaveLayerFlags); return SkCanvas::kNoLayer_SaveLayerStrategy; } |