| 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 "GrPipelineBuilder.h" | 23 #include "GrPipelineBuilder.h" |
| 24 #include "GrTypes.h" |
| 24 #include "GrXferProcessor.h" | 25 #include "GrXferProcessor.h" |
| 26 #include "SkTArray.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 |
| 34 | 36 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 140 |
| 139 private: | 141 private: |
| 140 GrGLGpu(GrGLContext* ctx, GrContext* context); | 142 GrGLGpu(GrGLContext* ctx, GrContext* context); |
| 141 | 143 |
| 142 // GrGpu overrides | 144 // GrGpu overrides |
| 143 void onResetContext(uint32_t resetBits) override; | 145 void onResetContext(uint32_t resetBits) override; |
| 144 | 146 |
| 145 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; | 147 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; |
| 146 | 148 |
| 147 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, | 149 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, |
| 148 const void* srcData, size_t rowBytes) override; | 150 const SkTArray<GrMipLevel>& texels) override; |
| 149 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, | 151 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |
| 150 GrGpuResource::LifeCycle lifeCycle, | 152 GrGpuResource::LifeCycle lifeCycle, |
| 151 const void* srcData) override; | 153 const SkTArray<GrMipLevel>& texels) ove
rride; |
| 154 |
| 152 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override; | 155 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override; |
| 153 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override; | 156 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override; |
| 154 GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType type) ove
rride; | 157 GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType type) ove
rride; |
| 155 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership
) override; | 158 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership
) override; |
| 156 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, | 159 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, |
| 157 GrWrapOwnership) override; | 160 GrWrapOwnership) override; |
| 158 GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDes
c&, | 161 GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDes
c&, |
| 159 GrWrapOwnership) override
; | 162 GrWrapOwnership) override
; |
| 160 // Given a GrPixelConfig return the index into the stencil format array on G
rGLCaps to a | 163 // Given a GrPixelConfig return the index into the stencil format array on G
rGLCaps to a |
| 161 // compatible stencil format, or negative if there is no compatible stencil
format. | 164 // compatible stencil format, or negative if there is no compatible stencil
format. |
| 162 int getCompatibleStencilIndex(GrPixelConfig config); | 165 int getCompatibleStencilIndex(GrPixelConfig config); |
| 163 | 166 |
| 164 // If |desc.fTextureStorageAllocator| exists, use that to create the | 167 // If |desc.fTextureStorageAllocator| exists, use that to create the |
| 165 // texture. Otherwise, create the texture directly. | 168 // texture. Otherwise, create the texture directly. |
| 166 // Returns whether the texture is successfully created. On success, the | 169 // Returns whether the texture is successfully created. On success, the |
| 167 // result is stored in |info|. | 170 // result is stored in |info|. |
| 168 // The texture is populated with |srcData|, if it exists. | 171 // The texture is populated with |texels|, if it exists. |
| 169 // The texture parameters are cached in |initialTexParams|. | 172 // The texture parameters are cached in |initialTexParams|. |
| 170 bool createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info, | 173 bool createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info, |
| 171 bool renderTarget, const void* srcData, | 174 bool renderTarget, GrGLTexture::TexParams* initialTex
Params, |
| 172 GrGLTexture::TexParams* initialTexParams, size_t rowB
ytes); | 175 const SkTArray<GrMipLevel>& texels); |
| 173 bool createTextureExternalAllocatorImpl(const GrSurfaceDesc& desc, GrGLTextu
reInfo* info, | 176 bool createTextureExternalAllocatorImpl(const GrSurfaceDesc& desc, GrGLTextu
reInfo* info, |
| 174 const void* srcData, size_t rowBytes
); | 177 const SkTArray<GrMipLevel>& texels); |
| 175 | 178 |
| 176 void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) override; | 179 void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) override; |
| 177 | 180 |
| 178 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli
p) override; | 181 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli
p) override; |
| 179 | 182 |
| 180 bool onMakeCopyForTextureParams(GrTexture*, const GrTextureParams&, | 183 bool onMakeCopyForTextureParams(GrTexture*, const GrTextureParams&, |
| 181 GrTextureProducer::CopyParams*) const overri
de; | 184 GrTextureProducer::CopyParams*) const overri
de; |
| 182 | 185 |
| 183 // Checks whether glReadPixels can be called to get pixel values in readConf
ig from the | 186 // Checks whether glReadPixels can be called to get pixel values in readConf
ig from the |
| 184 // render target. | 187 // render target. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 196 | 199 |
| 197 bool onReadPixels(GrSurface*, | 200 bool onReadPixels(GrSurface*, |
| 198 int left, int top, | 201 int left, int top, |
| 199 int width, int height, | 202 int width, int height, |
| 200 GrPixelConfig, | 203 GrPixelConfig, |
| 201 void* buffer, | 204 void* buffer, |
| 202 size_t rowBytes) override; | 205 size_t rowBytes) override; |
| 203 | 206 |
| 204 bool onWritePixels(GrSurface*, | 207 bool onWritePixels(GrSurface*, |
| 205 int left, int top, int width, int height, | 208 int left, int top, int width, int height, |
| 206 GrPixelConfig config, const void* buffer, | 209 GrPixelConfig config, |
| 207 size_t rowBytes) override; | 210 const SkTArray<GrMipLevel>& texels) override; |
| 208 | 211 |
| 209 bool onTransferPixels(GrSurface*, | 212 bool onTransferPixels(GrSurface*, |
| 210 int left, int top, int width, int height, | 213 int left, int top, int width, int height, |
| 211 GrPixelConfig config, GrTransferBuffer* buffer, | 214 GrPixelConfig config, GrTransferBuffer* buffer, |
| 212 size_t offset, size_t rowBytes) override; | 215 size_t offset, size_t rowBytes) override; |
| 213 | 216 |
| 214 void onResolveRenderTarget(GrRenderTarget* target) override; | 217 void onResolveRenderTarget(GrRenderTarget* target) override; |
| 215 | 218 |
| 216 void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override; | 219 void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override; |
| 217 | 220 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 enum UploadType { | 340 enum UploadType { |
| 338 kNewTexture_UploadType, // we are creating a new texture | 341 kNewTexture_UploadType, // we are creating a new texture |
| 339 kWrite_UploadType, // we are using TexSubImage2D to copy data to
an existing texture | 342 kWrite_UploadType, // we are using TexSubImage2D to copy data to
an existing texture |
| 340 kTransfer_UploadType, // we are using a transfer buffer to copy dat
a | 343 kTransfer_UploadType, // we are using a transfer buffer to copy dat
a |
| 341 }; | 344 }; |
| 342 bool uploadTexData(const GrSurfaceDesc& desc, | 345 bool uploadTexData(const GrSurfaceDesc& desc, |
| 343 GrGLenum target, | 346 GrGLenum target, |
| 344 UploadType uploadType, | 347 UploadType uploadType, |
| 345 int left, int top, int width, int height, | 348 int left, int top, int width, int height, |
| 346 GrPixelConfig dataConfig, | 349 GrPixelConfig dataConfig, |
| 347 const void* data, | 350 const SkTArray<GrMipLevel>& texels); |
| 348 size_t rowBytes); | |
| 349 | 351 |
| 350 // helper for onCreateCompressedTexture. If width and height are | 352 // helper for onCreateCompressedTexture. If width and height are |
| 351 // set to -1, then this function will use desc.fWidth and desc.fHeight | 353 // set to -1, then this function will use desc.fWidth and desc.fHeight |
| 352 // for the size of the data. The isNewTexture flag should be set to true | 354 // for the size of the data. The isNewTexture flag should be set to true |
| 353 // whenever a new texture needs to be created. Otherwise, we assume that | 355 // whenever a new texture needs to be created. Otherwise, we assume that |
| 354 // the texture is already in GPU memory and that it's going to be updated | 356 // the texture is already in GPU memory and that it's going to be updated |
| 355 // with new data. | 357 // with new data. |
| 356 bool uploadCompressedTexData(const GrSurfaceDesc& desc, | 358 bool uploadCompressedTexData(const GrSurfaceDesc& desc, |
| 357 GrGLenum target, | 359 GrGLenum target, |
| 358 const void* data, | 360 const SkTArray<GrMipLevel>& texels, |
| 359 UploadType uploadType = kNewTexture_UploadType, | 361 UploadType uploadType = kNewTexture_UploadType, |
| 360 int left = 0, int top = 0, | 362 int left = 0, int top = 0, |
| 361 int width = -1, int height = -1); | 363 int width = -1, int height = -1); |
| 362 | 364 |
| 363 bool createRenderTargetObjects(const GrSurfaceDesc&, GrGpuResource::LifeCycl
e lifeCycle, | 365 bool createRenderTargetObjects(const GrSurfaceDesc&, GrGpuResource::LifeCycl
e lifeCycle, |
| 364 const GrGLTextureInfo& texInfo, GrGLRenderTar
get::IDDesc*); | 366 const GrGLTextureInfo& texInfo, GrGLRenderTar
get::IDDesc*); |
| 365 | 367 |
| 366 enum TempFBOTarget { | 368 enum TempFBOTarget { |
| 367 kSrc_TempFBOTarget, | 369 kSrc_TempFBOTarget, |
| 368 kDst_TempFBOTarget | 370 kDst_TempFBOTarget |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 } fPLSSetupProgram; | 608 } fPLSSetupProgram; |
| 607 | 609 |
| 608 bool fHWPLSEnabled; | 610 bool fHWPLSEnabled; |
| 609 bool fPLSHasBeenUsed; | 611 bool fPLSHasBeenUsed; |
| 610 | 612 |
| 611 typedef GrGpu INHERITED; | 613 typedef GrGpu INHERITED; |
| 612 friend class GrGLPathRendering; // For accessing setTextureUnit. | 614 friend class GrGLPathRendering; // For accessing setTextureUnit. |
| 613 }; | 615 }; |
| 614 | 616 |
| 615 #endif | 617 #endif |
| OLD | NEW |