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