Remove SkSafeSetNull.
Update all users to sk_sp. Change-Id: I6453b9456b9a8f9e2b756381797f1382ef9e6561 Reviewed-on: https://skia-review.googlesource.com/141052 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Herb Derby <herb@google.com>
This commit is contained in:
parent
c434ade20e
commit
9ec70c6bd3
@ -62,7 +62,7 @@ void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) {
|
||||
int xTiles = SkScalarCeilToInt(bounds.width() / SkIntToScalar(tileW));
|
||||
int yTiles = SkScalarCeilToInt(bounds.height() / SkIntToScalar(tileH));
|
||||
|
||||
fSurfaces.setReserve(xTiles * yTiles);
|
||||
fSurfaces.reserve(xTiles * yTiles);
|
||||
fTileRects.setReserve(xTiles * yTiles);
|
||||
|
||||
SkImageInfo ii = canvas->imageInfo().makeWH(tileW, tileH);
|
||||
@ -71,16 +71,16 @@ void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) {
|
||||
for (int x = bounds.fLeft; x < bounds.fRight; x += tileW) {
|
||||
const SkIRect tileRect = SkIRect::MakeXYWH(x, y, tileW, tileH);
|
||||
*fTileRects.append() = tileRect;
|
||||
*fSurfaces.push() = canvas->makeSurface(ii).release();
|
||||
fSurfaces.emplace_back(canvas->makeSurface(ii));
|
||||
|
||||
// Never want the contents of a tile to include stuff the parent
|
||||
// canvas clips out
|
||||
SkRect clip = SkRect::Make(bounds);
|
||||
clip.offset(-SkIntToScalar(tileRect.fLeft), -SkIntToScalar(tileRect.fTop));
|
||||
fSurfaces.top()->getCanvas()->clipRect(clip);
|
||||
fSurfaces.back()->getCanvas()->clipRect(clip);
|
||||
|
||||
fSurfaces.top()->getCanvas()->setMatrix(canvas->getTotalMatrix());
|
||||
fSurfaces.top()->getCanvas()->scale(fScale, fScale);
|
||||
fSurfaces.back()->getCanvas()->setMatrix(canvas->getTotalMatrix());
|
||||
fSurfaces.back()->getCanvas()->scale(fScale, fScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -92,10 +92,9 @@ void SKPBench::onPerCanvasPostDraw(SkCanvas* canvas) {
|
||||
sk_sp<SkImage> image(fSurfaces[i]->makeImageSnapshot());
|
||||
canvas->drawImage(image,
|
||||
SkIntToScalar(fTileRects[i].fLeft), SkIntToScalar(fTileRects[i].fTop));
|
||||
SkSafeSetNull(fSurfaces[i]);
|
||||
}
|
||||
|
||||
fSurfaces.rewind();
|
||||
fSurfaces.reset();
|
||||
fTileRects.rewind();
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ protected:
|
||||
virtual void drawPicture();
|
||||
|
||||
const SkPicture* picture() const { return fPic.get(); }
|
||||
const SkTDArray<SkSurface*>& surfaces() const { return fSurfaces; }
|
||||
const SkTArray<sk_sp<SkSurface>, true>& surfaces() const { return fSurfaces; }
|
||||
const SkTDArray<SkIRect>& tileRects() const { return fTileRects; }
|
||||
|
||||
private:
|
||||
@ -54,7 +54,7 @@ private:
|
||||
SkString fUniqueName;
|
||||
|
||||
const bool fUseMultiPictureDraw;
|
||||
SkTDArray<SkSurface*> fSurfaces; // for MultiPictureDraw
|
||||
SkTArray<sk_sp<SkSurface>, true> fSurfaces; // for MultiPictureDraw
|
||||
SkTDArray<SkIRect> fTileRects; // for MultiPictureDraw
|
||||
|
||||
const bool fDoLooping;
|
||||
|
@ -199,13 +199,6 @@ template <typename T> static inline void SkSafeUnref(T* obj) {
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T> static inline void SkSafeSetNull(T*& obj) {
|
||||
if (obj) {
|
||||
obj->unref();
|
||||
obj = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This is a variant of SkRefCnt that's Not Virtual, so weighs 4 bytes instead of 8 or 16.
|
||||
|
@ -110,6 +110,7 @@ public:
|
||||
|
||||
protected:
|
||||
GrRenderTarget(GrGpu*, const GrSurfaceDesc&, GrStencilAttachment* = nullptr);
|
||||
~GrRenderTarget() override;
|
||||
|
||||
// override of GrResource
|
||||
void onAbandon() override;
|
||||
@ -125,7 +126,7 @@ private:
|
||||
friend class GrRenderTargetPriv;
|
||||
|
||||
int fSampleCnt;
|
||||
GrStencilAttachment* fStencilAttachment;
|
||||
sk_sp<GrStencilAttachment> fStencilAttachment;
|
||||
|
||||
SkIRect fResolveRect;
|
||||
|
||||
|
@ -80,9 +80,8 @@ void GrDrawingManager::cleanup() {
|
||||
|
||||
fOpLists.reset();
|
||||
|
||||
delete fPathRendererChain;
|
||||
fPathRendererChain = nullptr;
|
||||
SkSafeSetNull(fSoftwarePathRenderer);
|
||||
fSoftwarePathRenderer = nullptr;
|
||||
|
||||
fOnFlushCBObjects.reset();
|
||||
}
|
||||
@ -105,9 +104,8 @@ void GrDrawingManager::freeGpuResources() {
|
||||
}
|
||||
|
||||
// a path renderer may be holding onto resources
|
||||
delete fPathRendererChain;
|
||||
fPathRendererChain = nullptr;
|
||||
SkSafeSetNull(fSoftwarePathRenderer);
|
||||
fSoftwarePathRenderer = nullptr;
|
||||
}
|
||||
|
||||
// MDB TODO: make use of the 'proxy' parameter.
|
||||
@ -498,7 +496,7 @@ GrPathRenderer* GrDrawingManager::getPathRenderer(const GrPathRenderer::CanDrawP
|
||||
GrPathRenderer::StencilSupport* stencilSupport) {
|
||||
|
||||
if (!fPathRendererChain) {
|
||||
fPathRendererChain = new GrPathRendererChain(fContext, fOptionsForPathRendererChain);
|
||||
fPathRendererChain.reset(new GrPathRendererChain(fContext, fOptionsForPathRendererChain));
|
||||
}
|
||||
|
||||
GrPathRenderer* pr = fPathRendererChain->getPathRenderer(args, drawType, stencilSupport);
|
||||
@ -514,16 +512,16 @@ GrPathRenderer* GrDrawingManager::getPathRenderer(const GrPathRenderer::CanDrawP
|
||||
|
||||
GrPathRenderer* GrDrawingManager::getSoftwarePathRenderer() {
|
||||
if (!fSoftwarePathRenderer) {
|
||||
fSoftwarePathRenderer =
|
||||
fSoftwarePathRenderer.reset(
|
||||
new GrSoftwarePathRenderer(fContext->contextPriv().proxyProvider(),
|
||||
fOptionsForPathRendererChain.fAllowPathMaskCaching);
|
||||
fOptionsForPathRendererChain.fAllowPathMaskCaching));
|
||||
}
|
||||
return fSoftwarePathRenderer;
|
||||
return fSoftwarePathRenderer.get();
|
||||
}
|
||||
|
||||
GrCoverageCountingPathRenderer* GrDrawingManager::getCoverageCountingPathRenderer() {
|
||||
if (!fPathRendererChain) {
|
||||
fPathRendererChain = new GrPathRendererChain(fContext, fOptionsForPathRendererChain);
|
||||
fPathRendererChain.reset(new GrPathRendererChain(fContext, fOptionsForPathRendererChain));
|
||||
}
|
||||
return fPathRendererChain->getCoverageCountingPathRenderer();
|
||||
}
|
||||
|
@ -125,8 +125,8 @@ private:
|
||||
|
||||
std::unique_ptr<GrTextContext> fTextContext;
|
||||
|
||||
GrPathRendererChain* fPathRendererChain;
|
||||
GrSoftwarePathRenderer* fSoftwarePathRenderer;
|
||||
std::unique_ptr<GrPathRendererChain> fPathRendererChain;
|
||||
sk_sp<GrSoftwarePathRenderer> fSoftwarePathRenderer;
|
||||
|
||||
GrTokenTracker fTokenTracker;
|
||||
bool fFlushing;
|
||||
|
@ -29,6 +29,8 @@ GrRenderTarget::GrRenderTarget(GrGpu* gpu, const GrSurfaceDesc& desc,
|
||||
fResolveRect = SkRectPriv::MakeILargestInverted();
|
||||
}
|
||||
|
||||
GrRenderTarget::~GrRenderTarget() = default;
|
||||
|
||||
void GrRenderTarget::flagAsNeedingResolve(const SkIRect* rect) {
|
||||
if (kCanResolve_ResolveType == getResolveType()) {
|
||||
if (rect) {
|
||||
@ -58,13 +60,13 @@ void GrRenderTarget::flagAsResolved() {
|
||||
}
|
||||
|
||||
void GrRenderTarget::onRelease() {
|
||||
SkSafeSetNull(fStencilAttachment);
|
||||
fStencilAttachment = nullptr;
|
||||
|
||||
INHERITED::onRelease();
|
||||
}
|
||||
|
||||
void GrRenderTarget::onAbandon() {
|
||||
SkSafeSetNull(fStencilAttachment);
|
||||
fStencilAttachment = nullptr;
|
||||
|
||||
INHERITED::onAbandon();
|
||||
}
|
||||
@ -77,9 +79,9 @@ bool GrRenderTargetPriv::attachStencilAttachment(sk_sp<GrStencilAttachment> sten
|
||||
// we're not actually adding one.
|
||||
return true;
|
||||
}
|
||||
fRenderTarget->fStencilAttachment = stencil.release();
|
||||
fRenderTarget->fStencilAttachment = std::move(stencil);
|
||||
if (!fRenderTarget->completeStencilAttachment()) {
|
||||
SkSafeSetNull(fRenderTarget->fStencilAttachment);
|
||||
fRenderTarget->fStencilAttachment = nullptr;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -21,7 +21,9 @@ public:
|
||||
/**
|
||||
* GrStencilAttachment is not part of the public API.
|
||||
*/
|
||||
GrStencilAttachment* getStencilAttachment() const { return fRenderTarget->fStencilAttachment; }
|
||||
GrStencilAttachment* getStencilAttachment() const {
|
||||
return fRenderTarget->fStencilAttachment.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the GrStencilAttachment onto the render target. If stencil is a nullptr then the
|
||||
|
@ -145,8 +145,8 @@ HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, bool deepColor, SkWGLConte
|
||||
*/
|
||||
class SkWGLPbufferContext : public SkRefCnt {
|
||||
public:
|
||||
static SkWGLPbufferContext* Create(HDC parentDC, SkWGLContextRequest contextType,
|
||||
HGLRC shareContext);
|
||||
static sk_sp<SkWGLPbufferContext> Create(HDC parentDC, SkWGLContextRequest contextType,
|
||||
HGLRC shareContext);
|
||||
|
||||
virtual ~SkWGLPbufferContext();
|
||||
|
||||
|
@ -443,8 +443,9 @@ HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, bool deepColor,
|
||||
return create_gl_context(dc, extensions, contextType, shareContext);
|
||||
}
|
||||
|
||||
SkWGLPbufferContext* SkWGLPbufferContext::Create(HDC parentDC, SkWGLContextRequest contextType,
|
||||
HGLRC shareContext) {
|
||||
sk_sp<SkWGLPbufferContext> SkWGLPbufferContext::Create(HDC parentDC,
|
||||
SkWGLContextRequest contextType,
|
||||
HGLRC shareContext) {
|
||||
SkWGLExtensions extensions;
|
||||
if (!extensions.hasExtension(parentDC, "WGL_ARB_pixel_format") ||
|
||||
!extensions.hasExtension(parentDC, "WGL_ARB_pbuffer")) {
|
||||
@ -485,7 +486,7 @@ SkWGLPbufferContext* SkWGLPbufferContext::Create(HDC parentDC, SkWGLContextReque
|
||||
if (dc) {
|
||||
HGLRC glrc = create_gl_context(dc, extensions, contextType, shareContext);
|
||||
if (glrc) {
|
||||
return new SkWGLPbufferContext(pbuf, dc, glrc);
|
||||
return sk_sp<SkWGLPbufferContext>(new SkWGLPbufferContext(pbuf, dc, glrc));
|
||||
}
|
||||
extensions.releasePbufferDC(pbuf, dc);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ private:
|
||||
HDC fDeviceContext;
|
||||
HGLRC fGlRenderContext;
|
||||
static ATOM gWC;
|
||||
SkWGLPbufferContext* fPbufferContext;
|
||||
sk_sp<SkWGLPbufferContext> fPbufferContext;
|
||||
};
|
||||
|
||||
ATOM WinGLTestContext::gWC = 0;
|
||||
@ -148,7 +148,7 @@ WinGLTestContext::~WinGLTestContext() {
|
||||
}
|
||||
|
||||
void WinGLTestContext::destroyGLContext() {
|
||||
SkSafeSetNull(fPbufferContext);
|
||||
fPbufferContext = nullptr;
|
||||
if (fGlRenderContext) {
|
||||
// This deletes the context immediately even if it is current.
|
||||
wglDeleteContext(fGlRenderContext);
|
||||
|
Loading…
Reference in New Issue
Block a user