• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright 2013 Google Inc.
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 #ifndef GrDrawTargetCaps_DEFINED
9 #define GrDrawTargetCaps_DEFINED
10 
11 #include "GrTypes.h"
12 #include "SkRefCnt.h"
13 #include "SkString.h"
14 
15 /**
16  * Represents the draw target capabilities.
17  */
18 class GrDrawTargetCaps : public SkRefCnt {
19 public:
SK_DECLARE_INST_COUNT(Caps)20     SK_DECLARE_INST_COUNT(Caps)
21 
22     GrDrawTargetCaps() { this->reset(); }
GrDrawTargetCaps(const GrDrawTargetCaps & other)23     GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED() { *this = other; }
24     GrDrawTargetCaps& operator= (const GrDrawTargetCaps&);
25 
26     virtual void reset();
27     virtual SkString dump() const;
28 
eightBitPaletteSupport()29     bool eightBitPaletteSupport() const { return f8BitPaletteSupport; }
npotTextureTileSupport()30     bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
twoSidedStencilSupport()31     bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; }
stencilWrapOpsSupport()32     bool stencilWrapOpsSupport() const { return  fStencilWrapOpsSupport; }
hwAALineSupport()33     bool hwAALineSupport() const { return fHWAALineSupport; }
shaderDerivativeSupport()34     bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; }
geometryShaderSupport()35     bool geometryShaderSupport() const { return fGeometryShaderSupport; }
dualSourceBlendingSupport()36     bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; }
bufferLockSupport()37     bool bufferLockSupport() const { return fBufferLockSupport; }
pathRenderingSupport()38     bool pathRenderingSupport() const { return fPathRenderingSupport; }
dstReadInShaderSupport()39     bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; }
40 
41     // Scratch textures not being reused means that those scratch textures
42     // that we upload to (i.e., don't have a render target) will not be
43     // recycled in the texture cache. This is to prevent ghosting by drivers
44     // (in particular for deferred architectures).
reuseScratchTextures()45     bool reuseScratchTextures() const { return fReuseScratchTextures; }
46 
maxRenderTargetSize()47     int maxRenderTargetSize() const { return fMaxRenderTargetSize; }
maxTextureSize()48     int maxTextureSize() const { return fMaxTextureSize; }
49     // Will be 0 if MSAA is not supported
maxSampleCount()50     int maxSampleCount() const { return fMaxSampleCount; }
51 
isConfigRenderable(GrPixelConfig config,bool withMSAA)52     bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const {
53         SkASSERT(kGrPixelConfigCnt > config);
54         return fConfigRenderSupport[config][withMSAA];
55     }
56 
57 protected:
58     bool f8BitPaletteSupport        : 1;
59     bool fNPOTTextureTileSupport    : 1;
60     bool fTwoSidedStencilSupport    : 1;
61     bool fStencilWrapOpsSupport     : 1;
62     bool fHWAALineSupport           : 1;
63     bool fShaderDerivativeSupport   : 1;
64     bool fGeometryShaderSupport     : 1;
65     bool fDualSourceBlendingSupport : 1;
66     bool fBufferLockSupport         : 1;
67     bool fPathRenderingSupport      : 1;
68     bool fDstReadInShaderSupport    : 1;
69     bool fReuseScratchTextures      : 1;
70 
71     int fMaxRenderTargetSize;
72     int fMaxTextureSize;
73     int fMaxSampleCount;
74 
75     // The first entry for each config is without msaa and the second is with.
76     bool fConfigRenderSupport[kGrPixelConfigCnt][2];
77 
78     typedef SkRefCnt INHERITED;
79 };
80 
81 #endif
82