| 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 GrGpuGL_DEFINED | 8 #ifndef GrGpuGL_DEFINED |
| 9 #define GrGpuGL_DEFINED | 9 #define GrGpuGL_DEFINED |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "GrOptDrawState.h" | 23 #include "GrOptDrawState.h" |
| 24 #include "SkTypes.h" | 24 #include "SkTypes.h" |
| 25 | 25 |
| 26 #ifdef SK_DEVELOPER | 26 #ifdef SK_DEVELOPER |
| 27 #define PROGRAM_CACHE_STATS | 27 #define PROGRAM_CACHE_STATS |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 class GrGLGpu : public GrGpu { | 30 class GrGLGpu : public GrGpu { |
| 31 public: | 31 public: |
| 32 GrGLGpu(const GrGLContext& ctx, GrContext* context); | 32 GrGLGpu(const GrGLContext& ctx, GrContext* context); |
| 33 virtual ~GrGLGpu(); | 33 ~GrGLGpu() SK_OVERRIDE; |
| 34 | 34 |
| 35 virtual void contextAbandoned() SK_OVERRIDE; | 35 void contextAbandoned() SK_OVERRIDE; |
| 36 | 36 |
| 37 const GrGLContext& glContext() const { return fGLContext; } | 37 const GrGLContext& glContext() const { return fGLContext; } |
| 38 | 38 |
| 39 const GrGLInterface* glInterface() const { return fGLContext.interface(); } | 39 const GrGLInterface* glInterface() const { return fGLContext.interface(); } |
| 40 const GrGLContextInfo& ctxInfo() const { return fGLContext; } | 40 const GrGLContextInfo& ctxInfo() const { return fGLContext; } |
| 41 GrGLStandard glStandard() const { return fGLContext.standard(); } | 41 GrGLStandard glStandard() const { return fGLContext.standard(); } |
| 42 GrGLVersion glVersion() const { return fGLContext.version(); } | 42 GrGLVersion glVersion() const { return fGLContext.version(); } |
| 43 GrGLSLGeneration glslGeneration() const { return fGLContext.glslGeneration()
; } | 43 GrGLSLGeneration glslGeneration() const { return fGLContext.glslGeneration()
; } |
| 44 const GrGLCaps& glCaps() const { return *fGLContext.caps(); } | 44 const GrGLCaps& glCaps() const { return *fGLContext.caps(); } |
| 45 | 45 |
| 46 GrGLPathRendering* glPathRendering() { | 46 GrGLPathRendering* glPathRendering() { |
| 47 SkASSERT(glCaps().pathRenderingSupport()); | 47 SkASSERT(glCaps().pathRenderingSupport()); |
| 48 return static_cast<GrGLPathRendering*>(pathRendering()); | 48 return static_cast<GrGLPathRendering*>(pathRendering()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 virtual void discard(GrRenderTarget*) SK_OVERRIDE; | 51 void discard(GrRenderTarget*) SK_OVERRIDE; |
| 52 | 52 |
| 53 // Used by GrGLProgram and GrGLPathTexGenProgramEffects to configure OpenGL | 53 // Used by GrGLProgram and GrGLPathTexGenProgramEffects to configure OpenGL |
| 54 // state. | 54 // state. |
| 55 void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* te
xture); | 55 void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* te
xture); |
| 56 | 56 |
| 57 // GrGpu overrides | 57 // GrGpu overrides |
| 58 virtual GrPixelConfig preferredReadPixelsConfig(GrPixelConfig readConfig, | 58 GrPixelConfig preferredReadPixelsConfig(GrPixelConfig readConfig, |
| 59 GrPixelConfig surfaceConfig)
const SK_OVERRIDE; | 59 GrPixelConfig surfaceConfig) const S
K_OVERRIDE; |
| 60 virtual GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig, | 60 GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig, |
| 61 GrPixelConfig surfaceConfig
) const SK_OVERRIDE; | 61 GrPixelConfig surfaceConfig) const
SK_OVERRIDE; |
| 62 virtual bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig
) const SK_OVERRIDE; | 62 bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const
SK_OVERRIDE; |
| 63 virtual bool readPixelsWillPayForYFlip( | 63 bool readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, |
| 64 GrRenderTarget* renderTarget, | 64 int left, int top, |
| 65 int left, int top, | 65 int width, int height, |
| 66 int width, int height, | 66 GrPixelConfig config, |
| 67 GrPixelConfig config, | 67 size_t rowBytes) const SK_OVERRIDE; |
| 68 size_t rowBytes) const SK_OVERRIDE; | 68 bool fullReadPixelsIsFasterThanPartial() const SK_OVERRIDE; |
| 69 virtual bool fullReadPixelsIsFasterThanPartial() const SK_OVERRIDE; | |
| 70 | 69 |
| 71 virtual bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* des
c) SK_OVERRIDE; | 70 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) SK_OV
ERRIDE; |
| 72 | 71 |
| 73 // These functions should be used to bind GL objects. They track the GL stat
e and skip redundant | 72 // These functions should be used to bind GL objects. They track the GL stat
e and skip redundant |
| 74 // bindings. Making the equivalent glBind calls directly will confuse the st
ate tracking. | 73 // bindings. Making the equivalent glBind calls directly will confuse the st
ate tracking. |
| 75 void bindVertexArray(GrGLuint id) { | 74 void bindVertexArray(GrGLuint id) { |
| 76 fHWGeometryState.setVertexArrayID(this, id); | 75 fHWGeometryState.setVertexArrayID(this, id); |
| 77 } | 76 } |
| 78 void bindIndexBufferAndDefaultVertexArray(GrGLuint id) { | 77 void bindIndexBufferAndDefaultVertexArray(GrGLuint id) { |
| 79 fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, id); | 78 fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, id); |
| 80 } | 79 } |
| 81 void bindVertexBuffer(GrGLuint id) { | 80 void bindVertexBuffer(GrGLuint id) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 98 GrSurface* src, | 97 GrSurface* src, |
| 99 const SkIRect& srcRect, | 98 const SkIRect& srcRect, |
| 100 const SkIPoint& dstPoint) SK_OVERRIDE; | 99 const SkIPoint& dstPoint) SK_OVERRIDE; |
| 101 | 100 |
| 102 bool canCopySurface(const GrSurface* dst, | 101 bool canCopySurface(const GrSurface* dst, |
| 103 const GrSurface* src, | 102 const GrSurface* src, |
| 104 const SkIRect& srcRect, | 103 const SkIRect& srcRect, |
| 105 const SkIPoint& dstPoint) SK_OVERRIDE; | 104 const SkIPoint& dstPoint) SK_OVERRIDE; |
| 106 | 105 |
| 107 protected: | 106 protected: |
| 108 virtual void buildProgramDesc(const GrOptDrawState&, | 107 void buildProgramDesc(const GrOptDrawState&, |
| 109 const GrProgramDesc::DescInfo&, | 108 const GrProgramDesc::DescInfo&, |
| 110 GrGpu::DrawType, | 109 GrGpu::DrawType, |
| 111 GrProgramDesc*) SK_OVERRIDE; | 110 GrProgramDesc*) SK_OVERRIDE; |
| 112 | 111 |
| 113 private: | 112 private: |
| 114 // GrGpu overrides | 113 // GrGpu overrides |
| 115 virtual void onResetContext(uint32_t resetBits) SK_OVERRIDE; | 114 void onResetContext(uint32_t resetBits) SK_OVERRIDE; |
| 116 | 115 |
| 117 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc, | 116 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, |
| 118 const void* srcData, | 117 const void* srcData, |
| 119 size_t rowBytes) SK_OVERRIDE; | 118 size_t rowBytes) SK_OVERRIDE; |
| 120 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, | 119 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |
| 121 const void* srcData) SK_OVERRID
E; | 120 const void* srcData) SK_OVERRIDE; |
| 122 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_O
VERRIDE; | 121 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_OVERRIDE; |
| 123 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) SK_OVE
RRIDE; | 122 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) SK_OVERRIDE; |
| 124 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) SK_OVER
RIDE; | 123 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) SK_OVERRIDE; |
| 125 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) SK_OVERRIDE; | 124 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&)
SK_OVERRIDE; |
| 126 virtual bool createStencilBufferForRenderTarget(GrRenderTarget* rt, | 125 bool createStencilBufferForRenderTarget(GrRenderTarget* rt, |
| 127 int width, | 126 int width, int height) SK_OVERRIDE; |
| 128 int height) SK_OVERRIDE; | 127 bool attachStencilBufferToRenderTarget(GrStencilBuffer* sb, GrRenderTarget*
rt) SK_OVERRIDE; |
| 129 virtual bool attachStencilBufferToRenderTarget( | |
| 130 GrStencilBuffer* sb, | |
| 131 GrRenderTarget* rt) SK_OVERRIDE; | |
| 132 | 128 |
| 133 virtual void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, | 129 void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, |
| 134 bool canIgnoreRect) SK_OVERRIDE; | 130 bool canIgnoreRect) SK_OVERRIDE; |
| 135 | 131 |
| 136 virtual void onClearStencilClip(GrRenderTarget*, | 132 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli
p) SK_OVERRIDE; |
| 137 const SkIRect& rect, | |
| 138 bool insideClip) SK_OVERRIDE; | |
| 139 | 133 |
| 140 virtual bool onReadPixels(GrRenderTarget* target, | 134 bool onReadPixels(GrRenderTarget* target, |
| 141 int left, int top, | 135 int left, int top, |
| 142 int width, int height, | 136 int width, int height, |
| 143 GrPixelConfig, | 137 GrPixelConfig, |
| 144 void* buffer, | 138 void* buffer, |
| 139 size_t rowBytes) SK_OVERRIDE; |
| 140 |
| 141 bool onWriteTexturePixels(GrTexture* texture, |
| 142 int left, int top, int width, int height, |
| 143 GrPixelConfig config, const void* buffer, |
| 145 size_t rowBytes) SK_OVERRIDE; | 144 size_t rowBytes) SK_OVERRIDE; |
| 146 | 145 |
| 147 virtual bool onWriteTexturePixels(GrTexture* texture, | 146 void onResolveRenderTarget(GrRenderTarget* target) SK_OVERRIDE; |
| 148 int left, int top, int width, int height, | |
| 149 GrPixelConfig config, const void* buffer, | |
| 150 size_t rowBytes) SK_OVERRIDE; | |
| 151 | 147 |
| 152 virtual void onResolveRenderTarget(GrRenderTarget* target) SK_OVERRIDE; | 148 void onDraw(const GrOptDrawState&, const GrDrawTarget::DrawInfo&) SK_OVERRID
E; |
| 149 void onStencilPath(const GrOptDrawState&, const GrPath*, const GrStencilSett
ings&) SK_OVERRIDE; |
| 150 void onDrawPath(const GrOptDrawState&, const GrPath*, const GrStencilSetting
s&) SK_OVERRIDE; |
| 151 void onDrawPaths(const GrOptDrawState&, |
| 152 const GrPathRange*, |
| 153 const void* indices, |
| 154 GrDrawTarget::PathIndexType, |
| 155 const float transformValues[], |
| 156 GrDrawTarget::PathTransformType, |
| 157 int count, |
| 158 const GrStencilSettings&) SK_OVERRIDE; |
| 153 | 159 |
| 154 virtual void onDraw(const GrOptDrawState&, const GrDrawTarget::DrawInfo&) SK
_OVERRIDE; | 160 void clearStencil(GrRenderTarget*) SK_OVERRIDE; |
| 155 | |
| 156 | |
| 157 virtual void clearStencil(GrRenderTarget*) SK_OVERRIDE; | |
| 158 virtual bool flushGraphicsState(const GrOptDrawState&) SK_OVERRIDE; | |
| 159 | 161 |
| 160 // GrDrawTarget overrides | 162 // GrDrawTarget overrides |
| 161 virtual void didAddGpuTraceMarker() SK_OVERRIDE; | 163 void didAddGpuTraceMarker() SK_OVERRIDE; |
| 162 virtual void didRemoveGpuTraceMarker() SK_OVERRIDE; | 164 void didRemoveGpuTraceMarker() SK_OVERRIDE; |
| 163 | 165 |
| 164 // binds texture unit in GL | 166 // binds texture unit in GL |
| 165 void setTextureUnit(int unitIdx); | 167 void setTextureUnit(int unitIdx); |
| 166 | 168 |
| 169 // Flushes state from GrOptDrawState to GL. Returns false if the state could
n't be set. |
| 170 bool flushGLState(const GrOptDrawState&); |
| 171 |
| 167 // Sets up vertex attribute pointers and strides. On return indexOffsetInByt
es gives the offset | 172 // Sets up vertex attribute pointers and strides. On return indexOffsetInByt
es gives the offset |
| 168 // an into the index buffer. It does not account for drawInfo.startIndex() b
ut rather the start | 173 // an into the index buffer. It does not account for drawInfo.startIndex() b
ut rather the start |
| 169 // index is relative to the returned offset. | 174 // index is relative to the returned offset. |
| 170 void setupGeometry(const GrOptDrawState&, | 175 void setupGeometry(const GrOptDrawState&, |
| 171 const GrDrawTarget::DrawInfo& info, | 176 const GrDrawTarget::DrawInfo& info, |
| 172 size_t* indexOffsetInBytes); | 177 size_t* indexOffsetInBytes); |
| 173 | 178 |
| 174 // Subclasses should call this to flush the blend state. | 179 // Subclasses should call this to flush the blend state. |
| 175 void flushBlend(const GrOptDrawState& optState); | 180 void flushBlend(const GrOptDrawState& optState); |
| 176 | 181 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 | 449 |
| 445 // we record what stencil format worked last time to hopefully exit early | 450 // we record what stencil format worked last time to hopefully exit early |
| 446 // from our loop that tries stencil formats and calls check fb status. | 451 // from our loop that tries stencil formats and calls check fb status. |
| 447 int fLastSuccessfulStencilFmtIdx; | 452 int fLastSuccessfulStencilFmtIdx; |
| 448 | 453 |
| 449 typedef GrGpu INHERITED; | 454 typedef GrGpu INHERITED; |
| 450 friend class GrGLPathRendering; // For accessing setTextureUnit. | 455 friend class GrGLPathRendering; // For accessing setTextureUnit. |
| 451 }; | 456 }; |
| 452 | 457 |
| 453 #endif | 458 #endif |
| OLD | NEW |