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 "GrGLPathRendering.h" | 14 #include "GrGLPathRendering.h" |
14 #include "GrGLProgram.h" | 15 #include "GrGLProgram.h" |
15 #include "GrGLRenderTarget.h" | 16 #include "GrGLRenderTarget.h" |
16 #include "GrGLStencilAttachment.h" | 17 #include "GrGLStencilAttachment.h" |
17 #include "GrGLTexture.h" | 18 #include "GrGLTexture.h" |
| 19 #include "GrGLTransferBuffer.h" |
18 #include "GrGLVertexArray.h" | 20 #include "GrGLVertexArray.h" |
| 21 #include "GrGLVertexBuffer.h" |
19 #include "GrGpu.h" | 22 #include "GrGpu.h" |
20 #include "GrPipelineBuilder.h" | 23 #include "GrPipelineBuilder.h" |
21 #include "GrTypes.h" | 24 #include "GrTypes.h" |
22 #include "GrXferProcessor.h" | 25 #include "GrXferProcessor.h" |
23 #include "SkTArray.h" | 26 #include "SkTArray.h" |
24 #include "SkTypes.h" | 27 #include "SkTypes.h" |
25 | 28 |
26 class GrGLBuffer; | |
27 class GrPipeline; | 29 class GrPipeline; |
28 class GrNonInstancedMesh; | 30 class GrNonInstancedMesh; |
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 |
35 class GrGLGpu : public GrGpu { | 37 class GrGLGpu : public GrGpu { |
36 public: | 38 public: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 94 } |
93 void notifyIndexBufferDelete(GrGLuint id) { | 95 void notifyIndexBufferDelete(GrGLuint id) { |
94 fHWGeometryState.notifyIndexBufferDelete(id); | 96 fHWGeometryState.notifyIndexBufferDelete(id); |
95 } | 97 } |
96 | 98 |
97 // id and type (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, etc.) of buffer to
bind | 99 // id and type (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, etc.) of buffer to
bind |
98 void bindBuffer(GrGLuint id, GrGLenum type); | 100 void bindBuffer(GrGLuint id, GrGLenum type); |
99 | 101 |
100 void releaseBuffer(GrGLuint id, GrGLenum type); | 102 void releaseBuffer(GrGLuint id, GrGLenum type); |
101 | 103 |
| 104 // sizes are in bytes |
| 105 void* mapBuffer(GrGLuint id, GrGLenum type, GrGLBufferImpl::Usage usage, siz
e_t currentSize, |
| 106 size_t requestedSize); |
| 107 |
| 108 void unmapBuffer(GrGLuint id, GrGLenum type, void* mapPtr); |
| 109 |
| 110 void bufferData(GrGLuint id, GrGLenum type, GrGLBufferImpl::Usage usage, siz
e_t currentSize, |
| 111 const void* src, size_t srcSizeInBytes); |
| 112 |
102 const GrGLContext* glContextForTesting() const override { | 113 const GrGLContext* glContextForTesting() const override { |
103 return &this->glContext(); | 114 return &this->glContext(); |
104 } | 115 } |
105 | 116 |
106 void clearStencil(GrRenderTarget*) override; | 117 void clearStencil(GrRenderTarget*) override; |
107 | 118 |
108 void invalidateBoundRenderTarget() { | 119 void invalidateBoundRenderTarget() { |
109 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 120 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
110 } | 121 } |
111 | 122 |
(...skipping 19 matching lines...) Expand all Loading... |
131 void onResetContext(uint32_t resetBits) override; | 142 void onResetContext(uint32_t resetBits) override; |
132 | 143 |
133 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; | 144 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; |
134 | 145 |
135 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, | 146 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, |
136 const SkTArray<GrMipLevel>& texels) override; | 147 const SkTArray<GrMipLevel>& texels) override; |
137 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, | 148 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |
138 GrGpuResource::LifeCycle lifeCycle, | 149 GrGpuResource::LifeCycle lifeCycle, |
139 const SkTArray<GrMipLevel>& texels) ove
rride; | 150 const SkTArray<GrMipLevel>& texels) ove
rride; |
140 | 151 |
141 GrBuffer* onCreateBuffer(GrBufferType, size_t size, GrAccessPattern) overrid
e; | 152 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override; |
| 153 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override; |
| 154 GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType type) ove
rride; |
142 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership
) override; | 155 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership
) override; |
143 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, | 156 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, |
144 GrWrapOwnership) override; | 157 GrWrapOwnership) override; |
145 GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDes
c&, | 158 GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDes
c&, |
146 GrWrapOwnership) override
; | 159 GrWrapOwnership) override
; |
147 // Given a GrPixelConfig return the index into the stencil format array on G
rGLCaps to a | 160 // Given a GrPixelConfig return the index into the stencil format array on G
rGLCaps to a |
148 // compatible stencil format, or negative if there is no compatible stencil
format. | 161 // compatible stencil format, or negative if there is no compatible stencil
format. |
149 int getCompatibleStencilIndex(GrPixelConfig config); | 162 int getCompatibleStencilIndex(GrPixelConfig config); |
150 | 163 |
151 // If |desc.fTextureStorageAllocator| exists, use that to create the | 164 // If |desc.fTextureStorageAllocator| exists, use that to create the |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 void* buffer, | 201 void* buffer, |
189 size_t rowBytes) override; | 202 size_t rowBytes) override; |
190 | 203 |
191 bool onWritePixels(GrSurface*, | 204 bool onWritePixels(GrSurface*, |
192 int left, int top, int width, int height, | 205 int left, int top, int width, int height, |
193 GrPixelConfig config, | 206 GrPixelConfig config, |
194 const SkTArray<GrMipLevel>& texels) override; | 207 const SkTArray<GrMipLevel>& texels) override; |
195 | 208 |
196 bool onTransferPixels(GrSurface*, | 209 bool onTransferPixels(GrSurface*, |
197 int left, int top, int width, int height, | 210 int left, int top, int width, int height, |
198 GrPixelConfig config, GrBuffer* transferBuffer, | 211 GrPixelConfig config, GrTransferBuffer* buffer, |
199 size_t offset, size_t rowBytes) override; | 212 size_t offset, size_t rowBytes) override; |
200 | 213 |
201 void onResolveRenderTarget(GrRenderTarget* target) override; | 214 void onResolveRenderTarget(GrRenderTarget* target) override; |
202 | 215 |
203 void onDraw(const GrPipeline&, | 216 void onDraw(const GrPipeline&, |
204 const GrPrimitiveProcessor&, | 217 const GrPrimitiveProcessor&, |
205 const GrMesh*, | 218 const GrMesh*, |
206 int meshCount) override; | 219 int meshCount) override; |
207 | 220 |
208 bool onCopySurface(GrSurface* dst, | 221 bool onCopySurface(GrSurface* dst, |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 } | 504 } |
492 } | 505 } |
493 | 506 |
494 /** | 507 /** |
495 * Binds the vertex array object that should be used to render from the
vertex buffer. | 508 * Binds the vertex array object that should be used to render from the
vertex buffer. |
496 * The vertex array is bound and its attrib array state object is return
ed. The vertex | 509 * The vertex array is bound and its attrib array state object is return
ed. The vertex |
497 * buffer is bound. The index buffer (if non-nullptr) is bound to the ve
rtex array. The | 510 * buffer is bound. The index buffer (if non-nullptr) is bound to the ve
rtex array. The |
498 * returned GrGLAttribArrayState should be used to set vertex attribute
arrays. | 511 * returned GrGLAttribArrayState should be used to set vertex attribute
arrays. |
499 */ | 512 */ |
500 GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGLGpu* gpu, | 513 GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGLGpu* gpu, |
501 const GrGLBuffer* vbuffe
r, | 514 const GrGLVertexBuffer*
vbuffer, |
502 const GrGLBuffer* ibuffe
r); | 515 const GrGLIndexBuffer* i
buffer); |
503 | 516 |
504 /** Variants of the above that takes GL buffer IDs. Note that 0 does not
imply that a | 517 /** Variants of the above that takes GL buffer IDs. Note that 0 does not
imply that a |
505 buffer won't be bound. The "default buffer" will be bound, which is
used for client-side | 518 buffer won't be bound. The "default buffer" will be bound, which is
used for client-side |
506 array rendering. */ | 519 array rendering. */ |
507 GrGLAttribArrayState* bindArrayAndBufferToDraw(GrGLGpu* gpu, GrGLuint vb
ufferID); | 520 GrGLAttribArrayState* bindArrayAndBufferToDraw(GrGLGpu* gpu, GrGLuint vb
ufferID); |
508 GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGLGpu* gpu, | 521 GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGLGpu* gpu, |
509 GrGLuint vbufferID, | 522 GrGLuint vbufferID, |
510 GrGLuint ibufferID); | 523 GrGLuint ibufferID); |
511 | 524 |
512 private: | 525 private: |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 } fPLSSetupProgram; | 617 } fPLSSetupProgram; |
605 | 618 |
606 bool fHWPLSEnabled; | 619 bool fHWPLSEnabled; |
607 bool fPLSHasBeenUsed; | 620 bool fPLSHasBeenUsed; |
608 | 621 |
609 typedef GrGpu INHERITED; | 622 typedef GrGpu INHERITED; |
610 friend class GrGLPathRendering; // For accessing setTextureUnit. | 623 friend class GrGLPathRendering; // For accessing setTextureUnit. |
611 }; | 624 }; |
612 | 625 |
613 #endif | 626 #endif |
OLD | NEW |