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 onReadPixels(GrSurface*, | 167 bool onReadPixels(GrSurface*, |
165 int left, int top, | 168 int left, int top, |
166 int width, int height, | 169 int width, int height, |
167 GrPixelConfig, | 170 GrPixelConfig, |
168 void* buffer, | 171 void* buffer, |
169 size_t rowBytes) override; | 172 size_t rowBytes) override; |
170 | 173 |
171 bool onWritePixels(GrSurface*, | 174 bool onWritePixels(GrSurface*, |
172 int left, int top, int width, int height, | 175 int left, int top, int width, int height, |
173 GrPixelConfig config, const void* buffer, | 176 GrPixelConfig config, |
174 size_t rowBytes) override; | 177 const SkTArray<SkMipMapLevel>& texels) override; |
175 | 178 |
176 bool onTransferPixels(GrSurface*, | 179 bool onTransferPixels(GrSurface*, |
177 int left, int top, int width, int height, | 180 int left, int top, int width, int height, |
178 GrPixelConfig config, GrTransferBuffer* buffer, | 181 GrPixelConfig config, GrTransferBuffer* buffer, |
179 size_t offset, size_t rowBytes) override; | 182 size_t offset, size_t rowBytes) override; |
180 | 183 |
181 void onResolveRenderTarget(GrRenderTarget* target) override; | 184 void onResolveRenderTarget(GrRenderTarget* target) override; |
182 | 185 |
183 void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override; | 186 void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override; |
184 | 187 |
(...skipping 107 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, |
314 UploadType uploadType = kNewTexture_UploadType, | 316 UploadType uploadType = kNewTexture_UploadType, |
315 int left = 0, int top = 0, | 317 int left = 0, int top = 0, |
316 int width = -1, int height = -1); | 318 int width = -1, int height = -1); |
317 | 319 |
318 bool createRenderTargetObjects(const GrSurfaceDesc&, GrGpuResource::LifeCycl
e lifeCycle, | 320 bool createRenderTargetObjects(const GrSurfaceDesc&, GrGpuResource::LifeCycl
e lifeCycle, |
319 const GrGLTextureInfo& texInfo, GrGLRenderTar
get::IDDesc*); | 321 const GrGLTextureInfo& texInfo, GrGLRenderTar
get::IDDesc*); |
320 | 322 |
321 enum TempFBOTarget { | 323 enum TempFBOTarget { |
322 kSrc_TempFBOTarget, | 324 kSrc_TempFBOTarget, |
323 kDst_TempFBOTarget | 325 kDst_TempFBOTarget |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 SkASSERT(target == GR_GL_TEXTURE_EXTERNAL); | 543 SkASSERT(target == GR_GL_TEXTURE_EXTERNAL); |
542 return 1; | 544 return 1; |
543 } | 545 } |
544 } | 546 } |
545 | 547 |
546 typedef GrGpu INHERITED; | 548 typedef GrGpu INHERITED; |
547 friend class GrGLPathRendering; // For accessing setTextureUnit. | 549 friend class GrGLPathRendering; // For accessing setTextureUnit. |
548 }; | 550 }; |
549 | 551 |
550 #endif | 552 #endif |
OLD | NEW |