epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2011 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. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 10 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 11 | #ifndef GrGpuGL_DEFINED |
| 12 | #define GrGpuGL_DEFINED |
| 13 | |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 14 | #include "GrDrawState.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 15 | #include "GrGpu.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 | |
bsalomon@google.com | 2c17fcd | 2011-07-06 17:47:02 +0000 | [diff] [blame] | 22 | #include "SkString.h" |
| 23 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 24 | class GrGpuGL : public GrGpu { |
| 25 | public: |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 26 | virtual ~GrGpuGL(); |
| 27 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 28 | const GrGLInterface* glInterface() const { return fGL; } |
| 29 | GrGLBinding glBinding() const { return fGLBinding; } |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 30 | GrGLVersion glVersion() const { return fGLVersion; } |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 31 | |
bsalomon@google.com | 0a97be2 | 2011-11-08 19:20:57 +0000 | [diff] [blame] | 32 | virtual GrPixelConfig preferredReadPixelsConfig(GrPixelConfig config) |
| 33 | SK_OVERRIDE; |
bsalomon@google.com | a85449d | 2011-11-19 02:36:05 +0000 | [diff] [blame^] | 34 | virtual GrPixelConfig preferredWritePixelsConfig(GrPixelConfig config) |
| 35 | SK_OVERRIDE; |
bsalomon@google.com | 0a97be2 | 2011-11-08 19:20:57 +0000 | [diff] [blame] | 36 | |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 37 | virtual bool readPixelsWillPayForYFlip( |
| 38 | GrRenderTarget* renderTarget, |
| 39 | int left, int top, |
| 40 | int width, int height, |
| 41 | GrPixelConfig config, |
| 42 | size_t rowBytes) SK_OVERRIDE; |
| 43 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 44 | protected: |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 45 | GrGpuGL(const GrGLInterface* glInterface, GrGLBinding glBinding); |
bsalomon@google.com | 6aa25c3 | 2011-04-27 19:55:29 +0000 | [diff] [blame] | 46 | |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 47 | struct GLCaps { |
| 48 | GLCaps() |
| 49 | // make defaults be the most restrictive |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 50 | : fStencilFormats(8) // prealloc space for stencil formats |
| 51 | , fMSFBOType(kNone_MSFBO) |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 52 | , fMaxFragmentUniformVectors(0) |
bsalomon@google.com | 7107fa7 | 2011-11-10 14:54:14 +0000 | [diff] [blame] | 53 | , fRGBA8RenderbufferSupport(false) |
| 54 | , fBGRAFormatSupport(false) |
| 55 | , fBGRAIsInternalFormat(false) |
| 56 | , fTextureSwizzleSupport(false) |
| 57 | , fUnpackRowLengthSupport(false) |
| 58 | , fPackRowLengthSupport(false) { |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 59 | memset(fAASamples, 0, sizeof(fAASamples)); |
| 60 | } |
| 61 | SkTArray<GrGLStencilBuffer::Format, true> fStencilFormats; |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 62 | |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 63 | enum { |
| 64 | /** |
| 65 | * no support for MSAA FBOs |
| 66 | */ |
| 67 | kNone_MSFBO = 0, |
| 68 | /** |
| 69 | * GL3.0-style MSAA FBO (GL_ARB_framebuffer_object) |
| 70 | */ |
| 71 | kDesktopARB_MSFBO, |
| 72 | /** |
| 73 | * earlier GL_EXT_framebuffer* extensions |
| 74 | */ |
| 75 | kDesktopEXT_MSFBO, |
| 76 | /** |
| 77 | * GL_APPLE_framebuffer_multisample ES extension |
| 78 | */ |
| 79 | kAppleES_MSFBO, |
| 80 | } fMSFBOType; |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 81 | |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 82 | // TODO: get rid of GrAALevel and use sample cnt directly |
| 83 | GrGLuint fAASamples[4]; |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 84 | |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 85 | // The maximum number of fragment uniform vectors (GLES has min. 16). |
| 86 | int fMaxFragmentUniformVectors; |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 87 | |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 88 | // ES requires an extension to support RGBA8 in RenderBufferStorage |
bsalomon@google.com | 7107fa7 | 2011-11-10 14:54:14 +0000 | [diff] [blame] | 89 | bool fRGBA8RenderbufferSupport; |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 90 | |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 91 | // Is GL_BGRA supported |
bsalomon@google.com | 7107fa7 | 2011-11-10 14:54:14 +0000 | [diff] [blame] | 92 | bool fBGRAFormatSupport; |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 93 | |
| 94 | // Depending on the ES extensions present the BGRA external format may |
| 95 | // correspond either a BGRA or RGBA internalFormat. On desktop GL it is |
| 96 | // RGBA |
bsalomon@google.com | 7107fa7 | 2011-11-10 14:54:14 +0000 | [diff] [blame] | 97 | bool fBGRAIsInternalFormat; |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 98 | |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 99 | // GL_ARB_texture_swizzle support |
bsalomon@google.com | 7107fa7 | 2011-11-10 14:54:14 +0000 | [diff] [blame] | 100 | bool fTextureSwizzleSupport; |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 101 | |
bsalomon@google.com | 7107fa7 | 2011-11-10 14:54:14 +0000 | [diff] [blame] | 102 | // Is there support for GL_UNPACK_ROW_LENGTH |
| 103 | bool fUnpackRowLengthSupport; |
| 104 | |
| 105 | // Is there support for GL_PACK_ROW_LENGTH |
| 106 | bool fPackRowLengthSupport; |
| 107 | |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 108 | void print() const; |
| 109 | } fGLCaps; |
| 110 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 111 | struct { |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 112 | size_t fVertexOffset; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 113 | GrVertexLayout fVertexLayout; |
| 114 | const GrVertexBuffer* fVertexBuffer; |
| 115 | const GrIndexBuffer* fIndexBuffer; |
bsalomon@google.com | 7acdb8e | 2011-02-11 14:07:02 +0000 | [diff] [blame] | 116 | bool fArrayPtrsDirty; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 117 | } fHWGeometryState; |
| 118 | |
bsalomon@google.com | f954d8d | 2011-04-06 17:50:02 +0000 | [diff] [blame] | 119 | struct AAState { |
| 120 | bool fMSAAEnabled; |
| 121 | bool fSmoothLineEnabled; |
| 122 | } fHWAAState; |
| 123 | |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 124 | GrDrawState fHWDrawState; |
| 125 | bool fHWStencilClip; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 126 | |
bsalomon@google.com | c6cf723 | 2011-02-17 16:43:10 +0000 | [diff] [blame] | 127 | // As flush of GL state proceeds it updates fHDrawState |
| 128 | // to reflect the new state. Later parts of the state flush |
| 129 | // may perform cascaded changes but cannot refer to fHWDrawState. |
| 130 | // These code paths can refer to the dirty flags. Subclass should |
| 131 | // call resetDirtyFlags after its flush is complete |
| 132 | struct { |
| 133 | bool fRenderTargetChanged : 1; |
bsalomon@google.com | c6cf723 | 2011-02-17 16:43:10 +0000 | [diff] [blame] | 134 | int fTextureChangedMask; |
| 135 | } fDirtyFlags; |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 136 | GR_STATIC_ASSERT(8 * sizeof(int) >= GrDrawState::kNumStages); |
bsalomon@google.com | c6cf723 | 2011-02-17 16:43:10 +0000 | [diff] [blame] | 137 | |
| 138 | // clears the dirty flags |
| 139 | void resetDirtyFlags(); |
| 140 | |
| 141 | // last scissor / viewport scissor state seen by the GL. |
bsalomon@google.com | 8895a7a | 2011-02-18 16:09:55 +0000 | [diff] [blame] | 142 | struct { |
| 143 | bool fScissorEnabled; |
| 144 | GrGLIRect fScissorRect; |
| 145 | GrGLIRect fViewportRect; |
| 146 | } fHWBounds; |
bsalomon@google.com | c6cf723 | 2011-02-17 16:43:10 +0000 | [diff] [blame] | 147 | |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 148 | const GLCaps& glCaps() const { return fGLCaps; } |
| 149 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 150 | // GrGpu overrides |
bsalomon@google.com | 1bf1c21 | 2011-11-05 12:18:58 +0000 | [diff] [blame] | 151 | virtual void onResetContext() SK_OVERRIDE; |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 152 | |
bsalomon@google.com | fea37b5 | 2011-04-25 15:51:06 +0000 | [diff] [blame] | 153 | virtual GrTexture* onCreateTexture(const GrTextureDesc& desc, |
bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 154 | const void* srcData, |
| 155 | size_t rowBytes); |
| 156 | virtual GrVertexBuffer* onCreateVertexBuffer(uint32_t size, |
| 157 | bool dynamic); |
| 158 | virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size, |
| 159 | bool dynamic); |
bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 160 | virtual GrResource* onCreatePlatformSurface(const GrPlatformSurfaceDesc& desc); |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 161 | virtual GrTexture* onCreatePlatformTexture(const GrPlatformTextureDesc& desc) SK_OVERRIDE; |
| 162 | virtual GrRenderTarget* onCreatePlatformRenderTarget(const GrPlatformRenderTargetDesc& desc) SK_OVERRIDE; |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 163 | virtual bool createStencilBufferForRenderTarget(GrRenderTarget* rt, |
| 164 | int width, int height); |
| 165 | virtual bool attachStencilBufferToRenderTarget(GrStencilBuffer* sb, |
| 166 | GrRenderTarget* rt); |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 167 | |
bsalomon@google.com | 6aa25c3 | 2011-04-27 19:55:29 +0000 | [diff] [blame] | 168 | virtual void onClear(const GrIRect* rect, GrColor color); |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 169 | |
bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 170 | virtual void onForceRenderTargetFlush(); |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 171 | |
bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 172 | virtual bool onReadPixels(GrRenderTarget* target, |
bsalomon@google.com | c698097 | 2011-11-02 19:57:21 +0000 | [diff] [blame] | 173 | int left, int top, |
| 174 | int width, int height, |
| 175 | GrPixelConfig, |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 176 | void* buffer, |
| 177 | size_t rowBytes, |
| 178 | bool invertY) SK_OVERRIDE; |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 179 | |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 180 | virtual void onWriteTexturePixels(GrTexture* texture, |
| 181 | int left, int top, int width, int height, |
| 182 | GrPixelConfig config, const void* buffer, |
| 183 | size_t rowBytes) SK_OVERRIDE; |
| 184 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 185 | virtual void onGpuDrawIndexed(GrPrimitiveType type, |
| 186 | uint32_t startVertex, |
| 187 | uint32_t startIndex, |
| 188 | uint32_t vertexCount, |
| 189 | uint32_t indexCount); |
| 190 | virtual void onGpuDrawNonIndexed(GrPrimitiveType type, |
| 191 | uint32_t vertexCount, |
| 192 | uint32_t numVertices); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 193 | virtual void flushScissor(const GrIRect* rect); |
bsalomon@google.com | edc177d | 2011-08-05 15:46:40 +0000 | [diff] [blame] | 194 | virtual void clearStencil(); |
bsalomon@google.com | ab3dee5 | 2011-08-29 15:18:41 +0000 | [diff] [blame] | 195 | virtual void clearStencilClip(const GrIRect& rect, bool insideClip); |
senorblanco@chromium.org | ef3913b | 2011-05-19 17:11:07 +0000 | [diff] [blame] | 196 | virtual int getMaxEdges() const; |
bsalomon@google.com | 5782d71 | 2011-01-21 21:03:59 +0000 | [diff] [blame] | 197 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 198 | // binds texture unit in GL |
bsalomon@google.com | 8531c1c | 2011-01-13 19:52:45 +0000 | [diff] [blame] | 199 | void setTextureUnit(int unitIdx); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 200 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 201 | // binds appropriate vertex and index buffers, also returns any extra |
| 202 | // extra verts or indices to offset by. |
| 203 | void setBuffers(bool indexed, |
| 204 | int* extraVertexOffset, |
| 205 | int* extraIndexOffset); |
bsalomon@google.com | 7acdb8e | 2011-02-11 14:07:02 +0000 | [diff] [blame] | 206 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 207 | // flushes state that is common to fixed and programmable GL |
| 208 | // dither |
| 209 | // line smoothing |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 210 | // texture binding |
| 211 | // sampler state (filtering, tiling) |
| 212 | // FBO binding |
| 213 | // line width |
bsalomon@google.com | ffca400 | 2011-02-22 20:34:01 +0000 | [diff] [blame] | 214 | bool flushGLStateCommon(GrPrimitiveType type); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 215 | |
bsalomon@google.com | 86c1f71 | 2011-10-12 14:54:26 +0000 | [diff] [blame] | 216 | // Subclasses should call this to flush the blend state. |
| 217 | // The params should be the final coeffecients to apply |
| 218 | // (after any blending optimizations or dual source blending considerations |
| 219 | // have been accounted for). |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 220 | void flushBlend(GrPrimitiveType type, |
| 221 | GrBlendCoeff srcCoeff, |
| 222 | GrBlendCoeff dstCoeff); |
| 223 | |
bsalomon@google.com | 2c17fcd | 2011-07-06 17:47:02 +0000 | [diff] [blame] | 224 | bool hasExtension(const char* ext) { |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 225 | return GrGLHasExtensionFromString(ext, fExtensionString.c_str()); |
bsalomon@google.com | 2c17fcd | 2011-07-06 17:47:02 +0000 | [diff] [blame] | 226 | } |
| 227 | |
bsalomon@google.com | 9962108 | 2011-11-15 16:47:16 +0000 | [diff] [blame] | 228 | // adjusts texture matrix to account for orientation |
bsalomon@google.com | c6cf723 | 2011-02-17 16:43:10 +0000 | [diff] [blame] | 229 | static void AdjustTextureMatrix(const GrGLTexture* texture, |
| 230 | GrSamplerState::SampleMode mode, |
| 231 | GrMatrix* matrix); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 232 | |
bsalomon@google.com | c6cf723 | 2011-02-17 16:43:10 +0000 | [diff] [blame] | 233 | // subclass may try to take advantage of identity tex matrices. |
| 234 | // This helper determines if matrix will be identity after all |
| 235 | // adjustments are applied. |
| 236 | static bool TextureMatrixIsIdentity(const GrGLTexture* texture, |
| 237 | const GrSamplerState& sampler); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 238 | |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 239 | static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); |
bsalomon@google.com | 080773c | 2011-03-15 19:09:25 +0000 | [diff] [blame] | 240 | |
bsalomon@google.com | 8531c1c | 2011-01-13 19:52:45 +0000 | [diff] [blame] | 241 | private: |
bsalomon@google.com | 18c9c19 | 2011-09-22 21:01:31 +0000 | [diff] [blame] | 242 | // Inits GrDrawTarget::Caps and GLCaps, sublcass may enable |
| 243 | // additional caps. |
| 244 | void initCaps(); |
| 245 | |
| 246 | void initFSAASupport(); |
bsalomon@google.com | 6aa25c3 | 2011-04-27 19:55:29 +0000 | [diff] [blame] | 247 | |
bsalomon@google.com | 2c17fcd | 2011-07-06 17:47:02 +0000 | [diff] [blame] | 248 | // determines valid stencil formats |
bsalomon@google.com | 18c9c19 | 2011-09-22 21:01:31 +0000 | [diff] [blame] | 249 | void initStencilFormats(); |
bsalomon@google.com | 2c17fcd | 2011-07-06 17:47:02 +0000 | [diff] [blame] | 250 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 251 | // notify callbacks to update state tracking when related |
| 252 | // objects are bound to GL or deleted outside of the class |
| 253 | void notifyVertexBufferBind(const GrGLVertexBuffer* buffer); |
| 254 | void notifyVertexBufferDelete(const GrGLVertexBuffer* buffer); |
| 255 | void notifyIndexBufferBind(const GrGLIndexBuffer* buffer); |
| 256 | void notifyIndexBufferDelete(const GrGLIndexBuffer* buffer); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 257 | void notifyTextureDelete(GrGLTexture* texture); |
| 258 | void notifyRenderTargetDelete(GrRenderTarget* renderTarget); |
bsalomon@google.com | 5782d71 | 2011-01-21 21:03:59 +0000 | [diff] [blame] | 259 | |
bsalomon@google.com | 8531c1c | 2011-01-13 19:52:45 +0000 | [diff] [blame] | 260 | void setSpareTextureUnit(); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 261 | |
bsalomon@google.com | 8295dc1 | 2011-05-02 12:53:34 +0000 | [diff] [blame] | 262 | // bound is region that may be modified and therefore has to be resolved. |
| 263 | // NULL means whole target. Can be an empty rect. |
| 264 | void flushRenderTarget(const GrIRect* bound); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 265 | void flushStencil(); |
bsalomon@google.com | f954d8d | 2011-04-06 17:50:02 +0000 | [diff] [blame] | 266 | void flushAAState(GrPrimitiveType type); |
bsalomon@google.com | 0650e81 | 2011-04-08 18:07:53 +0000 | [diff] [blame] | 267 | |
bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 268 | void resolveRenderTarget(GrGLRenderTarget* texture); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 269 | |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 270 | bool canBeTexture(GrPixelConfig config, |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 271 | GrGLenum* internalFormat, |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 272 | GrGLenum* externalFormat, |
| 273 | GrGLenum* externalType); |
| 274 | // helper for onCreateTexture and writeTexturePixels |
| 275 | void uploadTexData(const GrGLTexture::Desc& desc, |
| 276 | int left, int top, int width, int height, |
| 277 | GrPixelConfig dataConfig, |
| 278 | const void* data, |
| 279 | size_t rowBytes); |
bsalomon@google.com | 0650e81 | 2011-04-08 18:07:53 +0000 | [diff] [blame] | 280 | |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 281 | bool createRenderTargetObjects(int width, int height, |
| 282 | GrGLuint texID, |
| 283 | GrGLRenderTarget::Desc* desc); |
| 284 | |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 285 | bool fboInternalFormat(GrPixelConfig config, GrGLenum* format); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 286 | |
| 287 | friend class GrGLVertexBuffer; |
| 288 | friend class GrGLIndexBuffer; |
| 289 | friend class GrGLTexture; |
| 290 | friend class GrGLRenderTarget; |
| 291 | |
bsalomon@google.com | 4fa6694 | 2011-09-20 19:06:12 +0000 | [diff] [blame] | 292 | // read these once at begining and then never again |
| 293 | SkString fExtensionString; |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 294 | GrGLVersion fGLVersion; |
bsalomon@google.com | 2c17fcd | 2011-07-06 17:47:02 +0000 | [diff] [blame] | 295 | |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 296 | // we want to clear stencil buffers when they are created. We want to clear |
| 297 | // the entire buffer even if it is larger than the color attachment. We |
| 298 | // attach it to this fbo with no color attachment to do the initial clear. |
| 299 | GrGLuint fStencilClearFBO; |
bsalomon@google.com | 4fa6694 | 2011-09-20 19:06:12 +0000 | [diff] [blame] | 300 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 301 | bool fHWBlendDisabled; |
| 302 | |
bsalomon@google.com | 8531c1c | 2011-01-13 19:52:45 +0000 | [diff] [blame] | 303 | int fActiveTextureUnitIdx; |
bsalomon@google.com | 5782d71 | 2011-01-21 21:03:59 +0000 | [diff] [blame] | 304 | |
bsalomon@google.com | fe67652 | 2011-06-17 18:12:21 +0000 | [diff] [blame] | 305 | // we record what stencil format worked last time to hopefully exit early |
| 306 | // from our loop that tries stencil formats and calls check fb status. |
| 307 | int fLastSuccessfulStencilFmtIdx; |
| 308 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 309 | const GrGLInterface* fGL; |
| 310 | GrGLBinding fGLBinding; |
| 311 | |
bsalomon@google.com | 18c9c19 | 2011-09-22 21:01:31 +0000 | [diff] [blame] | 312 | bool fPrintedCaps; |
| 313 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 314 | typedef GrGpu INHERITED; |
| 315 | }; |
| 316 | |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 317 | #endif |
bsalomon@google.com | fe67652 | 2011-06-17 18:12:21 +0000 | [diff] [blame] | 318 | |