Move nested class GrDrawTarget::Caps out as GrDrawTargetCaps.
Pass caps to GrEffect::TestCreate() functions so that they can return effects that will work with the capabilities.
Review URL: https://codereview.chromium.org/12965018

git-svn-id: http://skia.googlecode.com/svn/trunk@8369 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index b4509b3..cff6324 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -10,6 +10,7 @@
 
 #include "GrContext.h"
 #include "GrDrawState.h"
+#include "GrDrawTargetCaps.h"
 #include "GrPathUtils.h"
 #include "SkString.h"
 #include "SkStrokeRec.h"
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index 90ab128..80304f8 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -10,6 +10,7 @@
 
 #include "GrContext.h"
 #include "GrDrawState.h"
+#include "GrDrawTargetCaps.h"
 #include "GrGpu.h"
 #include "GrIndexBuffer.h"
 #include "GrPathUtils.h"
diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp
index 8d748b8..d8dd8bd 100644
--- a/src/gpu/GrBufferAllocPool.cpp
+++ b/src/gpu/GrBufferAllocPool.cpp
@@ -8,10 +8,11 @@
 
 
 #include "GrBufferAllocPool.h"
+#include "GrDrawTargetCaps.h"
+#include "GrGpu.h"
+#include "GrIndexBuffer.h"
 #include "GrTypes.h"
 #include "GrVertexBuffer.h"
-#include "GrIndexBuffer.h"
-#include "GrGpu.h"
 
 #if GR_DEBUG
     #define VALIDATE validate
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 4626af8..ca5f378 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -7,18 +7,18 @@
  */
 
 #include "GrClipMaskManager.h"
-#include "effects/GrTextureDomainEffect.h"
-#include "GrGpu.h"
-#include "GrRenderTarget.h"
-#include "GrStencilBuffer.h"
-#include "GrPathRenderer.h"
-#include "GrPaint.h"
-#include "SkRasterClip.h"
-#include "SkStrokeRec.h"
 #include "GrAAConvexPathRenderer.h"
 #include "GrAAHairLinePathRenderer.h"
+#include "GrDrawTargetCaps.h"
+#include "GrGpu.h"
+#include "GrPaint.h"
+#include "GrPathRenderer.h"
+#include "GrRenderTarget.h"
+#include "GrStencilBuffer.h"
 #include "GrSWMaskHelper.h"
-
+#include "effects/GrTextureDomainEffect.h"
+#include "SkRasterClip.h"
+#include "SkStrokeRec.h"
 #include "SkTLazy.h"
 
 #define GR_AA_CLIP 1
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 0a2f01d..32b4d6a 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -15,6 +15,7 @@
 
 #include "GrBufferAllocPool.h"
 #include "GrGpu.h"
+#include "GrDrawTargetCaps.h"
 #include "GrIndexBuffer.h"
 #include "GrInOrderDrawBuffer.h"
 #include "GrOvalRenderer.h"
@@ -573,7 +574,7 @@
 
 bool GrContext::supportsIndex8PixelConfig(const GrTextureParams* params,
                                           int width, int height) const {
-    const GrDrawTarget::Caps* caps = fGpu->caps();
+    const GrDrawTargetCaps* caps = fGpu->caps();
     if (!caps->eightBitPaletteSupport()) {
         return false;
     }
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 9f9c7d6..d263d40 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -9,6 +9,7 @@
 
 
 #include "GrDrawTarget.h"
+#include "GrDrawTargetCaps.h"
 #include "GrRenderTarget.h"
 #include "GrTexture.h"
 #include "GrVertexBuffer.h"
@@ -679,9 +680,9 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-SK_DEFINE_INST_COUNT(GrDrawTarget::Caps)
+SK_DEFINE_INST_COUNT(GrDrawTargetCaps)
 
-void GrDrawTarget::Caps::reset() {
+void GrDrawTargetCaps::reset() {
     f8BitPaletteSupport = false;
     fNPOTTextureTileSupport = false;
     fTwoSidedStencilSupport = false;
@@ -689,7 +690,7 @@
     fHWAALineSupport = false;
     fShaderDerivativeSupport = false;
     fGeometryShaderSupport = false;
-    fDualSourceBlendingSupport = false;
+    fDualSourceBlendingSupport = false; 
     fBufferLockSupport = false;
     fPathStencilingSupport = false;
 
@@ -698,7 +699,7 @@
     fMaxSampleCount = 0;
 }
 
-GrDrawTarget::Caps& GrDrawTarget::Caps::operator=(const GrDrawTarget::Caps& other) {
+GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) {
     f8BitPaletteSupport = other.f8BitPaletteSupport;
     fNPOTTextureTileSupport = other.fNPOTTextureTileSupport;
     fTwoSidedStencilSupport = other.fTwoSidedStencilSupport;
@@ -717,7 +718,7 @@
     return *this;
 }
 
-void GrDrawTarget::Caps::print() const {
+void GrDrawTargetCaps::print() const {
     static const char* gNY[] = {"NO", "YES"};
     GrPrintf("8 Bit Palette Support       : %s\n", gNY[f8BitPaletteSupport]);
     GrPrintf("NPOT Texture Tile Support   : %s\n", gNY[fNPOTTextureTileSupport]);
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 68ba591..e54a04d 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -7,7 +7,6 @@
  */
 
 
-
 #ifndef GrDrawTarget_DEFINED
 #define GrDrawTarget_DEFINED
 
@@ -24,6 +23,7 @@
 #include "SkXfermode.h"
 
 class GrClipData;
+class GrDrawTargetCaps;
 class GrPath;
 class GrVertexBuffer;
 class SkStrokeRec;
@@ -35,55 +35,6 @@
 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;
-        bool fStencilWrapOpsSupport     : 1;
-        bool fHWAALineSupport           : 1;
-        bool fShaderDerivativeSupport   : 1;
-        bool fGeometryShaderSupport     : 1;
-        bool fDualSourceBlendingSupport : 1;
-        bool fBufferLockSupport         : 1;
-        bool fPathStencilingSupport     : 1;
-
-        int fMaxRenderTargetSize;
-        int fMaxTextureSize;
-        int fMaxSampleCount;
-
-        typedef SkRefCnt INHERITED;
-    };
-
     ///////////////////////////////////////////////////////////////////////////
 
     // The context may not be fully constructed and should not be used during GrDrawTarget
@@ -94,7 +45,7 @@
     /**
      * Gets the capabilities of the draw target.
      */
-    const Caps* caps() const { return fCaps.get(); }
+    const GrDrawTargetCaps* caps() const { return fCaps.get(); }
 
     /**
      * Sets the current clip to the region specified by clip. All draws will be
@@ -665,7 +616,7 @@
     }
 
     // Subclass must initialize this in its constructor.
-    SkAutoTUnref<const Caps> fCaps;
+    SkAutoTUnref<const GrDrawTargetCaps> fCaps;
 
     /**
      * Used to communicate draws to subclass's onDraw function.
diff --git a/src/gpu/GrDrawTargetCaps.h b/src/gpu/GrDrawTargetCaps.h
new file mode 100644
index 0000000..35a05f9
--- /dev/null
+++ b/src/gpu/GrDrawTargetCaps.h
@@ -0,0 +1,63 @@
+
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkRefCnt.h"
+
+#ifndef GrDrawTargetCaps_DEFINED
+#define GrDrawTargetCaps_DEFINED
+
+/**
+ * Represents the draw target capabilities.
+ */
+class GrDrawTargetCaps : public SkRefCnt {
+public:
+    SK_DECLARE_INST_COUNT(Caps)
+
+    GrDrawTargetCaps() { this->reset(); }
+    GrDrawTargetCaps(const GrDrawTargetCaps& other) { *this = other; }
+    GrDrawTargetCaps& operator= (const GrDrawTargetCaps&);
+
+    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;
+    bool fStencilWrapOpsSupport     : 1;
+    bool fHWAALineSupport           : 1;
+    bool fShaderDerivativeSupport   : 1;
+    bool fGeometryShaderSupport     : 1;
+    bool fDualSourceBlendingSupport : 1;
+    bool fBufferLockSupport         : 1;
+    bool fPathStencilingSupport     : 1;
+
+    int fMaxRenderTargetSize;
+    int fMaxTextureSize;
+    int fMaxSampleCount;
+
+    typedef SkRefCnt INHERITED;
+};
+
+#endif
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index ba7bedd..c9e876a 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -11,6 +11,7 @@
 
 #include "GrBufferAllocPool.h"
 #include "GrContext.h"
+#include "GrDrawTargetCaps.h"
 #include "GrIndexBuffer.h"
 #include "GrStencilBuffer.h"
 #include "GrVertexBuffer.h"
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 2e86147..a090dcf 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -9,6 +9,7 @@
 
 #include "GrInOrderDrawBuffer.h"
 #include "GrBufferAllocPool.h"
+#include "GrDrawTargetCaps.h"
 #include "GrGpu.h"
 #include "GrIndexBuffer.h"
 #include "GrPath.h"
diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp
index 3458841..b9157c7 100644
--- a/src/gpu/GrPathRendererChain.cpp
+++ b/src/gpu/GrPathRendererChain.cpp
@@ -11,6 +11,7 @@
 
 #include "GrContext.h"
 #include "GrDefaultPathRenderer.h"
+#include "GrDrawTargetCaps.h"
 #include "GrGpu.h"
 
 SK_DEFINE_INST_COUNT(GrPathRendererChain)
diff --git a/src/gpu/GrStencilAndCoverPathRenderer.cpp b/src/gpu/GrStencilAndCoverPathRenderer.cpp
index 04d7674..fa87599 100644
--- a/src/gpu/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/GrStencilAndCoverPathRenderer.cpp
@@ -9,6 +9,7 @@
 
 #include "GrStencilAndCoverPathRenderer.h"
 #include "GrContext.h"
+#include "GrDrawTargetCaps.h"
 #include "GrGpu.h"
 #include "GrPath.h"
 #include "SkStrokeRec.h"
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index 479d7bb..44a1442 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -10,6 +10,7 @@
 #include "GrTexture.h"
 
 #include "GrContext.h"
+#include "GrDrawTargetCaps.h"
 #include "GrGpu.h"
 #include "GrRenderTarget.h"
 #include "GrResourceCache.h"
diff --git a/src/gpu/effects/GrCircleEdgeEffect.cpp b/src/gpu/effects/GrCircleEdgeEffect.cpp
index 3804fc7..19544d7 100644
--- a/src/gpu/effects/GrCircleEdgeEffect.cpp
+++ b/src/gpu/effects/GrCircleEdgeEffect.cpp
@@ -75,6 +75,7 @@
 
 GrEffectRef* GrCircleEdgeEffect::TestCreate(SkMWCRandom* random,
                                             GrContext* context,
+                                            const GrDrawTargetCaps&,
                                             GrTexture* textures[]) {
     return GrCircleEdgeEffect::Create(random->nextBool());
 }
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index df8ab8d..1e65a6f 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -135,6 +135,7 @@
 
 GrEffectRef* GrConfigConversionEffect::TestCreate(SkMWCRandom* random,
                                                   GrContext*,
+                                                  const GrDrawTargetCaps&,
                                                   GrTexture* textures[]) {
     PMConversion pmConv = static_cast<PMConversion>(random->nextULessThan(kPMConversionCnt));
     bool swapRB;
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 924b03c..380581f 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -183,6 +183,7 @@
 
 GrEffectRef* GrConvolutionEffect::TestCreate(SkMWCRandom* random,
                                              GrContext*,
+                                             const GrDrawTargetCaps&,
                                              GrTexture* textures[]) {
     int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
                                       GrEffectUnitTest::kAlphaTextureIdx;
diff --git a/src/gpu/effects/GrEllipseEdgeEffect.cpp b/src/gpu/effects/GrEllipseEdgeEffect.cpp
index 5d7908e..7a773b0 100644
--- a/src/gpu/effects/GrEllipseEdgeEffect.cpp
+++ b/src/gpu/effects/GrEllipseEdgeEffect.cpp
@@ -96,6 +96,7 @@
 
 GrEffectRef* GrEllipseEdgeEffect::TestCreate(SkMWCRandom* random,
                                                GrContext* context,
+                                               const GrDrawTargetCaps&,
                                                GrTexture* textures[]) {
     return GrEllipseEdgeEffect::Create(random->nextBool());
 }
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index 80627aa..172558d 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -97,6 +97,7 @@
 
 GrEffectRef* GrSimpleTextureEffect::TestCreate(SkMWCRandom* random,
                                                GrContext*,
+                                               const GrDrawTargetCaps&,
                                                GrTexture* textures[]) {
     int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
                                       GrEffectUnitTest::kAlphaTextureIdx;
diff --git a/src/gpu/effects/GrTextureDomainEffect.cpp b/src/gpu/effects/GrTextureDomainEffect.cpp
index b1fd3ed..f3838ae 100644
--- a/src/gpu/effects/GrTextureDomainEffect.cpp
+++ b/src/gpu/effects/GrTextureDomainEffect.cpp
@@ -221,6 +221,7 @@
 
 GrEffectRef* GrTextureDomainEffect::TestCreate(SkMWCRandom* random,
                                                GrContext*,
+                                               const GrDrawTargetCaps&,
                                                GrTexture* textures[]) {
     int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
                                       GrEffectUnitTest::kAlphaTextureIdx;
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 1bf5036..5e555f9 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -45,7 +45,7 @@
     fIsCoreProfile = false;
 }
 
-GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTarget::Caps() {
+GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() {
     *this = caps;
 }
 
@@ -205,14 +205,13 @@
     this->initStencilFormats(ctxInfo);
 
     /**************************************************************************
-     * GrDrawTarget::Caps fields
+     * GrDrawTargetCaps fields
      **************************************************************************/
     GrGLint maxTextureUnits;
     // check FS and fixed-function texture unit limits
     // we only use textures in the fragment stage currently.
     // checks are > to make sure we have a spare unit.
     GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
-    GrAssert(maxTextureUnits > GrDrawState::kNumStages);
 
     GrGLint numFormats;
     GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats);
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index d19c989..920140f 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -9,10 +9,10 @@
 #ifndef GrGLCaps_DEFINED
 #define GrGLCaps_DEFINED
 
+#include "GrDrawTargetCaps.h"
+#include "GrGLStencilBuffer.h"
 #include "SkTArray.h"
 #include "SkTDArray.h"
-#include "GrGLStencilBuffer.h"
-#include "GrDrawTarget.h"
 
 class GrGLContextInfo;
 
@@ -21,7 +21,7 @@
  * version and the extensions string. It also tracks formats that have passed
  * the FBO completeness test.
  */
-class GrGLCaps : public GrDrawTarget::Caps {
+class GrGLCaps : public GrDrawTargetCaps {
 public:
     SK_DECLARE_INST_COUNT(GrGLCaps)
 
@@ -312,7 +312,7 @@
     bool fUseNonVBOVertexAndIndexDynamicData : 1;
     bool fIsCoreProfile : 1;
 
-    typedef GrDrawTarget::Caps INHERITED;
+    typedef GrDrawTargetCaps INHERITED;
 };
 
 #endif