Remove GrRefCnt.h in favor of SkRefCnt.h

This removes GrRefCnt.h with all its tyepdefs and #defines and just switch them
to the Sk* equivalents.

GrSafeSetNull was promoted to SkSafeSetNull in SkRefCnt.h.

BUG=None
TEST=none, no functional changes.
R=bsalomon@google.com, robertphillips@google.com

Author: tfarina@chromium.org

Review URL: https://chromiumcodereview.appspot.com/23904003

git-svn-id: http://skia.googlecode.com/svn/trunk@11151 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2013-09-09 13:38:37 +00:00
parent 18c7617a30
commit a4de8c257e
35 changed files with 70 additions and 122 deletions

View File

@ -93,7 +93,7 @@ protected:
if (!texture) {
return;
}
GrAutoUnref au(texture);
SkAutoUnref au(texture);
GrContext::AutoClip acs(ctx, SkRect::MakeWH(2*S, 2*S));

View File

@ -25,7 +25,6 @@
'<(skia_include_path)/gpu/GrPathRendererChain.h',
'<(skia_include_path)/gpu/GrPoint.h',
'<(skia_include_path)/gpu/GrRect.h',
'<(skia_include_path)/gpu/GrRefCnt.h',
'<(skia_include_path)/gpu/GrRenderTarget.h',
'<(skia_include_path)/gpu/GrResource.h',
'<(skia_include_path)/gpu/GrSurface.h',

View File

@ -34,7 +34,6 @@
'gpu/GrTypes.h',
'gpu/GrFontScaler.h',
'gpu/GrResource.h',
'gpu/GrRefCnt.h',
'gpu/GrKey.h',
'gpu/GrOvalRenderer.h',
'gpu/GrEffectUnitTest.h',

View File

@ -160,6 +160,13 @@ template <typename T> static inline void SkSafeUnref(T* obj) {
}
}
template<typename T> static inline void SkSafeSetNull(T*& obj) {
if (NULL != obj) {
obj->unref();
obj = NULL;
}
}
///////////////////////////////////////////////////////////////////////////////
/**

View File

@ -15,7 +15,6 @@
#include "GrPathRendererChain.h"
#include "GrPoint.h"
#include "GrRenderTarget.h"
#include "GrRefCnt.h"
#include "GrTexture.h"
class GrAARectRenderer;
@ -40,7 +39,7 @@ class GrVertexBufferAllocPool;
class GrSoftwarePathRenderer;
class SkStrokeRec;
class SK_API GrContext : public GrRefCnt {
class SK_API GrContext : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrContext)
@ -635,20 +634,20 @@ public:
public:
AutoRenderTarget(GrContext* context, GrRenderTarget* target) {
fPrevTarget = context->getRenderTarget();
GrSafeRef(fPrevTarget);
SkSafeRef(fPrevTarget);
context->setRenderTarget(target);
fContext = context;
}
AutoRenderTarget(GrContext* context) {
fPrevTarget = context->getRenderTarget();
GrSafeRef(fPrevTarget);
SkSafeRef(fPrevTarget);
fContext = context;
}
~AutoRenderTarget() {
if (NULL != fContext) {
fContext->setRenderTarget(fPrevTarget);
}
GrSafeUnref(fPrevTarget);
SkSafeUnref(fPrevTarget);
}
private:
GrContext* fContext;
@ -934,7 +933,7 @@ private:
*/
static bool OverbudgetCB(void* data);
typedef GrRefCnt INHERITED;
typedef SkRefCnt INHERITED;
};
/**

View File

@ -11,7 +11,6 @@
#include "GrColor.h"
#include "GrEffectUnitTest.h"
#include "GrNoncopyable.h"
#include "GrRefCnt.h"
#include "GrTexture.h"
#include "GrTextureAccess.h"
#include "GrTypesPriv.h"
@ -74,13 +73,13 @@ private:
member function of a GrEffect subclass.
Because almost no code should ever handle a GrEffect directly outside of a GrEffectRef, we
privately inherit from GrRefCnt to help prevent accidental direct ref'ing/unref'ing of effects.
privately inherit from SkRefCnt to help prevent accidental direct ref'ing/unref'ing of effects.
Dynamically allocated GrEffects and their corresponding GrEffectRefs are managed by a per-thread
memory pool. The ref count of an effect must reach 0 before the thread terminates and the pool
is destroyed. To create a static effect use the macro GR_CREATE_STATIC_EFFECT declared below.
*/
class GrEffect : private GrRefCnt {
class GrEffect : private SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrEffect)
@ -317,7 +316,7 @@ private:
bool fWillReadFragmentPosition;
GrEffectRef* fEffectRef;
typedef GrRefCnt INHERITED;
typedef SkRefCnt INHERITED;
};
inline GrEffectRef::GrEffectRef(GrEffect* effect) {

View File

@ -20,7 +20,7 @@ class SkPath;
* The client is responsible for subclassing, and instantiating this. The
* instance is create for a specific font+size+matrix.
*/
class GrFontScaler : public GrRefCnt {
class GrFontScaler : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrFontScaler)
@ -32,7 +32,7 @@ public:
virtual bool getGlyphPath(uint16_t glyphID, SkPath*) = 0;
private:
typedef GrRefCnt INHERITED;
typedef SkRefCnt INHERITED;
};
#endif

View File

@ -1,4 +1,3 @@
/*
* Copyright 2010 Google Inc.
*
@ -6,14 +5,10 @@
* found in the LICENSE file.
*/
#ifndef GrKey_DEFINED
#define GrKey_DEFINED
#include "GrRefCnt.h"
class GrKey : public GrRefCnt {
class GrKey : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrKey)
@ -37,7 +32,7 @@ protected:
private:
const Hash fHash;
typedef GrRefCnt INHERITED;
typedef SkRefCnt INHERITED;
};
#endif

View File

@ -1,4 +1,3 @@
/*
* Copyright 2011 Google Inc.
*
@ -6,11 +5,10 @@
* found in the LICENSE file.
*/
#ifndef GrPathRendererChain_DEFINED
#define GrPathRendererChain_DEFINED
#include "GrRefCnt.h"
#include "SkRefCnt.h"
#include "SkTArray.h"
class GrContext;
@ -64,7 +62,6 @@ public:
StencilSupport* stencilSupport);
private:
GrPathRendererChain();
void init();
@ -79,5 +76,4 @@ private:
typedef SkRefCnt INHERITED;
};
#endif

View File

@ -1,33 +0,0 @@
/*
* Copyright 2010 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrRefCnt_DEFINED
#define GrRefCnt_DEFINED
#include "GrTypes.h"
#include "SkRefCnt.h"
typedef SkRefCnt GrRefCnt;
typedef SkAutoRef GrAutoRef;
typedef SkAutoUnref GrAutoUnref;
#define GrSafeRef SkSafeRef
#define GrSafeUnref SkSafeUnref
#define GrSafeAssign(a, b) SkRefCnt_SafeAssign(a, b)
template<typename T>
static inline void GrSafeSetNull(T*& obj) {
if (NULL != obj) {
obj->unref();
obj = NULL;
}
}
#endif

View File

@ -1,4 +1,3 @@
/*
* Copyright 2011 Google Inc.
*
@ -6,12 +5,10 @@
* found in the LICENSE file.
*/
#ifndef GrResource_DEFINED
#define GrResource_DEFINED
#include "GrRefCnt.h"
#include "SkRefCnt.h"
#include "SkTInternalLList.h"
class GrGpu;
@ -21,7 +18,7 @@ class GrResourceEntry;
/**
* Base class for the GPU resources created by a GrContext.
*/
class GrResource : public GrRefCnt {
class GrResource : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrResource)
@ -111,7 +108,7 @@ private:
};
uint32_t fFlags;
typedef GrRefCnt INHERITED;
typedef SkRefCnt INHERITED;
};
#endif

View File

@ -1,4 +1,3 @@
/*
* Copyright 2011 Google Inc.
*
@ -6,12 +5,11 @@
* found in the LICENSE file.
*/
#ifndef GrGLInterface_DEFINED
#define GrGLInterface_DEFINED
#include "GrGLFunctions.h"
#include "GrRefCnt.h"
#include "SkRefCnt.h"
////////////////////////////////////////////////////////////////////////////////
@ -110,7 +108,7 @@ typedef intptr_t GrGLInterfaceCallbackData;
* non-NULL or GrContext creation will fail. This can be tested with the
* validate() method when the OpenGL context has been made current.
*/
struct SK_API GrGLInterface : public GrRefCnt {
struct SK_API GrGLInterface : public SkRefCnt {
private:
// simple wrapper class that exists only to initialize a pointer to NULL
template <typename FNPTR_TYPE> class GLPtr {
@ -122,7 +120,7 @@ private:
FNPTR_TYPE fPtr;
};
typedef GrRefCnt INHERITED;
typedef SkRefCnt INHERITED;
public:
SK_DECLARE_INST_COUNT(GrGLInterface)

View File

@ -6,7 +6,6 @@
*/
#include "GrAARectRenderer.h"
#include "GrRefCnt.h"
#include "GrGpu.h"
#include "gl/GrGLEffect.h"
#include "GrTBackendEffectFactory.h"
@ -295,8 +294,8 @@ static void set_inset_fan(GrPoint* pts, size_t stride,
};
void GrAARectRenderer::reset() {
GrSafeSetNull(fAAFillRectIndexBuffer);
GrSafeSetNull(fAAStrokeRectIndexBuffer);
SkSafeSetNull(fAAFillRectIndexBuffer);
SkSafeSetNull(fAAStrokeRectIndexBuffer);
}
static const uint16_t gFillAARectIdx[] = {

View File

@ -5,13 +5,12 @@
* found in the LICENSE file.
*/
#ifndef GrAARectRenderer_DEFINED
#define GrAARectRenderer_DEFINED
#include "GrRefCnt.h"
#include "SkMatrix.h"
#include "SkRect.h"
#include "SkRefCnt.h"
class GrGpu;
class GrDrawTarget;
@ -20,7 +19,7 @@ class GrIndexBuffer;
/*
* This class wraps helper functions that draw AA rects (filled & stroked)
*/
class GrAARectRenderer : public GrRefCnt {
class GrAARectRenderer : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrAARectRenderer)
@ -108,7 +107,7 @@ private:
const SkRect& devInside,
bool useVertexCoverage);
typedef GrRefCnt INHERITED;
typedef SkRefCnt INHERITED;
};
#endif // GrAARectRenderer_DEFINED

View File

@ -170,7 +170,7 @@ GrAtlasMgr::GrAtlasMgr(GrGpu* gpu) {
GrAtlasMgr::~GrAtlasMgr() {
for (size_t i = 0; i < GR_ARRAY_COUNT(fTexture); i++) {
GrSafeUnref(fTexture[i]);
SkSafeUnref(fTexture[i]);
}
delete fPlotMgr;

View File

@ -167,8 +167,8 @@ GrContext::~GrContext() {
fOvalRenderer->unref();
fGpu->unref();
GrSafeUnref(fPathRendererChain);
GrSafeUnref(fSoftwarePathRenderer);
SkSafeUnref(fPathRendererChain);
SkSafeUnref(fSoftwarePathRenderer);
fDrawState->unref();
--THREAD_INSTANCE_COUNT;
@ -186,8 +186,8 @@ void GrContext::contextDestroyed() {
// a path renderer may be holding onto resources that
// are now unusable
GrSafeSetNull(fPathRendererChain);
GrSafeSetNull(fSoftwarePathRenderer);
SkSafeSetNull(fPathRendererChain);
SkSafeSetNull(fSoftwarePathRenderer);
delete fDrawBuffer;
fDrawBuffer = NULL;
@ -221,8 +221,8 @@ void GrContext::freeGpuResources() {
fTextureCache->purgeAllUnlocked();
fFontCache->freeAll();
// a path renderer may be holding onto resources
GrSafeSetNull(fPathRendererChain);
GrSafeSetNull(fSoftwarePathRenderer);
SkSafeSetNull(fPathRendererChain);
SkSafeSetNull(fSoftwarePathRenderer);
}
size_t GrContext::getGpuTextureCacheBytes() const {

View File

@ -14,7 +14,6 @@
#include "GrEffectStage.h"
#include "GrPaint.h"
#include "GrPoint.h"
#include "GrRefCnt.h"
#include "GrRenderTarget.h"
#include "GrStencil.h"
#include "GrTemplates.h"
@ -25,7 +24,7 @@
#include "SkMatrix.h"
#include "SkXfermode.h"
class GrDrawState : public GrRefCnt {
class GrDrawState : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrDrawState)
@ -675,7 +674,7 @@ public:
fDrawState->setRenderTarget(fSavedTarget);
fDrawState = NULL;
}
GrSafeSetNull(fSavedTarget);
SkSafeSetNull(fSavedTarget);
}
void set(GrDrawState* ds, GrRenderTarget* newTarget) {
@ -1077,7 +1076,7 @@ private:
*/
void setVertexAttribs(const GrVertexAttrib attribs[], int count);
typedef GrRefCnt INHERITED;
typedef SkRefCnt INHERITED;
};
GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags);

View File

@ -1,4 +1,3 @@
/*
* Copyright 2010 Google Inc.
*
@ -6,20 +5,18 @@
* found in the LICENSE file.
*/
#ifndef GrDrawTarget_DEFINED
#define GrDrawTarget_DEFINED
#include "GrClipData.h"
#include "GrDrawState.h"
#include "GrIndexBuffer.h"
#include "SkMatrix.h"
#include "GrRefCnt.h"
#include "SkClipStack.h"
#include "SkMatrix.h"
#include "SkPath.h"
#include "SkTLazy.h"
#include "SkTArray.h"
#include "SkTLazy.h"
#include "SkXfermode.h"
class GrClipData;
@ -28,7 +25,7 @@ class GrPath;
class GrVertexBuffer;
class SkStrokeRec;
class GrDrawTarget : public GrRefCnt {
class GrDrawTarget : public SkRefCnt {
protected:
class DrawInfo;
@ -869,7 +866,7 @@ private:
// The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTarget.
GrContext* fContext;
typedef GrRefCnt INHERITED;
typedef SkRefCnt INHERITED;
};
#endif

View File

@ -66,7 +66,7 @@ void GrGpu::abandonResources() {
}
SkASSERT(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid());
GrSafeSetNull(fQuadIndexBuffer);
SkSafeSetNull(fQuadIndexBuffer);
delete fVertexPool;
fVertexPool = NULL;
delete fIndexPool;
@ -82,7 +82,7 @@ void GrGpu::releaseResources() {
}
SkASSERT(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid());
GrSafeSetNull(fQuadIndexBuffer);
SkSafeSetNull(fQuadIndexBuffer);
delete fVertexPool;
fVertexPool = NULL;
delete fIndexPool;

View File

@ -9,7 +9,6 @@
#define GrGpu_DEFINED
#include "GrDrawTarget.h"
#include "GrRefCnt.h"
#include "GrClipMaskManager.h"
#include "SkPath.h"

View File

@ -431,7 +431,7 @@ void GrInOrderDrawBuffer::reset() {
// we always have a VB, but not always an IB
SkASSERT(NULL != fDraws[d].fVertexBuffer);
fDraws[d].fVertexBuffer->unref();
GrSafeUnref(fDraws[d].fIndexBuffer);
SkSafeUnref(fDraws[d].fIndexBuffer);
}
fCmds.reset();
fDraws.reset();

View File

@ -108,7 +108,7 @@ private:
struct Clear : GrNoncopyable {
Clear() : fRenderTarget(NULL) {}
~Clear() { GrSafeUnref(fRenderTarget); }
~Clear() { SkSafeUnref(fRenderTarget); }
SkIRect fRect;
GrColor fColor;

View File

@ -464,7 +464,7 @@ GrEffectRef* DIEllipseEdgeEffect::TestCreate(SkMWCRandom* random,
///////////////////////////////////////////////////////////////////////////////
void GrOvalRenderer::reset() {
GrSafeSetNull(fRRectIndexBuffer);
SkSafeSetNull(fRRectIndexBuffer);
}
bool GrOvalRenderer::drawOval(GrDrawTarget* target, const GrContext* context, bool useAA,

View File

@ -10,7 +10,6 @@
#include "GrContext.h"
#include "GrPaint.h"
#include "GrRefCnt.h"
class GrContext;
class GrDrawTarget;
@ -21,7 +20,7 @@ class SkStrokeRec;
/*
* This class wraps helper functions that draw ovals and roundrects (filled & stroked)
*/
class GrOvalRenderer : public GrRefCnt {
class GrOvalRenderer : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrOvalRenderer)
@ -52,7 +51,7 @@ private:
GrIndexBuffer* fRRectIndexBuffer;
typedef GrRefCnt INHERITED;
typedef SkRefCnt INHERITED;
};
#endif // GrOvalRenderer_DEFINED

View File

@ -27,7 +27,7 @@ struct GrPoint;
* stages before GrPaint::kTotalStages are reserved for setting up the draw (i.e., textures and
* filter masks).
*/
class SK_API GrPathRenderer : public GrRefCnt {
class SK_API GrPathRenderer : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrPathRenderer)
@ -192,7 +192,7 @@ protected:
private:
typedef GrRefCnt INHERITED;
typedef SkRefCnt INHERITED;
};
#endif

View File

@ -67,7 +67,7 @@ void GrTextContext::flushGlyphs() {
fVertices = NULL;
fMaxVertices = 0;
fCurrVertex = 0;
GrSafeSetNull(fCurrTexture);
SkSafeSetNull(fCurrTexture);
}
}

View File

@ -231,7 +231,7 @@ bool GrTextStrike::getGlyphAtlas(GrGlyph* glyph, GrFontScaler* scaler,
return true;
}
GrAutoRef ar(scaler);
SkAutoRef ar(scaler);
int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat);
size_t size = glyph->fBounds.area() * bytesPerPixel;

View File

@ -73,7 +73,7 @@ SkGrFontScaler::SkGrFontScaler(SkGlyphCache* strike) {
}
SkGrFontScaler::~SkGrFontScaler() {
GrSafeUnref(fKey);
SkSafeUnref(fKey);
}
GrMaskFormat SkGrFontScaler::getMaskFormat() {

View File

@ -94,7 +94,7 @@ static SkGrPixelRef* copyToTexturePixelRef(GrTexture* texture, SkBitmap::Config
#endif
SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (dst));
GrSafeUnref(dst);
SkSafeUnref(dst);
return pixelRef;
}
@ -114,7 +114,7 @@ SkGrPixelRef::SkGrPixelRef(GrSurface* surface, bool transferCacheLock) {
fSurface = surface;
}
fUnlock = transferCacheLock;
GrSafeRef(surface);
SkSafeRef(surface);
}
SkGrPixelRef::~SkGrPixelRef() {
@ -125,7 +125,7 @@ SkGrPixelRef::~SkGrPixelRef() {
context->unlockScratchTexture(texture);
}
}
GrSafeUnref(fSurface);
SkSafeUnref(fSurface);
}
GrTexture* SkGrPixelRef::getTexture() {

View File

@ -73,13 +73,13 @@ GrGLContext::GrGLContext(const GrGLContext& ctx) {
}
GrGLContext& GrGLContext::operator = (const GrGLContext& ctx) {
GrSafeAssign(fInterface, ctx.fInterface);
SkRefCnt_SafeAssign(fInterface, ctx.fInterface);
fInfo = ctx.fInfo;
return *this;
}
void GrGLContext::reset() {
GrSafeSetNull(fInterface);
SkSafeSetNull(fInterface);
fInfo.reset();
}

View File

@ -101,7 +101,7 @@ public:
*/
GrGLContext(const GrGLContext& ctx);
~GrGLContext() { GrSafeUnref(fInterface); }
~GrGLContext() { SkSafeUnref(fInterface); }
/**
* Copies a GrGLContext

View File

@ -33,7 +33,7 @@ class GrGLShaderBuilder;
* Uniforms are program-local so we can't rely on fHWState to hold the
* previous uniform state after a program change.
*/
class GrGLProgram : public GrRefCnt {
class GrGLProgram : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrGLProgram)
@ -235,7 +235,7 @@ private:
GrGLUniformManager fUniformManager;
UniformHandles fUniformHandles;
typedef GrRefCnt INHERITED;
typedef SkRefCnt INHERITED;
};
#endif

View File

@ -15,7 +15,7 @@
/**
* A ref counted tex id that deletes the texture in its destructor.
*/
class GrGLTexID : public GrRefCnt {
class GrGLTexID : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrGLTexID)
@ -39,7 +39,7 @@ private:
GrGLuint fTexID;
bool fIsWrapped;
typedef GrRefCnt INHERITED;
typedef SkRefCnt INHERITED;
};
////////////////////////////////////////////////////////////////////////////////

View File

@ -58,7 +58,7 @@ static void test_clip_bounds(skiatest::Reporter* reporter, GrContext* context) {
return;
}
GrAutoUnref au(texture);
SkAutoUnref au(texture);
SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize);
SkRect screen;

View File

@ -46,7 +46,7 @@ static void ReadWriteAlphaTest(skiatest::Reporter* reporter, GrContextFactory* f
return;
}
GrAutoUnref au(texture);
SkAutoUnref au(texture);
// create a distinctive texture
for (int y = 0; y < Y_SIZE; ++y) {