Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright 2011 Google Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | * found in the LICENSE file. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef GrGpuGL_DEFINED |
michael@0 | 9 | #define GrGpuGL_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "GrBinHashKey.h" |
michael@0 | 12 | #include "GrDrawState.h" |
michael@0 | 13 | #include "GrGLContext.h" |
michael@0 | 14 | #include "GrGLIRect.h" |
michael@0 | 15 | #include "GrGLIndexBuffer.h" |
michael@0 | 16 | #include "GrGLProgram.h" |
michael@0 | 17 | #include "GrGLStencilBuffer.h" |
michael@0 | 18 | #include "GrGLTexture.h" |
michael@0 | 19 | #include "GrGLVertexArray.h" |
michael@0 | 20 | #include "GrGLVertexBuffer.h" |
michael@0 | 21 | #include "GrGpu.h" |
michael@0 | 22 | #include "GrTHashTable.h" |
michael@0 | 23 | #include "SkTypes.h" |
michael@0 | 24 | |
michael@0 | 25 | #ifdef SK_DEVELOPER |
michael@0 | 26 | #define PROGRAM_CACHE_STATS |
michael@0 | 27 | #endif |
michael@0 | 28 | |
michael@0 | 29 | class GrGpuGL : public GrGpu { |
michael@0 | 30 | public: |
michael@0 | 31 | GrGpuGL(const GrGLContext& ctx, GrContext* context); |
michael@0 | 32 | virtual ~GrGpuGL(); |
michael@0 | 33 | |
michael@0 | 34 | const GrGLContext& glContext() const { return fGLContext; } |
michael@0 | 35 | |
michael@0 | 36 | const GrGLInterface* glInterface() const { return fGLContext.interface(); } |
michael@0 | 37 | const GrGLContextInfo& ctxInfo() const { return fGLContext; } |
michael@0 | 38 | GrGLStandard glStandard() const { return fGLContext.standard(); } |
michael@0 | 39 | GrGLVersion glVersion() const { return fGLContext.version(); } |
michael@0 | 40 | GrGLSLGeneration glslGeneration() const { return fGLContext.glslGeneration(); } |
michael@0 | 41 | const GrGLCaps& glCaps() const { return *fGLContext.caps(); } |
michael@0 | 42 | |
michael@0 | 43 | // Used by GrGLProgram and GrGLTexGenProgramEffects to configure OpenGL state. |
michael@0 | 44 | void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture); |
michael@0 | 45 | void setProjectionMatrix(const SkMatrix& matrix, |
michael@0 | 46 | const SkISize& renderTargetSize, |
michael@0 | 47 | GrSurfaceOrigin renderTargetOrigin); |
michael@0 | 48 | enum TexGenComponents { |
michael@0 | 49 | kS_TexGenComponents = 1, |
michael@0 | 50 | kST_TexGenComponents = 2, |
michael@0 | 51 | kSTR_TexGenComponents = 3 |
michael@0 | 52 | }; |
michael@0 | 53 | void enableTexGen(int unitIdx, TexGenComponents, const GrGLfloat* coefficients); |
michael@0 | 54 | void enableTexGen(int unitIdx, TexGenComponents, const SkMatrix& matrix); |
michael@0 | 55 | void flushTexGenSettings(int numUsedTexCoordSets); |
michael@0 | 56 | bool shouldUseFixedFunctionTexturing() const { |
michael@0 | 57 | return this->glCaps().fixedFunctionSupport() && |
michael@0 | 58 | this->glCaps().pathRenderingSupport(); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | bool programUnitTest(int maxStages); |
michael@0 | 62 | |
michael@0 | 63 | // GrGpu overrides |
michael@0 | 64 | virtual GrPixelConfig preferredReadPixelsConfig(GrPixelConfig readConfig, |
michael@0 | 65 | GrPixelConfig surfaceConfig) const SK_OVERRIDE; |
michael@0 | 66 | virtual GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig, |
michael@0 | 67 | GrPixelConfig surfaceConfig) const SK_OVERRIDE; |
michael@0 | 68 | virtual bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const SK_OVERRIDE; |
michael@0 | 69 | virtual bool readPixelsWillPayForYFlip( |
michael@0 | 70 | GrRenderTarget* renderTarget, |
michael@0 | 71 | int left, int top, |
michael@0 | 72 | int width, int height, |
michael@0 | 73 | GrPixelConfig config, |
michael@0 | 74 | size_t rowBytes) const SK_OVERRIDE; |
michael@0 | 75 | virtual bool fullReadPixelsIsFasterThanPartial() const SK_OVERRIDE; |
michael@0 | 76 | |
michael@0 | 77 | virtual void initCopySurfaceDstDesc(const GrSurface* src, GrTextureDesc* desc) SK_OVERRIDE; |
michael@0 | 78 | |
michael@0 | 79 | virtual void abandonResources() SK_OVERRIDE; |
michael@0 | 80 | |
michael@0 | 81 | // These functions should be used to bind GL objects. They track the GL state and skip redundant |
michael@0 | 82 | // bindings. Making the equivalent glBind calls directly will confuse the state tracking. |
michael@0 | 83 | void bindVertexArray(GrGLuint id) { |
michael@0 | 84 | fHWGeometryState.setVertexArrayID(this, id); |
michael@0 | 85 | } |
michael@0 | 86 | void bindIndexBufferAndDefaultVertexArray(GrGLuint id) { |
michael@0 | 87 | fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, id); |
michael@0 | 88 | } |
michael@0 | 89 | void bindVertexBuffer(GrGLuint id) { |
michael@0 | 90 | fHWGeometryState.setVertexBufferID(this, id); |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | // These callbacks update state tracking when GL objects are deleted. They are called from |
michael@0 | 94 | // GrGLResource onRelease functions. |
michael@0 | 95 | void notifyVertexArrayDelete(GrGLuint id) { |
michael@0 | 96 | fHWGeometryState.notifyVertexArrayDelete(id); |
michael@0 | 97 | } |
michael@0 | 98 | void notifyVertexBufferDelete(GrGLuint id) { |
michael@0 | 99 | fHWGeometryState.notifyVertexBufferDelete(id); |
michael@0 | 100 | } |
michael@0 | 101 | void notifyIndexBufferDelete(GrGLuint id) { |
michael@0 | 102 | fHWGeometryState.notifyIndexBufferDelete(id); |
michael@0 | 103 | } |
michael@0 | 104 | void notifyTextureDelete(GrGLTexture* texture); |
michael@0 | 105 | void notifyRenderTargetDelete(GrRenderTarget* renderTarget); |
michael@0 | 106 | |
michael@0 | 107 | protected: |
michael@0 | 108 | virtual bool onCopySurface(GrSurface* dst, |
michael@0 | 109 | GrSurface* src, |
michael@0 | 110 | const SkIRect& srcRect, |
michael@0 | 111 | const SkIPoint& dstPoint) SK_OVERRIDE; |
michael@0 | 112 | |
michael@0 | 113 | virtual bool onCanCopySurface(GrSurface* dst, |
michael@0 | 114 | GrSurface* src, |
michael@0 | 115 | const SkIRect& srcRect, |
michael@0 | 116 | const SkIPoint& dstPoint) SK_OVERRIDE; |
michael@0 | 117 | |
michael@0 | 118 | private: |
michael@0 | 119 | // GrGpu overrides |
michael@0 | 120 | virtual void onResetContext(uint32_t resetBits) SK_OVERRIDE; |
michael@0 | 121 | |
michael@0 | 122 | virtual GrTexture* onCreateTexture(const GrTextureDesc& desc, |
michael@0 | 123 | const void* srcData, |
michael@0 | 124 | size_t rowBytes) SK_OVERRIDE; |
michael@0 | 125 | virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_OVERRIDE; |
michael@0 | 126 | virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) SK_OVERRIDE; |
michael@0 | 127 | virtual GrPath* onCreatePath(const SkPath&, const SkStrokeRec&) SK_OVERRIDE; |
michael@0 | 128 | virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) SK_OVERRIDE; |
michael@0 | 129 | virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) SK_OVERRIDE; |
michael@0 | 130 | virtual bool createStencilBufferForRenderTarget(GrRenderTarget* rt, |
michael@0 | 131 | int width, |
michael@0 | 132 | int height) SK_OVERRIDE; |
michael@0 | 133 | virtual bool attachStencilBufferToRenderTarget( |
michael@0 | 134 | GrStencilBuffer* sb, |
michael@0 | 135 | GrRenderTarget* rt) SK_OVERRIDE; |
michael@0 | 136 | |
michael@0 | 137 | virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect) SK_OVERRIDE; |
michael@0 | 138 | |
michael@0 | 139 | virtual void onForceRenderTargetFlush() SK_OVERRIDE; |
michael@0 | 140 | |
michael@0 | 141 | virtual bool onReadPixels(GrRenderTarget* target, |
michael@0 | 142 | int left, int top, |
michael@0 | 143 | int width, int height, |
michael@0 | 144 | GrPixelConfig, |
michael@0 | 145 | void* buffer, |
michael@0 | 146 | size_t rowBytes) SK_OVERRIDE; |
michael@0 | 147 | |
michael@0 | 148 | virtual bool onWriteTexturePixels(GrTexture* texture, |
michael@0 | 149 | int left, int top, int width, int height, |
michael@0 | 150 | GrPixelConfig config, const void* buffer, |
michael@0 | 151 | size_t rowBytes) SK_OVERRIDE; |
michael@0 | 152 | |
michael@0 | 153 | virtual void onResolveRenderTarget(GrRenderTarget* target) SK_OVERRIDE; |
michael@0 | 154 | |
michael@0 | 155 | virtual void onGpuDraw(const DrawInfo&) SK_OVERRIDE; |
michael@0 | 156 | |
michael@0 | 157 | virtual void onGpuStencilPath(const GrPath*, SkPath::FillType) SK_OVERRIDE; |
michael@0 | 158 | virtual void onGpuDrawPath(const GrPath*, SkPath::FillType) SK_OVERRIDE; |
michael@0 | 159 | |
michael@0 | 160 | virtual void clearStencil() SK_OVERRIDE; |
michael@0 | 161 | virtual void clearStencilClip(const SkIRect& rect, |
michael@0 | 162 | bool insideClip) SK_OVERRIDE; |
michael@0 | 163 | virtual bool flushGraphicsState(DrawType, const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
michael@0 | 164 | |
michael@0 | 165 | // GrDrawTarget ovverides |
michael@0 | 166 | virtual void onInstantGpuTraceEvent(const char* marker) SK_OVERRIDE; |
michael@0 | 167 | virtual void onPushGpuTraceEvent(const char* marker) SK_OVERRIDE; |
michael@0 | 168 | virtual void onPopGpuTraceEvent() SK_OVERRIDE; |
michael@0 | 169 | |
michael@0 | 170 | |
michael@0 | 171 | // binds texture unit in GL |
michael@0 | 172 | void setTextureUnit(int unitIdx); |
michael@0 | 173 | |
michael@0 | 174 | // Sets up vertex attribute pointers and strides. On return indexOffsetInBytes gives the offset |
michael@0 | 175 | // an into the index buffer. It does not account for drawInfo.startIndex() but rather the start |
michael@0 | 176 | // index is relative to the returned offset. |
michael@0 | 177 | void setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes); |
michael@0 | 178 | |
michael@0 | 179 | // Subclasses should call this to flush the blend state. |
michael@0 | 180 | // The params should be the final coefficients to apply |
michael@0 | 181 | // (after any blending optimizations or dual source blending considerations |
michael@0 | 182 | // have been accounted for). |
michael@0 | 183 | void flushBlend(bool isLines, GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff); |
michael@0 | 184 | |
michael@0 | 185 | bool hasExtension(const char* ext) const { return fGLContext.hasExtension(ext); } |
michael@0 | 186 | |
michael@0 | 187 | static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); |
michael@0 | 188 | |
michael@0 | 189 | class ProgramCache : public ::SkNoncopyable { |
michael@0 | 190 | public: |
michael@0 | 191 | ProgramCache(GrGpuGL* gpu); |
michael@0 | 192 | ~ProgramCache(); |
michael@0 | 193 | |
michael@0 | 194 | void abandon(); |
michael@0 | 195 | GrGLProgram* getProgram(const GrGLProgramDesc& desc, |
michael@0 | 196 | const GrEffectStage* colorStages[], |
michael@0 | 197 | const GrEffectStage* coverageStages[]); |
michael@0 | 198 | |
michael@0 | 199 | private: |
michael@0 | 200 | enum { |
michael@0 | 201 | // We may actually have kMaxEntries+1 shaders in the GL context because we create a new |
michael@0 | 202 | // shader before evicting from the cache. |
michael@0 | 203 | kMaxEntries = 32, |
michael@0 | 204 | kHashBits = 6, |
michael@0 | 205 | }; |
michael@0 | 206 | |
michael@0 | 207 | struct Entry; |
michael@0 | 208 | |
michael@0 | 209 | struct ProgDescLess; |
michael@0 | 210 | |
michael@0 | 211 | // binary search for entry matching desc. returns index into fEntries that matches desc or ~ |
michael@0 | 212 | // of the index of where it should be inserted. |
michael@0 | 213 | int search(const GrGLProgramDesc& desc) const; |
michael@0 | 214 | |
michael@0 | 215 | // sorted array of all the entries |
michael@0 | 216 | Entry* fEntries[kMaxEntries]; |
michael@0 | 217 | // hash table based on lowest kHashBits bits of the program key. Used to avoid binary |
michael@0 | 218 | // searching fEntries. |
michael@0 | 219 | Entry* fHashTable[1 << kHashBits]; |
michael@0 | 220 | |
michael@0 | 221 | int fCount; |
michael@0 | 222 | unsigned int fCurrLRUStamp; |
michael@0 | 223 | GrGpuGL* fGpu; |
michael@0 | 224 | #ifdef PROGRAM_CACHE_STATS |
michael@0 | 225 | int fTotalRequests; |
michael@0 | 226 | int fCacheMisses; |
michael@0 | 227 | int fHashMisses; // cache hit but hash table missed |
michael@0 | 228 | #endif |
michael@0 | 229 | }; |
michael@0 | 230 | |
michael@0 | 231 | // flushes dithering, color-mask, and face culling stat |
michael@0 | 232 | void flushMiscFixedFunctionState(); |
michael@0 | 233 | |
michael@0 | 234 | // flushes the scissor. see the note on flushBoundTextureAndParams about |
michael@0 | 235 | // flushing the scissor after that function is called. |
michael@0 | 236 | void flushScissor(); |
michael@0 | 237 | |
michael@0 | 238 | void initFSAASupport(); |
michael@0 | 239 | |
michael@0 | 240 | // determines valid stencil formats |
michael@0 | 241 | void initStencilFormats(); |
michael@0 | 242 | |
michael@0 | 243 | // sets a texture unit to use for texture operations other than binding a texture to a program. |
michael@0 | 244 | // ensures that such operations don't negatively interact with tracking bound textures. |
michael@0 | 245 | void setScratchTextureUnit(); |
michael@0 | 246 | |
michael@0 | 247 | // bound is region that may be modified and therefore has to be resolved. |
michael@0 | 248 | // NULL means whole target. Can be an empty rect. |
michael@0 | 249 | void flushRenderTarget(const SkIRect* bound); |
michael@0 | 250 | void flushStencil(DrawType); |
michael@0 | 251 | void flushAAState(DrawType); |
michael@0 | 252 | void flushPathStencilSettings(SkPath::FillType fill); |
michael@0 | 253 | |
michael@0 | 254 | bool configToGLFormats(GrPixelConfig config, |
michael@0 | 255 | bool getSizedInternal, |
michael@0 | 256 | GrGLenum* internalFormat, |
michael@0 | 257 | GrGLenum* externalFormat, |
michael@0 | 258 | GrGLenum* externalType); |
michael@0 | 259 | // helper for onCreateTexture and writeTexturePixels |
michael@0 | 260 | bool uploadTexData(const GrGLTexture::Desc& desc, |
michael@0 | 261 | bool isNewTexture, |
michael@0 | 262 | int left, int top, int width, int height, |
michael@0 | 263 | GrPixelConfig dataConfig, |
michael@0 | 264 | const void* data, |
michael@0 | 265 | size_t rowBytes); |
michael@0 | 266 | |
michael@0 | 267 | bool createRenderTargetObjects(int width, int height, |
michael@0 | 268 | GrGLuint texID, |
michael@0 | 269 | GrGLRenderTarget::Desc* desc); |
michael@0 | 270 | |
michael@0 | 271 | GrGLContext fGLContext; |
michael@0 | 272 | |
michael@0 | 273 | // GL program-related state |
michael@0 | 274 | ProgramCache* fProgramCache; |
michael@0 | 275 | SkAutoTUnref<GrGLProgram> fCurrentProgram; |
michael@0 | 276 | |
michael@0 | 277 | /////////////////////////////////////////////////////////////////////////// |
michael@0 | 278 | ///@name Caching of GL State |
michael@0 | 279 | ///@{ |
michael@0 | 280 | int fHWActiveTextureUnitIdx; |
michael@0 | 281 | GrGLuint fHWProgramID; |
michael@0 | 282 | |
michael@0 | 283 | GrGLProgram::SharedGLState fSharedGLProgramState; |
michael@0 | 284 | |
michael@0 | 285 | enum TriState { |
michael@0 | 286 | kNo_TriState, |
michael@0 | 287 | kYes_TriState, |
michael@0 | 288 | kUnknown_TriState |
michael@0 | 289 | }; |
michael@0 | 290 | |
michael@0 | 291 | // last scissor / viewport scissor state seen by the GL. |
michael@0 | 292 | struct { |
michael@0 | 293 | TriState fEnabled; |
michael@0 | 294 | GrGLIRect fRect; |
michael@0 | 295 | void invalidate() { |
michael@0 | 296 | fEnabled = kUnknown_TriState; |
michael@0 | 297 | fRect.invalidate(); |
michael@0 | 298 | } |
michael@0 | 299 | } fHWScissorSettings; |
michael@0 | 300 | |
michael@0 | 301 | GrGLIRect fHWViewport; |
michael@0 | 302 | |
michael@0 | 303 | /** |
michael@0 | 304 | * Tracks bound vertex and index buffers and vertex attrib array state. |
michael@0 | 305 | */ |
michael@0 | 306 | class HWGeometryState { |
michael@0 | 307 | public: |
michael@0 | 308 | HWGeometryState() { fVBOVertexArray = NULL; this->invalidate(); } |
michael@0 | 309 | |
michael@0 | 310 | ~HWGeometryState() { SkSafeUnref(fVBOVertexArray); } |
michael@0 | 311 | |
michael@0 | 312 | void invalidate() { |
michael@0 | 313 | fBoundVertexArrayIDIsValid = false; |
michael@0 | 314 | fBoundVertexBufferIDIsValid = false; |
michael@0 | 315 | fDefaultVertexArrayBoundIndexBufferID = false; |
michael@0 | 316 | fDefaultVertexArrayBoundIndexBufferIDIsValid = false; |
michael@0 | 317 | fDefaultVertexArrayAttribState.invalidate(); |
michael@0 | 318 | if (NULL != fVBOVertexArray) { |
michael@0 | 319 | fVBOVertexArray->invalidateCachedState(); |
michael@0 | 320 | } |
michael@0 | 321 | } |
michael@0 | 322 | |
michael@0 | 323 | void notifyVertexArrayDelete(GrGLuint id) { |
michael@0 | 324 | if (fBoundVertexArrayIDIsValid && fBoundVertexArrayID == id) { |
michael@0 | 325 | // Does implicit bind to 0 |
michael@0 | 326 | fBoundVertexArrayID = 0; |
michael@0 | 327 | } |
michael@0 | 328 | } |
michael@0 | 329 | |
michael@0 | 330 | void setVertexArrayID(GrGpuGL* gpu, GrGLuint arrayID) { |
michael@0 | 331 | if (!gpu->glCaps().vertexArrayObjectSupport()) { |
michael@0 | 332 | SkASSERT(0 == arrayID); |
michael@0 | 333 | return; |
michael@0 | 334 | } |
michael@0 | 335 | if (!fBoundVertexArrayIDIsValid || arrayID != fBoundVertexArrayID) { |
michael@0 | 336 | GR_GL_CALL(gpu->glInterface(), BindVertexArray(arrayID)); |
michael@0 | 337 | fBoundVertexArrayIDIsValid = true; |
michael@0 | 338 | fBoundVertexArrayID = arrayID; |
michael@0 | 339 | } |
michael@0 | 340 | } |
michael@0 | 341 | |
michael@0 | 342 | void notifyVertexBufferDelete(GrGLuint id) { |
michael@0 | 343 | if (fBoundVertexBufferIDIsValid && id == fBoundVertexBufferID) { |
michael@0 | 344 | fBoundVertexBufferID = 0; |
michael@0 | 345 | } |
michael@0 | 346 | if (NULL != fVBOVertexArray) { |
michael@0 | 347 | fVBOVertexArray->notifyVertexBufferDelete(id); |
michael@0 | 348 | } |
michael@0 | 349 | fDefaultVertexArrayAttribState.notifyVertexBufferDelete(id); |
michael@0 | 350 | } |
michael@0 | 351 | |
michael@0 | 352 | void notifyIndexBufferDelete(GrGLuint id) { |
michael@0 | 353 | if (fDefaultVertexArrayBoundIndexBufferIDIsValid && |
michael@0 | 354 | id == fDefaultVertexArrayBoundIndexBufferID) { |
michael@0 | 355 | fDefaultVertexArrayBoundIndexBufferID = 0; |
michael@0 | 356 | } |
michael@0 | 357 | if (NULL != fVBOVertexArray) { |
michael@0 | 358 | fVBOVertexArray->notifyIndexBufferDelete(id); |
michael@0 | 359 | } |
michael@0 | 360 | } |
michael@0 | 361 | |
michael@0 | 362 | void setVertexBufferID(GrGpuGL* gpu, GrGLuint id) { |
michael@0 | 363 | if (!fBoundVertexBufferIDIsValid || id != fBoundVertexBufferID) { |
michael@0 | 364 | GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ARRAY_BUFFER, id)); |
michael@0 | 365 | fBoundVertexBufferIDIsValid = true; |
michael@0 | 366 | fBoundVertexBufferID = id; |
michael@0 | 367 | } |
michael@0 | 368 | } |
michael@0 | 369 | |
michael@0 | 370 | /** |
michael@0 | 371 | * Binds the default vertex array and binds the index buffer. This is used when binding |
michael@0 | 372 | * an index buffer in order to update it. |
michael@0 | 373 | */ |
michael@0 | 374 | void setIndexBufferIDOnDefaultVertexArray(GrGpuGL* gpu, GrGLuint id) { |
michael@0 | 375 | this->setVertexArrayID(gpu, 0); |
michael@0 | 376 | if (!fDefaultVertexArrayBoundIndexBufferIDIsValid || |
michael@0 | 377 | id != fDefaultVertexArrayBoundIndexBufferID) { |
michael@0 | 378 | GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, id)); |
michael@0 | 379 | fDefaultVertexArrayBoundIndexBufferIDIsValid = true; |
michael@0 | 380 | fDefaultVertexArrayBoundIndexBufferID = id; |
michael@0 | 381 | } |
michael@0 | 382 | } |
michael@0 | 383 | |
michael@0 | 384 | /** |
michael@0 | 385 | * Binds the vertex array object that should be used to render from the vertex buffer. |
michael@0 | 386 | * The vertex array is bound and its attrib array state object is returned. The vertex |
michael@0 | 387 | * buffer is bound. The index buffer (if non-NULL) is bound to the vertex array. The |
michael@0 | 388 | * returned GrGLAttribArrayState should be used to set vertex attribute arrays. |
michael@0 | 389 | */ |
michael@0 | 390 | GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGpuGL* gpu, |
michael@0 | 391 | const GrGLVertexBuffer* vbuffer, |
michael@0 | 392 | const GrGLIndexBuffer* ibuffer); |
michael@0 | 393 | |
michael@0 | 394 | private: |
michael@0 | 395 | GrGLuint fBoundVertexArrayID; |
michael@0 | 396 | GrGLuint fBoundVertexBufferID; |
michael@0 | 397 | bool fBoundVertexArrayIDIsValid; |
michael@0 | 398 | bool fBoundVertexBufferIDIsValid; |
michael@0 | 399 | |
michael@0 | 400 | GrGLuint fDefaultVertexArrayBoundIndexBufferID; |
michael@0 | 401 | bool fDefaultVertexArrayBoundIndexBufferIDIsValid; |
michael@0 | 402 | // We return a non-const pointer to this from bindArrayAndBuffersToDraw when vertex array 0 |
michael@0 | 403 | // is bound. However, this class is internal to GrGpuGL and this object never leaks out of |
michael@0 | 404 | // GrGpuGL. |
michael@0 | 405 | GrGLAttribArrayState fDefaultVertexArrayAttribState; |
michael@0 | 406 | |
michael@0 | 407 | // This is used when we're using a core profile and the vertices are in a VBO. |
michael@0 | 408 | GrGLVertexArray* fVBOVertexArray; |
michael@0 | 409 | } fHWGeometryState; |
michael@0 | 410 | |
michael@0 | 411 | struct { |
michael@0 | 412 | GrBlendCoeff fSrcCoeff; |
michael@0 | 413 | GrBlendCoeff fDstCoeff; |
michael@0 | 414 | GrColor fConstColor; |
michael@0 | 415 | bool fConstColorValid; |
michael@0 | 416 | TriState fEnabled; |
michael@0 | 417 | |
michael@0 | 418 | void invalidate() { |
michael@0 | 419 | fSrcCoeff = kInvalid_GrBlendCoeff; |
michael@0 | 420 | fDstCoeff = kInvalid_GrBlendCoeff; |
michael@0 | 421 | fConstColorValid = false; |
michael@0 | 422 | fEnabled = kUnknown_TriState; |
michael@0 | 423 | } |
michael@0 | 424 | } fHWBlendState; |
michael@0 | 425 | |
michael@0 | 426 | struct { |
michael@0 | 427 | TriState fMSAAEnabled; |
michael@0 | 428 | TriState fSmoothLineEnabled; |
michael@0 | 429 | void invalidate() { |
michael@0 | 430 | fMSAAEnabled = kUnknown_TriState; |
michael@0 | 431 | fSmoothLineEnabled = kUnknown_TriState; |
michael@0 | 432 | } |
michael@0 | 433 | } fHWAAState; |
michael@0 | 434 | |
michael@0 | 435 | |
michael@0 | 436 | GrGLProgram::MatrixState fHWProjectionMatrixState; |
michael@0 | 437 | |
michael@0 | 438 | GrStencilSettings fHWStencilSettings; |
michael@0 | 439 | TriState fHWStencilTestEnabled; |
michael@0 | 440 | GrStencilSettings fHWPathStencilSettings; |
michael@0 | 441 | |
michael@0 | 442 | GrDrawState::DrawFace fHWDrawFace; |
michael@0 | 443 | TriState fHWWriteToColor; |
michael@0 | 444 | TriState fHWDitherEnabled; |
michael@0 | 445 | GrRenderTarget* fHWBoundRenderTarget; |
michael@0 | 446 | SkTArray<GrTexture*, true> fHWBoundTextures; |
michael@0 | 447 | |
michael@0 | 448 | struct TexGenData { |
michael@0 | 449 | GrGLenum fMode; |
michael@0 | 450 | GrGLint fNumComponents; |
michael@0 | 451 | GrGLfloat fCoefficients[3 * 3]; |
michael@0 | 452 | }; |
michael@0 | 453 | int fHWActiveTexGenSets; |
michael@0 | 454 | SkTArray<TexGenData, true> fHWTexGenSettings; |
michael@0 | 455 | ///@} |
michael@0 | 456 | |
michael@0 | 457 | // we record what stencil format worked last time to hopefully exit early |
michael@0 | 458 | // from our loop that tries stencil formats and calls check fb status. |
michael@0 | 459 | int fLastSuccessfulStencilFmtIdx; |
michael@0 | 460 | |
michael@0 | 461 | typedef GrGpu INHERITED; |
michael@0 | 462 | }; |
michael@0 | 463 | |
michael@0 | 464 | #endif |