| 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 |
| 11 #include "GrGLContext.h" | 11 #include "GrGLContext.h" |
| 12 #include "GrGLIRect.h" | 12 #include "GrGLIRect.h" |
| 13 #include "GrGLIndexBuffer.h" | 13 #include "GrGLIndexBuffer.h" |
| 14 #include "GrGLPathRendering.h" | 14 #include "GrGLPathRendering.h" |
| 15 #include "GrGLProgram.h" | 15 #include "GrGLProgram.h" |
| 16 #include "GrGLRenderTarget.h" | 16 #include "GrGLRenderTarget.h" |
| 17 #include "GrGLStencilAttachment.h" | 17 #include "GrGLStencilAttachment.h" |
| 18 #include "GrGLTexture.h" | 18 #include "GrGLTexture.h" |
| 19 #include "GrGLVertexArray.h" | 19 #include "GrGLVertexArray.h" |
| 20 #include "GrGLVertexBuffer.h" | 20 #include "GrGLVertexBuffer.h" |
| 21 #include "GrGpu.h" | 21 #include "GrGpu.h" |
| 22 #include "SkMipMapLevel.h" |
| 22 #include "GrPipelineBuilder.h" | 23 #include "GrPipelineBuilder.h" |
| 24 #include "SkTArray.h" |
| 23 #include "GrXferProcessor.h" | 25 #include "GrXferProcessor.h" |
| 24 #include "SkTypes.h" | 26 #include "SkTypes.h" |
| 25 | 27 |
| 26 class GrPipeline; | 28 class GrPipeline; |
| 27 class GrNonInstancedVertices; | 29 class GrNonInstancedVertices; |
| 28 | 30 |
| 29 #ifdef SK_DEVELOPER | 31 #ifdef SK_DEVELOPER |
| 30 #define PROGRAM_CACHE_STATS | 32 #define PROGRAM_CACHE_STATS |
| 31 #endif | 33 #endif |
| 32 | 34 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 55 void discard(GrRenderTarget*) override; | 57 void discard(GrRenderTarget*) override; |
| 56 | 58 |
| 57 // Used by GrGLProgram to configure OpenGL state. | 59 // Used by GrGLProgram to configure OpenGL state. |
| 58 void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* te
xture); | 60 void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* te
xture); |
| 59 | 61 |
| 60 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, | 62 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, |
| 61 GrPixelConfig readConfig, DrawPreference*, | 63 GrPixelConfig readConfig, DrawPreference*, |
| 62 ReadPixelTempDrawInfo*) override; | 64 ReadPixelTempDrawInfo*) override; |
| 63 | 65 |
| 64 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, | 66 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, |
| 65 size_t rowBytes, GrPixelConfig srcConfig, DrawPref
erence*, | 67 GrPixelConfig srcConfig, DrawPreference*, |
| 66 WritePixelTempDrawInfo*) override; | 68 WritePixelTempDrawInfo*) override; |
| 67 | 69 |
| 68 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const
override; | 70 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const
override; |
| 69 | 71 |
| 70 // 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 |
| 71 // 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. |
| 72 void bindVertexArray(GrGLuint id) { | 74 void bindVertexArray(GrGLuint id) { |
| 73 fHWGeometryState.setVertexArrayID(this, id); | 75 fHWGeometryState.setVertexArrayID(this, id); |
| 74 } | 76 } |
| 75 void bindIndexBufferAndDefaultVertexArray(GrGLuint id) { | 77 void bindIndexBufferAndDefaultVertexArray(GrGLuint id) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 132 |
| 131 private: | 133 private: |
| 132 GrGLGpu(GrGLContext* ctx, GrContext* context); | 134 GrGLGpu(GrGLContext* ctx, GrContext* context); |
| 133 | 135 |
| 134 // GrGpu overrides | 136 // GrGpu overrides |
| 135 void onResetContext(uint32_t resetBits) override; | 137 void onResetContext(uint32_t resetBits) override; |
| 136 | 138 |
| 137 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; | 139 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; |
| 138 | 140 |
| 139 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, | 141 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, |
| 140 const void* srcData, size_t rowBytes) override; | 142 const SkTArray<SkMipMapLevel>& texels) override; |
| 141 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, | 143 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |
| 142 GrGpuResource::LifeCycle lifeCycle, | 144 GrGpuResource::LifeCycle lifeCycle, |
| 143 const void* srcData) override; | 145 const SkTArray<SkMipMapLevel>& texels)
override; |
| 146 |
| 144 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override; | 147 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override; |
| 145 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override; | 148 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override; |
| 146 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership
) override; | 149 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership
) override; |
| 147 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, | 150 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, |
| 148 GrWrapOwnership) override; | 151 GrWrapOwnership) override; |
| 149 // Given a GrPixelConfig return the index into the stencil format array on G
rGLCaps to a | 152 // Given a GrPixelConfig return the index into the stencil format array on G
rGLCaps to a |
| 150 // compatible stencil format. | 153 // compatible stencil format. |
| 151 int getCompatibleStencilIndex(GrPixelConfig config); | 154 int getCompatibleStencilIndex(GrPixelConfig config); |
| 152 | 155 |
| 153 void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) override; | 156 void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) override; |
| 154 | 157 |
| 155 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli
p) override; | 158 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli
p) override; |
| 156 | 159 |
| 157 bool onReadPixels(GrSurface*, | 160 bool onReadPixels(GrSurface*, |
| 158 int left, int top, | 161 int left, int top, |
| 159 int width, int height, | 162 int width, int height, |
| 160 GrPixelConfig, | 163 GrPixelConfig, |
| 161 void* buffer, | 164 void* buffer, |
| 162 size_t rowBytes) override; | 165 size_t rowBytes) override; |
| 163 | 166 |
| 164 bool onWritePixels(GrSurface*, | 167 bool onWritePixels(GrSurface*, |
| 165 int left, int top, int width, int height, | 168 int left, int top, int width, int height, |
| 166 GrPixelConfig config, const void* buffer, | 169 GrPixelConfig config, |
| 167 size_t rowBytes) override; | 170 const SkTArray<SkMipMapLevel>& texels) override; |
| 168 | 171 |
| 169 void onResolveRenderTarget(GrRenderTarget* target) override; | 172 void onResolveRenderTarget(GrRenderTarget* target) override; |
| 170 | 173 |
| 171 void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override; | 174 void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override; |
| 172 | 175 |
| 173 bool onCopySurface(GrSurface* dst, | 176 bool onCopySurface(GrSurface* dst, |
| 174 GrSurface* src, | 177 GrSurface* src, |
| 175 const SkIRect& srcRect, | 178 const SkIRect& srcRect, |
| 176 const SkIPoint& dstPoint) override; | 179 const SkIPoint& dstPoint) override; |
| 177 | 180 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 bool getSizedInternal, | 287 bool getSizedInternal, |
| 285 GrGLenum* internalFormat, | 288 GrGLenum* internalFormat, |
| 286 GrGLenum* externalFormat, | 289 GrGLenum* externalFormat, |
| 287 GrGLenum* externalType) const; | 290 GrGLenum* externalType) const; |
| 288 // helper for onCreateTexture and writeTexturePixels | 291 // helper for onCreateTexture and writeTexturePixels |
| 289 bool uploadTexData(const GrSurfaceDesc& desc, | 292 bool uploadTexData(const GrSurfaceDesc& desc, |
| 290 GrGLenum target, | 293 GrGLenum target, |
| 291 bool isNewTexture, | 294 bool isNewTexture, |
| 292 int left, int top, int width, int height, | 295 int left, int top, int width, int height, |
| 293 GrPixelConfig dataConfig, | 296 GrPixelConfig dataConfig, |
| 294 const void* data, | 297 const SkTArray<SkMipMapLevel>& texels); |
| 295 size_t rowBytes); | |
| 296 | 298 |
| 297 // helper for onCreateCompressedTexture. If width and height are | 299 // helper for onCreateCompressedTexture. If width and height are |
| 298 // set to -1, then this function will use desc.fWidth and desc.fHeight | 300 // set to -1, then this function will use desc.fWidth and desc.fHeight |
| 299 // for the size of the data. The isNewTexture flag should be set to true | 301 // for the size of the data. The isNewTexture flag should be set to true |
| 300 // whenever a new texture needs to be created. Otherwise, we assume that | 302 // whenever a new texture needs to be created. Otherwise, we assume that |
| 301 // the texture is already in GPU memory and that it's going to be updated | 303 // the texture is already in GPU memory and that it's going to be updated |
| 302 // with new data. | 304 // with new data. |
| 303 bool uploadCompressedTexData(const GrSurfaceDesc& desc, | 305 bool uploadCompressedTexData(const GrSurfaceDesc& desc, |
| 304 GrGLenum target, | 306 GrGLenum target, |
| 305 const void* data, | 307 const SkTArray<SkMipMapLevel>& texels, |
| 306 bool isNewTexture = true, | 308 bool isNewTexture = true, |
| 307 int left = 0, int top = 0, | 309 int left = 0, int top = 0, |
| 308 int width = -1, int height = -1); | 310 int width = -1, int height = -1); |
| 309 | 311 |
| 310 bool createRenderTargetObjects(const GrSurfaceDesc&, GrGpuResource::LifeCycl
e lifeCycle, | 312 bool createRenderTargetObjects(const GrSurfaceDesc&, GrGpuResource::LifeCycl
e lifeCycle, |
| 311 GrGLenum textureTarget, GrGLuint texID, | 313 GrGLenum textureTarget, GrGLuint texID, |
| 312 GrGLRenderTarget::IDDesc*); | 314 GrGLRenderTarget::IDDesc*); |
| 313 | 315 |
| 314 enum TempFBOTarget { | 316 enum TempFBOTarget { |
| 315 kSrc_TempFBOTarget, | 317 kSrc_TempFBOTarget, |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 | 523 |
| 522 // Mapping of pixel configs to known supported stencil formats to be used | 524 // Mapping of pixel configs to known supported stencil formats to be used |
| 523 // when adding a stencil buffer to a framebuffer. | 525 // when adding a stencil buffer to a framebuffer. |
| 524 int fPixelConfigToStencilIndex[kGrPixelConfigCnt]; | 526 int fPixelConfigToStencilIndex[kGrPixelConfigCnt]; |
| 525 | 527 |
| 526 typedef GrGpu INHERITED; | 528 typedef GrGpu INHERITED; |
| 527 friend class GrGLPathRendering; // For accessing setTextureUnit. | 529 friend class GrGLPathRendering; // For accessing setTextureUnit. |
| 528 }; | 530 }; |
| 529 | 531 |
| 530 #endif | 532 #endif |
| OLD | NEW |