| 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 "GrGLTransferBuffer.h" | 19 #include "GrGLTransferBuffer.h" |
| 20 #include "GrGLVertexArray.h" | 20 #include "GrGLVertexArray.h" |
| 21 #include "GrGLVertexBuffer.h" | 21 #include "GrGLVertexBuffer.h" |
| 22 #include "GrGpu.h" | 22 #include "GrGpu.h" |
| 23 #include "SkMipMapLevel.h" |
| 23 #include "GrPipelineBuilder.h" | 24 #include "GrPipelineBuilder.h" |
| 25 #include "SkTArray.h" |
| 24 #include "GrXferProcessor.h" | 26 #include "GrXferProcessor.h" |
| 25 #include "SkTypes.h" | 27 #include "SkTypes.h" |
| 26 | 28 |
| 27 class GrPipeline; | 29 class GrPipeline; |
| 28 class GrNonInstancedVertices; | 30 class GrNonInstancedVertices; |
| 29 | 31 |
| 30 #ifdef SK_DEVELOPER | 32 #ifdef SK_DEVELOPER |
| 31 #define PROGRAM_CACHE_STATS | 33 #define PROGRAM_CACHE_STATS |
| 32 #endif | 34 #endif |
| 33 | 35 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 56 void discard(GrRenderTarget*) override; | 58 void discard(GrRenderTarget*) override; |
| 57 | 59 |
| 58 // Used by GrGLProgram to configure OpenGL state. | 60 // Used by GrGLProgram to configure OpenGL state. |
| 59 void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* te
xture); | 61 void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* te
xture); |
| 60 | 62 |
| 61 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, | 63 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, |
| 62 GrPixelConfig readConfig, DrawPreference*, | 64 GrPixelConfig readConfig, DrawPreference*, |
| 63 ReadPixelTempDrawInfo*) override; | 65 ReadPixelTempDrawInfo*) override; |
| 64 | 66 |
| 65 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, | 67 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, |
| 66 size_t rowBytes, GrPixelConfig srcConfig, DrawPref
erence*, | 68 GrPixelConfig srcConfig, DrawPreference*, |
| 67 WritePixelTempDrawInfo*) override; | 69 WritePixelTempDrawInfo*) override; |
| 68 | 70 |
| 69 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const
override; | 71 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const
override; |
| 70 | 72 |
| 71 // These functions should be used to bind GL objects. They track the GL stat
e and skip redundant | 73 // These functions should be used to bind GL objects. They track the GL stat
e and skip redundant |
| 72 // bindings. Making the equivalent glBind calls directly will confuse the st
ate tracking. | 74 // bindings. Making the equivalent glBind calls directly will confuse the st
ate tracking. |
| 73 void bindVertexArray(GrGLuint id) { | 75 void bindVertexArray(GrGLuint id) { |
| 74 fHWGeometryState.setVertexArrayID(this, id); | 76 fHWGeometryState.setVertexArrayID(this, id); |
| 75 } | 77 } |
| 76 void bindIndexBufferAndDefaultVertexArray(GrGLuint id) { | 78 void bindIndexBufferAndDefaultVertexArray(GrGLuint id) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 137 |
| 136 private: | 138 private: |
| 137 GrGLGpu(GrGLContext* ctx, GrContext* context); | 139 GrGLGpu(GrGLContext* ctx, GrContext* context); |
| 138 | 140 |
| 139 // GrGpu overrides | 141 // GrGpu overrides |
| 140 void onResetContext(uint32_t resetBits) override; | 142 void onResetContext(uint32_t resetBits) override; |
| 141 | 143 |
| 142 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; | 144 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; |
| 143 | 145 |
| 144 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, | 146 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, |
| 145 const void* srcData, size_t rowBytes) override; | 147 const SkTArray<SkMipMapLevel>& texels) override; |
| 146 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, | 148 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |
| 147 GrGpuResource::LifeCycle lifeCycle, | 149 GrGpuResource::LifeCycle lifeCycle, |
| 148 const void* srcData) override; | 150 const SkTArray<SkMipMapLevel>& texels)
override; |
| 151 |
| 149 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override; | 152 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override; |
| 150 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override; | 153 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override; |
| 151 GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType type) ove
rride; | 154 GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType type) ove
rride; |
| 152 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership
) override; | 155 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership
) override; |
| 153 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, | 156 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, |
| 154 GrWrapOwnership) override; | 157 GrWrapOwnership) override; |
| 155 // Given a GrPixelConfig return the index into the stencil format array on G
rGLCaps to a | 158 // Given a GrPixelConfig return the index into the stencil format array on G
rGLCaps to a |
| 156 // compatible stencil format, or negative if there is no compatible stencil
format. | 159 // compatible stencil format, or negative if there is no compatible stencil
format. |
| 157 int getCompatibleStencilIndex(GrPixelConfig config); | 160 int getCompatibleStencilIndex(GrPixelConfig config); |
| 158 | 161 |
| 159 void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) override; | 162 void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) override; |
| 160 | 163 |
| 161 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli
p) override; | 164 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli
p) override; |
| 162 | 165 |
| 163 bool onReadPixels(GrSurface*, | 166 bool onReadPixels(GrSurface*, |
| 164 int left, int top, | 167 int left, int top, |
| 165 int width, int height, | 168 int width, int height, |
| 166 GrPixelConfig, | 169 GrPixelConfig, |
| 167 void* buffer, | 170 void* buffer, |
| 168 size_t rowBytes) override; | 171 size_t rowBytes) override; |
| 169 | 172 |
| 170 bool onWritePixels(GrSurface*, | 173 bool onWritePixels(GrSurface*, |
| 171 int left, int top, int width, int height, | 174 int left, int top, int width, int height, |
| 172 GrPixelConfig config, const void* buffer, | 175 GrPixelConfig config, |
| 173 size_t rowBytes) override; | 176 const SkTArray<SkMipMapLevel>& texels) override; |
| 174 | 177 |
| 175 bool onTransferPixels(GrSurface*, | 178 bool onTransferPixels(GrSurface*, |
| 176 int left, int top, int width, int height, | 179 int left, int top, int width, int height, |
| 177 GrPixelConfig config, GrTransferBuffer* buffer, | 180 GrPixelConfig config, GrTransferBuffer* buffer, |
| 178 size_t offset, size_t rowBytes) override; | 181 size_t offset, size_t rowBytes) override; |
| 179 | 182 |
| 180 void onResolveRenderTarget(GrRenderTarget* target) override; | 183 void onResolveRenderTarget(GrRenderTarget* target) override; |
| 181 | 184 |
| 182 void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override; | 185 void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override; |
| 183 | 186 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 enum UploadType { | 295 enum UploadType { |
| 293 kNewTexture_UploadType, // we are creating a new texture | 296 kNewTexture_UploadType, // we are creating a new texture |
| 294 kWrite_UploadType, // we are using TexSubImage2D to copy data to
an existing texture | 297 kWrite_UploadType, // we are using TexSubImage2D to copy data to
an existing texture |
| 295 kTransfer_UploadType, // we are using a transfer buffer to copy dat
a | 298 kTransfer_UploadType, // we are using a transfer buffer to copy dat
a |
| 296 }; | 299 }; |
| 297 bool uploadTexData(const GrSurfaceDesc& desc, | 300 bool uploadTexData(const GrSurfaceDesc& desc, |
| 298 GrGLenum target, | 301 GrGLenum target, |
| 299 UploadType uploadType, | 302 UploadType uploadType, |
| 300 int left, int top, int width, int height, | 303 int left, int top, int width, int height, |
| 301 GrPixelConfig dataConfig, | 304 GrPixelConfig dataConfig, |
| 302 const void* data, | 305 const SkTArray<SkMipMapLevel>& texels); |
| 303 size_t rowBytes); | |
| 304 | 306 |
| 305 // helper for onCreateCompressedTexture. If width and height are | 307 // helper for onCreateCompressedTexture. If width and height are |
| 306 // set to -1, then this function will use desc.fWidth and desc.fHeight | 308 // set to -1, then this function will use desc.fWidth and desc.fHeight |
| 307 // for the size of the data. The isNewTexture flag should be set to true | 309 // for the size of the data. The isNewTexture flag should be set to true |
| 308 // whenever a new texture needs to be created. Otherwise, we assume that | 310 // whenever a new texture needs to be created. Otherwise, we assume that |
| 309 // the texture is already in GPU memory and that it's going to be updated | 311 // the texture is already in GPU memory and that it's going to be updated |
| 310 // with new data. | 312 // with new data. |
| 311 bool uploadCompressedTexData(const GrSurfaceDesc& desc, | 313 bool uploadCompressedTexData(const GrSurfaceDesc& desc, |
| 312 GrGLenum target, | 314 GrGLenum target, |
| 313 const void* data, | 315 const SkTArray<SkMipMapLevel>& texels, |
| 316 bool isNewTexture = true, |
| 314 UploadType uploadType = kNewTexture_UploadType, | 317 UploadType uploadType = kNewTexture_UploadType, |
| 315 int left = 0, int top = 0, | 318 int left = 0, int top = 0, |
| 316 int width = -1, int height = -1); | 319 int width = -1, int height = -1); |
| 317 | 320 |
| 318 bool createRenderTargetObjects(const GrSurfaceDesc&, GrGpuResource::LifeCycl
e lifeCycle, | 321 bool createRenderTargetObjects(const GrSurfaceDesc&, GrGpuResource::LifeCycl
e lifeCycle, |
| 319 const GrGLTextureInfo& texInfo, GrGLRenderTar
get::IDDesc*); | 322 const GrGLTextureInfo& texInfo, GrGLRenderTar
get::IDDesc*); |
| 320 | 323 |
| 321 enum TempFBOTarget { | 324 enum TempFBOTarget { |
| 322 kSrc_TempFBOTarget, | 325 kSrc_TempFBOTarget, |
| 323 kDst_TempFBOTarget | 326 kDst_TempFBOTarget |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 SkASSERT(target == GR_GL_TEXTURE_EXTERNAL); | 544 SkASSERT(target == GR_GL_TEXTURE_EXTERNAL); |
| 542 return 1; | 545 return 1; |
| 543 } | 546 } |
| 544 } | 547 } |
| 545 | 548 |
| 546 typedef GrGpu INHERITED; | 549 typedef GrGpu INHERITED; |
| 547 friend class GrGLPathRendering; // For accessing setTextureUnit. | 550 friend class GrGLPathRendering; // For accessing setTextureUnit. |
| 548 }; | 551 }; |
| 549 | 552 |
| 550 #endif | 553 #endif |
| OLD | NEW |