| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 void discard(GrRenderTarget*) override; | 57 void discard(GrRenderTarget*) override; |
| 58 | 58 |
| 59 // Used by GrGLProgram to configure OpenGL state. | 59 // Used by GrGLProgram to configure OpenGL state. |
| 60 void bindTexture(int unitIdx, const GrTextureParams& params, bool allowSRGBI
nputs, | 60 void bindTexture(int unitIdx, const GrTextureParams& params, bool allowSRGBI
nputs, |
| 61 GrGLTexture* texture); | 61 GrGLTexture* texture); |
| 62 | 62 |
| 63 void bindTexelBuffer(int unitIdx, intptr_t offsetInBytes, GrPixelConfig, GrG
LBuffer*); | 63 void bindTexelBuffer(int unitIdx, intptr_t offsetInBytes, GrPixelConfig, GrG
LBuffer*); |
| 64 | 64 |
| 65 void generateMipmaps(const GrTextureParams& params, bool allowSRGBInputs, Gr
GLTexture* texture); |
| 66 |
| 65 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, | 67 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, |
| 66 GrPixelConfig readConfig, DrawPreference*, | 68 GrPixelConfig readConfig, DrawPreference*, |
| 67 ReadPixelTempDrawInfo*) override; | 69 ReadPixelTempDrawInfo*) override; |
| 68 | 70 |
| 69 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, | 71 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, |
| 70 GrPixelConfig srcConfig, DrawPreference*, | 72 GrPixelConfig srcConfig, DrawPreference*, |
| 71 WritePixelTempDrawInfo*) override; | 73 WritePixelTempDrawInfo*) override; |
| 72 | 74 |
| 73 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const
override; | 75 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const
override; |
| 74 | 76 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 const SkIRect& srcRect, | 232 const SkIRect& srcRect, |
| 231 const SkIPoint& dstPoint); | 233 const SkIPoint& dstPoint); |
| 232 void copySurfaceAsCopyTexSubImage(GrSurface* dst, | 234 void copySurfaceAsCopyTexSubImage(GrSurface* dst, |
| 233 GrSurface* src, | 235 GrSurface* src, |
| 234 const SkIRect& srcRect, | 236 const SkIRect& srcRect, |
| 235 const SkIPoint& dstPoint); | 237 const SkIPoint& dstPoint); |
| 236 bool copySurfaceAsBlitFramebuffer(GrSurface* dst, | 238 bool copySurfaceAsBlitFramebuffer(GrSurface* dst, |
| 237 GrSurface* src, | 239 GrSurface* src, |
| 238 const SkIRect& srcRect, | 240 const SkIRect& srcRect, |
| 239 const SkIPoint& dstPoint); | 241 const SkIPoint& dstPoint); |
| 242 bool generateMipmap(GrGLTexture* texture, bool gammaCorrect); |
| 240 | 243 |
| 241 void stampPLSSetupRect(const SkRect& bounds); | 244 void stampPLSSetupRect(const SkRect& bounds); |
| 242 | 245 |
| 243 void setupPixelLocalStorage(const GrPipeline&, const GrPrimitiveProcessor&); | 246 void setupPixelLocalStorage(const GrPipeline&, const GrPrimitiveProcessor&); |
| 244 | 247 |
| 245 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); | 248 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); |
| 246 | 249 |
| 247 class ProgramCache : public ::SkNoncopyable { | 250 class ProgramCache : public ::SkNoncopyable { |
| 248 public: | 251 public: |
| 249 ProgramCache(GrGLGpu* gpu); | 252 ProgramCache(GrGLGpu* gpu); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 // Need not be called if flushRenderTarget is used. | 315 // Need not be called if flushRenderTarget is used. |
| 313 void flushViewport(const GrGLIRect&); | 316 void flushViewport(const GrGLIRect&); |
| 314 | 317 |
| 315 void flushStencil(const GrStencilSettings&); | 318 void flushStencil(const GrStencilSettings&); |
| 316 | 319 |
| 317 // rt is used only if useHWAA is true. | 320 // rt is used only if useHWAA is true. |
| 318 void flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabled); | 321 void flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabled); |
| 319 | 322 |
| 320 void flushMinSampleShading(float minSampleShading); | 323 void flushMinSampleShading(float minSampleShading); |
| 321 | 324 |
| 325 void flushFramebufferSRGB(bool enable); |
| 326 |
| 322 // helper for onCreateTexture and writeTexturePixels | 327 // helper for onCreateTexture and writeTexturePixels |
| 323 enum UploadType { | 328 enum UploadType { |
| 324 kNewTexture_UploadType, // we are creating a new texture | 329 kNewTexture_UploadType, // we are creating a new texture |
| 325 kWrite_UploadType, // we are using TexSubImage2D to copy data to
an existing texture | 330 kWrite_UploadType, // we are using TexSubImage2D to copy data to
an existing texture |
| 326 kTransfer_UploadType, // we are using a transfer buffer to copy dat
a | 331 kTransfer_UploadType, // we are using a transfer buffer to copy dat
a |
| 327 }; | 332 }; |
| 328 bool uploadTexData(const GrSurfaceDesc& desc, | 333 bool uploadTexData(const GrSurfaceDesc& desc, |
| 329 GrGLenum target, | 334 GrGLenum target, |
| 330 UploadType uploadType, | 335 UploadType uploadType, |
| 331 int left, int top, int width, int height, | 336 int left, int top, int width, int height, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 358 // This must be paired with a call to unbindSurfaceFBOForCopy(). | 363 // This must be paired with a call to unbindSurfaceFBOForCopy(). |
| 359 void bindSurfaceFBOForCopy(GrSurface* surface, GrGLenum fboTarget, GrGLIRect
* viewport, | 364 void bindSurfaceFBOForCopy(GrSurface* surface, GrGLenum fboTarget, GrGLIRect
* viewport, |
| 360 TempFBOTarget tempFBOTarget); | 365 TempFBOTarget tempFBOTarget); |
| 361 | 366 |
| 362 // Must be called if bindSurfaceFBOForCopy was used to bind a surface for co
pying. | 367 // Must be called if bindSurfaceFBOForCopy was used to bind a surface for co
pying. |
| 363 void unbindTextureFBOForCopy(GrGLenum fboTarget, GrSurface* surface); | 368 void unbindTextureFBOForCopy(GrGLenum fboTarget, GrSurface* surface); |
| 364 | 369 |
| 365 SkAutoTUnref<GrGLContext> fGLContext; | 370 SkAutoTUnref<GrGLContext> fGLContext; |
| 366 | 371 |
| 367 bool createCopyProgram(int progIdx); | 372 bool createCopyProgram(int progIdx); |
| 373 bool createMipmapProgram(int progIdx); |
| 368 bool createWireRectProgram(); | 374 bool createWireRectProgram(); |
| 369 bool createPLSSetupProgram(); | 375 bool createPLSSetupProgram(); |
| 370 | 376 |
| 371 // GL program-related state | 377 // GL program-related state |
| 372 ProgramCache* fProgramCache; | 378 ProgramCache* fProgramCache; |
| 373 | 379 |
| 374 /////////////////////////////////////////////////////////////////////////// | 380 /////////////////////////////////////////////////////////////////////////// |
| 375 ///@name Caching of GL State | 381 ///@name Caching of GL State |
| 376 ///@{ | 382 ///@{ |
| 377 int fHWActiveTextureUnitIdx; | 383 int fHWActiveTextureUnitIdx; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 | 531 |
| 526 /** IDs for copy surface program. */ | 532 /** IDs for copy surface program. */ |
| 527 struct { | 533 struct { |
| 528 GrGLuint fProgram; | 534 GrGLuint fProgram; |
| 529 GrGLint fTextureUniform; | 535 GrGLint fTextureUniform; |
| 530 GrGLint fTexCoordXformUniform; | 536 GrGLint fTexCoordXformUniform; |
| 531 GrGLint fPosXformUniform; | 537 GrGLint fPosXformUniform; |
| 532 } fCopyPrograms[3]; | 538 } fCopyPrograms[3]; |
| 533 SkAutoTUnref<GrGLBuffer> fCopyProgramArrayBuffer; | 539 SkAutoTUnref<GrGLBuffer> fCopyProgramArrayBuffer; |
| 534 | 540 |
| 541 /** IDs for texture mipmap program. (4 filter configurations) */ |
| 542 struct { |
| 543 GrGLuint fProgram; |
| 544 GrGLint fTextureUniform; |
| 545 GrGLint fTexCoordXformUniform; |
| 546 } fMipmapPrograms[4]; |
| 547 SkAutoTUnref<GrGLBuffer> fMipmapProgramArrayBuffer; |
| 548 |
| 535 struct { | 549 struct { |
| 536 GrGLuint fProgram; | 550 GrGLuint fProgram; |
| 537 GrGLint fColorUniform; | 551 GrGLint fColorUniform; |
| 538 GrGLint fRectUniform; | 552 GrGLint fRectUniform; |
| 539 } fWireRectProgram; | 553 } fWireRectProgram; |
| 540 SkAutoTUnref<GrGLBuffer> fWireRectArrayBuffer; | 554 SkAutoTUnref<GrGLBuffer> fWireRectArrayBuffer; |
| 541 | 555 |
| 542 static int TextureTargetToCopyProgramIdx(GrGLenum target) { | 556 static int TextureTargetToCopyProgramIdx(GrGLenum target) { |
| 543 switch (target) { | 557 switch (target) { |
| 544 case GR_GL_TEXTURE_2D: | 558 case GR_GL_TEXTURE_2D: |
| 545 return 0; | 559 return 0; |
| 546 case GR_GL_TEXTURE_EXTERNAL: | 560 case GR_GL_TEXTURE_EXTERNAL: |
| 547 return 1; | 561 return 1; |
| 548 case GR_GL_TEXTURE_RECTANGLE: | 562 case GR_GL_TEXTURE_RECTANGLE: |
| 549 return 2; | 563 return 2; |
| 550 default: | 564 default: |
| 551 SkFAIL("Unexpected texture target type."); | 565 SkFAIL("Unexpected texture target type."); |
| 552 return 0; | 566 return 0; |
| 553 } | 567 } |
| 554 } | 568 } |
| 555 | 569 |
| 570 static int TextureSizeToMipmapProgramIdx(int width, int height) { |
| 571 const bool wide = (width > 1) && SkToBool(width & 0x1); |
| 572 const bool tall = (height > 1) && SkToBool(height & 0x1); |
| 573 return (wide ? 0x2 : 0x0) | (tall ? 0x1 : 0x0); |
| 574 } |
| 575 |
| 556 struct { | 576 struct { |
| 557 GrGLuint fProgram; | 577 GrGLuint fProgram; |
| 558 GrGLint fPosXformUniform; | 578 GrGLint fPosXformUniform; |
| 559 SkAutoTUnref<GrGLBuffer> fArrayBuffer; | 579 SkAutoTUnref<GrGLBuffer> fArrayBuffer; |
| 560 } fPLSSetupProgram; | 580 } fPLSSetupProgram; |
| 561 | 581 |
| 562 bool fHWPLSEnabled; | 582 bool fHWPLSEnabled; |
| 563 bool fPLSHasBeenUsed; | 583 bool fPLSHasBeenUsed; |
| 564 | 584 |
| 565 float fHWMinSampleShading; | 585 float fHWMinSampleShading; |
| 566 | 586 |
| 567 typedef GrGpu INHERITED; | 587 typedef GrGpu INHERITED; |
| 568 friend class GrGLPathRendering; // For accessing setTextureUnit. | 588 friend class GrGLPathRendering; // For accessing setTextureUnit. |
| 569 }; | 589 }; |
| 570 | 590 |
| 571 #endif | 591 #endif |
| OLD | NEW |