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

Side by Side Diff: src/gpu/GrGpu.h

Issue 1825393002: Consolidate GPU buffer implementations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: asserts 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
« no previous file with comments | « src/gpu/GrGeometryBuffer.h ('k') | src/gpu/GrGpu.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 GrGpu_DEFINED 8 #ifndef GrGpu_DEFINED
9 #define GrGpu_DEFINED 9 #define GrGpu_DEFINED
10 10
11 #include "GrPipelineBuilder.h" 11 #include "GrPipelineBuilder.h"
12 #include "GrProgramDesc.h" 12 #include "GrProgramDesc.h"
13 #include "GrStencil.h" 13 #include "GrStencil.h"
14 #include "GrSwizzle.h" 14 #include "GrSwizzle.h"
15 #include "GrAllocator.h" 15 #include "GrAllocator.h"
16 #include "GrTextureParamsAdjuster.h" 16 #include "GrTextureParamsAdjuster.h"
17 #include "GrTypes.h" 17 #include "GrTypes.h"
18 #include "GrXferProcessor.h" 18 #include "GrXferProcessor.h"
19 #include "SkPath.h" 19 #include "SkPath.h"
20 #include "SkTArray.h" 20 #include "SkTArray.h"
21 21
22 class GrBatchTracker; 22 class GrBatchTracker;
23 class GrBuffer;
23 class GrContext; 24 class GrContext;
24 class GrGLContext; 25 class GrGLContext;
25 class GrIndexBuffer;
26 class GrMesh; 26 class GrMesh;
27 class GrNonInstancedVertices; 27 class GrNonInstancedVertices;
28 class GrPath; 28 class GrPath;
29 class GrPathRange; 29 class GrPathRange;
30 class GrPathRenderer; 30 class GrPathRenderer;
31 class GrPathRendererChain; 31 class GrPathRendererChain;
32 class GrPathRendering; 32 class GrPathRendering;
33 class GrPipeline; 33 class GrPipeline;
34 class GrPrimitiveProcessor; 34 class GrPrimitiveProcessor;
35 class GrRenderTarget; 35 class GrRenderTarget;
36 class GrStencilAttachment; 36 class GrStencilAttachment;
37 class GrSurface; 37 class GrSurface;
38 class GrTexture; 38 class GrTexture;
39 class GrTransferBuffer;
40 class GrVertexBuffer;
41 39
42 class GrGpu : public SkRefCnt { 40 class GrGpu : public SkRefCnt {
43 public: 41 public:
44 /** 42 /**
45 * Create an instance of GrGpu that matches the specified backend. If the re quested backend is 43 * Create an instance of GrGpu that matches the specified backend. If the re quested backend is
46 * not supported (at compile-time or run-time) this returns nullptr. The con text will not be 44 * not supported (at compile-time or run-time) this returns nullptr. The con text will not be
47 * fully constructed and should not be used by GrGpu until after this functi on returns. 45 * fully constructed and should not be used by GrGpu until after this functi on returns.
48 */ 46 */
49 static GrGpu* Create(GrBackend, GrBackendContext, const GrContextOptions&, G rContext* context); 47 static GrGpu* Create(GrBackend, GrBackendContext, const GrContextOptions&, G rContext* context);
50 48
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 * Implements GrTextureProvider::wrapBackendRenderTarget 120 * Implements GrTextureProvider::wrapBackendRenderTarget
123 */ 121 */
124 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc&, Gr WrapOwnership); 122 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc&, Gr WrapOwnership);
125 123
126 /** 124 /**
127 * Implements GrTextureProvider::wrapBackendTextureAsRenderTarget 125 * Implements GrTextureProvider::wrapBackendTextureAsRenderTarget
128 */ 126 */
129 GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& , GrWrapOwnership); 127 GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& , GrWrapOwnership);
130 128
131 /** 129 /**
132 * Creates a vertex buffer. 130 * Creates a buffer.
133 * 131 *
134 * @param size size in bytes of the vertex buffer 132 * @return the buffer if successful, otherwise nullptr.
135 * @param dynamic hints whether the data will be frequently changed
136 * by either GrVertexBuffer::map() or
137 * GrVertexBuffer::updateData().
138 *
139 * @return The vertex buffer if successful, otherwise nullptr.
140 */ 133 */
141 GrVertexBuffer* createVertexBuffer(size_t size, bool dynamic); 134 GrBuffer* createBuffer(GrBufferType, size_t size, GrAccessPattern);
142
143 /**
144 * Creates an index buffer.
145 *
146 * @param size size in bytes of the index buffer
147 * @param dynamic hints whether the data will be frequently changed
148 * by either GrIndexBuffer::map() or
149 * GrIndexBuffer::updateData().
150 *
151 * @return The index buffer if successful, otherwise nullptr.
152 */
153 GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic);
154
155 /**
156 * Creates a transfer buffer.
157 *
158 * @param size size in bytes of the index buffer
159 * @param toGpu true if used to transfer from the cpu to the gpu
160 * otherwise to be used to transfer from the gpu to the cpu
161 *
162 * @return The transfer buffer if successful, otherwise nullptr.
163 */
164 GrTransferBuffer* createTransferBuffer(size_t size, TransferType type);
165 135
166 /** 136 /**
167 * Resolves MSAA. 137 * Resolves MSAA.
168 */ 138 */
169 void resolveRenderTarget(GrRenderTarget* target); 139 void resolveRenderTarget(GrRenderTarget* target);
170 140
171 /** Info struct returned by getReadPixelsInfo about performing intermediate draws before 141 /** Info struct returned by getReadPixelsInfo about performing intermediate draws before
172 reading pixels for performance or correctness. */ 142 reading pixels for performance or correctness. */
173 struct ReadPixelTempDrawInfo { 143 struct ReadPixelTempDrawInfo {
174 /** If the GrGpu is requesting that the caller do a draw to an intermedi ate surface then 144 /** If the GrGpu is requesting that the caller do a draw to an intermedi ate surface then
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 * @param buffer memory to read pixels from. 261 * @param buffer memory to read pixels from.
292 * @param rowBytes number of bytes between consecutive rows. Zero 262 * @param rowBytes number of bytes between consecutive rows. Zero
293 * means rows are tightly packed. 263 * means rows are tightly packed.
294 */ 264 */
295 bool writePixels(GrSurface* surface, 265 bool writePixels(GrSurface* surface,
296 int left, int top, int width, int height, 266 int left, int top, int width, int height,
297 GrPixelConfig config, const void* buffer, 267 GrPixelConfig config, const void* buffer,
298 size_t rowBytes); 268 size_t rowBytes);
299 269
300 /** 270 /**
301 * Updates the pixels in a rectangle of a surface using a GrTransferBuffer 271 * Updates the pixels in a rectangle of a surface using a buffer
302 * 272 *
303 * @param surface The surface to write to. 273 * @param surface The surface to write to.
304 * @param left left edge of the rectangle to write (inclusive) 274 * @param left left edge of the rectangle to write (inclusive)
305 * @param top top edge of the rectangle to write (inclusive) 275 * @param top top edge of the rectangle to write (inclusive)
306 * @param width width of rectangle to write in pixels. 276 * @param width width of rectangle to write in pixels.
307 * @param height height of rectangle to write in pixels. 277 * @param height height of rectangle to write in pixels.
308 * @param config the pixel config of the source buffer 278 * @param config the pixel config of the source buffer
309 * @param buffer GrTransferBuffer to read pixels from 279 * @param transferBuffer GrBuffer to read pixels from (type must be "kCpuT oGpu")
310 * @param offset offset from the start of the buffer 280 * @param offset offset from the start of the buffer
311 * @param rowBytes number of bytes between consecutive rows. Zero 281 * @param rowBytes number of bytes between consecutive rows. Zero
312 * means rows are tightly packed. 282 * means rows are tightly packed.
313 */ 283 */
314 bool transferPixels(GrSurface* surface, 284 bool transferPixels(GrSurface* surface,
315 int left, int top, int width, int height, 285 int left, int top, int width, int height,
316 GrPixelConfig config, GrTransferBuffer* buffer, 286 GrPixelConfig config, GrBuffer* transferBuffer,
317 size_t offset, size_t rowBytes); 287 size_t offset, size_t rowBytes);
318 288
319 /** 289 /**
320 * Clear the passed in render target. Ignores the draw state and clip. 290 * Clear the passed in render target. Ignores the draw state and clip.
321 */ 291 */
322 void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget) ; 292 void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget) ;
323 293
324 294
325 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* renderTarget); 295 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* renderTarget);
326 296
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 const SkTArray<GrMipLevel>& texels) = 0; 521 const SkTArray<GrMipLevel>& texels) = 0;
552 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, 522 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc,
553 GrGpuResource::LifeCycle lifeCy cle, 523 GrGpuResource::LifeCycle lifeCy cle,
554 const SkTArray<GrMipLevel>& tex els) = 0; 524 const SkTArray<GrMipLevel>& tex els) = 0;
555 525
556 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO wnership) = 0; 526 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO wnership) = 0;
557 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge tDesc&, 527 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge tDesc&,
558 GrWrapOwnership) = 0; 528 GrWrapOwnership) = 0;
559 virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTe xtureDesc&, 529 virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTe xtureDesc&,
560 GrWrapOwnership) = 0; 530 GrWrapOwnership) = 0;
561 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; 531 virtual GrBuffer* onCreateBuffer(GrBufferType, size_t size, GrAccessPattern) = 0;
562 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0;
563 virtual GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType t ype) = 0;
564 532
565 // overridden by backend-specific derived class to perform the clear. 533 // overridden by backend-specific derived class to perform the clear.
566 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) = 0; 534 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) = 0;
567 535
568 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is 536 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is
569 // ONLY used by the the clip target 537 // ONLY used by the the clip target
570 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i nsideClip) = 0; 538 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i nsideClip) = 0;
571 539
572 // overridden by backend-specific derived class to perform the draw call. 540 // overridden by backend-specific derived class to perform the draw call.
573 virtual void onDraw(const GrPipeline&, 541 virtual void onDraw(const GrPipeline&,
(...skipping 21 matching lines...) Expand all
595 563
596 // overridden by backend-specific derived class to perform the surface write 564 // overridden by backend-specific derived class to perform the surface write
597 virtual bool onWritePixels(GrSurface*, 565 virtual bool onWritePixels(GrSurface*,
598 int left, int top, int width, int height, 566 int left, int top, int width, int height,
599 GrPixelConfig config, 567 GrPixelConfig config,
600 const SkTArray<GrMipLevel>& texels) = 0; 568 const SkTArray<GrMipLevel>& texels) = 0;
601 569
602 // overridden by backend-specific derived class to perform the surface write 570 // overridden by backend-specific derived class to perform the surface write
603 virtual bool onTransferPixels(GrSurface*, 571 virtual bool onTransferPixels(GrSurface*,
604 int left, int top, int width, int height, 572 int left, int top, int width, int height,
605 GrPixelConfig config, GrTransferBuffer* buffer , 573 GrPixelConfig config, GrBuffer* transferBuffer ,
606 size_t offset, size_t rowBytes) = 0; 574 size_t offset, size_t rowBytes) = 0;
607 575
608 // overridden by backend-specific derived class to perform the resolve 576 // overridden by backend-specific derived class to perform the resolve
609 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; 577 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0;
610 578
611 // overridden by backend specific derived class to perform the copy surface 579 // overridden by backend specific derived class to perform the copy surface
612 virtual bool onCopySurface(GrSurface* dst, 580 virtual bool onCopySurface(GrSurface* dst,
613 GrSurface* src, 581 GrSurface* src,
614 const SkIRect& srcRect, 582 const SkIRect& srcRect,
615 const SkIPoint& dstPoint) = 0; 583 const SkIPoint& dstPoint) = 0;
(...skipping 15 matching lines...) Expand all
631 SkTArray<const MultisampleSpecs*, true> fMultisa mpleSpecsMap; 599 SkTArray<const MultisampleSpecs*, true> fMultisa mpleSpecsMap;
632 GrTAllocator<MultisampleSpecs> fMultisa mpleSpecsAllocator; 600 GrTAllocator<MultisampleSpecs> fMultisa mpleSpecsAllocator;
633 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. 601 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu.
634 GrContext* fContext ; 602 GrContext* fContext ;
635 603
636 friend class GrPathRendering; 604 friend class GrPathRendering;
637 typedef SkRefCnt INHERITED; 605 typedef SkRefCnt INHERITED;
638 }; 606 };
639 607
640 #endif 608 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrGeometryBuffer.h ('k') | src/gpu/GrGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698