| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrGLGpu_DEFINED | 8 #ifndef GrGLGpu_DEFINED |
| 9 #define GrGLGpu_DEFINED | 9 #define GrGLGpu_DEFINED |
| 10 | 10 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 94 } |
| 95 void notifyIndexBufferDelete(GrGLuint id) { | 95 void notifyIndexBufferDelete(GrGLuint id) { |
| 96 fHWGeometryState.notifyIndexBufferDelete(id); | 96 fHWGeometryState.notifyIndexBufferDelete(id); |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool copySurface(GrSurface* dst, | 99 bool copySurface(GrSurface* dst, |
| 100 GrSurface* src, | 100 GrSurface* src, |
| 101 const SkIRect& srcRect, | 101 const SkIRect& srcRect, |
| 102 const SkIPoint& dstPoint) override; | 102 const SkIPoint& dstPoint) override; |
| 103 | 103 |
| 104 bool canCopySurface(const GrSurface* dst, |
| 105 const GrSurface* src, |
| 106 const SkIRect& srcRect, |
| 107 const SkIPoint& dstPoint) override; |
| 108 |
| 104 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; | 109 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; |
| 105 | 110 |
| 106 void buildProgramDesc(GrProgramDesc*, | 111 void buildProgramDesc(GrProgramDesc*, |
| 107 const GrPrimitiveProcessor&, | 112 const GrPrimitiveProcessor&, |
| 108 const GrPipeline&, | 113 const GrPipeline&, |
| 109 const GrBatchTracker&) const override; | 114 const GrBatchTracker&) const override; |
| 110 | 115 |
| 111 private: | 116 private: |
| 112 // GrGpu overrides | 117 // GrGpu overrides |
| 113 void onResetContext(uint32_t resetBits) override; | 118 void onResetContext(uint32_t resetBits) override; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // Sets up vertex attribute pointers and strides. On return indexOffsetInByt
es gives the offset | 176 // Sets up vertex attribute pointers and strides. On return indexOffsetInByt
es gives the offset |
| 172 // an into the index buffer. It does not account for vertices.startIndex() b
ut rather the start | 177 // an into the index buffer. It does not account for vertices.startIndex() b
ut rather the start |
| 173 // index is relative to the returned offset. | 178 // index is relative to the returned offset. |
| 174 void setupGeometry(const GrPrimitiveProcessor&, | 179 void setupGeometry(const GrPrimitiveProcessor&, |
| 175 const GrNonInstancedVertices& vertices, | 180 const GrNonInstancedVertices& vertices, |
| 176 size_t* indexOffsetInBytes); | 181 size_t* indexOffsetInBytes); |
| 177 | 182 |
| 178 // Subclasses should call this to flush the blend state. | 183 // Subclasses should call this to flush the blend state. |
| 179 void flushBlend(const GrXferProcessor::BlendInfo& blendInfo); | 184 void flushBlend(const GrXferProcessor::BlendInfo& blendInfo); |
| 180 | 185 |
| 181 void copySurfaceAsDraw(GrSurface* dst, | |
| 182 GrSurface* src, | |
| 183 const SkIRect& srcRect, | |
| 184 const SkIPoint& dstPoint); | |
| 185 void copySurfaceAsCopyTexSubImage(GrSurface* dst, | |
| 186 GrSurface* src, | |
| 187 const SkIRect& srcRect, | |
| 188 const SkIPoint& dstPoint); | |
| 189 bool copySurfaceAsBlitFramebuffer(GrSurface* dst, | |
| 190 GrSurface* src, | |
| 191 const SkIRect& srcRect, | |
| 192 const SkIPoint& dstPoint); | |
| 193 | |
| 194 bool hasExtension(const char* ext) const { return fGLContext.hasExtension(ex
t); } | 186 bool hasExtension(const char* ext) const { return fGLContext.hasExtension(ex
t); } |
| 195 | 187 |
| 196 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); | 188 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); |
| 197 | 189 |
| 198 class ProgramCache : public ::SkNoncopyable { | 190 class ProgramCache : public ::SkNoncopyable { |
| 199 public: | 191 public: |
| 200 ProgramCache(GrGLGpu* gpu); | 192 ProgramCache(GrGLGpu* gpu); |
| 201 ~ProgramCache(); | 193 ~ProgramCache(); |
| 202 | 194 |
| 203 void abandon(); | 195 void abandon(); |
| 204 GrGLProgram* refProgram(const DrawArgs&); | 196 GrGLProgram* getProgram(const DrawArgs&); |
| 205 | 197 |
| 206 private: | 198 private: |
| 207 enum { | 199 enum { |
| 208 // We may actually have kMaxEntries+1 shaders in the GL context beca
use we create a new | 200 // We may actually have kMaxEntries+1 shaders in the GL context beca
use we create a new |
| 209 // shader before evicting from the cache. | 201 // shader before evicting from the cache. |
| 210 kMaxEntries = 128, | 202 kMaxEntries = 128, |
| 211 kHashBits = 6, | 203 kHashBits = 6, |
| 212 }; | 204 }; |
| 213 | 205 |
| 214 struct Entry; | 206 struct Entry; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 enum TempFBOTarget { | 287 enum TempFBOTarget { |
| 296 kSrc_TempFBOTarget, | 288 kSrc_TempFBOTarget, |
| 297 kDst_TempFBOTarget | 289 kDst_TempFBOTarget |
| 298 }; | 290 }; |
| 299 | 291 |
| 300 GrGLuint bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLIRect*
viewport, | 292 GrGLuint bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLIRect*
viewport, |
| 301 TempFBOTarget tempFBOTarget); | 293 TempFBOTarget tempFBOTarget); |
| 302 | 294 |
| 303 void unbindTextureFromFBO(GrGLenum fboTarget); | 295 void unbindTextureFromFBO(GrGLenum fboTarget); |
| 304 | 296 |
| 305 void createCopyProgram(); | |
| 306 | |
| 307 GrGLContext fGLContext; | 297 GrGLContext fGLContext; |
| 308 | 298 |
| 309 // GL program-related state | 299 // GL program-related state |
| 310 ProgramCache* fProgramCache; | 300 ProgramCache* fProgramCache; |
| 301 SkAutoTUnref<GrGLProgram> fCurrentProgram; |
| 311 | 302 |
| 312 /////////////////////////////////////////////////////////////////////////// | 303 /////////////////////////////////////////////////////////////////////////// |
| 313 ///@name Caching of GL State | 304 ///@name Caching of GL State |
| 314 ///@{ | 305 ///@{ |
| 315 int fHWActiveTextureUnitIdx; | 306 int fHWActiveTextureUnitIdx; |
| 316 GrGLuint fHWProgramID; | 307 GrGLuint fHWProgramID; |
| 317 | 308 |
| 318 enum TriState { | 309 enum TriState { |
| 319 kNo_TriState, | 310 kNo_TriState, |
| 320 kYes_TriState, | 311 kYes_TriState, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 /** | 413 /** |
| 423 * Binds the vertex array object that should be used to render from the
vertex buffer. | 414 * Binds the vertex array object that should be used to render from the
vertex buffer. |
| 424 * The vertex array is bound and its attrib array state object is return
ed. The vertex | 415 * The vertex array is bound and its attrib array state object is return
ed. The vertex |
| 425 * buffer is bound. The index buffer (if non-NULL) is bound to the verte
x array. The | 416 * buffer is bound. The index buffer (if non-NULL) is bound to the verte
x array. The |
| 426 * returned GrGLAttribArrayState should be used to set vertex attribute
arrays. | 417 * returned GrGLAttribArrayState should be used to set vertex attribute
arrays. |
| 427 */ | 418 */ |
| 428 GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGLGpu* gpu, | 419 GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGLGpu* gpu, |
| 429 const GrGLVertexBuffer*
vbuffer, | 420 const GrGLVertexBuffer*
vbuffer, |
| 430 const GrGLIndexBuffer* i
buffer); | 421 const GrGLIndexBuffer* i
buffer); |
| 431 | 422 |
| 432 /** Variants of the above that takes GL buffer IDs. Note that 0 does not
imply that a | |
| 433 buffer won't be bound. The "default buffer" will be bound, which is
used for client-side | |
| 434 array rendering. */ | |
| 435 GrGLAttribArrayState* bindArrayAndBufferToDraw(GrGLGpu* gpu, GrGLuint vb
ufferID); | |
| 436 GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGLGpu* gpu, | |
| 437 GrGLuint vbufferID, | |
| 438 GrGLuint ibufferID); | |
| 439 | |
| 440 private: | 423 private: |
| 441 GrGLAttribArrayState* internalBind(GrGLGpu* gpu, GrGLuint vbufferID, GrG
Luint* ibufferID); | |
| 442 | |
| 443 GrGLuint fBoundVertexArrayID; | 424 GrGLuint fBoundVertexArrayID; |
| 444 GrGLuint fBoundVertexBufferID; | 425 GrGLuint fBoundVertexBufferID; |
| 445 bool fBoundVertexArrayIDIsValid; | 426 bool fBoundVertexArrayIDIsValid; |
| 446 bool fBoundVertexBufferIDIsValid; | 427 bool fBoundVertexBufferIDIsValid; |
| 447 | 428 |
| 448 GrGLuint fDefaultVertexArrayBoundIndexBufferID; | 429 GrGLuint fDefaultVertexArrayBoundIndexBufferID; |
| 449 bool fDefaultVertexArrayBoundIndexBufferIDIsValid; | 430 bool fDefaultVertexArrayBoundIndexBufferIDIsValid; |
| 450 // We return a non-const pointer to this from bindArrayAndBuffersToDraw
when vertex array 0 | 431 // We return a non-const pointer to this from bindArrayAndBuffersToDraw
when vertex array 0 |
| 451 // is bound. However, this class is internal to GrGLGpu and this object
never leaks out of | 432 // is bound. However, this class is internal to GrGLGpu and this object
never leaks out of |
| 452 // GrGLGpu. | 433 // GrGLGpu. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 466 | 447 |
| 467 void invalidate() { | 448 void invalidate() { |
| 468 fEquation = static_cast<GrBlendEquation>(-1); | 449 fEquation = static_cast<GrBlendEquation>(-1); |
| 469 fSrcCoeff = static_cast<GrBlendCoeff>(-1); | 450 fSrcCoeff = static_cast<GrBlendCoeff>(-1); |
| 470 fDstCoeff = static_cast<GrBlendCoeff>(-1); | 451 fDstCoeff = static_cast<GrBlendCoeff>(-1); |
| 471 fConstColorValid = false; | 452 fConstColorValid = false; |
| 472 fEnabled = kUnknown_TriState; | 453 fEnabled = kUnknown_TriState; |
| 473 } | 454 } |
| 474 } fHWBlendState; | 455 } fHWBlendState; |
| 475 | 456 |
| 476 /** IDs for copy surface program. */ | |
| 477 struct { | |
| 478 GrGLuint fProgram; | |
| 479 GrGLint fTextureUniform; | |
| 480 GrGLint fTexCoordXformUniform; | |
| 481 GrGLint fPosXformUniform; | |
| 482 GrGLuint fArrayBuffer; | |
| 483 } fCopyProgram; | |
| 484 | |
| 485 TriState fMSAAEnabled; | 457 TriState fMSAAEnabled; |
| 486 | 458 |
| 487 GrStencilSettings fHWStencilSettings; | 459 GrStencilSettings fHWStencilSettings; |
| 488 TriState fHWStencilTestEnabled; | 460 TriState fHWStencilTestEnabled; |
| 489 | 461 |
| 490 | 462 |
| 491 GrPipelineBuilder::DrawFace fHWDrawFace; | 463 GrPipelineBuilder::DrawFace fHWDrawFace; |
| 492 TriState fHWWriteToColor; | 464 TriState fHWWriteToColor; |
| 493 TriState fHWDitherEnabled; | 465 TriState fHWDitherEnabled; |
| 494 uint32_t fHWBoundRenderTargetUniqueID; | 466 uint32_t fHWBoundRenderTargetUniqueID; |
| 495 SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs; | 467 SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs; |
| 496 | 468 |
| 497 ///@} | 469 ///@} |
| 498 | 470 |
| 499 // we record what stencil format worked last time to hopefully exit early | 471 // we record what stencil format worked last time to hopefully exit early |
| 500 // from our loop that tries stencil formats and calls check fb status. | 472 // from our loop that tries stencil formats and calls check fb status. |
| 501 int fLastSuccessfulStencilFmtIdx; | 473 int fLastSuccessfulStencilFmtIdx; |
| 502 | 474 |
| 503 typedef GrGpu INHERITED; | 475 typedef GrGpu INHERITED; |
| 504 friend class GrGLPathRendering; // For accessing setTextureUnit. | 476 friend class GrGLPathRendering; // For accessing setTextureUnit. |
| 505 }; | 477 }; |
| 506 | 478 |
| 507 #endif | 479 #endif |
| OLD | NEW |