Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / src / gpu / GrDrawTargetCaps.h
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:
20     SK_DECLARE_INST_COUNT(GrDrawTargetCaps)
21
22     GrDrawTargetCaps() : fUniqueID(CreateUniqueID()) {
23         this->reset();
24     }
25     GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED(), fUniqueID(CreateUniqueID()) {
26         *this = other;
27     }
28     GrDrawTargetCaps& operator= (const GrDrawTargetCaps&);
29
30     virtual void reset();
31     virtual SkString dump() const;
32
33     bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
34     /** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g.
35         only for POT textures) */
36     bool mipMapSupport() const { return fMipMapSupport; }
37     bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; }
38     bool stencilWrapOpsSupport() const { return  fStencilWrapOpsSupport; }
39     bool hwAALineSupport() const { return fHWAALineSupport; }
40     bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; }
41     bool geometryShaderSupport() const { return fGeometryShaderSupport; }
42     bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; }
43     bool pathRenderingSupport() const { return fPathRenderingSupport; }
44     bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; }
45     bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport; }
46     bool gpuTracingSupport() const { return fGpuTracingSupport; }
47     bool compressedTexSubImageSupport() const { return fCompressedTexSubImageSupport; }
48
49     /**
50      * Indicates whether GPU->CPU memory mapping for GPU resources such as vertex buffers and
51      * textures allows partial mappings or full mappings.
52      */
53     enum MapFlags {
54         kNone_MapFlags   = 0x0,       //<! Cannot map the resource.
55
56         kCanMap_MapFlag  = 0x1,       //<! The resource can be mapped. Must be set for any of
57                                       //   the other flags to have meaning.k
58         kSubset_MapFlag  = 0x2,       //<! The resource can be partially mapped.
59     };
60
61     uint32_t mapBufferFlags() const { return fMapBufferFlags; }
62
63     // Scratch textures not being reused means that those scratch textures
64     // that we upload to (i.e., don't have a render target) will not be
65     // recycled in the texture cache. This is to prevent ghosting by drivers
66     // (in particular for deferred architectures).
67     bool reuseScratchTextures() const { return fReuseScratchTextures; }
68
69     int maxRenderTargetSize() const { return fMaxRenderTargetSize; }
70     int maxTextureSize() const { return fMaxTextureSize; }
71     // Will be 0 if MSAA is not supported
72     int maxSampleCount() const { return fMaxSampleCount; }
73
74     bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const {
75         SkASSERT(kGrPixelConfigCnt > config);
76         return fConfigRenderSupport[config][withMSAA];
77     }
78
79     bool isConfigTexturable(GrPixelConfig config) const {
80         SkASSERT(kGrPixelConfigCnt > config);
81         return fConfigTextureSupport[config];
82     }
83
84     /**
85      * Gets an id that is unique for this GrDrawTargetCaps object. It is static in that it does
86      * not change when the content of the GrDrawTargetCaps object changes. This will never return
87      * 0.
88      */
89     uint32_t getUniqueID() const { return fUniqueID; }
90
91 protected:
92     bool fNPOTTextureTileSupport    : 1;
93     bool fMipMapSupport             : 1;
94     bool fTwoSidedStencilSupport    : 1;
95     bool fStencilWrapOpsSupport     : 1;
96     bool fHWAALineSupport           : 1;
97     bool fShaderDerivativeSupport   : 1;
98     bool fGeometryShaderSupport     : 1;
99     bool fDualSourceBlendingSupport : 1;
100     bool fPathRenderingSupport      : 1;
101     bool fDstReadInShaderSupport    : 1;
102     bool fDiscardRenderTargetSupport: 1;
103     bool fReuseScratchTextures      : 1;
104     bool fGpuTracingSupport         : 1;
105     bool fCompressedTexSubImageSupport : 1;
106
107     uint32_t fMapBufferFlags;
108
109     int fMaxRenderTargetSize;
110     int fMaxTextureSize;
111     int fMaxSampleCount;
112
113     // The first entry for each config is without msaa and the second is with.
114     bool fConfigRenderSupport[kGrPixelConfigCnt][2];
115     bool fConfigTextureSupport[kGrPixelConfigCnt];
116
117 private:
118     static uint32_t CreateUniqueID();
119
120     const uint32_t          fUniqueID;
121
122     typedef SkRefCnt INHERITED;
123 };
124
125 #endif