From 6bd5284415bd983b0628c4941dff5def40018f5a Mon Sep 17 00:00:00 2001 From: bungeman Date: Thu, 27 Oct 2016 09:30:08 -0700 Subject: 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 --- src/gpu/gl/GrGLExtensions.cpp | 28 ++++++++++++++-------------- src/gpu/gl/GrGLGpu.cpp | 25 +++++++++---------------- src/gpu/gl/GrGLGpu.h | 8 ++++---- src/gpu/gl/GrGLRenderTarget.cpp | 10 +++++----- src/gpu/gl/GrGLRenderTarget.h | 8 ++++---- src/gpu/gl/GrGLTexture.cpp | 6 +++--- src/gpu/gl/GrGLTexture.h | 2 +- src/gpu/gl/GrGLTextureRenderTarget.cpp | 11 ++++++----- src/gpu/gl/GrGLTextureRenderTarget.h | 6 +++--- 9 files changed, 49 insertions(+), 55 deletions(-) (limited to 'src/gpu/gl') 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 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 > oldStrings(fStrings.release()); - fStrings.reset(new SkTArray(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 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 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 GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc, + GrWrapOwnership ownership) { const GrGLTextureInfo* info = reinterpret_cast(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 GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDesc& wrapDesc, + GrWrapOwnership ownership) { GrGLRenderTarget::IDDesc idDesc; idDesc.fRTFBOID = static_cast(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 GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc){ const GrGLTextureInfo* info = reinterpret_cast(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 onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) override; + sk_sp onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, + GrWrapOwnership) override; + sk_sp 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::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(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 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::MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc, + const IDDesc& idDesc) { + return sk_sp(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 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::MakeWrapped( + GrGLGpu* gpu, const GrSurfaceDesc& desc, + const GrGLTexture::IDDesc& texIDDesc, const GrGLRenderTarget::IDDesc& rtIDDesc) +{ + return sk_sp( + 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 MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc, + const GrGLTexture::IDDesc& texIDDesc, + const GrGLRenderTarget::IDDesc& rtIDDesc); protected: void onAbandon() override { GrGLRenderTarget::onAbandon(); -- cgit v1.2.3