| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 class GrPipeline; | 26 class GrPipeline; |
| 27 class GrNonInstancedVertices; | 27 class GrNonInstancedVertices; |
| 28 | 28 |
| 29 #ifdef SK_DEVELOPER | 29 #ifdef SK_DEVELOPER |
| 30 #define PROGRAM_CACHE_STATS | 30 #define PROGRAM_CACHE_STATS |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 class GrGLGpu : public GrGpu { | 33 class GrGLGpu : public GrGpu { |
| 34 public: | 34 public: |
| 35 GrGLGpu(const GrGLContext& ctx, GrContext* context); | 35 static GrGpu* Create(GrBackendContext backendContext, GrContext* context); |
| 36 ~GrGLGpu() override; | 36 ~GrGLGpu() override; |
| 37 | 37 |
| 38 void contextAbandoned() override; | 38 void contextAbandoned() override; |
| 39 | 39 |
| 40 const GrGLContext& glContext() const { return fGLContext; } | 40 const GrGLContext& glContext() const { return *fGLContext; } |
| 41 | 41 |
| 42 const GrGLInterface* glInterface() const { return fGLContext.interface(); } | 42 const GrGLInterface* glInterface() const { return fGLContext->interface(); } |
| 43 const GrGLContextInfo& ctxInfo() const { return fGLContext; } | 43 const GrGLContextInfo& ctxInfo() const { return *fGLContext; } |
| 44 GrGLStandard glStandard() const { return fGLContext.standard(); } | 44 GrGLStandard glStandard() const { return fGLContext->standard(); } |
| 45 GrGLVersion glVersion() const { return fGLContext.version(); } | 45 GrGLVersion glVersion() const { return fGLContext->version(); } |
| 46 GrGLSLGeneration glslGeneration() const { return fGLContext.glslGeneration()
; } | 46 GrGLSLGeneration glslGeneration() const { return fGLContext->glslGeneration(
); } |
| 47 const GrGLCaps& glCaps() const { return *fGLContext.caps(); } | 47 const GrGLCaps& glCaps() const { return *fGLContext->caps(); } |
| 48 | 48 |
| 49 GrGLPathRendering* glPathRendering() { | 49 GrGLPathRendering* glPathRendering() { |
| 50 SkASSERT(glCaps().shaderCaps()->pathRenderingSupport()); | 50 SkASSERT(glCaps().shaderCaps()->pathRenderingSupport()); |
| 51 return static_cast<GrGLPathRendering*>(pathRendering()); | 51 return static_cast<GrGLPathRendering*>(pathRendering()); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void discard(GrRenderTarget*) override; | 54 void discard(GrRenderTarget*) override; |
| 55 | 55 |
| 56 // Used by GrGLProgram and GrGLPathTexGenProgramEffects to configure OpenGL | 56 // Used by GrGLProgram and GrGLPathTexGenProgramEffects to configure OpenGL |
| 57 // state. | 57 // state. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 const SkIPoint& dstPoint) override; | 107 const SkIPoint& dstPoint) override; |
| 108 | 108 |
| 109 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; | 109 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; |
| 110 | 110 |
| 111 void buildProgramDesc(GrProgramDesc*, | 111 void buildProgramDesc(GrProgramDesc*, |
| 112 const GrPrimitiveProcessor&, | 112 const GrPrimitiveProcessor&, |
| 113 const GrPipeline&, | 113 const GrPipeline&, |
| 114 const GrBatchTracker&) const override; | 114 const GrBatchTracker&) const override; |
| 115 | 115 |
| 116 private: | 116 private: |
| 117 GrGLGpu(GrGLContext* ctx, GrContext* context); |
| 118 |
| 117 // GrGpu overrides | 119 // GrGpu overrides |
| 118 void onResetContext(uint32_t resetBits) override; | 120 void onResetContext(uint32_t resetBits) override; |
| 119 | 121 |
| 120 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, | 122 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, |
| 121 const void* srcData, size_t rowBytes) override; | 123 const void* srcData, size_t rowBytes) override; |
| 122 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, | 124 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |
| 123 GrGpuResource::LifeCycle lifeCycle, | 125 GrGpuResource::LifeCycle lifeCycle, |
| 124 const void* srcData) override; | 126 const void* srcData) override; |
| 125 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override; | 127 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override; |
| 126 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override; | 128 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // Sets up vertex attribute pointers and strides. On return indexOffsetInByt
es gives the offset | 178 // Sets up vertex attribute pointers and strides. On return indexOffsetInByt
es gives the offset |
| 177 // an into the index buffer. It does not account for vertices.startIndex() b
ut rather the start | 179 // an into the index buffer. It does not account for vertices.startIndex() b
ut rather the start |
| 178 // index is relative to the returned offset. | 180 // index is relative to the returned offset. |
| 179 void setupGeometry(const GrPrimitiveProcessor&, | 181 void setupGeometry(const GrPrimitiveProcessor&, |
| 180 const GrNonInstancedVertices& vertices, | 182 const GrNonInstancedVertices& vertices, |
| 181 size_t* indexOffsetInBytes); | 183 size_t* indexOffsetInBytes); |
| 182 | 184 |
| 183 // Subclasses should call this to flush the blend state. | 185 // Subclasses should call this to flush the blend state. |
| 184 void flushBlend(const GrXferProcessor::BlendInfo& blendInfo); | 186 void flushBlend(const GrXferProcessor::BlendInfo& blendInfo); |
| 185 | 187 |
| 186 bool hasExtension(const char* ext) const { return fGLContext.hasExtension(ex
t); } | 188 bool hasExtension(const char* ext) const { return fGLContext->hasExtension(e
xt); } |
| 187 | 189 |
| 188 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); | 190 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); |
| 189 | 191 |
| 190 class ProgramCache : public ::SkNoncopyable { | 192 class ProgramCache : public ::SkNoncopyable { |
| 191 public: | 193 public: |
| 192 ProgramCache(GrGLGpu* gpu); | 194 ProgramCache(GrGLGpu* gpu); |
| 193 ~ProgramCache(); | 195 ~ProgramCache(); |
| 194 | 196 |
| 195 void abandon(); | 197 void abandon(); |
| 196 GrGLProgram* getProgram(const DrawArgs&); | 198 GrGLProgram* getProgram(const DrawArgs&); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 enum TempFBOTarget { | 289 enum TempFBOTarget { |
| 288 kSrc_TempFBOTarget, | 290 kSrc_TempFBOTarget, |
| 289 kDst_TempFBOTarget | 291 kDst_TempFBOTarget |
| 290 }; | 292 }; |
| 291 | 293 |
| 292 GrGLuint bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLIRect*
viewport, | 294 GrGLuint bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLIRect*
viewport, |
| 293 TempFBOTarget tempFBOTarget); | 295 TempFBOTarget tempFBOTarget); |
| 294 | 296 |
| 295 void unbindTextureFromFBO(GrGLenum fboTarget); | 297 void unbindTextureFromFBO(GrGLenum fboTarget); |
| 296 | 298 |
| 297 GrGLContext fGLContext; | 299 SkAutoTDelete<GrGLContext> fGLContext; |
| 298 | 300 |
| 299 // GL program-related state | 301 // GL program-related state |
| 300 ProgramCache* fProgramCache; | 302 ProgramCache* fProgramCache; |
| 301 SkAutoTUnref<GrGLProgram> fCurrentProgram; | 303 SkAutoTUnref<GrGLProgram> fCurrentProgram; |
| 302 | 304 |
| 303 /////////////////////////////////////////////////////////////////////////// | 305 /////////////////////////////////////////////////////////////////////////// |
| 304 ///@name Caching of GL State | 306 ///@name Caching of GL State |
| 305 ///@{ | 307 ///@{ |
| 306 int fHWActiveTextureUnitIdx; | 308 int fHWActiveTextureUnitIdx; |
| 307 GrGLuint fHWProgramID; | 309 GrGLuint fHWProgramID; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 320 // last scissor / viewport scissor state seen by the GL. | 322 // last scissor / viewport scissor state seen by the GL. |
| 321 struct { | 323 struct { |
| 322 TriState fEnabled; | 324 TriState fEnabled; |
| 323 GrGLIRect fRect; | 325 GrGLIRect fRect; |
| 324 void invalidate() { | 326 void invalidate() { |
| 325 fEnabled = kUnknown_TriState; | 327 fEnabled = kUnknown_TriState; |
| 326 fRect.invalidate(); | 328 fRect.invalidate(); |
| 327 } | 329 } |
| 328 } fHWScissorSettings; | 330 } fHWScissorSettings; |
| 329 | 331 |
| 330 GrGLIRect fHWViewport; | 332 GrGLIRect fHWViewport; |
| 331 | 333 |
| 332 /** | 334 /** |
| 333 * Tracks bound vertex and index buffers and vertex attrib array state. | 335 * Tracks bound vertex and index buffers and vertex attrib array state. |
| 334 */ | 336 */ |
| 335 class HWGeometryState { | 337 class HWGeometryState { |
| 336 public: | 338 public: |
| 337 HWGeometryState() { fVBOVertexArray = NULL; this->invalidate(); } | 339 HWGeometryState() { fVBOVertexArray = NULL; this->invalidate(); } |
| 338 | 340 |
| 339 ~HWGeometryState() { SkDELETE(fVBOVertexArray); } | 341 ~HWGeometryState() { SkDELETE(fVBOVertexArray); } |
| 340 | 342 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 472 |
| 471 // we record what stencil format worked last time to hopefully exit early | 473 // we record what stencil format worked last time to hopefully exit early |
| 472 // from our loop that tries stencil formats and calls check fb status. | 474 // from our loop that tries stencil formats and calls check fb status. |
| 473 int fLastSuccessfulStencilFmtIdx; | 475 int fLastSuccessfulStencilFmtIdx; |
| 474 | 476 |
| 475 typedef GrGpu INHERITED; | 477 typedef GrGpu INHERITED; |
| 476 friend class GrGLPathRendering; // For accessing setTextureUnit. | 478 friend class GrGLPathRendering; // For accessing setTextureUnit. |
| 477 }; | 479 }; |
| 478 | 480 |
| 479 #endif | 481 #endif |
| OLD | NEW |