Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: src/gpu/gl/GrGLGpu.h

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

Powered by Google App Engine
This is Rietveld 408576698