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

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

Issue 773433002: Add a base class for GrIODB that handles geometry data (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 6 years 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/GrDrawTarget.cpp ('k') | src/gpu/GrFlushToGpuDrawTarget.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef GrFlushToGpuDrawTarget_DEFINED
9 #define GrFlushToGpuDrawTarget_DEFINED
10
11 #include "GrDrawTarget.h"
12
13 class GrIndexBufferAllocPool;
14 class GrVertexBufferAllocPool;
15 class GrGpu;
16
17 /**
18 * Base class for draw targets that accumulate index and vertex data in buffers for deferred.
19 * When draw target clients reserve geometry this subclass will place that geome try into
20 * preallocated vertex/index buffers in the order the requests are made (assumin g the requests fit
21 * in the preallocated buffers).
22 */
23 class GrFlushToGpuDrawTarget : public GrClipTarget {
24 public:
25 GrFlushToGpuDrawTarget(GrGpu*, GrVertexBufferAllocPool*,GrIndexBufferAllocPo ol*);
26
27 ~GrFlushToGpuDrawTarget() SK_OVERRIDE;
28
29 /**
30 * Empties the draw buffer of any queued up draws. This must not be called w hile inside an
31 * unbalanced pushGeometrySource().
32 */
33 void reset();
34
35 /**
36 * This plays any queued up draws to its GrGpu target. It also resets this o bject (i.e. flushing
37 * is destructive). This buffer must not have an active reserved vertex or i ndex source. Any
38 * reserved geometry on the target will be finalized because it's geometry s ource will be pushed
39 * before flushing and popped afterwards.
40 */
41 void flush();
42
43 bool geometryHints(size_t vertexStride, int* vertexCount, int* indexCount) c onst SK_OVERRIDE;
44
45 protected:
46 GrGpu* getGpu() { return fGpu; }
47 const GrGpu* getGpu() const{ return fGpu; }
48
49 private:
50 enum {
51 kGeoPoolStatePreAllocCnt = 4,
52 };
53
54 struct GeometryPoolState {
55 const GrVertexBuffer* fPoolVertexBuffer;
56 int fPoolStartVertex;
57 const GrIndexBuffer* fPoolIndexBuffer;
58 int fPoolStartIndex;
59 // caller may conservatively over reserve vertices / indices.
60 // we release unused space back to allocator if possible
61 // can only do this if there isn't an intervening pushGeometrySource()
62 size_t fUsedPoolVertexBytes;
63 size_t fUsedPoolIndexBytes;
64 };
65
66 typedef SkSTArray<kGeoPoolStatePreAllocCnt, GeometryPoolState> GeoPoolStateS tack;
67
68 virtual void onReset() = 0;
69
70 virtual void onFlush() = 0;
71
72 void setDrawBuffers(DrawInfo*, size_t stride) SK_OVERRIDE;
73 bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertice s) SK_OVERRIDE;
74 bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE;
75 void releaseReservedVertexSpace() SK_OVERRIDE;
76 void releaseReservedIndexSpace() SK_OVERRIDE;
77 void geometrySourceWillPush() SK_OVERRIDE;
78 void geometrySourceWillPop(const GeometrySrcState& restoredState) SK_OVERRID E;
79 void willReserveVertexAndIndexSpace(int vertexCount,
80 size_t vertexStride,
81 int indexCount) SK_OVERRIDE;
82
83 GeoPoolStateStack fGeoPoolStateStack;
84 SkAutoTUnref<GrGpu> fGpu;
85 GrVertexBufferAllocPool* fVertexPool;
86 GrIndexBufferAllocPool* fIndexPool;
87 bool fFlushing;
88
89 typedef GrClipTarget INHERITED;
90 };
91
92 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrFlushToGpuDrawTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698