aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2016-10-27 09:30:08 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-27 09:30:08 -0700
commit6bd5284415bd983b0628c4941dff5def40018f5a (patch)
tree7de7e45431f76db69807204ecdce3ed6fcc4d9e8
parent56380524d903f27627a75e2e1189463999725008 (diff)
Remove SkAutoTUnref and SkAutoTDelete from public includes.
This also makes the required changed to src, tests, and tools. The few public APIs modified by this change appear to be unused outside of Skia. Removing these from the public API makes it easier to ensure users are no longer using them. This also updates GrGpu::wrapBackendXXX and the ::onWrapBackendXXX methods to clarify ownership. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2448593002 Review-Url: https://codereview.chromium.org/2448593002
-rw-r--r--dm/DMSrcSink.cpp2
-rw-r--r--gm/deferredtextureimage.cpp4
-rw-r--r--gm/image_pict.cpp19
-rw-r--r--include/codec/SkAndroidCodec.h2
-rw-r--r--include/codec/SkCodec.h2
-rw-r--r--include/core/SkCanvas.h10
-rw-r--r--include/core/SkPath.h2
-rw-r--r--include/core/SkPathRef.h10
-rw-r--r--include/core/SkPictureRecorder.h14
-rw-r--r--include/core/SkWriteBuffer.h8
-rw-r--r--include/gpu/GrCaps.h4
-rw-r--r--include/gpu/GrContext.h18
-rw-r--r--include/gpu/GrGpuResource.h2
-rw-r--r--include/gpu/GrGpuResourceRef.h2
-rw-r--r--include/gpu/GrTextureProvider.h6
-rw-r--r--include/gpu/GrXferProcessor.h11
-rw-r--r--include/gpu/gl/GrGLExtensions.h2
-rw-r--r--include/gpu/vk/GrVkBackendContext.h18
-rw-r--r--include/ports/SkFontMgr_indirect.h8
-rw-r--r--include/ports/SkTypeface_win.h2
-rw-r--r--include/private/GrAuditTrail.h6
-rw-r--r--include/private/SkMiniRecorder.h2
-rw-r--r--include/views/SkOSWindow_Win.h10
-rw-r--r--include/xml/SkDOM.h6
-rw-r--r--src/core/SkCanvas.cpp9
-rw-r--r--src/core/SkMaskGamma.h10
-rw-r--r--src/core/SkPath.cpp2
-rw-r--r--src/core/SkPathRef.cpp12
-rw-r--r--src/core/SkPictureData.cpp2
-rw-r--r--src/core/SkPictureRecorder.cpp11
-rw-r--r--src/core/SkRecordedDrawable.cpp2
-rw-r--r--src/core/SkRecordedDrawable.h16
-rw-r--r--src/core/SkRecorder.h4
-rw-r--r--src/core/SkSpecialImage.cpp6
-rw-r--r--src/core/SkWriteBuffer.cpp7
-rw-r--r--src/gpu/GrAuditTrail.cpp2
-rw-r--r--src/gpu/GrContext.cpp6
-rw-r--r--src/gpu/GrContextPriv.h2
-rw-r--r--src/gpu/GrGpu.cpp17
-rw-r--r--src/gpu/GrGpu.h14
-rw-r--r--src/gpu/GrRenderTargetOpList.cpp8
-rw-r--r--src/gpu/GrResourceProvider.cpp5
-rw-r--r--src/gpu/GrResourceProvider.h2
-rw-r--r--src/gpu/GrTextureProvider.cpp12
-rw-r--r--src/gpu/gl/GrGLExtensions.cpp28
-rw-r--r--src/gpu/gl/GrGLGpu.cpp25
-rw-r--r--src/gpu/gl/GrGLGpu.h8
-rw-r--r--src/gpu/gl/GrGLRenderTarget.cpp10
-rw-r--r--src/gpu/gl/GrGLRenderTarget.h8
-rw-r--r--src/gpu/gl/GrGLTexture.cpp6
-rw-r--r--src/gpu/gl/GrGLTexture.h2
-rw-r--r--src/gpu/gl/GrGLTextureRenderTarget.cpp11
-rw-r--r--src/gpu/gl/GrGLTextureRenderTarget.h6
-rw-r--r--src/gpu/vk/GrVkGpu.cpp30
-rw-r--r--src/gpu/vk/GrVkGpu.h12
-rw-r--r--src/gpu/vk/GrVkRenderTarget.cpp15
-rw-r--r--src/gpu/vk/GrVkRenderTarget.h6
-rw-r--r--src/gpu/vk/GrVkTexture.cpp10
-rw-r--r--src/gpu/vk/GrVkTexture.h4
-rw-r--r--src/gpu/vk/GrVkTextureRenderTarget.cpp14
-rw-r--r--src/gpu/vk/GrVkTextureRenderTarget.h8
-rw-r--r--src/image/SkImage_Gpu.cpp34
-rw-r--r--src/image/SkImage_Gpu.h16
-rw-r--r--src/image/SkSurface_Gpu.cpp10
-rw-r--r--src/ports/SkFontMgr_win_dw.cpp8
-rw-r--r--src/utils/SkDeferredCanvas.h1
-rw-r--r--tests/EGLImageTest.cpp12
-rw-r--r--tests/GrPorterDuffTest.cpp8
-rw-r--r--tests/GrSurfaceTest.cpp7
-rw-r--r--tests/ImageTest.cpp2
-rw-r--r--tests/PathTest.cpp2
-rw-r--r--tests/RectangleTextureTest.cpp12
-rw-r--r--tests/ResourceCacheTest.cpp9
-rw-r--r--tests/VkWrapTests.cpp12
-rw-r--r--tools/gpu/GrTest.cpp11
-rw-r--r--tools/gpu/vk/VkTestContext.h2
76 files changed, 313 insertions, 355 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 4b297c1e10..4c428a7b9c 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -1778,7 +1778,7 @@ Error ViaSingletonPictures::draw(
SkCanvas* macroCanvas = macroRec.beginRecording(SkIntToScalar(size.width()),
SkIntToScalar(size.height()));
- SkAutoTDelete<SkDrawableList> drawables(recorder.detachDrawableList());
+ std::unique_ptr<SkDrawableList> drawables(recorder.detachDrawableList());
const SkDrawableList empty;
DrawsAsSingletonPictures drawsAsSingletonPictures = {
diff --git a/gm/deferredtextureimage.cpp b/gm/deferredtextureimage.cpp
index 087c4eb686..1043c1b6d6 100644
--- a/gm/deferredtextureimage.cpp
+++ b/gm/deferredtextureimage.cpp
@@ -22,7 +22,7 @@ static void DrawDeferredTextureImageData(SkCanvas* canvas,
skiagm::GM::DrawGpuOnlyMessage(canvas);
return;
}
- SkAutoTUnref<GrContextThreadSafeProxy> proxy(context->threadSafeProxy());
+ sk_sp<GrContextThreadSafeProxy> proxy(context->threadSafeProxy());
@@ -80,7 +80,7 @@ static void DrawDeferredTextureImageMipMapTree(SkCanvas* canvas, SkImage* image,
skiagm::GM::DrawGpuOnlyMessage(canvas);
return;
}
- SkAutoTUnref<GrContextThreadSafeProxy> proxy(context->threadSafeProxy());
+ sk_sp<GrContextThreadSafeProxy> proxy(context->threadSafeProxy());
SkPaint paint;
paint.setFilterQuality(params->fQuality);
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index e8cd5e0748..f88a20ba27 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -314,10 +314,10 @@ protected:
static void draw_as_tex(SkCanvas* canvas, SkImageCacherator* cache, SkScalar x, SkScalar y) {
#if SK_SUPPORT_GPU
- SkAutoTUnref<GrTexture> texture(cache->lockAsTexture(canvas->getGrContext(),
- GrTextureParams::ClampBilerp(),
- SkSourceGammaTreatment::kRespect,
- nullptr));
+ sk_sp<GrTexture> texture(cache->lockAsTexture(canvas->getGrContext(),
+ GrTextureParams::ClampBilerp(),
+ SkSourceGammaTreatment::kRespect,
+ nullptr));
if (!texture) {
// show placeholder if we have no texture
SkPaint paint;
@@ -330,11 +330,12 @@ protected:
return;
}
// No API to draw a GrTexture directly, so we cheat and create a private image subclass
- SkAutoTUnref<SkImage> image(new SkImage_Gpu(cache->info().width(), cache->info().height(),
- cache->uniqueID(), kPremul_SkAlphaType, texture,
- sk_ref_sp(cache->info().colorSpace()),
- SkBudgeted::kNo));
- canvas->drawImage(image, x, y);
+ sk_sp<SkImage> image(new SkImage_Gpu(cache->info().width(), cache->info().height(),
+ cache->uniqueID(), kPremul_SkAlphaType,
+ std::move(texture),
+ sk_ref_sp(cache->info().colorSpace()),
+ SkBudgeted::kNo));
+ canvas->drawImage(image.get(), x, y);
#endif
}
diff --git a/include/codec/SkAndroidCodec.h b/include/codec/SkAndroidCodec.h
index c7587b62e9..07d1b135aa 100644
--- a/include/codec/SkAndroidCodec.h
+++ b/include/codec/SkAndroidCodec.h
@@ -260,6 +260,6 @@ private:
// embedded SkCodec.
const SkImageInfo& fInfo;
- SkAutoTDelete<SkCodec> fCodec;
+ std::unique_ptr<SkCodec> fCodec;
};
#endif // SkAndroidCodec_DEFINED
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index a97a79c4bb..368d5e37b3 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -775,7 +775,7 @@ protected:
private:
const SkEncodedInfo fEncodedInfo;
const SkImageInfo fSrcInfo;
- SkAutoTDelete<SkStream> fStream;
+ std::unique_ptr<SkStream> fStream;
bool fNeedsRewind;
const Origin fOrigin;
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 5b30a08772..b323b2af8e 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -1357,7 +1357,7 @@ public:
* @return the current clip stack ("list" of individual clip elements)
*/
const SkClipStack* getClipStack() const {
- return fClipStack;
+ return fClipStack.get();
}
typedef SkCanvasClipVisitor ClipVisitor;
@@ -1516,12 +1516,6 @@ protected:
const SkShadowParams& params);
#endif
- // Returns the canvas to be used by DrawIter. Default implementation
- // returns this. Subclasses that encapsulate an indirect canvas may
- // need to overload this method. The impl must keep track of this, as it
- // is not released or deleted by the caller.
- virtual SkCanvas* canvasForDrawIter();
-
// Clip rectangle bounds. Called internally by saveLayer.
// returns false if the entire rectangle is entirely clipped out
// If non-NULL, The imageFilter parameter will be used to expand the clip
@@ -1592,7 +1586,7 @@ private:
class MCRec;
- SkAutoTUnref<SkClipStack> fClipStack;
+ sk_sp<SkClipStack> fClipStack;
SkDeque fMCStack;
// points to top of stack
MCRec* fMCRec;
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index d1af4f31b6..46cb15c785 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -1121,7 +1121,7 @@ private:
kCurrent_Version = 2
};
- SkAutoTUnref<SkPathRef> fPathRef;
+ sk_sp<SkPathRef> fPathRef;
int fLastMoveToIndex;
uint8_t fFillType;
mutable uint8_t fConvexity;
diff --git a/include/core/SkPathRef.h b/include/core/SkPathRef.h
index 9b15c3e4f2..5e6fda7d85 100644
--- a/include/core/SkPathRef.h
+++ b/include/core/SkPathRef.h
@@ -26,8 +26,8 @@ class SkWBuffer;
* modify the contents. To modify or append to the verbs/points wrap the SkPathRef in an
* SkPathRef::Editor object. Installing the editor resets the generation ID. It also performs
* copy-on-write if the SkPathRef is shared by multiple SkPaths. The caller passes the Editor's
- * constructor a SkAutoTUnref, which may be updated to point to a new SkPathRef after the editor's
- * constructor returns.
+ * constructor a pointer to a sk_sp<SkPathRef>, which may be updated to point to a new SkPathRef
+ * after the editor's constructor returns.
*
* The points and verbs are stored in a single allocation. The points are at the begining of the
* allocation while the verbs are stored at end of the allocation, in reverse order. Thus the points
@@ -40,7 +40,7 @@ class SK_API SkPathRef final : public SkNVRefCnt<SkPathRef> {
public:
class Editor {
public:
- Editor(SkAutoTUnref<SkPathRef>* pathRef,
+ Editor(sk_sp<SkPathRef>* pathRef,
int incReserveVerbs = 0,
int incReservePoints = 0);
@@ -230,7 +230,7 @@ public:
/**
* Transforms a path ref by a matrix, allocating a new one only if necessary.
*/
- static void CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst,
+ static void CreateTransformedCopy(sk_sp<SkPathRef>* dst,
const SkPathRef& src,
const SkMatrix& matrix);
@@ -241,7 +241,7 @@ public:
* repopulated with approximately the same number of verbs and points. A new path ref is created
* only if necessary.
*/
- static void Rewind(SkAutoTUnref<SkPathRef>* pathRef);
+ static void Rewind(sk_sp<SkPathRef>* pathRef);
~SkPathRef();
int countPoints() const { SkDEBUGCODE(this->validate();) return fPointCnt; }
diff --git a/include/core/SkPictureRecorder.h b/include/core/SkPictureRecorder.h
index c824189300..890e7ca213 100644
--- a/include/core/SkPictureRecorder.h
+++ b/include/core/SkPictureRecorder.h
@@ -124,13 +124,13 @@ private:
friend class SkPictureRecorderReplayTester; // for unit testing
void partialReplay(SkCanvas* canvas) const;
- bool fActivelyRecording;
- uint32_t fFlags;
- SkRect fCullRect;
- SkAutoTUnref<SkBBoxHierarchy> fBBH;
- SkAutoTUnref<SkRecorder> fRecorder;
- SkAutoTUnref<SkRecord> fRecord;
- SkMiniRecorder fMiniRecorder;
+ bool fActivelyRecording;
+ uint32_t fFlags;
+ SkRect fCullRect;
+ sk_sp<SkBBoxHierarchy> fBBH;
+ sk_sp<SkRecorder> fRecorder;
+ sk_sp<SkRecord> fRecord;
+ SkMiniRecorder fMiniRecorder;
typedef SkNoncopyable INHERITED;
};
diff --git a/include/core/SkWriteBuffer.h b/include/core/SkWriteBuffer.h
index 29f923fedd..a104ffcb1f 100644
--- a/include/core/SkWriteBuffer.h
+++ b/include/core/SkWriteBuffer.h
@@ -134,12 +134,10 @@ public:
* Set an SkPixelSerializer to store an encoded representation of pixels,
* e.g. SkBitmaps.
*
- * Calls ref() on the serializer.
- *
* TODO: Encode SkImage pixels as well.
*/
- void setPixelSerializer(SkPixelSerializer*);
- SkPixelSerializer* getPixelSerializer() const { return fPixelSerializer; }
+ void setPixelSerializer(sk_sp<SkPixelSerializer>);
+ SkPixelSerializer* getPixelSerializer() const { return fPixelSerializer.get(); }
private:
const uint32_t fFlags;
@@ -148,7 +146,7 @@ private:
SkRefCntSet* fTFSet;
- SkAutoTUnref<SkPixelSerializer> fPixelSerializer;
+ sk_sp<SkPixelSerializer> fPixelSerializer;
// Only used if we do not have an fFactorySet
SkTHashMap<SkString, uint32_t> fFlattenableDict;
diff --git a/include/gpu/GrCaps.h b/include/gpu/GrCaps.h
index a97be72c3f..204cfc98cb 100644
--- a/include/gpu/GrCaps.h
+++ b/include/gpu/GrCaps.h
@@ -133,7 +133,7 @@ public:
virtual SkString dump() const;
- GrShaderCaps* shaderCaps() const { return fShaderCaps; }
+ GrShaderCaps* shaderCaps() const { return fShaderCaps.get(); }
bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
/** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g.
@@ -294,7 +294,7 @@ protected:
expand them. */
void applyOptionsOverrides(const GrContextOptions& options);
- SkAutoTUnref<GrShaderCaps> fShaderCaps;
+ sk_sp<GrShaderCaps> fShaderCaps;
bool fNPOTTextureTileSupport : 1;
bool fMipMapSupport : 1;
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 996b77f2db..8e5781100e 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -60,7 +60,7 @@ public:
virtual ~GrContext();
- GrContextThreadSafeProxy* threadSafeProxy();
+ sk_sp<GrContextThreadSafeProxy> threadSafeProxy();
/**
* The GrContext normally assumes that no outsider is setting state
@@ -327,7 +327,7 @@ public:
GrGpu* getGpu() { return fGpu; }
const GrGpu* getGpu() const { return fGpu; }
GrBatchFontCache* getBatchFontCache() { return fBatchFontCache; }
- GrTextBlobCache* getTextBlobCache() { return fTextBlobCache; }
+ GrTextBlobCache* getTextBlobCache() { return fTextBlobCache.get(); }
bool abandoned() const;
GrResourceProvider* resourceProvider() { return fResourceProvider; }
const GrResourceProvider* resourceProvider() const { return fResourceProvider; }
@@ -383,10 +383,10 @@ private:
GrTextureProvider* fTextureProvider;
};
- SkAutoTUnref<GrContextThreadSafeProxy> fThreadSafeProxy;
+ sk_sp<GrContextThreadSafeProxy> fThreadSafeProxy;
GrBatchFontCache* fBatchFontCache;
- SkAutoTDelete<GrTextBlobCache> fTextBlobCache;
+ std::unique_ptr<GrTextBlobCache> fTextBlobCache;
bool fDidTestPMConversions;
int fPMToUPMConversion;
@@ -418,7 +418,7 @@ private:
const uint32_t fUniqueID;
- SkAutoTDelete<GrDrawingManager> fDrawingManager;
+ std::unique_ptr<GrDrawingManager> fDrawingManager;
GrAuditTrail fAuditTrail;
@@ -463,12 +463,12 @@ private:
*/
class GrContextThreadSafeProxy : public SkRefCnt {
private:
- GrContextThreadSafeProxy(const GrCaps* caps, uint32_t uniqueID)
- : fCaps(SkRef(caps))
+ GrContextThreadSafeProxy(sk_sp<const GrCaps> caps, uint32_t uniqueID)
+ : fCaps(std::move(caps))
, fContextUniqueID(uniqueID) {}
- SkAutoTUnref<const GrCaps> fCaps;
- uint32_t fContextUniqueID;
+ sk_sp<const GrCaps> fCaps;
+ uint32_t fContextUniqueID;
friend class GrContext;
friend class SkImage;
diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h
index d3cfa86086..5f5ccbf8ee 100644
--- a/include/gpu/GrGpuResource.h
+++ b/include/gpu/GrGpuResource.h
@@ -46,7 +46,7 @@ class SkTraceMemoryDump;
template <typename DERIVED> class GrIORef : public SkNoncopyable {
public:
// Some of the signatures are written to mirror SkRefCnt so that GrGpuResource can work with
- // templated helper classes (e.g. SkAutoTUnref). However, we have different categories of
+ // templated helper classes (e.g. sk_sp). However, we have different categories of
// refs (e.g. pending reads). We also don't require thread safety as GrCacheable objects are
// not intended to cross thread boundaries.
void ref() const {
diff --git a/include/gpu/GrGpuResourceRef.h b/include/gpu/GrGpuResourceRef.h
index 13adbee242..a91dcfeed5 100644
--- a/include/gpu/GrGpuResourceRef.h
+++ b/include/gpu/GrGpuResourceRef.h
@@ -28,7 +28,7 @@
* state 2 to state 3. Calling pendingIOComplete() moves from state 2 to state 1. There is no
* valid way of going from state 3 back to 2 or 1.
*
- * Like SkAutoTUnref, its constructor and setter adopt a ref from their caller.
+ * Like sk_sp, its constructor and setter adopt a ref from their caller.
*
* TODO: Once GrDODrawState no longer exists and therefore GrDrawState and GrOptDrawState no
* longer share an instance of this class, attempt to make the resource owned by GrGpuResourceRef
diff --git a/include/gpu/GrTextureProvider.h b/include/gpu/GrTextureProvider.h
index e013bfff0f..efecc96358 100644
--- a/include/gpu/GrTextureProvider.h
+++ b/include/gpu/GrTextureProvider.h
@@ -98,8 +98,8 @@ public:
*
* @return GrTexture object or NULL on failure.
*/
- GrTexture* wrapBackendTexture(const GrBackendTextureDesc& desc,
- GrWrapOwnership = kBorrow_GrWrapOwnership);
+ sk_sp<GrTexture> wrapBackendTexture(const GrBackendTextureDesc& desc,
+ GrWrapOwnership = kBorrow_GrWrapOwnership);
/**
* Wraps an existing render target with a GrRenderTarget object. It is
@@ -110,7 +110,7 @@ public:
*
* @return GrRenderTarget object or NULL on failure.
*/
- GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc);
+ sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc);
protected:
GrTextureProvider(GrGpu* gpu, GrResourceCache* cache, GrSingleOwner* singleOwner);
diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h
index 1d4717e156..5317c187e2 100644
--- a/include/gpu/GrXferProcessor.h
+++ b/include/gpu/GrXferProcessor.h
@@ -70,7 +70,7 @@ public:
}
DstTexture& operator=(const DstTexture& other) {
- fTexture.reset(SkSafeRef(other.fTexture.get()));
+ fTexture = other.fTexture;
fOffset = other.fOffset;
return *this;
}
@@ -82,14 +82,13 @@ public:
GrTexture* texture() const { return fTexture.get(); }
- GrTexture* setTexture(GrTexture* texture) {
- fTexture.reset(SkSafeRef(texture));
- return texture;
+ void setTexture(sk_sp<GrTexture> texture) {
+ fTexture = std::move(texture);
}
private:
- SkAutoTUnref<GrTexture> fTexture;
- SkIPoint fOffset;
+ sk_sp<GrTexture> fTexture;
+ SkIPoint fOffset;
};
/**
diff --git a/include/gpu/gl/GrGLExtensions.h b/include/gpu/gl/GrGLExtensions.h
index dd088de671..faf73fd36c 100644
--- a/include/gpu/gl/GrGLExtensions.h
+++ b/include/gpu/gl/GrGLExtensions.h
@@ -68,7 +68,7 @@ public:
private:
bool fInitialized;
- SkAutoTDelete<SkTArray<SkString> > fStrings;
+ std::unique_ptr<SkTArray<SkString>> fStrings;
};
#endif
diff --git a/include/gpu/vk/GrVkBackendContext.h b/include/gpu/vk/GrVkBackendContext.h
index 9942016927..5e51beea6b 100644
--- a/include/gpu/vk/GrVkBackendContext.h
+++ b/include/gpu/vk/GrVkBackendContext.h
@@ -37,15 +37,15 @@ enum GrVkFeatureFlags {
// creation, and any GrBackendObjects handed to us (e.g., for wrapped textures) need to be created
// in or transitioned to that family.
struct GrVkBackendContext : public SkRefCnt {
- VkInstance fInstance;
- VkPhysicalDevice fPhysicalDevice;
- VkDevice fDevice;
- VkQueue fQueue;
- uint32_t fGraphicsQueueIndex;
- uint32_t fMinAPIVersion;
- uint32_t fExtensions;
- uint32_t fFeatures;
- SkAutoTUnref<const GrVkInterface> fInterface;
+ VkInstance fInstance;
+ VkPhysicalDevice fPhysicalDevice;
+ VkDevice fDevice;
+ VkQueue fQueue;
+ uint32_t fGraphicsQueueIndex;
+ uint32_t fMinAPIVersion;
+ uint32_t fExtensions;
+ uint32_t fFeatures;
+ sk_sp<const GrVkInterface> fInterface;
using CanPresentFn = std::function<bool(VkInstance, VkPhysicalDevice,
uint32_t queueFamilyIndex)>;
diff --git a/include/ports/SkFontMgr_indirect.h b/include/ports/SkFontMgr_indirect.h
index 406a75a7ee..6c258c851d 100644
--- a/include/ports/SkFontMgr_indirect.h
+++ b/include/ports/SkFontMgr_indirect.h
@@ -28,8 +28,8 @@ public:
// TODO: The SkFontMgr is only used for createFromStream/File/Data.
// In the future these calls should be broken out into their own interface
// with a name like SkFontRenderer.
- SkFontMgr_Indirect(SkFontMgr* impl, SkRemotableFontMgr* proxy)
- : fImpl(SkRef(impl)), fProxy(SkRef(proxy))
+ SkFontMgr_Indirect(sk_sp<SkFontMgr> impl, sk_sp<SkRemotableFontMgr> proxy)
+ : fImpl(std::move(impl)), fProxy(std::move(proxy))
{ }
protected:
@@ -60,8 +60,8 @@ protected:
private:
SkTypeface* createTypefaceFromFontId(const SkFontIdentity& fontId) const;
- SkAutoTUnref<SkFontMgr> fImpl;
- SkAutoTUnref<SkRemotableFontMgr> fProxy;
+ sk_sp<SkFontMgr> fImpl;
+ sk_sp<SkRemotableFontMgr> fProxy;
struct DataEntry {
uint32_t fDataId; // key1
diff --git a/include/ports/SkTypeface_win.h b/include/ports/SkTypeface_win.h
index 1945b755e7..f3a881f3cc 100644
--- a/include/ports/SkTypeface_win.h
+++ b/include/ports/SkTypeface_win.h
@@ -57,7 +57,7 @@ SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
*
* If DirectWrite could not be initialized, will return NULL.
*/
-SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr*);
+SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(sk_sp<SkRemotableFontMgr>);
/**
* Creates an SkRemotableFontMgr backed by DirectWrite using the default
diff --git a/include/private/GrAuditTrail.h b/include/private/GrAuditTrail.h
index 3bb7bea435..b39f13f362 100644
--- a/include/private/GrAuditTrail.h
+++ b/include/private/GrAuditTrail.h
@@ -134,7 +134,7 @@ private:
int fBatchListID;
int fChildID;
};
- typedef SkTArray<SkAutoTDelete<Batch>, true> BatchPool;
+ typedef SkTArray<std::unique_ptr<Batch>, true> BatchPool;
typedef SkTArray<Batch*> Batches;
@@ -144,14 +144,14 @@ private:
Batches fChildren;
uint32_t fRenderTargetUniqueID;
};
- typedef SkTArray<SkAutoTDelete<BatchNode>, true> BatchList;
+ typedef SkTArray<std::unique_ptr<BatchNode>, true> BatchList;
void copyOutFromBatchList(BatchInfo* outBatchInfo, int batchListID);
template <typename T>
static void JsonifyTArray(SkString* json, const char* name, const T& array,
bool addComma);
-
+
BatchPool fBatchPool;
SkTHashMap<uint32_t, int> fIDLookup;
SkTHashMap<int, Batches*> fClientIDLookup;
diff --git a/include/private/SkMiniRecorder.h b/include/private/SkMiniRecorder.h
index 6365ebc65b..06b35ca714 100644
--- a/include/private/SkMiniRecorder.h
+++ b/include/private/SkMiniRecorder.h
@@ -29,7 +29,7 @@ public:
// Flush anything we've recorded to the canvas, resetting this SkMiniRecorder.
// This is logically the same as but rather more efficient than:
- // SkAutoTUnref<SkPicture> pic(this->detachAsPicture(SkRect::MakeEmpty()));
+ // sk_sp<SkPicture> pic(this->detachAsPicture(SkRect::MakeEmpty()));
// pic->playback(canvas);
void flushAndReset(SkCanvas*);
diff --git a/include/views/SkOSWindow_Win.h b/include/views/SkOSWindow_Win.h
index 7ed22a6514..774244400c 100644
--- a/include/views/SkOSWindow_Win.h
+++ b/include/views/SkOSWindow_Win.h
@@ -91,11 +91,11 @@ private:
#if SK_SUPPORT_GPU
void* fHGLRC;
#if SK_ANGLE
- EGLDisplay fDisplay;
- EGLContext fContext;
- EGLSurface fSurface;
- EGLConfig fConfig;
- SkAutoTUnref<const GrGLInterface> fANGLEInterface;
+ EGLDisplay fDisplay;
+ EGLContext fContext;
+ EGLSurface fSurface;
+ EGLConfig fConfig;
+ sk_sp<const GrGLInterface> fANGLEInterface;
#endif // SK_ANGLE
#endif // SK_SUPPORT_GPU
diff --git a/include/xml/SkDOM.h b/include/xml/SkDOM.h
index b6f611af6e..c40f4bd522 100644
--- a/include/xml/SkDOM.h
+++ b/include/xml/SkDOM.h
@@ -89,9 +89,9 @@ public:
SkDEBUGCODE(void dump(const Node* node = NULL, int tabLevel = 0) const;)
private:
- SkChunkAlloc fAlloc;
- Node* fRoot;
- SkAutoTDelete<SkDOMParser> fParser;
+ SkChunkAlloc fAlloc;
+ Node* fRoot;
+ std::unique_ptr<SkDOMParser> fParser;
typedef SkNoncopyable INHERITED;
};
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index bcda0f2526..7c9f5c6cd5 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -319,15 +319,14 @@ static SkIRect compute_device_bounds(SkBaseDevice* device) {
class SkDrawIter : public SkDraw {
public:
SkDrawIter(SkCanvas* canvas) {
- canvas = canvas->canvasForDrawIter();
canvas->updateDeviceCMCache();
- fClipStack = canvas->fClipStack;
+ fClipStack = canvas->getClipStack();
fCurrLayer = canvas->fMCRec->fTopLayer;
fMultiDeviceCS = nullptr;
if (fCurrLayer->fNext) {
- fMultiDeviceCS = canvas->fClipStack;
+ fMultiDeviceCS = canvas->fClipStack.get();
fMultiDeviceCS->save();
}
}
@@ -966,10 +965,6 @@ bool SkCanvas::writePixels(const SkImageInfo& origInfo, const void* pixels, size
return device->writePixels(info, pixels, rowBytes, target.x(), target.y());
}
-SkCanvas* SkCanvas::canvasForDrawIter() {
- return this;
-}
-
//////////////////////////////////////////////////////////////////////////////
void SkCanvas::updateDeviceCMCache() {
diff --git a/src/core/SkMaskGamma.h b/src/core/SkMaskGamma.h
index 94219d42ac..f90f75a878 100644
--- a/src/core/SkMaskGamma.h
+++ b/src/core/SkMaskGamma.h
@@ -174,11 +174,11 @@ private:
*/
template <int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS> class SkTMaskPreBlend {
private:
- SkTMaskPreBlend(const SkTMaskGamma<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>* parent,
+ SkTMaskPreBlend(sk_sp<const SkTMaskGamma<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>> parent,
const uint8_t* r, const uint8_t* g, const uint8_t* b)
- : fParent(SkSafeRef(parent)), fR(r), fG(g), fB(b) { }
+ : fParent(std::move(parent)), fR(r), fG(g), fB(b) { }
- SkAutoTUnref<const SkTMaskGamma<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS> > fParent;
+ sk_sp<const SkTMaskGamma<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>> fParent;
friend class SkTMaskGamma<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>;
public:
/** Creates a non applicable SkTMaskPreBlend. */
@@ -189,7 +189,7 @@ public:
* when return value optimization is enabled.
*/
SkTMaskPreBlend(const SkTMaskPreBlend<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>& that)
- : fParent(SkSafeRef(that.fParent.get())), fR(that.fR), fG(that.fG), fB(that.fB) { }
+ : fParent(that.fParent), fR(that.fR), fG(that.fG), fB(that.fB) { }
~SkTMaskPreBlend() { }
@@ -205,7 +205,7 @@ template <int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS>
SkTMaskPreBlend<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>
SkTMaskGamma<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>::preBlend(SkColor color) const {
return fIsLinear ? SkTMaskPreBlend<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>()
- : SkTMaskPreBlend<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>(this,
+ : SkTMaskPreBlend<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>(sk_ref_sp(this),
fGammaTables[SkColorGetR(color) >> (8 - MAX_LUM_BITS)],
fGammaTables[SkColorGetG(color) >> (8 - MAX_LUM_BITS)],
fGammaTables[SkColorGetB(color) >> (8 - MAX_LUM_BITS)]);
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index d65687630c..4dc2f96656 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -220,7 +220,7 @@ bool SkPath::interpolate(const SkPath& ending, SkScalar weight, SkPath* out) con
}
out->reset();
out->addPath(*this);
- fPathRef->interpolate(*ending.fPathRef, weight, out->fPathRef);
+ fPathRef->interpolate(*ending.fPathRef, weight, out->fPathRef.get());
return true;
}
diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp
index 844c40a505..ef051f7e84 100644
--- a/src/core/SkPathRef.cpp
+++ b/src/core/SkPathRef.cpp
@@ -12,7 +12,7 @@
#include <limits>
//////////////////////////////////////////////////////////////////////////////
-SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef,
+SkPathRef::Editor::Editor(sk_sp<SkPathRef>* pathRef,
int incReserveVerbs,
int incReservePoints)
{
@@ -23,7 +23,7 @@ SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef,
copy->copy(**pathRef, incReserveVerbs, incReservePoints);
pathRef->reset(copy);
}
- fPathRef = *pathRef;
+ fPathRef = pathRef->get();
fPathRef->callGenIDChangeListeners();
fPathRef->fGenerationID = 0;
SkDEBUGCODE(sk_atomic_inc(&fPathRef->fEditorsAttached);)
@@ -111,12 +111,12 @@ static void transform_dir_and_start(const SkMatrix& matrix, bool isRRect, bool*
}
}
-void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst,
+void SkPathRef::CreateTransformedCopy(sk_sp<SkPathRef>* dst,
const SkPathRef& src,
const SkMatrix& matrix) {
SkDEBUGCODE(src.validate();)
if (matrix.isIdentity()) {
- if (*dst != &src) {
+ if (dst->get() != &src) {
src.ref();
dst->reset(const_cast<SkPathRef*>(&src));
SkDEBUGCODE((*dst)->validate();)
@@ -128,7 +128,7 @@ void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst,
dst->reset(new SkPathRef);
}
- if (*dst != &src) {
+ if (dst->get() != &src) {
(*dst)->resetToSize(src.fVerbCnt, src.fPointCnt, src.fConicWeights.count());
sk_careful_memcpy((*dst)->verbsMemWritable(), src.verbsMemBegin(),
src.fVerbCnt * sizeof(uint8_t));
@@ -242,7 +242,7 @@ SkPathRef* SkPathRef::CreateFromBuffer(SkRBuffer* buffer) {
return ref;
}
-void SkPathRef::Rewind(SkAutoTUnref<SkPathRef>* pathRef) {
+void SkPathRef::Rewind(sk_sp<SkPathRef>* pathRef) {
if ((*pathRef)->unique()) {
SkDEBUGCODE((*pathRef)->validate();)
(*pathRef)->callGenIDChangeListeners();
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp
index 68789acddf..cc529e3eca 100644
--- a/src/core/SkPictureData.cpp
+++ b/src/core/SkPictureData.cpp
@@ -268,7 +268,7 @@ void SkPictureData::serialize(SkWStream* stream,
SkFactorySet factSet; // buffer refs factSet, so factSet must come first.
SkBinaryWriteBuffer buffer(SkBinaryWriteBuffer::kCrossProcess_Flag);
buffer.setFactoryRecorder(&factSet);
- buffer.setPixelSerializer(pixelSerializer);
+ buffer.setPixelSerializer(sk_ref_sp(pixelSerializer));
buffer.setTypefaceRecorder(typefaceSet);
this->flattenToBuffer(buffer);
diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp
index 5631a081d4..758aa3e5ec 100644
--- a/src/core/SkPictureRecorder.cpp
+++ b/src/core/SkPictureRecorder.cpp
@@ -62,7 +62,7 @@ sk_sp<SkPicture> SkPictureRecorder::finishRecordingAsPicture(uint32_t finishFlag
}
// TODO: delay as much of this work until just before first playback?
- SkRecordOptimize(fRecord);
+ SkRecordOptimize(fRecord.get());
if (fRecord->count() == 0) {
if (finishFlags & kReturnNullForEmpty_FinishFlag) {
@@ -122,7 +122,7 @@ sk_sp<SkDrawable> SkPictureRecorder::finishRecordingAsDrawable(uint32_t finishFl
fRecorder->flushMiniRecorder();
fRecorder->restoreToCount(1); // If we were missing any restores, add them now.
- SkRecordOptimize(fRecord);
+ SkRecordOptimize(fRecord.get());
if (fRecord->count() == 0) {
if (finishFlags & kReturnNullForEmpty_FinishFlag) {
@@ -137,11 +137,8 @@ sk_sp<SkDrawable> SkPictureRecorder::finishRecordingAsDrawable(uint32_t finishFl
}
sk_sp<SkDrawable> drawable =
- sk_make_sp<SkRecordedDrawable>(fRecord, fBBH, fRecorder->detachDrawableList(), fCullRect);
-
- // release our refs now, so only the drawable will be the owner.
- fRecord.reset(nullptr);
- fBBH.reset(nullptr);
+ sk_make_sp<SkRecordedDrawable>(std::move(fRecord), std::move(fBBH),
+ fRecorder->detachDrawableList(), fCullRect);
return drawable;
}
diff --git a/src/core/SkRecordedDrawable.cpp b/src/core/SkRecordedDrawable.cpp
index 9e68be1d25..62a9339c6a 100644
--- a/src/core/SkRecordedDrawable.cpp
+++ b/src/core/SkRecordedDrawable.cpp
@@ -21,7 +21,7 @@ void SkRecordedDrawable::onDraw(SkCanvas* canvas) {
drawables = fDrawableList->begin();
drawableCount = fDrawableList->count();
}
- SkRecordDraw(*fRecord, canvas, nullptr, drawables, drawableCount, fBBH, nullptr/*callback*/);
+ SkRecordDraw(*fRecord, canvas, nullptr, drawables, drawableCount, fBBH.get(), nullptr);
}
SkPicture* SkRecordedDrawable::onNewPictureSnapshot() {
diff --git a/src/core/SkRecordedDrawable.h b/src/core/SkRecordedDrawable.h
index 7e2d9bc599..de1fca5233 100644
--- a/src/core/SkRecordedDrawable.h
+++ b/src/core/SkRecordedDrawable.h
@@ -12,11 +12,11 @@
class SkRecordedDrawable : public SkDrawable {
public:
- SkRecordedDrawable(SkRecord* record, SkBBoxHierarchy* bbh, SkDrawableList* drawableList,
- const SkRect& bounds)
- : fRecord(SkRef(record))
- , fBBH(SkSafeRef(bbh))
- , fDrawableList(drawableList) // we take ownership
+ SkRecordedDrawable(sk_sp<SkRecord> record, sk_sp<SkBBoxHierarchy> bbh,
+ std::unique_ptr<SkDrawableList> drawableList, const SkRect& bounds)
+ : fRecord(std::move(record))
+ , fBBH(std::move(bbh))
+ , fDrawableList(std::move(drawableList))
, fBounds(bounds)
{}
@@ -34,8 +34,8 @@ protected:
SkPicture* onNewPictureSnapshot() override;
private:
- SkAutoTUnref<SkRecord> fRecord;
- SkAutoTUnref<SkBBoxHierarchy> fBBH;
- SkAutoTDelete<SkDrawableList> fDrawableList;
+ sk_sp<SkRecord> fRecord;
+ sk_sp<SkBBoxHierarchy> fBBH;
+ std::unique_ptr<SkDrawableList> fDrawableList;
const SkRect fBounds;
};
diff --git a/src/core/SkRecorder.h b/src/core/SkRecorder.h
index 8efae17c6e..715fc9399c 100644
--- a/src/core/SkRecorder.h
+++ b/src/core/SkRecorder.h
@@ -48,7 +48,7 @@ public:
size_t approxBytesUsedBySubPictures() const { return fApproxBytesUsedBySubPictures; }
SkDrawableList* getDrawableList() const { return fDrawableList.get(); }
- SkDrawableList* detachDrawableList() { return fDrawableList.release(); }
+ std::unique_ptr<SkDrawableList> detachDrawableList() { return std::move(fDrawableList); }
// Make SkRecorder forget entirely about its SkRecord*; all calls to SkRecorder will fail.
void forgetRecord();
@@ -173,7 +173,7 @@ private:
DrawPictureMode fDrawPictureMode;
size_t fApproxBytesUsedBySubPictures;
SkRecord* fRecord;
- SkAutoTDelete<SkDrawableList> fDrawableList;
+ std::unique_ptr<SkDrawableList> fDrawableList;
SkMiniRecorder* fMiniRecorder;
};
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 5d62c6bc62..eeb00c995e 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -370,7 +370,7 @@ public:
this->subset().width(), this->subset().height());
auto img = sk_sp<SkImage>(new SkImage_Gpu(fTexture->width(), fTexture->height(),
- this->uniqueID(), fAlphaType, fTexture.get(),
+ this->uniqueID(), fAlphaType, fTexture,
fColorSpace, SkBudgeted::kNo));
canvas->drawImageRect(img, this->subset(),
@@ -439,7 +439,7 @@ public:
// The existing GrTexture is already tight so reuse it in the SkImage
return sk_make_sp<SkImage_Gpu>(fTexture->width(), fTexture->height(),
kNeedNewImageUniqueID,
- fAlphaType, fTexture.get(), fColorSpace,
+ fAlphaType, fTexture, fColorSpace,
SkBudgeted::kYes);
}
@@ -454,7 +454,7 @@ public:
}
ctx->copySurface(subTx.get(), fTexture.get(), subset, SkIPoint::Make(0, 0));
return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID,
- fAlphaType, subTx.get(), fColorSpace, SkBudgeted::kYes);
+ fAlphaType, std::move(subTx), fColorSpace, SkBudgeted::kYes);
}
sk_sp<SkSurface> onMakeTightSurface(const SkImageFilter::OutputProperties& outProps,
diff --git a/src/core/SkWriteBuffer.cpp b/src/core/SkWriteBuffer.cpp
index 019bc247b5..3d12889fa1 100644
--- a/src/core/SkWriteBuffer.cpp
+++ b/src/core/SkWriteBuffer.cpp
@@ -236,11 +236,8 @@ SkRefCntSet* SkBinaryWriteBuffer::setTypefaceRecorder(SkRefCntSet* rec) {
return rec;
}
-void SkBinaryWriteBuffer::setPixelSerializer(SkPixelSerializer* serializer) {
- fPixelSerializer.reset(serializer);
- if (serializer) {
- serializer->ref();
- }
+void SkBinaryWriteBuffer::setPixelSerializer(sk_sp<SkPixelSerializer> serializer) {
+ fPixelSerializer = std::move(serializer);
}
void SkBinaryWriteBuffer::writeFlattenable(const SkFlattenable* flattenable) {
diff --git a/src/gpu/GrAuditTrail.cpp b/src/gpu/GrAuditTrail.cpp
index 82dc7f713f..ff6debd032 100644
--- a/src/gpu/GrAuditTrail.cpp
+++ b/src/gpu/GrAuditTrail.cpp
@@ -88,7 +88,7 @@ void GrAuditTrail::batchingResultCombined(const GrBatch* consumer, const GrBatch
void GrAuditTrail::copyOutFromBatchList(BatchInfo* outBatchInfo, int batchListID) {
SkASSERT(batchListID < fBatchList.count());
- const BatchNode* bn = fBatchList[batchListID];
+ const BatchNode* bn = fBatchList[batchListID].get();
SkASSERT(bn);
outBatchInfo->fBounds = bn->fBounds;
outBatchInfo->fRenderTargetUniqueID = bn->fRenderTargetUniqueID;
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index a0884f9274..dfb2fce279 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -132,11 +132,11 @@ GrContext::~GrContext() {
fCaps->unref();
}
-GrContextThreadSafeProxy* GrContext::threadSafeProxy() {
+sk_sp<GrContextThreadSafeProxy> GrContext::threadSafeProxy() {
if (!fThreadSafeProxy) {
- fThreadSafeProxy.reset(new GrContextThreadSafeProxy(fCaps, this->uniqueID()));
+ fThreadSafeProxy.reset(new GrContextThreadSafeProxy(sk_ref_sp(fCaps), this->uniqueID()));
}
- return SkRef(fThreadSafeProxy.get());
+ return fThreadSafeProxy;
}
void GrContext::abandonContext() {
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index 29eb151b6c..398fc8a549 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -15,7 +15,7 @@
data members or virtual methods. */
class GrContextPriv {
public:
- GrDrawingManager* drawingManager() { return fContext->fDrawingManager; }
+ GrDrawingManager* drawingManager() { return fContext->fDrawingManager.get(); }
// Create a drawContext that wraps an existing renderTarget
sk_sp<GrDrawContext> makeWrappedDrawContext(sk_sp<GrRenderTarget> rt,
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 0de9fedb8c..f576424889 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -190,7 +190,8 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budget
return tex;
}
-GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc, GrWrapOwnership ownership) {
+sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc,
+ GrWrapOwnership ownership) {
this->handleDirtyContext();
if (!this->caps()->isConfigTexturable(desc.fConfig)) {
return nullptr;
@@ -203,22 +204,20 @@ GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc, GrWrapOwn
if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
return nullptr;
}
- GrTexture* tex = this->onWrapBackendTexture(desc, ownership);
- if (nullptr == tex) {
+ sk_sp<GrTexture> tex = this->onWrapBackendTexture(desc, ownership);
+ if (!tex) {
return nullptr;
}
// TODO: defer this and attach dynamically
GrRenderTarget* tgt = tex->asRenderTarget();
if (tgt && !fContext->resourceProvider()->attachStencilAttachment(tgt)) {
- tex->unref();
return nullptr;
- } else {
- return tex;
}
+ return tex;
}
-GrRenderTarget* GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc,
- GrWrapOwnership ownership) {
+sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc,
+ GrWrapOwnership ownership) {
if (!this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
return nullptr;
}
@@ -226,7 +225,7 @@ GrRenderTarget* GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc&
return this->onWrapBackendRenderTarget(desc, ownership);
}
-GrRenderTarget* GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc) {
+sk_sp<GrRenderTarget> GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc) {
this->handleDirtyContext();
if (!(desc.fFlags & kRenderTarget_GrBackendTextureFlag)) {
return nullptr;
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index ba7ed6f47e..8e9407a458 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -124,17 +124,17 @@ public:
/**
* Implements GrTextureProvider::wrapBackendTexture
*/
- GrTexture* wrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership);
+ sk_sp<GrTexture> wrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership);
/**
* Implements GrTextureProvider::wrapBackendRenderTarget
*/
- GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc&, GrWrapOwnership);
+ sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTargetDesc&,GrWrapOwnership);
/**
* Implements GrTextureProvider::wrapBackendTextureAsRenderTarget
*/
- GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&);
+ sk_sp<GrRenderTarget> wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&);
/**
* Creates a buffer in GPU memory. For a client-side buffer use GrBuffer::CreateCPUBacked.
@@ -532,10 +532,10 @@ private:
SkBudgeted budgeted,
const SkTArray<GrMipLevel>& texels) = 0;
- virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) = 0;
- virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
- GrWrapOwnership) = 0;
- virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) = 0;
+ virtual sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) = 0;
+ virtual sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
+ GrWrapOwnership) = 0;
+ virtual sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&)=0;
virtual GrBuffer* onCreateBuffer(size_t size, GrBufferType intendedType, GrAccessPattern,
const void* data) = 0;
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index e641e749ff..3eb047c1a8 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -113,7 +113,7 @@ bool GrRenderTargetOpList::setupDstReadIfNecessary(const GrPipelineBuilder& pipe
if (GrTexture* rtTex = rt->asTexture()) {
// The render target is a texture, so we can read from it directly in the shader. The XP
// will be responsible to detect this situation and request a texture barrier.
- dstTexture->setTexture(rtTex);
+ dstTexture->setTexture(sk_ref_sp(rtTex));
dstTexture->setOffset(0, 0);
return true;
}
@@ -145,15 +145,15 @@ bool GrRenderTargetOpList::setupDstReadIfNecessary(const GrPipelineBuilder& pipe
desc.fHeight = copyRect.height();
static const uint32_t kFlags = 0;
- SkAutoTUnref<GrTexture> copy(fResourceProvider->createApproxTexture(desc, kFlags));
+ sk_sp<GrTexture> copy(fResourceProvider->createApproxTexture(desc, kFlags));
if (!copy) {
SkDebugf("Failed to create temporary copy of destination texture.\n");
return false;
}
SkIPoint dstPoint = {0, 0};
- this->copySurface(copy, rt, copyRect, dstPoint);
- dstTexture->setTexture(copy);
+ this->copySurface(copy.get(), rt, copyRect, dstPoint);
+ dstTexture->setTexture(std::move(copy));
dstTexture->setOffset(copyRect.fLeft, copyRect.fTop);
return true;
}
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index b63a7eaa45..9739b05ad7 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -205,8 +205,9 @@ GrStencilAttachment* GrResourceProvider::attachStencilAttachment(GrRenderTarget*
return rt->renderTargetPriv().getStencilAttachment();
}
-GrRenderTarget* GrResourceProvider::wrapBackendTextureAsRenderTarget(
- const GrBackendTextureDesc& desc) {
+sk_sp<GrRenderTarget> GrResourceProvider::wrapBackendTextureAsRenderTarget(
+ const GrBackendTextureDesc& desc)
+{
if (this->isAbandoned()) {
return nullptr;
}
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index 4c90cddd4d..c29a40a2b4 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -164,7 +164,7 @@ public:
*
* @return GrRenderTarget object or NULL on failure.
*/
- GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc);
+ sk_sp<GrRenderTarget> wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc);
private:
const GrBuffer* createInstancedIndexBuffer(const uint16_t* pattern,
diff --git a/src/gpu/GrTextureProvider.cpp b/src/gpu/GrTextureProvider.cpp
index 68a5540484..dba24b5926 100644
--- a/src/gpu/GrTextureProvider.cpp
+++ b/src/gpu/GrTextureProvider.cpp
@@ -158,8 +158,8 @@ GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc,
return nullptr;
}
-GrTexture* GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& desc,
- GrWrapOwnership ownership) {
+sk_sp<GrTexture> GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& desc,
+ GrWrapOwnership ownership) {
ASSERT_SINGLE_OWNER
if (this->isAbandoned()) {
return nullptr;
@@ -167,10 +167,12 @@ GrTexture* GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& des
return fGpu->wrapBackendTexture(desc, ownership);
}
-GrRenderTarget* GrTextureProvider::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc) {
+sk_sp<GrRenderTarget> GrTextureProvider::wrapBackendRenderTarget(
+ const GrBackendRenderTargetDesc& desc)
+{
ASSERT_SINGLE_OWNER
- return this->isAbandoned() ? nullptr : fGpu->wrapBackendRenderTarget(desc,
- kBorrow_GrWrapOwnership);
+ return this->isAbandoned() ? nullptr
+ : fGpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership);
}
void GrTextureProvider::assignUniqueKeyToResource(const GrUniqueKey& key, GrGpuResource* resource) {
diff --git a/src/gpu/gl/GrGLExtensions.cpp b/src/gpu/gl/GrGLExtensions.cpp
index 43a147d763..29f7799462 100644
--- a/src/gpu/gl/GrGLExtensions.cpp
+++ b/src/gpu/gl/GrGLExtensions.cpp
@@ -9,6 +9,7 @@
#include "gl/GrGLDefines.h"
#include "gl/GrGLUtil.h"
+#include "SkMakeUnique.h"
#include "SkTSearch.h"
#include "SkTSort.h"
@@ -99,12 +100,12 @@ bool GrGLExtensions::init(GrGLStandard standard,
if (!extensions) {
return false;
}
- eat_space_sep_strings(fStrings, extensions);
+ eat_space_sep_strings(fStrings.get(), extensions);
}
if (queryString) {
const char* extensions = queryString(eglDisplay, GR_EGL_EXTENSIONS);
- eat_space_sep_strings(fStrings, extensions);
+ eat_space_sep_strings(fStrings.get(), extensions);
}
if (!fStrings->empty()) {
SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp;
@@ -122,27 +123,26 @@ bool GrGLExtensions::has(const char ext[]) const {
bool GrGLExtensions::remove(const char ext[]) {
SkASSERT(fInitialized);
int idx = find_string(*fStrings, ext);
- if (idx >= 0) {
- // This is not terribly effecient but we really only expect this function to be called at
- // most a handful of times when our test programs start.
- SkAutoTDelete< SkTArray<SkString> > oldStrings(fStrings.release());
- fStrings.reset(new SkTArray<SkString>(oldStrings->count() - 1));
- fStrings->push_back_n(idx, &oldStrings->front());
- fStrings->push_back_n(oldStrings->count() - idx - 1, &(*oldStrings)[idx] + 1);
- return true;
- } else {
+ if (idx < 0) {
return false;
}
+
+ // This is not terribly effecient but we really only expect this function to be called at
+ // most a handful of times when our test programs start.
+ fStrings->removeShuffle(idx);
+ SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp;
+ SkTInsertionSort(&(fStrings->operator[](idx)), &fStrings->back(), cmp);
+ return true;
}
void GrGLExtensions::add(const char ext[]) {
int idx = find_string(*fStrings, ext);
if (idx < 0) {
- // This is not the most effecient approach since we end up doing a full sort of the
+ // This is not the most effecient approach since we end up looking at all of the
// extensions after the add
- fStrings->push_back().set(ext);
+ fStrings->emplace_back(ext);
SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp;
- SkTQSort(&fStrings->front(), &fStrings->back(), cmp);
+ SkTInsertionSort(&fStrings->front(), &fStrings->back(), cmp);
}
}
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 4e579cc543..485a9bd09a 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -624,8 +624,8 @@ static GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget)
}
}
-GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
- GrWrapOwnership ownership) {
+sk_sp<GrTexture> GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
+ GrWrapOwnership ownership) {
const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc.fTextureHandle);
if (!info || !info->fID) {
return nullptr;
@@ -681,25 +681,18 @@ GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
surfDesc.fOrigin = desc.fOrigin;
}
- GrGLTexture* texture = nullptr;
if (renderTarget) {
GrGLRenderTarget::IDDesc rtIDDesc;
if (!this->createRenderTargetObjects(surfDesc, idDesc.fInfo, &rtIDDesc)) {
return nullptr;
}
- texture = GrGLTextureRenderTarget::CreateWrapped(this, surfDesc, idDesc, rtIDDesc);
- } else {
- texture = GrGLTexture::CreateWrapped(this, surfDesc, idDesc);
- }
- if (nullptr == texture) {
- return nullptr;
+ return GrGLTextureRenderTarget::MakeWrapped(this, surfDesc, idDesc, rtIDDesc);
}
-
- return texture;
+ return GrGLTexture::MakeWrapped(this, surfDesc, idDesc);
}
-GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDesc& wrapDesc,
- GrWrapOwnership ownership) {
+sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDesc& wrapDesc,
+ GrWrapOwnership ownership) {
GrGLRenderTarget::IDDesc idDesc;
idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle);
idDesc.fMSColorRenderbufferID = 0;
@@ -719,10 +712,10 @@ GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount());
desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true);
- return GrGLRenderTarget::CreateWrapped(this, desc, idDesc, wrapDesc.fStencilBits);
+ return GrGLRenderTarget::MakeWrapped(this, desc, idDesc, wrapDesc.fStencilBits);
}
-GrRenderTarget* GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc) {
+sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc){
const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc.fTextureHandle);
if (!info || !info->fID) {
return nullptr;
@@ -759,7 +752,7 @@ GrRenderTarget* GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextu
if (!this->createRenderTargetObjects(surfDesc, texInfo, &rtIDDesc)) {
return nullptr;
}
- return GrGLRenderTarget::CreateWrapped(this, surfDesc, rtIDDesc, 0);
+ return GrGLRenderTarget::MakeWrapped(this, surfDesc, rtIDDesc, 0);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 29d20e4b63..4420c658fe 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -164,10 +164,10 @@ private:
GrBuffer* onCreateBuffer(size_t size, GrBufferType intendedType, GrAccessPattern,
const void* data) override;
- GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) override;
- GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
- GrWrapOwnership) override;
- GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override;
+ sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) override;
+ sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
+ GrWrapOwnership) override;
+ sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override;
gr_instanced::InstancedRendering* onCreateInstancedRendering() override;
diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp
index f6ad3ba611..65366bd380 100644
--- a/src/gpu/gl/GrGLRenderTarget.cpp
+++ b/src/gpu/gl/GrGLRenderTarget.cpp
@@ -64,10 +64,10 @@ void GrGLRenderTarget::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
SkASSERT(fGpuMemorySize <= WorstCaseSize(desc));
}
-GrGLRenderTarget* GrGLRenderTarget::CreateWrapped(GrGLGpu* gpu,
- const GrSurfaceDesc& desc,
- const IDDesc& idDesc,
- int stencilBits) {
+sk_sp<GrGLRenderTarget> GrGLRenderTarget::MakeWrapped(GrGLGpu* gpu,
+ const GrSurfaceDesc& desc,
+ const IDDesc& idDesc,
+ int stencilBits) {
GrGLStencilAttachment* sb = nullptr;
if (stencilBits) {
GrGLStencilAttachment::IDDesc sbDesc;
@@ -80,7 +80,7 @@ GrGLRenderTarget* GrGLRenderTarget::CreateWrapped(GrGLGpu* gpu,
sb = new GrGLStencilAttachment(gpu, sbDesc, desc.fWidth, desc.fHeight,
desc.fSampleCnt, format);
}
- return (new GrGLRenderTarget(gpu, desc, idDesc, sb));
+ return sk_sp<GrGLRenderTarget>(new GrGLRenderTarget(gpu, desc, idDesc, sb));
}
size_t GrGLRenderTarget::onGpuMemorySize() const {
diff --git a/src/gpu/gl/GrGLRenderTarget.h b/src/gpu/gl/GrGLRenderTarget.h
index 85e377f69a..08dd88d523 100644
--- a/src/gpu/gl/GrGLRenderTarget.h
+++ b/src/gpu/gl/GrGLRenderTarget.h
@@ -31,10 +31,10 @@ public:
bool fIsMixedSampled;
};
- static GrGLRenderTarget* CreateWrapped(GrGLGpu*,
- const GrSurfaceDesc&,
- const IDDesc&,
- int stencilBits);
+ static sk_sp<GrGLRenderTarget> MakeWrapped(GrGLGpu*,
+ const GrSurfaceDesc&,
+ const IDDesc&,
+ int stencilBits);
void setViewport(const GrGLIRect& rect) { fViewport = rect; }
const GrGLIRect& getViewport() const { return fViewport; }
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index ed753472a8..4653c5bce7 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -92,8 +92,8 @@ void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
texture_id.c_str());
}
-GrGLTexture* GrGLTexture::CreateWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc,
- const IDDesc& idDesc) {
- return new GrGLTexture(gpu, kWrapped, desc, idDesc);
+sk_sp<GrGLTexture> GrGLTexture::MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc,
+ const IDDesc& idDesc) {
+ return sk_sp<GrGLTexture>(new GrGLTexture(gpu, kWrapped, desc, idDesc));
}
diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h
index 05d26c8de8..ee027d790d 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -56,7 +56,7 @@ public:
GrGLenum target() const { return fInfo.fTarget; }
- static GrGLTexture* CreateWrapped(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&);
+ static sk_sp<GrGLTexture> MakeWrapped(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&);
protected:
// Constructor for subclasses.
GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&);
diff --git a/src/gpu/gl/GrGLTextureRenderTarget.cpp b/src/gpu/gl/GrGLTextureRenderTarget.cpp
index 2ba469a9f2..9b37fbb343 100644
--- a/src/gpu/gl/GrGLTextureRenderTarget.cpp
+++ b/src/gpu/gl/GrGLTextureRenderTarget.cpp
@@ -44,9 +44,10 @@ bool GrGLTextureRenderTarget::canAttemptStencilAttachment() const {
return true;
}
-GrGLTextureRenderTarget* GrGLTextureRenderTarget::CreateWrapped(GrGLGpu* gpu,
- const GrSurfaceDesc& desc,
- const GrGLTexture::IDDesc& texIDDesc,
- const GrGLRenderTarget::IDDesc& rtIDDesc) {
- return new GrGLTextureRenderTarget(gpu, desc, texIDDesc, rtIDDesc);
+sk_sp<GrGLTextureRenderTarget> GrGLTextureRenderTarget::MakeWrapped(
+ GrGLGpu* gpu, const GrSurfaceDesc& desc,
+ const GrGLTexture::IDDesc& texIDDesc, const GrGLRenderTarget::IDDesc& rtIDDesc)
+{
+ return sk_sp<GrGLTextureRenderTarget>(
+ new GrGLTextureRenderTarget(gpu, desc, texIDDesc, rtIDDesc));
}
diff --git a/src/gpu/gl/GrGLTextureRenderTarget.h b/src/gpu/gl/GrGLTextureRenderTarget.h
index 0826cf3a71..c5c020fef6 100644
--- a/src/gpu/gl/GrGLTextureRenderTarget.h
+++ b/src/gpu/gl/GrGLTextureRenderTarget.h
@@ -40,9 +40,9 @@ public:
void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
- static GrGLTextureRenderTarget* CreateWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc,
- const GrGLTexture::IDDesc& texIDDesc,
- const GrGLRenderTarget::IDDesc& rtIDDesc);
+ static sk_sp<GrGLTextureRenderTarget> MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc,
+ const GrGLTexture::IDDesc& texIDDesc,
+ const GrGLRenderTarget::IDDesc& rtIDDesc);
protected:
void onAbandon() override {
GrGLRenderTarget::onAbandon();
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index b13e16282e..7d75921c23 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -756,8 +756,8 @@ static GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin) {
}
}
-GrTexture* GrVkGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
- GrWrapOwnership ownership) {
+sk_sp<GrTexture> GrVkGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
+ GrWrapOwnership ownership) {
if (0 == desc.fTextureHandle) {
return nullptr;
}
@@ -791,22 +791,14 @@ GrTexture* GrVkGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
// In VK, we don't have this restriction
surfDesc.fOrigin = resolve_origin(desc.fOrigin);
- GrVkTexture* texture = nullptr;
- if (renderTarget) {
- texture = GrVkTextureRenderTarget::CreateWrappedTextureRenderTarget(this, surfDesc,
- ownership, info);
- } else {
- texture = GrVkTexture::CreateWrappedTexture(this, surfDesc, ownership, info);
+ if (!renderTarget) {
+ return GrVkTexture::MakeWrappedTexture(this, surfDesc, ownership, info);
}
- if (!texture) {
- return nullptr;
- }
-
- return texture;
+ return GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(this, surfDesc, ownership, info);
}
-GrRenderTarget* GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDesc& wrapDesc,
- GrWrapOwnership ownership) {
+sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDesc& wrapDesc,
+ GrWrapOwnership ownership) {
const GrVkImageInfo* info =
reinterpret_cast<const GrVkImageInfo*>(wrapDesc.fRenderTargetHandle);
@@ -824,12 +816,10 @@ GrRenderTarget* GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
desc.fOrigin = resolve_origin(wrapDesc.fOrigin);
- GrVkRenderTarget* tgt = GrVkRenderTarget::CreateWrappedRenderTarget(this, desc,
- ownership,
- info);
+ sk_sp<GrVkRenderTarget> tgt = GrVkRenderTarget::MakeWrappedRenderTarget(this, desc,
+ ownership, info);
if (tgt && wrapDesc.fStencilBits) {
- if (!createStencilAttachmentForRenderTarget(tgt, desc.fWidth, desc.fHeight)) {
- tgt->unref();
+ if (!createStencilAttachmentForRenderTarget(tgt.get(), desc.fWidth, desc.fHeight)) {
return nullptr;
}
}
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index 77eb24215c..b62278337b 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -50,7 +50,7 @@ public:
~GrVkGpu() override;
- const GrVkInterface* vkInterface() const { return fBackendContext->fInterface; }
+ const GrVkInterface* vkInterface() const { return fBackendContext->fInterface.get(); }
const GrVkCaps& vkCaps() const { return *fVkCaps; }
VkDevice device() const { return fDevice; }
@@ -182,11 +182,13 @@ private:
GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, SkBudgeted,
const SkTArray<GrMipLevel>&) override { return NULL; }
- GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) override;
+ sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) override;
- GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
- GrWrapOwnership) override;
- GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override { return NULL; }
+ sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
+ GrWrapOwnership) override;
+ sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override {
+ return nullptr;
+ }
GrBuffer* onCreateBuffer(size_t size, GrBufferType type, GrAccessPattern,
const void* data) override;
diff --git a/src/gpu/vk/GrVkRenderTarget.cpp b/src/gpu/vk/GrVkRenderTarget.cpp
index d6895d25fc..e2f0019d9c 100644
--- a/src/gpu/vk/GrVkRenderTarget.cpp
+++ b/src/gpu/vk/GrVkRenderTarget.cpp
@@ -201,11 +201,11 @@ GrVkRenderTarget::CreateNewRenderTarget(GrVkGpu* gpu,
return rt;
}
-GrVkRenderTarget*
-GrVkRenderTarget::CreateWrappedRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
- GrWrapOwnership ownership,
- const GrVkImageInfo* info) {
+sk_sp<GrVkRenderTarget>
+GrVkRenderTarget::MakeWrappedRenderTarget(GrVkGpu* gpu,
+ const GrSurfaceDesc& desc,
+ GrWrapOwnership ownership,
+ const GrVkImageInfo* info) {
SkASSERT(info);
// We can wrap a rendertarget without its allocation, as long as we don't take ownership
SkASSERT(VK_NULL_HANDLE != info->fImage);
@@ -214,9 +214,8 @@ GrVkRenderTarget::CreateWrappedRenderTarget(GrVkGpu* gpu,
GrVkImage::Wrapped wrapped = kBorrow_GrWrapOwnership == ownership ? GrVkImage::kBorrowed_Wrapped
: GrVkImage::kAdopted_Wrapped;
- GrVkRenderTarget* rt = GrVkRenderTarget::Create(gpu, SkBudgeted::kNo, desc, *info, wrapped);
-
- return rt;
+ return sk_sp<GrVkRenderTarget>(
+ GrVkRenderTarget::Create(gpu, SkBudgeted::kNo, desc, *info, wrapped));
}
bool GrVkRenderTarget::completeStencilAttachment() {
diff --git a/src/gpu/vk/GrVkRenderTarget.h b/src/gpu/vk/GrVkRenderTarget.h
index e3ebefba5a..0855a6d020 100644
--- a/src/gpu/vk/GrVkRenderTarget.h
+++ b/src/gpu/vk/GrVkRenderTarget.h
@@ -34,9 +34,9 @@ public:
static GrVkRenderTarget* CreateNewRenderTarget(GrVkGpu*, SkBudgeted, const GrSurfaceDesc&,
const GrVkImage::ImageDesc&);
- static GrVkRenderTarget* CreateWrappedRenderTarget(GrVkGpu*, const GrSurfaceDesc&,
- GrWrapOwnership,
- const GrVkImageInfo*);
+ static sk_sp<GrVkRenderTarget> MakeWrappedRenderTarget(GrVkGpu*, const GrSurfaceDesc&,
+ GrWrapOwnership,
+ const GrVkImageInfo*);
~GrVkRenderTarget() override;
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index bf399a8352..8c461f8308 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -78,10 +78,10 @@ GrVkTexture* GrVkTexture::CreateNewTexture(GrVkGpu* gpu, SkBudgeted budgeted,
return new GrVkTexture(gpu, budgeted, desc, info, imageView);
}
-GrVkTexture* GrVkTexture::CreateWrappedTexture(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
- GrWrapOwnership ownership,
- const GrVkImageInfo* info) {
+sk_sp<GrVkTexture> GrVkTexture::MakeWrappedTexture(GrVkGpu* gpu,
+ const GrSurfaceDesc& desc,
+ GrWrapOwnership ownership,
+ const GrVkImageInfo* info) {
SkASSERT(info);
// Wrapped textures require both image and allocation (because they can be mapped)
SkASSERT(VK_NULL_HANDLE != info->fImage && VK_NULL_HANDLE != info->fAlloc.fMemory);
@@ -96,7 +96,7 @@ GrVkTexture* GrVkTexture::CreateWrappedTexture(GrVkGpu* gpu,
GrVkImage::Wrapped wrapped = kBorrow_GrWrapOwnership == ownership ? GrVkImage::kBorrowed_Wrapped
: GrVkImage::kAdopted_Wrapped;
- return new GrVkTexture(gpu, kWrapped, desc, *info, imageView, wrapped);
+ return sk_sp<GrVkTexture>(new GrVkTexture(gpu, kWrapped, desc, *info, imageView, wrapped));
}
GrVkTexture::~GrVkTexture() {
diff --git a/src/gpu/vk/GrVkTexture.h b/src/gpu/vk/GrVkTexture.h
index 06d147584a..70db54838d 100644
--- a/src/gpu/vk/GrVkTexture.h
+++ b/src/gpu/vk/GrVkTexture.h
@@ -21,8 +21,8 @@ public:
static GrVkTexture* CreateNewTexture(GrVkGpu*, SkBudgeted budgeted, const GrSurfaceDesc&,
const GrVkImage::ImageDesc&);
- static GrVkTexture* CreateWrappedTexture(GrVkGpu*, const GrSurfaceDesc&,
- GrWrapOwnership, const GrVkImageInfo*);
+ static sk_sp<GrVkTexture> MakeWrappedTexture(GrVkGpu*, const GrSurfaceDesc&,
+ GrWrapOwnership, const GrVkImageInfo*);
~GrVkTexture() override;
diff --git a/src/gpu/vk/GrVkTextureRenderTarget.cpp b/src/gpu/vk/GrVkTextureRenderTarget.cpp
index 37b68af827..cfa63be8af 100644
--- a/src/gpu/vk/GrVkTextureRenderTarget.cpp
+++ b/src/gpu/vk/GrVkTextureRenderTarget.cpp
@@ -135,11 +135,11 @@ GrVkTextureRenderTarget::CreateNewTextureRenderTarget(GrVkGpu* gpu,
return trt;
}
-GrVkTextureRenderTarget*
-GrVkTextureRenderTarget::CreateWrappedTextureRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
- GrWrapOwnership ownership,
- const GrVkImageInfo* info) {
+sk_sp<GrVkTextureRenderTarget>
+GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(GrVkGpu* gpu,
+ const GrSurfaceDesc& desc,
+ GrWrapOwnership ownership,
+ const GrVkImageInfo* info) {
SkASSERT(info);
// Wrapped textures require both image and allocation (because they can be mapped)
SkASSERT(VK_NULL_HANDLE != info->fImage && VK_NULL_HANDLE != info->fAlloc.fMemory);
@@ -147,9 +147,7 @@ GrVkTextureRenderTarget::CreateWrappedTextureRenderTarget(GrVkGpu* gpu,
GrVkImage::Wrapped wrapped = kBorrow_GrWrapOwnership == ownership ? GrVkImage::kBorrowed_Wrapped
: GrVkImage::kAdopted_Wrapped;
- GrVkTextureRenderTarget* trt = Create(gpu, desc, *info, SkBudgeted::kNo, wrapped);
-
- return trt;
+ return sk_sp<GrVkTextureRenderTarget>(Create(gpu, desc, *info, SkBudgeted::kNo, wrapped));
}
bool GrVkTextureRenderTarget::updateForMipmap(GrVkGpu* gpu, const GrVkImageInfo& newInfo) {
diff --git a/src/gpu/vk/GrVkTextureRenderTarget.h b/src/gpu/vk/GrVkTextureRenderTarget.h
index 2259511066..daa168758d 100644
--- a/src/gpu/vk/GrVkTextureRenderTarget.h
+++ b/src/gpu/vk/GrVkTextureRenderTarget.h
@@ -28,10 +28,10 @@ public:
const GrSurfaceDesc&,
const GrVkImage::ImageDesc&);
- static GrVkTextureRenderTarget* CreateWrappedTextureRenderTarget(GrVkGpu*,
- const GrSurfaceDesc&,
- GrWrapOwnership,
- const GrVkImageInfo*);
+ static sk_sp<GrVkTextureRenderTarget> MakeWrappedTextureRenderTarget(GrVkGpu*,
+ const GrSurfaceDesc&,
+ GrWrapOwnership,
+ const GrVkImageInfo*);
bool updateForMipmap(GrVkGpu* gpu, const GrVkImageInfo& newInfo);
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index c9315bb14d..6af8491e73 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -23,17 +23,17 @@
#include "SkMipMap.h"
#include "SkPixelRef.h"
-SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrTexture* tex,
+SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, sk_sp<GrTexture> tex,
sk_sp<SkColorSpace> colorSpace, SkBudgeted budgeted)
: INHERITED(w, h, uniqueID)
- , fTexture(SkRef(tex))
+ , fTexture(std::move(tex))
, fAlphaType(at)
, fBudgeted(budgeted)
, fColorSpace(std::move(colorSpace))
, fAddedRasterVersionToCache(false)
{
- SkASSERT(tex->width() == w);
- SkASSERT(tex->height() == h);
+ SkASSERT(fTexture->width() == w);
+ SkASSERT(fTexture->height() == h);
}
SkImage_Gpu::~SkImage_Gpu() {
@@ -149,9 +149,9 @@ sk_sp<SkImage> SkImage_Gpu::onMakeSubset(const SkIRect& subset) const {
if (!subTx) {
return nullptr;
}
- ctx->copySurface(subTx.get(), fTexture, subset, SkIPoint::Make(0, 0));
+ ctx->copySurface(subTx.get(), fTexture.get(), subset, SkIPoint::Make(0, 0));
return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID,
- fAlphaType, subTx.get(), fColorSpace, fBudgeted);
+ fAlphaType, std::move(subTx), fColorSpace, fBudgeted);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -164,7 +164,7 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx, const GrBackend
if (desc.fWidth <= 0 || desc.fHeight <= 0) {
return nullptr;
}
- SkAutoTUnref<GrTexture> tex(ctx->textureProvider()->wrapBackendTexture(desc, ownership));
+ sk_sp<GrTexture> tex = ctx->textureProvider()->wrapBackendTexture(desc, ownership);
if (!tex) {
return nullptr;
}
@@ -174,7 +174,7 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx, const GrBackend
const SkBudgeted budgeted = SkBudgeted::kNo;
return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID,
- at, tex, colorSpace, budgeted);
+ at, std::move(tex), std::move(colorSpace), budgeted);
}
sk_sp<SkImage> SkImage::MakeFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
@@ -271,7 +271,7 @@ static sk_sp<SkImage> make_from_yuv_textures_copy(GrContext* ctx, SkYUVColorSpac
drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), rect);
ctx->flushSurfaceWrites(drawContext->accessRenderTarget());
return sk_make_sp<SkImage_Gpu>(width, height, kNeedNewImageUniqueID,
- kOpaque_SkAlphaType, drawContext->asTexture().get(),
+ kOpaque_SkAlphaType, drawContext->asTexture(),
sk_ref_sp(drawContext->getColorSpace()), budgeted);
}
@@ -293,12 +293,12 @@ sk_sp<SkImage> SkImage::MakeFromNV12TexturesCopy(GrContext* ctx, SkYUVColorSpace
}
static sk_sp<SkImage> create_image_from_maker(GrTextureMaker* maker, SkAlphaType at, uint32_t id) {
- SkAutoTUnref<GrTexture> texture(maker->refTextureForParams(GrTextureParams::ClampNoFilter(),
- SkSourceGammaTreatment::kRespect));
+ sk_sp<GrTexture> texture(maker->refTextureForParams(GrTextureParams::ClampNoFilter(),
+ SkSourceGammaTreatment::kRespect));
if (!texture) {
return nullptr;
}
- return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), id, at, texture,
+ return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), id, at, std::move(texture),
sk_ref_sp(maker->getColorSpace()), SkBudgeted::kNo);
}
@@ -345,12 +345,12 @@ sk_sp<SkImage> SkImage::MakeTextureFromPixmap(GrContext* ctx, const SkPixmap& pi
if (!ctx) {
return nullptr;
}
- SkAutoTUnref<GrTexture> texture(GrUploadPixmapToTexture(ctx, pixmap, budgeted));
+ sk_sp<GrTexture> texture(GrUploadPixmapToTexture(ctx, pixmap, budgeted));
if (!texture) {
return nullptr;
}
return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNewImageUniqueID,
- pixmap.alphaType(), texture,
+ pixmap.alphaType(), std::move(texture),
sk_ref_sp(pixmap.info().colorSpace()), budgeted);
}
@@ -702,12 +702,12 @@ sk_sp<SkImage> SkImage::MakeTextureFromMipMap(GrContext* ctx, const SkImageInfo&
if (!ctx) {
return nullptr;
}
- SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, mipLevelCount));
+ sk_sp<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, mipLevelCount));
if (!texture) {
return nullptr;
}
texture->texturePriv().setGammaTreatment(gammaTreatment);
return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNewImageUniqueID,
- info.alphaType(), texture, sk_ref_sp(info.colorSpace()),
- budgeted);
+ info.alphaType(), std::move(texture),
+ sk_ref_sp(info.colorSpace()), budgeted);
}
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index 02260bcca5..b0380863b5 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -23,7 +23,7 @@ public:
* An "image" can be a subset/window into a larger texture, so we explicit take the
* width and height.
*/
- SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType, GrTexture*, sk_sp<SkColorSpace>,
+ SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType, sk_sp<GrTexture>, sk_sp<SkColorSpace>,
SkBudgeted);
~SkImage_Gpu() override;
@@ -43,20 +43,20 @@ public:
SkSourceGammaTreatment) const override;
sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
- GrTexture* peekTexture() const override { return fTexture; }
+ GrTexture* peekTexture() const override { return fTexture.get(); }
sk_sp<GrTexture> refPinnedTexture(uint32_t* uniqueID) const override {
*uniqueID = this->uniqueID();
- return sk_ref_sp(fTexture.get());
+ return fTexture;
}
bool onReadPixels(const SkImageInfo&, void* dstPixels, size_t dstRowBytes,
int srcX, int srcY, CachingHint) const override;
private:
- SkAutoTUnref<GrTexture> fTexture;
- const SkAlphaType fAlphaType;
- const SkBudgeted fBudgeted;
- sk_sp<SkColorSpace> fColorSpace;
- mutable SkAtomic<bool> fAddedRasterVersionToCache;
+ sk_sp<GrTexture> fTexture;
+ const SkAlphaType fAlphaType;
+ const SkBudgeted fBudgeted;
+ sk_sp<SkColorSpace> fColorSpace;
+ mutable SkAtomic<bool> fAddedRasterVersionToCache;
typedef SkImage_Base INHERITED;
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 3007313118..37e8eeb2e9 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -79,7 +79,7 @@ sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, SkCopyPixe
GrRenderTarget* rt = fDevice->accessDrawContext()->accessRenderTarget();
SkASSERT(rt);
GrTexture* tex = rt->asTexture();
- SkAutoTUnref<GrTexture> copy;
+ sk_sp<GrTexture> copy;
// If the original render target is a buffer originally created by the client, then we don't
// want to ever retarget the SkSurface at another buffer we create. Force a copy now to avoid
// copy-on-write.
@@ -91,17 +91,17 @@ sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, SkCopyPixe
if (!copy) {
return nullptr;
}
- if (!ctx->copySurface(copy, rt)) {
+ if (!ctx->copySurface(copy.get(), rt)) {
return nullptr;
}
- tex = copy;
+ tex = copy.get();
}
const SkImageInfo info = fDevice->imageInfo();
sk_sp<SkImage> image;
if (tex) {
image = sk_make_sp<SkImage_Gpu>(info.width(), info.height(), kNeedNewImageUniqueID,
- info.alphaType(), tex, sk_ref_sp(info.colorSpace()),
- budgeted);
+ info.alphaType(), sk_ref_sp(tex),
+ sk_ref_sp(info.colorSpace()), budgeted);
}
return image;
}
diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp
index 7201dc10b0..33ae767ec3 100644
--- a/src/ports/SkFontMgr_win_dw.cpp
+++ b/src/ports/SkFontMgr_win_dw.cpp
@@ -1085,11 +1085,11 @@ SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
}
#include "SkFontMgr_indirect.h"
-SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) {
- SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite());
- if (impl.get() == nullptr) {
+SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(sk_sp<SkRemotableFontMgr> proxy) {
+ sk_sp<SkFontMgr> impl(SkFontMgr_New_DirectWrite());
+ if (!impl) {
return nullptr;
}
- return new SkFontMgr_Indirect(impl.get(), proxy);
+ return new SkFontMgr_Indirect(std::move(impl), std::move(proxy));
}
#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/SkDeferredCanvas.h b/src/utils/SkDeferredCanvas.h
index 2ac594c903..68574caa73 100644
--- a/src/utils/SkDeferredCanvas.h
+++ b/src/utils/SkDeferredCanvas.h
@@ -35,7 +35,6 @@ protected:
SkImageInfo onImageInfo() const override;
bool onGetProps(SkSurfaceProps*) const override;
void onFlush() override;
-// SkCanvas* canvasForDrawIter() override;
void willSave() override;
SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index 4a23a9c3f5..de305c7443 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -173,7 +173,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
externalDesc.fWidth = kSize;
externalDesc.fHeight = kSize;
externalDesc.fTextureHandle = reinterpret_cast<GrBackendObject>(&externalTexture);
- SkAutoTUnref<GrTexture> externalTextureObj(
+ sk_sp<GrTexture> externalTextureObj(
context0->textureProvider()->wrapBackendTexture(externalDesc));
if (!externalTextureObj) {
ERRORF(reporter, "Error wrapping external texture in GrTexture.");
@@ -183,7 +183,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
// Should not be able to wrap as a RT
externalDesc.fFlags = kRenderTarget_GrBackendTextureFlag;
- SkAutoTUnref<GrTexture> externalTextureRTObj(
+ sk_sp<GrTexture> externalTextureRTObj(
context0->textureProvider()->wrapBackendTexture(externalDesc));
if (externalTextureRTObj) {
ERRORF(reporter, "Should not be able to wrap an EXTERNAL texture as a RT.");
@@ -192,18 +192,18 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
// Should not be able to wrap with a sample count
externalDesc.fSampleCnt = 4;
- SkAutoTUnref<GrTexture> externalTextureMSAAObj(
+ sk_sp<GrTexture> externalTextureMSAAObj(
context0->textureProvider()->wrapBackendTexture(externalDesc));
if (externalTextureMSAAObj) {
ERRORF(reporter, "Should not be able to wrap an EXTERNAL texture with MSAA.");
}
externalDesc.fSampleCnt = 0;
- test_read_pixels(reporter, context0, externalTextureObj, pixels.get());
+ test_read_pixels(reporter, context0, externalTextureObj.get(), pixels.get());
- test_write_pixels(reporter, context0, externalTextureObj);
+ test_write_pixels(reporter, context0, externalTextureObj.get());
- test_copy_surface(reporter, context0, externalTextureObj, pixels.get());
+ test_copy_surface(reporter, context0, externalTextureObj.get(), pixels.get());
cleanup(glCtx0, externalTexture.fID, glCtx1, context1, backendTexture1, image);
}
diff --git a/tests/GrPorterDuffTest.cpp b/tests/GrPorterDuffTest.cpp
index 845dae16e4..719f787d1d 100644
--- a/tests/GrPorterDuffTest.cpp
+++ b/tests/GrPorterDuffTest.cpp
@@ -1161,16 +1161,14 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) {
}
GrBackendObject backendTex =
- ctx->getGpu()->createTestingOnlyBackendTexture(nullptr, 100, 100,
- kRGBA_8888_GrPixelConfig);
+ ctx->getGpu()->createTestingOnlyBackendTexture(nullptr, 100, 100, kRGBA_8888_GrPixelConfig);
GrBackendTextureDesc fakeDesc;
fakeDesc.fConfig = kRGBA_8888_GrPixelConfig;
fakeDesc.fWidth = fakeDesc.fHeight = 100;
fakeDesc.fTextureHandle = backendTex;
- SkAutoTUnref<GrTexture> fakeTexture(ctx->textureProvider()->wrapBackendTexture(fakeDesc,
- kBorrow_GrWrapOwnership));
GrXferProcessor::DstTexture fakeDstTexture;
- fakeDstTexture.setTexture(fakeTexture);
+ fakeDstTexture.setTexture(
+ ctx->textureProvider()->wrapBackendTexture(fakeDesc, kBorrow_GrWrapOwnership));
static const GrColor testColors[] = {
0,
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index b6ca406118..5a69e53474 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -54,10 +54,10 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) {
backendDesc.fHeight = 256;
backendDesc.fSampleCnt = 0;
backendDesc.fTextureHandle = backendTex;
- GrSurface* texRT2 = context->textureProvider()->wrapBackendTexture(
+ sk_sp<GrSurface> texRT2 = context->textureProvider()->wrapBackendTexture(
backendDesc, kBorrow_GrWrapOwnership);
- REPORTER_ASSERT(reporter, texRT2 == texRT2->asRenderTarget());
- REPORTER_ASSERT(reporter, texRT2 == texRT2->asTexture());
+ REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asRenderTarget());
+ REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asTexture());
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget()) ==
texRT2->asTexture());
REPORTER_ASSERT(reporter, texRT2->asRenderTarget() ==
@@ -66,7 +66,6 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) {
static_cast<GrSurface*>(texRT2->asTexture()));
texRT1->unref();
- texRT2->unref();
tex1->unref();
context->getGpu()->deleteTestingOnlyBackendTexture(backendTex);
}
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index e7de3694df..a0ce16fcab 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -889,7 +889,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(NewTextureFromPixmap, reporter, ctxInfo) {
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredTextureImage, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
sk_gpu_test::TestContext* testContext = ctxInfo.testContext();
- SkAutoTUnref<GrContextThreadSafeProxy> proxy(context->threadSafeProxy());
+ sk_sp<GrContextThreadSafeProxy> proxy = context->threadSafeProxy();
GrContextFactory otherFactory;
ContextInfo otherContextInfo =
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 99a4e5b5af..1b8071e013 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -4007,7 +4007,7 @@ public:
static void TestPathRef(skiatest::Reporter* reporter) {
static const int kRepeatCnt = 10;
- SkAutoTUnref<SkPathRef> pathRef(new SkPathRef);
+ sk_sp<SkPathRef> pathRef(new SkPathRef);
SkPathRef::Editor ed(&pathRef);
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index a21b5a2f63..1491326236 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -187,7 +187,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
}
}
- SkAutoTUnref<GrTexture> rectangleTexture(
+ sk_sp<GrTexture> rectangleTexture(
context->textureProvider()->wrapBackendTexture(rectangleDesc));
if (!rectangleTexture) {
ERRORF(reporter, "Error wrapping rectangle texture in GrTexture.");
@@ -195,15 +195,15 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
continue;
}
- test_read_pixels(reporter, context, rectangleTexture, refPixels);
+ test_read_pixels(reporter, context, rectangleTexture.get(), refPixels);
- test_copy_surface_src(reporter, context, rectangleTexture, refPixels);
+ test_copy_surface_src(reporter, context, rectangleTexture.get(), refPixels);
- test_copy_surface_dst(reporter, context, rectangleTexture);
+ test_copy_surface_dst(reporter, context, rectangleTexture.get());
- test_write_pixels(reporter, context, rectangleTexture);
+ test_write_pixels(reporter, context, rectangleTexture.get());
- test_clear(reporter, context, rectangleTexture);
+ test_clear(reporter, context, rectangleTexture.get());
GR_GL_CALL(glContext->gl(), DeleteTextures(1, &rectTexID));
}
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index b6f13e69bb..3e4efb108f 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -221,13 +221,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI
desc.fHeight = kH;
desc.fTextureHandle = texHandles[0];
- SkAutoTUnref<GrTexture> borrowed(context->textureProvider()->wrapBackendTexture(
- desc, kBorrow_GrWrapOwnership));
+ sk_sp<GrTexture> borrowed(context->textureProvider()->wrapBackendTexture(
+ desc, kBorrow_GrWrapOwnership));
desc.fTextureHandle = texHandles[1];
- SkAutoTUnref<GrTexture> adopted(context->textureProvider()->wrapBackendTexture(
- desc, kAdopt_GrWrapOwnership));
+ sk_sp<GrTexture> adopted(context->textureProvider()->wrapBackendTexture(
+ desc, kAdopt_GrWrapOwnership));
+ printf("\nborrowed: %p, adopted: %p\n", borrowed.get(), adopted.get());
REPORTER_ASSERT(reporter, borrowed != nullptr && adopted != nullptr);
if (!borrowed || !adopted) {
return;
diff --git a/tests/VkWrapTests.cpp b/tests/VkWrapTests.cpp
index b3456c28ba..58c4b356c6 100644
--- a/tests/VkWrapTests.cpp
+++ b/tests/VkWrapTests.cpp
@@ -39,9 +39,8 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
desc.fWidth = kW;
desc.fHeight = kH;
desc.fTextureHandle = backendObj;
- GrTexture* tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership);
+ sk_sp<GrTexture> tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership);
REPORTER_ASSERT(reporter, tex);
- tex->unref();
// image is null
GrVkImageInfo backendCopy = *backendTex;
@@ -64,7 +63,6 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
backendCopy.fAlloc = backendTex->fAlloc;
tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership);
REPORTER_ASSERT(reporter, tex);
- tex->unref();
gpu->deleteTestingOnlyBackendTexture(backendObj, true);
}
@@ -85,9 +83,8 @@ void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
desc.fSampleCnt = 0;
desc.fStencilBits = 0;
desc.fRenderTargetHandle = backendObj;
- GrRenderTarget* rt = gpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership);
+ sk_sp<GrRenderTarget> rt = gpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership);
REPORTER_ASSERT(reporter, rt);
- rt->unref();
// image is null
GrVkImageInfo backendCopy = *backendTex;
@@ -112,7 +109,6 @@ void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
backendCopy.fAlloc = backendTex->fAlloc;
rt = gpu->wrapBackendRenderTarget(desc, kAdopt_GrWrapOwnership);
REPORTER_ASSERT(reporter, rt);
- rt->unref();
gpu->deleteTestingOnlyBackendTexture(backendObj, true);
}
@@ -131,9 +127,8 @@ void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
desc.fWidth = kW;
desc.fHeight = kH;
desc.fTextureHandle = backendObj;
- GrTexture* tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership);
+ sk_sp<GrTexture> tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership);
REPORTER_ASSERT(reporter, tex);
- tex->unref();
// image is null
GrVkImageInfo backendCopy = *backendTex;
@@ -156,7 +151,6 @@ void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
backendCopy.fAlloc = backendTex->fAlloc;
tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership);
REPORTER_ASSERT(reporter, tex);
- tex->unref();
gpu->deleteTestingOnlyBackendTexture(backendObj, true);
}
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index 60c10e8226..387ef32ffd 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -337,15 +337,16 @@ private:
return nullptr;
}
- GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&,
- GrWrapOwnership) override { return nullptr; }
+ sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) override {
+ return nullptr;
+ }
- GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
- GrWrapOwnership) override {
+ sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
+ GrWrapOwnership) override {
return nullptr;
}
- GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override {
+ sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override {
return nullptr;
}
diff --git a/tools/gpu/vk/VkTestContext.h b/tools/gpu/vk/VkTestContext.h
index 5c6408a549..ecec17b7dc 100644
--- a/tools/gpu/vk/VkTestContext.h
+++ b/tools/gpu/vk/VkTestContext.h
@@ -24,7 +24,7 @@ public:
bool isValid() const override { return NULL != this->vk(); }
- const GrVkInterface* vk() const { return fVk->fInterface; }
+ const GrVkInterface* vk() const { return fVk->fInterface.get(); }
protected:
VkTestContext(sk_sp<const GrVkBackendContext> vk) : fVk(std::move(vk)) {}