| 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 | 27 |
| 28 #ifdef SK_DEVELOPER | 28 #ifdef SK_DEVELOPER |
| 29 #define PROGRAM_CACHE_STATS | 29 #define PROGRAM_CACHE_STATS |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 class GrGLGpu : public GrGpu { | 32 class GrGLGpu : public GrGpu { |
| 33 public: | 33 public: |
| 34 GrGLGpu(const GrGLContext& ctx, GrContext* context); | 34 GrGLGpu(const GrGLContext& ctx, GrContext* context); |
| 35 ~GrGLGpu() SK_OVERRIDE; | 35 ~GrGLGpu() override; |
| 36 | 36 |
| 37 void contextAbandoned() SK_OVERRIDE; | 37 void contextAbandoned() override; |
| 38 | 38 |
| 39 const GrGLContext& glContext() const { return fGLContext; } | 39 const GrGLContext& glContext() const { return fGLContext; } |
| 40 | 40 |
| 41 const GrGLInterface* glInterface() const { return fGLContext.interface(); } | 41 const GrGLInterface* glInterface() const { return fGLContext.interface(); } |
| 42 const GrGLContextInfo& ctxInfo() const { return fGLContext; } | 42 const GrGLContextInfo& ctxInfo() const { return fGLContext; } |
| 43 GrGLStandard glStandard() const { return fGLContext.standard(); } | 43 GrGLStandard glStandard() const { return fGLContext.standard(); } |
| 44 GrGLVersion glVersion() const { return fGLContext.version(); } | 44 GrGLVersion glVersion() const { return fGLContext.version(); } |
| 45 GrGLSLGeneration glslGeneration() const { return fGLContext.glslGeneration()
; } | 45 GrGLSLGeneration glslGeneration() const { return fGLContext.glslGeneration()
; } |
| 46 const GrGLCaps& glCaps() const { return *fGLContext.caps(); } | 46 const GrGLCaps& glCaps() const { return *fGLContext.caps(); } |
| 47 | 47 |
| 48 GrGLPathRendering* glPathRendering() { | 48 GrGLPathRendering* glPathRendering() { |
| 49 SkASSERT(glCaps().pathRenderingSupport()); | 49 SkASSERT(glCaps().pathRenderingSupport()); |
| 50 return static_cast<GrGLPathRendering*>(pathRendering()); | 50 return static_cast<GrGLPathRendering*>(pathRendering()); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void discard(GrRenderTarget*) SK_OVERRIDE; | 53 void discard(GrRenderTarget*) override; |
| 54 | 54 |
| 55 // Used by GrGLProgram and GrGLPathTexGenProgramEffects to configure OpenGL | 55 // Used by GrGLProgram and GrGLPathTexGenProgramEffects to configure OpenGL |
| 56 // state. | 56 // state. |
| 57 void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* te
xture); | 57 void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* te
xture); |
| 58 | 58 |
| 59 // GrGpu overrides | 59 // GrGpu overrides |
| 60 GrPixelConfig preferredReadPixelsConfig(GrPixelConfig readConfig, | 60 GrPixelConfig preferredReadPixelsConfig(GrPixelConfig readConfig, |
| 61 GrPixelConfig surfaceConfig) const S
K_OVERRIDE; | 61 GrPixelConfig surfaceConfig) const o
verride; |
| 62 GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig, | 62 GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig, |
| 63 GrPixelConfig surfaceConfig) const
SK_OVERRIDE; | 63 GrPixelConfig surfaceConfig) const
override; |
| 64 bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const
SK_OVERRIDE; | 64 bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const
override; |
| 65 bool readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, | 65 bool readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, |
| 66 int left, int top, | 66 int left, int top, |
| 67 int width, int height, | 67 int width, int height, |
| 68 GrPixelConfig config, | 68 GrPixelConfig config, |
| 69 size_t rowBytes) const SK_OVERRIDE; | 69 size_t rowBytes) const override; |
| 70 bool fullReadPixelsIsFasterThanPartial() const SK_OVERRIDE; | 70 bool fullReadPixelsIsFasterThanPartial() const override; |
| 71 | 71 |
| 72 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) SK_OV
ERRIDE; | 72 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) overr
ide; |
| 73 | 73 |
| 74 // These functions should be used to bind GL objects. They track the GL stat
e and skip redundant | 74 // These functions should be used to bind GL objects. They track the GL stat
e and skip redundant |
| 75 // bindings. Making the equivalent glBind calls directly will confuse the st
ate tracking. | 75 // bindings. Making the equivalent glBind calls directly will confuse the st
ate tracking. |
| 76 void bindVertexArray(GrGLuint id) { | 76 void bindVertexArray(GrGLuint id) { |
| 77 fHWGeometryState.setVertexArrayID(this, id); | 77 fHWGeometryState.setVertexArrayID(this, id); |
| 78 } | 78 } |
| 79 void bindIndexBufferAndDefaultVertexArray(GrGLuint id) { | 79 void bindIndexBufferAndDefaultVertexArray(GrGLuint id) { |
| 80 fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, id); | 80 fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, id); |
| 81 } | 81 } |
| 82 void bindVertexBuffer(GrGLuint id) { | 82 void bindVertexBuffer(GrGLuint id) { |
| 83 fHWGeometryState.setVertexBufferID(this, id); | 83 fHWGeometryState.setVertexBufferID(this, id); |
| 84 } | 84 } |
| 85 | 85 |
| 86 // These callbacks update state tracking when GL objects are deleted. They a
re called from | 86 // These callbacks update state tracking when GL objects are deleted. They a
re called from |
| 87 // GrGLResource onRelease functions. | 87 // GrGLResource onRelease functions. |
| 88 void notifyVertexArrayDelete(GrGLuint id) { | 88 void notifyVertexArrayDelete(GrGLuint id) { |
| 89 fHWGeometryState.notifyVertexArrayDelete(id); | 89 fHWGeometryState.notifyVertexArrayDelete(id); |
| 90 } | 90 } |
| 91 void notifyVertexBufferDelete(GrGLuint id) { | 91 void notifyVertexBufferDelete(GrGLuint id) { |
| 92 fHWGeometryState.notifyVertexBufferDelete(id); | 92 fHWGeometryState.notifyVertexBufferDelete(id); |
| 93 } | 93 } |
| 94 void notifyIndexBufferDelete(GrGLuint id) { | 94 void notifyIndexBufferDelete(GrGLuint id) { |
| 95 fHWGeometryState.notifyIndexBufferDelete(id); | 95 fHWGeometryState.notifyIndexBufferDelete(id); |
| 96 } | 96 } |
| 97 | 97 |
| 98 bool copySurface(GrSurface* dst, | 98 bool copySurface(GrSurface* dst, |
| 99 GrSurface* src, | 99 GrSurface* src, |
| 100 const SkIRect& srcRect, | 100 const SkIRect& srcRect, |
| 101 const SkIPoint& dstPoint) SK_OVERRIDE; | 101 const SkIPoint& dstPoint) override; |
| 102 | 102 |
| 103 bool canCopySurface(const GrSurface* dst, | 103 bool canCopySurface(const GrSurface* dst, |
| 104 const GrSurface* src, | 104 const GrSurface* src, |
| 105 const SkIRect& srcRect, | 105 const SkIRect& srcRect, |
| 106 const SkIPoint& dstPoint) SK_OVERRIDE; | 106 const SkIPoint& dstPoint) override; |
| 107 | 107 |
| 108 void buildProgramDesc(GrProgramDesc*, | 108 void buildProgramDesc(GrProgramDesc*, |
| 109 const GrPrimitiveProcessor&, | 109 const GrPrimitiveProcessor&, |
| 110 const GrPipeline&, | 110 const GrPipeline&, |
| 111 const GrBatchTracker&) const SK_OVERRIDE; | 111 const GrBatchTracker&) const override; |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 // GrGpu overrides | 114 // GrGpu overrides |
| 115 void onResetContext(uint32_t resetBits) SK_OVERRIDE; | 115 void onResetContext(uint32_t resetBits) override; |
| 116 | 116 |
| 117 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, bool budgeted, const v
oid* srcData, | 117 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, bool budgeted, const v
oid* srcData, |
| 118 size_t rowBytes) SK_OVERRIDE; | 118 size_t rowBytes) override; |
| 119 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, bool budgete
d, | 119 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, bool budgete
d, |
| 120 const void* srcData) SK_OVERRIDE; | 120 const void* srcData) override; |
| 121 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_OVERRIDE; | 121 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override; |
| 122 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) SK_OVERRIDE; | 122 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override; |
| 123 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) SK_OVERRIDE; | 123 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) override; |
| 124 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&)
SK_OVERRIDE; | 124 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&)
override; |
| 125 bool createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, int h
eight) SK_OVERRIDE; | 125 bool createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, int h
eight) override; |
| 126 bool attachStencilBufferToRenderTarget(GrStencilBuffer* sb, GrRenderTarget*
rt) SK_OVERRIDE; | 126 bool attachStencilBufferToRenderTarget(GrStencilBuffer* sb, GrRenderTarget*
rt) override; |
| 127 | 127 |
| 128 void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, | 128 void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, |
| 129 bool canIgnoreRect) SK_OVERRIDE; | 129 bool canIgnoreRect) override; |
| 130 | 130 |
| 131 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli
p) SK_OVERRIDE; | 131 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli
p) override; |
| 132 | 132 |
| 133 bool onReadPixels(GrRenderTarget* target, | 133 bool onReadPixels(GrRenderTarget* target, |
| 134 int left, int top, | 134 int left, int top, |
| 135 int width, int height, | 135 int width, int height, |
| 136 GrPixelConfig, | 136 GrPixelConfig, |
| 137 void* buffer, | 137 void* buffer, |
| 138 size_t rowBytes) SK_OVERRIDE; | 138 size_t rowBytes) override; |
| 139 | 139 |
| 140 bool onWriteTexturePixels(GrTexture* texture, | 140 bool onWriteTexturePixels(GrTexture* texture, |
| 141 int left, int top, int width, int height, | 141 int left, int top, int width, int height, |
| 142 GrPixelConfig config, const void* buffer, | 142 GrPixelConfig config, const void* buffer, |
| 143 size_t rowBytes) SK_OVERRIDE; | 143 size_t rowBytes) override; |
| 144 | 144 |
| 145 void onResolveRenderTarget(GrRenderTarget* target) SK_OVERRIDE; | 145 void onResolveRenderTarget(GrRenderTarget* target) override; |
| 146 | 146 |
| 147 void onDraw(const DrawArgs&, const GrDrawTarget::DrawInfo&) SK_OVERRIDE; | 147 void onDraw(const DrawArgs&, const GrDrawTarget::DrawInfo&) override; |
| 148 void onStencilPath(const GrPath*, const StencilPathState&) SK_OVERRIDE; | 148 void onStencilPath(const GrPath*, const StencilPathState&) override; |
| 149 void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&) SK
_OVERRIDE; | 149 void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&) ov
erride; |
| 150 void onDrawPaths(const DrawArgs&, | 150 void onDrawPaths(const DrawArgs&, |
| 151 const GrPathRange*, | 151 const GrPathRange*, |
| 152 const void* indices, | 152 const void* indices, |
| 153 GrDrawTarget::PathIndexType, | 153 GrDrawTarget::PathIndexType, |
| 154 const float transformValues[], | 154 const float transformValues[], |
| 155 GrDrawTarget::PathTransformType, | 155 GrDrawTarget::PathTransformType, |
| 156 int count, | 156 int count, |
| 157 const GrStencilSettings&) SK_OVERRIDE; | 157 const GrStencilSettings&) override; |
| 158 | 158 |
| 159 void clearStencil(GrRenderTarget*) SK_OVERRIDE; | 159 void clearStencil(GrRenderTarget*) override; |
| 160 | 160 |
| 161 // GrDrawTarget overrides | 161 // GrDrawTarget overrides |
| 162 void didAddGpuTraceMarker() SK_OVERRIDE; | 162 void didAddGpuTraceMarker() override; |
| 163 void didRemoveGpuTraceMarker() SK_OVERRIDE; | 163 void didRemoveGpuTraceMarker() override; |
| 164 | 164 |
| 165 // binds texture unit in GL | 165 // binds texture unit in GL |
| 166 void setTextureUnit(int unitIdx); | 166 void setTextureUnit(int unitIdx); |
| 167 | 167 |
| 168 // Flushes state from GrPipeline to GL. Returns false if the state couldn't
be set. | 168 // Flushes state from GrPipeline to GL. Returns false if the state couldn't
be set. |
| 169 bool flushGLState(const DrawArgs&); | 169 bool flushGLState(const DrawArgs&); |
| 170 | 170 |
| 171 // Sets up vertex attribute pointers and strides. On return indexOffsetInByt
es gives the offset | 171 // 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 drawInfo.startIndex() b
ut rather the start | 172 // an into the index buffer. It does not account for drawInfo.startIndex() b
ut rather the start |
| 173 // index is relative to the returned offset. | 173 // index is relative to the returned offset. |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 | 463 |
| 464 // we record what stencil format worked last time to hopefully exit early | 464 // we record what stencil format worked last time to hopefully exit early |
| 465 // from our loop that tries stencil formats and calls check fb status. | 465 // from our loop that tries stencil formats and calls check fb status. |
| 466 int fLastSuccessfulStencilFmtIdx; | 466 int fLastSuccessfulStencilFmtIdx; |
| 467 | 467 |
| 468 typedef GrGpu INHERITED; | 468 typedef GrGpu INHERITED; |
| 469 friend class GrGLPathRendering; // For accessing setTextureUnit. | 469 friend class GrGLPathRendering; // For accessing setTextureUnit. |
| 470 }; | 470 }; |
| 471 | 471 |
| 472 #endif | 472 #endif |
| OLD | NEW |