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

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: 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 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 const SkTArray<GrMipLevel>& texels) = 0; 515 const SkTArray<GrMipLevel>& texels) = 0;
546 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, 516 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc,
547 GrGpuResource::LifeCycle lifeCy cle, 517 GrGpuResource::LifeCycle lifeCy cle,
548 const SkTArray<GrMipLevel>& tex els) = 0; 518 const SkTArray<GrMipLevel>& tex els) = 0;
549 519
550 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO wnership) = 0; 520 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO wnership) = 0;
551 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge tDesc&, 521 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge tDesc&,
552 GrWrapOwnership) = 0; 522 GrWrapOwnership) = 0;
553 virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTe xtureDesc&, 523 virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTe xtureDesc&,
554 GrWrapOwnership) = 0; 524 GrWrapOwnership) = 0;
555 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; 525 virtual GrBuffer* onCreateBuffer(GrBufferType, size_t size, GrAccessPattern) = 0;
556 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0;
557 virtual GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType t ype) = 0;
558 526
559 // overridden by backend-specific derived class to perform the clear. 527 // overridden by backend-specific derived class to perform the clear.
560 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) = 0; 528 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) = 0;
561 529
562 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is 530 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is
563 // ONLY used by the the clip target 531 // ONLY used by the the clip target
564 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i nsideClip) = 0; 532 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i nsideClip) = 0;
565 533
566 // overridden by backend-specific derived class to perform the draw call. 534 // overridden by backend-specific derived class to perform the draw call.
567 virtual void onDraw(const GrPipeline&, 535 virtual void onDraw(const GrPipeline&,
(...skipping 21 matching lines...) Expand all
589 557
590 // overridden by backend-specific derived class to perform the surface write 558 // overridden by backend-specific derived class to perform the surface write
591 virtual bool onWritePixels(GrSurface*, 559 virtual bool onWritePixels(GrSurface*,
592 int left, int top, int width, int height, 560 int left, int top, int width, int height,
593 GrPixelConfig config, 561 GrPixelConfig config,
594 const SkTArray<GrMipLevel>& texels) = 0; 562 const SkTArray<GrMipLevel>& texels) = 0;
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 onTransferPixels(GrSurface*, 565 virtual bool onTransferPixels(GrSurface*,
598 int left, int top, int width, int height, 566 int left, int top, int width, int height,
599 GrPixelConfig config, GrTransferBuffer* buffer , 567 GrPixelConfig config, GrBuffer* transferBuffer ,
600 size_t offset, size_t rowBytes) = 0; 568 size_t offset, size_t rowBytes) = 0;
601 569
602 // overridden by backend-specific derived class to perform the resolve 570 // overridden by backend-specific derived class to perform the resolve
603 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; 571 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0;
604 572
605 // overridden by backend specific derived class to perform the copy surface 573 // overridden by backend specific derived class to perform the copy surface
606 virtual bool onCopySurface(GrSurface* dst, 574 virtual bool onCopySurface(GrSurface* dst,
607 GrSurface* src, 575 GrSurface* src,
608 const SkIRect& srcRect, 576 const SkIRect& srcRect,
609 const SkIPoint& dstPoint) = 0; 577 const SkIPoint& dstPoint) = 0;
(...skipping 15 matching lines...) Expand all
625 SkTArray<const MultisampleSpecs*, true> fMultisa mpleSpecsMap; 593 SkTArray<const MultisampleSpecs*, true> fMultisa mpleSpecsMap;
626 GrTAllocator<MultisampleSpecs> fMultisa mpleSpecsAllocator; 594 GrTAllocator<MultisampleSpecs> fMultisa mpleSpecsAllocator;
627 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. 595 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu.
628 GrContext* fContext ; 596 GrContext* fContext ;
629 597
630 friend class GrPathRendering; 598 friend class GrPathRendering;
631 typedef SkRefCnt INHERITED; 599 typedef SkRefCnt INHERITED;
632 }; 600 };
633 601
634 #endif 602 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrGeometryBuffer.h ('k') | src/gpu/GrGpu.cpp » ('j') | src/gpu/GrResourceProvider.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698