src/core: s/SkAutoTUnref/sk_sp/g
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4492 Change-Id: I753ad01b03e891221965252e3befe280d09cdb9f Reviewed-on: https://skia-review.googlesource.com/4492 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
This commit is contained in:
parent
e9592f56c8
commit
704cd32e4a
@ -54,8 +54,8 @@ public:
|
||||
int stop,
|
||||
const SkMatrix& initialCTM) const;
|
||||
// Used by GrRecordReplaceDraw
|
||||
const SkBBoxHierarchy* bbh() const { return fBBH; }
|
||||
const SkRecord* record() const { return fRecord; }
|
||||
const SkBBoxHierarchy* bbh() const { return fBBH.get(); }
|
||||
const SkRecord* record() const { return fRecord.get(); }
|
||||
|
||||
private:
|
||||
struct Analysis {
|
||||
@ -76,9 +76,9 @@ private:
|
||||
const size_t fApproxBytesUsedBySubPictures;
|
||||
mutable SkOnce fAnalysisOnce;
|
||||
mutable Analysis fAnalysis;
|
||||
SkAutoTUnref<const SkRecord> fRecord;
|
||||
sk_sp<const SkRecord> fRecord;
|
||||
std::unique_ptr<const SnapshotArray> fDrawablePicts;
|
||||
SkAutoTUnref<const SkBBoxHierarchy> fBBH;
|
||||
sk_sp<const SkBBoxHierarchy> fBBH;
|
||||
};
|
||||
|
||||
#endif//SkBigPicture_DEFINED
|
||||
|
@ -803,11 +803,11 @@ bool SkBitmap::copyTo(SkBitmap* dst, SkColorType dstColorType, Allocator* alloc)
|
||||
}
|
||||
|
||||
// allocate colortable if srcConfig == kIndex8_Config
|
||||
SkAutoTUnref<SkColorTable> ctable;
|
||||
sk_sp<SkColorTable> ctable;
|
||||
if (dstColorType == kIndex_8_SkColorType) {
|
||||
ctable.reset(SkRef(srcPM.ctable()));
|
||||
}
|
||||
if (!tmpDst.tryAllocPixels(alloc, ctable)) {
|
||||
if (!tmpDst.tryAllocPixels(alloc, ctable.get())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1021,7 +1021,7 @@ bool SkBitmap::ReadRawPixels(SkReadBuffer* buffer, SkBitmap* bitmap) {
|
||||
SkASSERT(srcRow == dstRow); // first row does not need to be moved
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkColorTable> ctable;
|
||||
sk_sp<SkColorTable> ctable;
|
||||
if (buffer->readBool()) {
|
||||
ctable.reset(SkColorTable::Create(*buffer));
|
||||
if (!ctable) {
|
||||
@ -1047,13 +1047,13 @@ bool SkBitmap::ReadRawPixels(SkReadBuffer* buffer, SkBitmap* bitmap) {
|
||||
}
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewWithData(info, info.minRowBytes(),
|
||||
sk_sp<SkPixelRef> pr(SkMallocPixelRef::NewWithData(info, info.minRowBytes(),
|
||||
ctable.get(), data.get()));
|
||||
if (!pr.get()) {
|
||||
return false;
|
||||
}
|
||||
bitmap->setInfo(pr->info());
|
||||
bitmap->setPixelRef(pr, 0, 0);
|
||||
bitmap->setPixelRef(pr.get(), 0, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
private:
|
||||
SkBitmap fResultBitmap;
|
||||
SkSourceGammaTreatment fSrcGammaTreatment;
|
||||
SkAutoTUnref<const SkMipMap> fCurrMip;
|
||||
sk_sp<const SkMipMap> fCurrMip;
|
||||
|
||||
bool processHQRequest(const SkBitmapProvider&);
|
||||
bool processMediumRequest(const SkBitmapProvider&);
|
||||
|
@ -394,7 +394,7 @@ void SkBitmapDevice::drawSpecial(const SkDraw& draw, SkSpecialImage* srcImg, int
|
||||
SkMatrix matrix = *draw.fMatrix;
|
||||
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
|
||||
const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-x, -y);
|
||||
SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache());
|
||||
sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
|
||||
SkImageFilter::OutputProperties outputProperties(fBitmap.colorSpace());
|
||||
SkImageFilter::Context ctx(matrix, clipBounds, cache.get(), outputProperties);
|
||||
|
||||
|
@ -762,8 +762,8 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props)
|
||||
{
|
||||
inc_canvas();
|
||||
|
||||
SkAutoTUnref<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps));
|
||||
this->init(device, kDefault_InitFlags);
|
||||
sk_sp<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps));
|
||||
this->init(device.get(), kDefault_InitFlags);
|
||||
}
|
||||
|
||||
SkCanvas::SkCanvas(const SkBitmap& bitmap)
|
||||
@ -773,8 +773,8 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap)
|
||||
{
|
||||
inc_canvas();
|
||||
|
||||
SkAutoTUnref<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps));
|
||||
this->init(device, kDefault_InitFlags);
|
||||
sk_sp<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps));
|
||||
this->init(device.get(), kDefault_InitFlags);
|
||||
}
|
||||
|
||||
SkCanvas::~SkCanvas() {
|
||||
@ -1248,7 +1248,7 @@ void SkCanvas::internalSaveLayer(const SaveLayerRec& rec, SaveLayerStrategy stra
|
||||
SkImageInfo info = make_layer_info(priorDevice->imageInfo(), ir.width(), ir.height(), isOpaque,
|
||||
paint);
|
||||
|
||||
SkAutoTUnref<SkBaseDevice> newDevice;
|
||||
sk_sp<SkBaseDevice> newDevice;
|
||||
{
|
||||
const bool preserveLCDText = kOpaque_SkAlphaType == info.alphaType() ||
|
||||
(saveLayerFlags & kPreserveLCDText_SaveLayerFlag);
|
||||
@ -1262,14 +1262,15 @@ void SkCanvas::internalSaveLayer(const SaveLayerRec& rec, SaveLayerStrategy stra
|
||||
}
|
||||
newDevice->setOrigin(ir.fLeft, ir.fTop);
|
||||
|
||||
DeviceCM* layer = new DeviceCM(newDevice, paint, this, fConservativeRasterClip, stashedMatrix);
|
||||
DeviceCM* layer =
|
||||
new DeviceCM(newDevice.get(), paint, this, fConservativeRasterClip, stashedMatrix);
|
||||
|
||||
layer->fNext = fMCRec->fTopLayer;
|
||||
fMCRec->fLayer = layer;
|
||||
fMCRec->fTopLayer = layer; // this field is NOT an owner of layer
|
||||
|
||||
if (rec.fBackdrop) {
|
||||
DrawDeviceWithFilter(priorDevice, rec.fBackdrop, newDevice,
|
||||
DrawDeviceWithFilter(priorDevice, rec.fBackdrop, newDevice.get(),
|
||||
fMCRec->fMatrix, this->getClipStack());
|
||||
}
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ bool SkPixelInfo::CopyPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t
|
||||
if (!bm.installPixels(srcInfo, const_cast<void*>(srcPixels), srcRB, ctable, nullptr, nullptr)) {
|
||||
return false;
|
||||
}
|
||||
SkAutoTUnref<SkCanvas> canvas(SkCanvas::NewRasterDirect(dstInfo, dstPixels, dstRB));
|
||||
sk_sp<SkCanvas> canvas(SkCanvas::NewRasterDirect(dstInfo, dstPixels, dstRB));
|
||||
if (nullptr == canvas.get()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ bool SkImageCacherator::lockAsBitmap(SkBitmap* bitmap, const SkImage* client,
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
// Try to get a texture and read it back to raster (and then cache that with our ID)
|
||||
SkAutoTUnref<GrTexture> tex;
|
||||
sk_sp<GrTexture> tex;
|
||||
|
||||
{
|
||||
ScopedGenerator generator(fSharedGenerator);
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
: fKey(key), fImage(SkRef(image)), fOffset(offset) {}
|
||||
|
||||
Key fKey;
|
||||
SkAutoTUnref<SkSpecialImage> fImage;
|
||||
sk_sp<SkSpecialImage> fImage;
|
||||
SkIPoint fOffset;
|
||||
static const Key& GetKey(const Value& v) {
|
||||
return v.fKey;
|
||||
@ -60,7 +60,7 @@ public:
|
||||
fLRU.remove(v);
|
||||
fLRU.addToHead(v);
|
||||
}
|
||||
return v->fImage;
|
||||
return v->fImage.get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -140,14 +140,14 @@ bool SkImageGenerator::tryGenerateBitmap(SkBitmap* bitmap, const SkImageInfo* in
|
||||
|
||||
SkPMColor ctStorage[256];
|
||||
memset(ctStorage, 0xFF, sizeof(ctStorage)); // init with opaque-white for the moment
|
||||
SkAutoTUnref<SkColorTable> ctable(new SkColorTable(ctStorage, 256));
|
||||
if (!bitmap->tryAllocPixels(allocator, ctable)) {
|
||||
sk_sp<SkColorTable> ctable(new SkColorTable(ctStorage, 256));
|
||||
if (!bitmap->tryAllocPixels(allocator, ctable.get())) {
|
||||
// SkResourceCache's custom allcator can'thandle ctables, so it may fail on
|
||||
// kIndex_8_SkColorTable.
|
||||
// https://bug.skia.org/4355
|
||||
#if 1
|
||||
// ignroe the allocator, and see if we can succeed without it
|
||||
if (!bitmap->tryAllocPixels(nullptr, ctable)) {
|
||||
if (!bitmap->tryAllocPixels(nullptr, ctable.get())) {
|
||||
return reset_and_return_false(bitmap);
|
||||
}
|
||||
#else
|
||||
|
@ -35,7 +35,7 @@ protected:
|
||||
private:
|
||||
SkPictureImageGenerator(const SkISize&, const SkPicture*, const SkMatrix*, const SkPaint*);
|
||||
|
||||
SkAutoTUnref<const SkPicture> fPicture;
|
||||
sk_sp<const SkPicture> fPicture;
|
||||
SkMatrix fMatrix;
|
||||
SkTLazy<SkPaint> fPaint;
|
||||
|
||||
@ -80,7 +80,7 @@ bool SkPictureImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels,
|
||||
|
||||
bitmap.eraseColor(SK_ColorTRANSPARENT);
|
||||
SkCanvas canvas(bitmap, SkSurfaceProps(0, kUnknown_SkPixelGeometry));
|
||||
canvas.drawPicture(fPicture, &fMatrix, fPaint.getMaybeNull());
|
||||
canvas.drawPicture(fPicture.get(), &fMatrix, fPaint.getMaybeNull());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -119,7 +119,7 @@ bool SkPictureImageGenerator::onGenerateScaledPixels(const SkISize& scaledSize,
|
||||
bitmap.eraseColor(SK_ColorTRANSPARENT);
|
||||
SkCanvas canvas(bitmap, SkSurfaceProps(0, kUnknown_SkPixelGeometry));
|
||||
matrix.preConcat(fMatrix);
|
||||
canvas.drawPicture(fPicture, &matrix, fPaint.getMaybeNull());
|
||||
canvas.drawPicture(fPicture.get(), &matrix, fPaint.getMaybeNull());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, const SkIR
|
||||
matrix.postTranslate(-subset->x(), -subset->y());
|
||||
}
|
||||
surface->getCanvas()->clear(0); // does NewRenderTarget promise to do this for us?
|
||||
surface->getCanvas()->drawPicture(fPicture, &matrix, fPaint.getMaybeNull());
|
||||
surface->getCanvas()->drawPicture(fPicture.get(), &matrix, fPaint.getMaybeNull());
|
||||
sk_sp<SkImage> image(surface->makeImageSnapshot());
|
||||
if (!image) {
|
||||
return nullptr;
|
||||
|
@ -69,7 +69,7 @@ struct BitmapShaderRec : public SkResourceCache::Rec {
|
||||
, fShader(SkRef(tileShader)) {}
|
||||
|
||||
BitmapShaderKey fKey;
|
||||
SkAutoTUnref<SkShader> fShader;
|
||||
sk_sp<SkShader> fShader;
|
||||
size_t fBitmapBytes;
|
||||
|
||||
const Key& getKey() const override { return fKey; }
|
||||
@ -82,9 +82,9 @@ struct BitmapShaderRec : public SkResourceCache::Rec {
|
||||
|
||||
static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextShader) {
|
||||
const BitmapShaderRec& rec = static_cast<const BitmapShaderRec&>(baseRec);
|
||||
SkAutoTUnref<SkShader>* result = reinterpret_cast<SkAutoTUnref<SkShader>*>(contextShader);
|
||||
sk_sp<SkShader>* result = reinterpret_cast<sk_sp<SkShader>*>(contextShader);
|
||||
|
||||
result->reset(SkRef(rec.fShader.get()));
|
||||
*result = rec.fShader;
|
||||
|
||||
// The bitmap shader is backed by an image generator, thus it can always re-generate its
|
||||
// pixels if discarded.
|
||||
|
@ -355,6 +355,6 @@ private:
|
||||
};
|
||||
|
||||
SkStreamAsset* SkRWBuffer::newStreamSnapshot() const {
|
||||
SkAutoTUnref<SkROBuffer> buffer(this->newRBufferSnapshot());
|
||||
return new SkROBufferStreamAsset(buffer);
|
||||
sk_sp<SkROBuffer> buffer(this->newRBufferSnapshot());
|
||||
return new SkROBufferStreamAsset(buffer.get());
|
||||
}
|
||||
|
@ -24,12 +24,12 @@ public:
|
||||
void reset() { fCanvas.reset(); }
|
||||
|
||||
// This can return nullptr if reset has already been called or something when wrong in the ctor
|
||||
SkCanvas* onGetCanvas() { return fCanvas; }
|
||||
SkCanvas* onGetCanvas() { return fCanvas.get(); }
|
||||
|
||||
virtual sk_sp<SkSpecialImage> onMakeImageSnapshot() = 0;
|
||||
|
||||
protected:
|
||||
SkAutoTUnref<SkCanvas> fCanvas; // initialized by derived classes in ctors
|
||||
sk_sp<SkCanvas> fCanvas; // initialized by derived classes in ctors
|
||||
|
||||
private:
|
||||
typedef SkSpecialSurface INHERITED;
|
||||
@ -98,14 +98,14 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromBitmap(const SkIRect& subset,
|
||||
|
||||
sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRaster(const SkImageInfo& info,
|
||||
const SkSurfaceProps* props) {
|
||||
SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewZeroed(info, 0, nullptr));
|
||||
sk_sp<SkPixelRef> pr(SkMallocPixelRef::NewZeroed(info, 0, nullptr));
|
||||
if (nullptr == pr.get()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const SkIRect subset = SkIRect::MakeWH(pr->info().width(), pr->info().height());
|
||||
|
||||
return sk_make_sp<SkSpecialSurface_Raster>(pr, subset, props);
|
||||
return sk_make_sp<SkSpecialSurface_Raster>(pr.get(), subset, props);
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
|
@ -787,7 +787,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
SkAutoTUnref<SkBlockMemoryRefCnt> const fBlockMemory;
|
||||
sk_sp<SkBlockMemoryRefCnt> const fBlockMemory;
|
||||
SkDynamicMemoryWStream::Block const * fCurrent;
|
||||
size_t const fSize;
|
||||
size_t fOffset;
|
||||
|
@ -71,7 +71,7 @@ private:
|
||||
SkScalar fSize;
|
||||
SkScalar fScaleX;
|
||||
|
||||
// Keep this SkAutoTUnref off the first position, to avoid interfering with SkNoncopyable
|
||||
// Keep this sk_sp off the first position, to avoid interfering with SkNoncopyable
|
||||
// empty baseclass optimization (http://code.google.com/p/skia/issues/detail?id=3694).
|
||||
sk_sp<SkTypeface> fTypeface;
|
||||
SkScalar fSkewX;
|
||||
|
@ -87,7 +87,7 @@ SkTypeface* SkTypeface::GetDefaultTypeface(Style style) {
|
||||
|
||||
SkASSERT((int)style < 4);
|
||||
once[style]([style] {
|
||||
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
SkTypeface* t = fm->legacyCreateTypeface(nullptr, SkFontStyle::FromOldStyle(style));
|
||||
defaults[style] = t ? t : SkEmptyTypeface::Create();
|
||||
});
|
||||
@ -129,7 +129,7 @@ sk_sp<SkTypeface> SkTypeface::MakeFromName(const char name[],
|
||||
(fontStyle.weight() == SkFontStyle::kBold_Weight ? SkTypeface::kBold :
|
||||
SkTypeface::kNormal)));
|
||||
}
|
||||
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
return sk_sp<SkTypeface>(fm->legacyCreateTypeface(name, fontStyle));
|
||||
}
|
||||
|
||||
@ -142,22 +142,22 @@ sk_sp<SkTypeface> SkTypeface::MakeFromTypeface(SkTypeface* family, Style s) {
|
||||
return sk_ref_sp(family);
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
return sk_sp<SkTypeface>(fm->matchFaceStyle(family, SkFontStyle::FromOldStyle(s)));
|
||||
}
|
||||
|
||||
sk_sp<SkTypeface> SkTypeface::MakeFromStream(SkStreamAsset* stream, int index) {
|
||||
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
return sk_sp<SkTypeface>(fm->createFromStream(stream, index));
|
||||
}
|
||||
|
||||
sk_sp<SkTypeface> SkTypeface::MakeFromFontData(std::unique_ptr<SkFontData> data) {
|
||||
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
return sk_sp<SkTypeface>(fm->createFromFontData(std::move(data)));
|
||||
}
|
||||
|
||||
sk_sp<SkTypeface> SkTypeface::MakeFromFile(const char path[], int index) {
|
||||
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
return sk_sp<SkTypeface>(fm->createFromFile(path, index));
|
||||
}
|
||||
|
||||
|
@ -1369,7 +1369,7 @@ static sk_sp<GrTexture> make_mipmap_texture(GrTextureProvider* provider,
|
||||
bm.allocN32Pixels(width, height, true);
|
||||
bm.eraseColor(SK_ColorBLUE);
|
||||
|
||||
SkAutoTUnref<SkMipMap> mipmaps(SkMipMap::Build(bm, SkSourceGammaTreatment::kIgnore, nullptr));
|
||||
sk_sp<SkMipMap> mipmaps(SkMipMap::Build(bm, SkSourceGammaTreatment::kIgnore, nullptr));
|
||||
SkASSERT(mipmaps);
|
||||
SkASSERT(mipmaps->countLevels() > 1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user