From bcce8926524827775539874346dd424a9510dbc9 Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Mon, 25 Mar 2013 15:38:39 +0000 Subject: Make GrDrawTarget::Caps ref counted and GrGLCaps derive from it. Also rename GrDrawTarget::getCaps() -> GrDrawTarget::caps(). Review URL: https://codereview.chromium.org/12843026 git-svn-id: http://skia.googlecode.com/svn/trunk@8364 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/GrDrawTarget.h | 86 +++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 47 deletions(-) (limited to 'src/gpu/GrDrawTarget.h') diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index de8c5c4580..68ba5913bc 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -30,10 +30,42 @@ class SkStrokeRec; class GrDrawTarget : public GrRefCnt { protected: - /** This helper class allows GrDrawTarget subclasses to set the caps values without having to be - made a friend of GrDrawTarget::Caps. */ - class CapsInternals { + class DrawInfo; + +public: + SK_DECLARE_INST_COUNT(GrDrawTarget) + + /** + * Represents the draw target capabilities. + */ + class Caps : public SkRefCnt { public: + SK_DECLARE_INST_COUNT(Caps) + + Caps() { this->reset(); } + Caps(const Caps& c) { *this = c; } + Caps& operator= (const Caps& c); + + virtual void reset(); + virtual void print() const; + + bool eightBitPaletteSupport() const { return f8BitPaletteSupport; } + bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; } + bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; } + bool stencilWrapOpsSupport() const { return fStencilWrapOpsSupport; } + bool hwAALineSupport() const { return fHWAALineSupport; } + bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; } + bool geometryShaderSupport() const { return fGeometryShaderSupport; } + bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; } + bool bufferLockSupport() const { return fBufferLockSupport; } + bool pathStencilingSupport() const { return fPathStencilingSupport; } + + int maxRenderTargetSize() const { return fMaxRenderTargetSize; } + int maxTextureSize() const { return fMaxTextureSize; } + // Will be 0 if MSAA is not supported + int maxSampleCount() const { return fMaxSampleCount; } + protected: + bool f8BitPaletteSupport : 1; bool fNPOTTextureTileSupport : 1; bool fTwoSidedStencilSupport : 1; @@ -41,7 +73,6 @@ protected: bool fHWAALineSupport : 1; bool fShaderDerivativeSupport : 1; bool fGeometryShaderSupport : 1; - bool fFSAASupport : 1; bool fDualSourceBlendingSupport : 1; bool fBufferLockSupport : 1; bool fPathStencilingSupport : 1; @@ -49,45 +80,8 @@ protected: int fMaxRenderTargetSize; int fMaxTextureSize; int fMaxSampleCount; - }; - class DrawInfo; - -public: - SK_DECLARE_INST_COUNT(GrDrawTarget) - - /** - * Represents the draw target capabilities. - */ - class Caps { - public: - Caps() { memset(this, 0, sizeof(Caps)); } - Caps(const Caps& c) { *this = c; } - Caps& operator= (const Caps& c) { - memcpy(this, &c, sizeof(Caps)); - return *this; - } - void print() const; - - bool eightBitPaletteSupport() const { return fInternals.f8BitPaletteSupport; } - bool npotTextureTileSupport() const { return fInternals.fNPOTTextureTileSupport; } - bool twoSidedStencilSupport() const { return fInternals.fTwoSidedStencilSupport; } - bool stencilWrapOpsSupport() const { return fInternals.fStencilWrapOpsSupport; } - bool hwAALineSupport() const { return fInternals.fHWAALineSupport; } - bool shaderDerivativeSupport() const { return fInternals.fShaderDerivativeSupport; } - bool geometryShaderSupport() const { return fInternals.fGeometryShaderSupport; } - bool fsaaSupport() const { return fInternals.fFSAASupport; } - bool dualSourceBlendingSupport() const { return fInternals.fDualSourceBlendingSupport; } - bool bufferLockSupport() const { return fInternals.fBufferLockSupport; } - bool pathStencilingSupport() const { return fInternals.fPathStencilingSupport; } - - int maxRenderTargetSize() const { return fInternals.fMaxRenderTargetSize; } - int maxTextureSize() const { return fInternals.fMaxTextureSize; } - // Will be 0 if MSAA is not supported - int maxSampleCount() const { return fInternals.fMaxSampleCount; } - private: - CapsInternals fInternals; - friend class GrDrawTarget; // to set values of fInternals + typedef SkRefCnt INHERITED; }; /////////////////////////////////////////////////////////////////////////// @@ -100,7 +94,7 @@ public: /** * Gets the capabilities of the draw target. */ - const Caps& getCaps() const { return fCaps; } + const Caps* caps() const { return fCaps.get(); } /** * Sets the current clip to the region specified by clip. All draws will be @@ -652,9 +646,6 @@ protected: GrContext* getContext() { return fContext; } const GrContext* getContext() const { return fContext; } - // allows derived class to set the caps - CapsInternals* capsInternals() { return &fCaps.fInternals; } - // A subclass may override this function if it wishes to be notified when the clip is changed. // The override should call INHERITED::clipWillBeSet(). virtual void clipWillBeSet(const GrClipData* clipData); @@ -673,7 +664,8 @@ protected: return this->getGeomSrc().fVertexSize; } - Caps fCaps; + // Subclass must initialize this in its constructor. + SkAutoTUnref fCaps; /** * Used to communicate draws to subclass's onDraw function. -- cgit v1.2.3