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