| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | |
| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 10 | #ifndef GrGpuGL_DEFINED |
| 11 | #define GrGpuGL_DEFINED |
| 12 | |
| tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 13 | #include "GrDrawState.h" |
| 14 | #include "GrGpu.h" |
| bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 15 | #include "GrGLContextInfo.h" |
| bsalomon@google.com | 4043ae2 | 2011-08-02 14:19:11 +0000 | [diff] [blame] | 16 | #include "GrGLIndexBuffer.h" |
| bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 17 | #include "GrGLIRect.h" |
| 18 | #include "GrGLStencilBuffer.h" |
| 19 | #include "GrGLTexture.h" |
| 20 | #include "GrGLVertexBuffer.h" |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 21 | |
| 22 | class GrGpuGL : public GrGpu { |
| 23 | public: |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 24 | virtual ~GrGpuGL(); |
| 25 | |
| bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 26 | const GrGLInterface* glInterface() const { |
| 27 | return fGLContextInfo.interface(); |
| 28 | } |
| tomhudson@google.com | dd182cb | 2012-02-10 21:01:00 +0000 | [diff] [blame] | 29 | GrGLBinding glBinding() const { return fGLContextInfo.binding(); } |
| 30 | GrGLVersion glVersion() const { return fGLContextInfo.version(); } |
| 31 | GrGLSLGeneration glslGeneration() const { |
| bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 32 | return fGLContextInfo.glslGeneration(); |
| 33 | } |
| bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 34 | |
| bsalomon@google.com | 56d11e0 | 2011-11-30 19:59:08 +0000 | [diff] [blame] | 35 | // GrGpu overrides |
| bsalomon@google.com | 0a97be2 | 2011-11-08 19:20:57 +0000 | [diff] [blame] | 36 | virtual GrPixelConfig preferredReadPixelsConfig(GrPixelConfig config) |
| bsalomon@google.com | 56d11e0 | 2011-11-30 19:59:08 +0000 | [diff] [blame] | 37 | const SK_OVERRIDE; |
| bsalomon@google.com | a85449d | 2011-11-19 02:36:05 +0000 | [diff] [blame] | 38 | virtual GrPixelConfig preferredWritePixelsConfig(GrPixelConfig config) |
| bsalomon@google.com | 56d11e0 | 2011-11-30 19:59:08 +0000 | [diff] [blame] | 39 | const SK_OVERRIDE; |
| bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 40 | virtual bool readPixelsWillPayForYFlip( |
| 41 | GrRenderTarget* renderTarget, |
| 42 | int left, int top, |
| 43 | int width, int height, |
| 44 | GrPixelConfig config, |
| bsalomon@google.com | 56d11e0 | 2011-11-30 19:59:08 +0000 | [diff] [blame] | 45 | size_t rowBytes) const SK_OVERRIDE; |
| 46 | virtual bool fullReadPixelsIsFasterThanPartial() const SK_OVERRIDE; |
| bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 47 | |
| bsalomon@google.com | a91e923 | 2012-02-23 15:39:54 +0000 | [diff] [blame] | 48 | virtual bool canPreserveReadWriteUnpremulPixels() SK_OVERRIDE; |
| 49 | |
| bsalomon@google.com | 88939ae | 2011-12-14 15:58:11 +0000 | [diff] [blame] | 50 | protected: |
| bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 51 | GrGpuGL(const GrGLContextInfo& ctxInfo); |
| bsalomon@google.com | 6aa25c3 | 2011-04-27 19:55:29 +0000 | [diff] [blame] | 52 | |
| bsalomon@google.com | a4d8fc2 | 2012-05-21 13:21:46 +0000 | [diff] [blame] | 53 | enum TriState { |
| 54 | kNo_TriState, |
| 55 | kYes_TriState, |
| 56 | kUnknown_TriState |
| 57 | }; |
| 58 | |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 59 | struct { |
| bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 60 | size_t fVertexOffset; |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 61 | GrVertexLayout fVertexLayout; |
| 62 | const GrVertexBuffer* fVertexBuffer; |
| 63 | const GrIndexBuffer* fIndexBuffer; |
| bsalomon@google.com | 7acdb8e | 2011-02-11 14:07:02 +0000 | [diff] [blame] | 64 | bool fArrayPtrsDirty; |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 65 | } fHWGeometryState; |
| 66 | |
| bsalomon@google.com | a91e923 | 2012-02-23 15:39:54 +0000 | [diff] [blame] | 67 | enum UnpremulConversion { |
| 68 | kUpOnWrite_DownOnRead_UnpremulConversion, |
| 69 | kDownOnWrite_UpOnRead_UnpremulConversion |
| 70 | } fUnpremulConversion; |
| 71 | |
| bsalomon@google.com | bcc8486 | 2012-05-22 15:44:03 +0000 | [diff] [blame] | 72 | // The current render target and textures are bound by GrGpuGL when it |
| 73 | // flushes state to GL. After the bindings occur the variables that track |
| 74 | // the current GL state are updated to reflect the new bindings. However, |
| 75 | // the GrGpuGL subclass may have subsequent GL state manipulation it must |
| 76 | // perform whenever RT or textures change. So the GrGpuGL will set these |
| 77 | // dirty flags when it changes the RT or texture bindings. The subclass can |
| 78 | // use them to trigger its dependent state flushing. The subclass should |
| 79 | // call resetDirtyFlags to zero these out after it has consumed them. |
| 80 | // |
| bsalomon@google.com | f3fcbbe | 2012-05-21 22:15:46 +0000 | [diff] [blame] | 81 | // TODO: Merge GrGpuGLShaders into GrGpuGL and remove the need for these |
| bsalomon@google.com | bcc8486 | 2012-05-22 15:44:03 +0000 | [diff] [blame] | 82 | // flags. |
| bsalomon@google.com | c6cf723 | 2011-02-17 16:43:10 +0000 | [diff] [blame] | 83 | struct { |
| 84 | bool fRenderTargetChanged : 1; |
| bsalomon@google.com | c6cf723 | 2011-02-17 16:43:10 +0000 | [diff] [blame] | 85 | int fTextureChangedMask; |
| 86 | } fDirtyFlags; |
| tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 87 | GR_STATIC_ASSERT(8 * sizeof(int) >= GrDrawState::kNumStages); |
| bsalomon@google.com | c6cf723 | 2011-02-17 16:43:10 +0000 | [diff] [blame] | 88 | |
| 89 | // clears the dirty flags |
| 90 | void resetDirtyFlags(); |
| 91 | |
| 92 | // last scissor / viewport scissor state seen by the GL. |
| bsalomon@google.com | 8895a7a | 2011-02-18 16:09:55 +0000 | [diff] [blame] | 93 | struct { |
| 94 | bool fScissorEnabled; |
| 95 | GrGLIRect fScissorRect; |
| 96 | GrGLIRect fViewportRect; |
| 97 | } fHWBounds; |
| bsalomon@google.com | c6cf723 | 2011-02-17 16:43:10 +0000 | [diff] [blame] | 98 | |
| bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 99 | const GrGLCaps& glCaps() const { return fGLContextInfo.caps(); } |
| bsalomon@google.com | 88939ae | 2011-12-14 15:58:11 +0000 | [diff] [blame] | 100 | |
| bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 101 | // GrGpu overrides |
| bsalomon@google.com | 1bf1c21 | 2011-11-05 12:18:58 +0000 | [diff] [blame] | 102 | virtual void onResetContext() SK_OVERRIDE; |
| bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 103 | |
| bsalomon@google.com | fea37b5 | 2011-04-25 15:51:06 +0000 | [diff] [blame] | 104 | virtual GrTexture* onCreateTexture(const GrTextureDesc& desc, |
| bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 105 | const void* srcData, |
| bsalomon@google.com | 13f1b6f | 2012-05-31 12:52:43 +0000 | [diff] [blame^] | 106 | size_t rowBytes) SK_OVERRIDE; |
| bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 107 | virtual GrVertexBuffer* onCreateVertexBuffer(uint32_t size, |
| bsalomon@google.com | 13f1b6f | 2012-05-31 12:52:43 +0000 | [diff] [blame^] | 108 | bool dynamic) SK_OVERRIDE; |
| bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 109 | virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size, |
| bsalomon@google.com | 13f1b6f | 2012-05-31 12:52:43 +0000 | [diff] [blame^] | 110 | bool dynamic) SK_OVERRIDE; |
| 111 | virtual GrTexture* onCreatePlatformTexture( |
| 112 | const GrPlatformTextureDesc& desc) SK_OVERRIDE; |
| 113 | virtual GrRenderTarget* onCreatePlatformRenderTarget( |
| 114 | const GrPlatformRenderTargetDesc& desc) SK_OVERRIDE; |
| bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 115 | virtual bool createStencilBufferForRenderTarget(GrRenderTarget* rt, |
| bsalomon@google.com | 13f1b6f | 2012-05-31 12:52:43 +0000 | [diff] [blame^] | 116 | int width, |
| 117 | int height) SK_OVERRIDE; |
| 118 | virtual bool attachStencilBufferToRenderTarget( |
| 119 | GrStencilBuffer* sb, |
| 120 | GrRenderTarget* rt) SK_OVERRIDE; |
| bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 121 | |
| bsalomon@google.com | 13f1b6f | 2012-05-31 12:52:43 +0000 | [diff] [blame^] | 122 | virtual void onClear(const GrIRect* rect, GrColor color) SK_OVERRIDE; |
| bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 123 | |
| bsalomon@google.com | 13f1b6f | 2012-05-31 12:52:43 +0000 | [diff] [blame^] | 124 | virtual void onForceRenderTargetFlush() SK_OVERRIDE; |
| bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 125 | |
| bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 126 | virtual bool onReadPixels(GrRenderTarget* target, |
| bsalomon@google.com | c698097 | 2011-11-02 19:57:21 +0000 | [diff] [blame] | 127 | int left, int top, |
| 128 | int width, int height, |
| 129 | GrPixelConfig, |
| bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 130 | void* buffer, |
| 131 | size_t rowBytes, |
| 132 | bool invertY) SK_OVERRIDE; |
| bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 133 | |
| bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 134 | virtual void onWriteTexturePixels(GrTexture* texture, |
| 135 | int left, int top, int width, int height, |
| 136 | GrPixelConfig config, const void* buffer, |
| 137 | size_t rowBytes) SK_OVERRIDE; |
| 138 | |
| bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 139 | virtual void onResolveRenderTarget(GrRenderTarget* target) SK_OVERRIDE; |
| 140 | |
| 141 | |
| bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 142 | virtual void onGpuDrawIndexed(GrPrimitiveType type, |
| 143 | uint32_t startVertex, |
| 144 | uint32_t startIndex, |
| 145 | uint32_t vertexCount, |
| bsalomon@google.com | 13f1b6f | 2012-05-31 12:52:43 +0000 | [diff] [blame^] | 146 | uint32_t indexCount) SK_OVERRIDE; |
| bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 147 | virtual void onGpuDrawNonIndexed(GrPrimitiveType type, |
| 148 | uint32_t vertexCount, |
| bsalomon@google.com | 13f1b6f | 2012-05-31 12:52:43 +0000 | [diff] [blame^] | 149 | uint32_t numVertices) SK_OVERRIDE; |
| 150 | virtual void enableScissoring(const GrIRect& rect) SK_OVERRIDE; |
| 151 | virtual void disableScissor() SK_OVERRIDE; |
| robertphillips@google.com | 730ebe5 | 2012-04-16 16:33:13 +0000 | [diff] [blame] | 152 | |
| bsalomon@google.com | 13f1b6f | 2012-05-31 12:52:43 +0000 | [diff] [blame^] | 153 | virtual void clearStencil() SK_OVERRIDE; |
| 154 | virtual void clearStencilClip(const GrIRect& rect, |
| 155 | bool insideClip) SK_OVERRIDE; |
| bsalomon@google.com | 5782d71 | 2011-01-21 21:03:59 +0000 | [diff] [blame] | 156 | |
| bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 157 | // binds texture unit in GL |
| bsalomon@google.com | 8531c1c | 2011-01-13 19:52:45 +0000 | [diff] [blame] | 158 | void setTextureUnit(int unitIdx); |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 159 | |
| bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 160 | // binds appropriate vertex and index buffers, also returns any extra |
| 161 | // extra verts or indices to offset by. |
| 162 | void setBuffers(bool indexed, |
| 163 | int* extraVertexOffset, |
| 164 | int* extraIndexOffset); |
| bsalomon@google.com | 7acdb8e | 2011-02-11 14:07:02 +0000 | [diff] [blame] | 165 | |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 166 | // flushes state that is common to fixed and programmable GL |
| 167 | // dither |
| 168 | // line smoothing |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 169 | // texture binding |
| 170 | // sampler state (filtering, tiling) |
| 171 | // FBO binding |
| 172 | // line width |
| bsalomon@google.com | ffca400 | 2011-02-22 20:34:01 +0000 | [diff] [blame] | 173 | bool flushGLStateCommon(GrPrimitiveType type); |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 174 | |
| bsalomon@google.com | 86c1f71 | 2011-10-12 14:54:26 +0000 | [diff] [blame] | 175 | // Subclasses should call this to flush the blend state. |
| 176 | // The params should be the final coeffecients to apply |
| 177 | // (after any blending optimizations or dual source blending considerations |
| 178 | // have been accounted for). |
| bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 179 | void flushBlend(GrPrimitiveType type, |
| 180 | GrBlendCoeff srcCoeff, |
| 181 | GrBlendCoeff dstCoeff); |
| 182 | |
| bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 183 | bool hasExtension(const char* ext) const { |
| 184 | return fGLContextInfo.hasExtension(ext); |
| bsalomon@google.com | 9639994 | 2012-02-13 14:39:16 +0000 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | const GrGLContextInfo& glContextInfo() const { return fGLContextInfo; } |
| bsalomon@google.com | 2c17fcd | 2011-07-06 17:47:02 +0000 | [diff] [blame] | 188 | |
| bsalomon@google.com | 9962108 | 2011-11-15 16:47:16 +0000 | [diff] [blame] | 189 | // adjusts texture matrix to account for orientation |
| bsalomon@google.com | c6cf723 | 2011-02-17 16:43:10 +0000 | [diff] [blame] | 190 | static void AdjustTextureMatrix(const GrGLTexture* texture, |
| 191 | GrSamplerState::SampleMode mode, |
| 192 | GrMatrix* matrix); |
| bsalomon@google.com | 88939ae | 2011-12-14 15:58:11 +0000 | [diff] [blame] | 193 | |
| 194 | // subclass may try to take advantage of identity tex matrices. |
| 195 | // This helper determines if matrix will be identity after all |
| 196 | // adjustments are applied. |
| 197 | static bool TextureMatrixIsIdentity(const GrGLTexture* texture, |
| 198 | const GrSamplerState& sampler); |
| 199 | |
| bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 200 | static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); |
| bsalomon@google.com | 080773c | 2011-03-15 19:09:25 +0000 | [diff] [blame] | 201 | |
| bsalomon@google.com | 8531c1c | 2011-01-13 19:52:45 +0000 | [diff] [blame] | 202 | private: |
| bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 203 | // Inits GrDrawTarget::Caps, sublcass may enable additional caps. |
| bsalomon@google.com | 18c9c19 | 2011-09-22 21:01:31 +0000 | [diff] [blame] | 204 | void initCaps(); |
| 205 | |
| 206 | void initFSAASupport(); |
| bsalomon@google.com | 6aa25c3 | 2011-04-27 19:55:29 +0000 | [diff] [blame] | 207 | |
| bsalomon@google.com | 2c17fcd | 2011-07-06 17:47:02 +0000 | [diff] [blame] | 208 | // determines valid stencil formats |
| bsalomon@google.com | 18c9c19 | 2011-09-22 21:01:31 +0000 | [diff] [blame] | 209 | void initStencilFormats(); |
| bsalomon@google.com | 2c17fcd | 2011-07-06 17:47:02 +0000 | [diff] [blame] | 210 | |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 211 | // notify callbacks to update state tracking when related |
| 212 | // objects are bound to GL or deleted outside of the class |
| 213 | void notifyVertexBufferBind(const GrGLVertexBuffer* buffer); |
| 214 | void notifyVertexBufferDelete(const GrGLVertexBuffer* buffer); |
| 215 | void notifyIndexBufferBind(const GrGLIndexBuffer* buffer); |
| 216 | void notifyIndexBufferDelete(const GrGLIndexBuffer* buffer); |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 217 | void notifyTextureDelete(GrGLTexture* texture); |
| 218 | void notifyRenderTargetDelete(GrRenderTarget* renderTarget); |
| bsalomon@google.com | 5782d71 | 2011-01-21 21:03:59 +0000 | [diff] [blame] | 219 | |
| bsalomon@google.com | 8531c1c | 2011-01-13 19:52:45 +0000 | [diff] [blame] | 220 | void setSpareTextureUnit(); |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 221 | |
| bsalomon@google.com | 8295dc1 | 2011-05-02 12:53:34 +0000 | [diff] [blame] | 222 | // bound is region that may be modified and therefore has to be resolved. |
| 223 | // NULL means whole target. Can be an empty rect. |
| 224 | void flushRenderTarget(const GrIRect* bound); |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 225 | void flushStencil(); |
| bsalomon@google.com | f954d8d | 2011-04-06 17:50:02 +0000 | [diff] [blame] | 226 | void flushAAState(GrPrimitiveType type); |
| bsalomon@google.com | 0650e81 | 2011-04-08 18:07:53 +0000 | [diff] [blame] | 227 | |
| bsalomon@google.com | 280e99f | 2012-01-05 16:17:38 +0000 | [diff] [blame] | 228 | bool configToGLFormats(GrPixelConfig config, |
| 229 | bool getSizedInternal, |
| 230 | GrGLenum* internalFormat, |
| 231 | GrGLenum* externalFormat, |
| 232 | GrGLenum* externalType); |
| bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 233 | // helper for onCreateTexture and writeTexturePixels |
| bsalomon@google.com | 136f55b | 2011-11-28 18:34:44 +0000 | [diff] [blame] | 234 | bool uploadTexData(const GrGLTexture::Desc& desc, |
| bsalomon@google.com | 1e0e607 | 2011-11-28 18:49:37 +0000 | [diff] [blame] | 235 | bool isNewTexture, |
| bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 236 | int left, int top, int width, int height, |
| 237 | GrPixelConfig dataConfig, |
| 238 | const void* data, |
| 239 | size_t rowBytes); |
| bsalomon@google.com | 0650e81 | 2011-04-08 18:07:53 +0000 | [diff] [blame] | 240 | |
| bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 241 | bool createRenderTargetObjects(int width, int height, |
| 242 | GrGLuint texID, |
| 243 | GrGLRenderTarget::Desc* desc); |
| 244 | |
| robertphillips@google.com | 99a5ac0 | 2012-04-10 19:26:38 +0000 | [diff] [blame] | 245 | void fillInConfigRenderableTable(); |
| 246 | |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 247 | friend class GrGLVertexBuffer; |
| 248 | friend class GrGLIndexBuffer; |
| 249 | friend class GrGLTexture; |
| 250 | friend class GrGLRenderTarget; |
| 251 | |
| bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 252 | GrGLContextInfo fGLContextInfo; |
| bsalomon@google.com | 2c17fcd | 2011-07-06 17:47:02 +0000 | [diff] [blame] | 253 | |
| bsalomon@google.com | 8531c1c | 2011-01-13 19:52:45 +0000 | [diff] [blame] | 254 | int fActiveTextureUnitIdx; |
| bsalomon@google.com | 5782d71 | 2011-01-21 21:03:59 +0000 | [diff] [blame] | 255 | |
| bsalomon@google.com | a4d8fc2 | 2012-05-21 13:21:46 +0000 | [diff] [blame] | 256 | struct { |
| 257 | GrBlendCoeff fSrcCoeff; |
| 258 | GrBlendCoeff fDstCoeff; |
| 259 | GrColor fConstColor; |
| 260 | bool fConstColorValid; |
| 261 | TriState fEnabled; |
| 262 | |
| 263 | void invalidate() { |
| 264 | fSrcCoeff = kInvalid_BlendCoeff; |
| 265 | fDstCoeff = kInvalid_BlendCoeff; |
| 266 | fConstColorValid = false; |
| 267 | fEnabled = kUnknown_TriState; |
| 268 | } |
| 269 | } fHWBlendState; |
| 270 | |
| bsalomon@google.com | 4d5f3fe | 2012-05-21 17:11:44 +0000 | [diff] [blame] | 271 | struct { |
| 272 | TriState fMSAAEnabled; |
| 273 | TriState fSmoothLineEnabled; |
| 274 | void invalidate() { |
| 275 | fMSAAEnabled = kUnknown_TriState; |
| 276 | fSmoothLineEnabled = kUnknown_TriState; |
| 277 | } |
| 278 | } fHWAAState; |
| 279 | |
| bsalomon@google.com | 457b8a3 | 2012-05-21 21:19:58 +0000 | [diff] [blame] | 280 | // The high bit of the stencil buffer is used for clipping. This enum is |
| 281 | // used to track whether the clip bit of the stencil buffer is being used, |
| 282 | // manipulated, or neither. |
| 283 | enum StencilClipMode { |
| 284 | // Draw to the clip bit of the stencil buffer |
| 285 | kModifyClip_StencilClipMode, |
| 286 | // Clip against the existing representation of the clip in the high bit |
| 287 | // of the stencil buffer. |
| 288 | kUseClip_StencilClipMode, |
| 289 | // Neither writing to nor clipping against the clip bit. |
| 290 | kIgnoreClip_StencilClipMode, |
| 291 | // Unknown state of HW |
| 292 | kInvalid_StencilClipMode, |
| 293 | }; |
| 294 | StencilClipMode fHWStencilClipMode; |
| 295 | GrStencilSettings fHWStencilSettings; |
| 296 | |
| bsalomon@google.com | c811ea3 | 2012-05-21 15:33:09 +0000 | [diff] [blame] | 297 | GrDrawState::DrawFace fHWDrawFace; |
| 298 | TriState fHWWriteToColor; |
| 299 | TriState fHWDitherEnabled; |
| 300 | GrRenderTarget* fHWBoundRenderTarget; |
| 301 | GrTexture* fHWBoundTextures[GrDrawState::kNumStages]; |
| bsalomon@google.com | 978c8c6 | 2012-05-21 14:45:49 +0000 | [diff] [blame] | 302 | |
| bsalomon@google.com | fe67652 | 2011-06-17 18:12:21 +0000 | [diff] [blame] | 303 | // we record what stencil format worked last time to hopefully exit early |
| 304 | // from our loop that tries stencil formats and calls check fb status. |
| 305 | int fLastSuccessfulStencilFmtIdx; |
| 306 | |
| bsalomon@google.com | a91e923 | 2012-02-23 15:39:54 +0000 | [diff] [blame] | 307 | enum CanPreserveUnpremulRoundtrip { |
| 308 | kUnknown_CanPreserveUnpremulRoundtrip, |
| 309 | kNo_CanPreserveUnpremulRoundtrip, |
| 310 | kYes_CanPreserveUnpremulRoundtrip, |
| 311 | } fCanPreserveUnpremulRoundtrip; |
| bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 312 | |
| bsalomon@google.com | 18c9c19 | 2011-09-22 21:01:31 +0000 | [diff] [blame] | 313 | bool fPrintedCaps; |
| 314 | |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 315 | typedef GrGpu INHERITED; |
| 316 | }; |
| 317 | |
| bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 318 | #endif |
| bsalomon@google.com | fe67652 | 2011-06-17 18:12:21 +0000 | [diff] [blame] | 319 | |