OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 GrFlushToGpuDrawTarget_DEFINED | 8 #ifndef GrFlushToGpuDrawTarget_DEFINED |
9 #define GrFlushToGpuDrawTarget_DEFINED | 9 #define GrFlushToGpuDrawTarget_DEFINED |
10 | 10 |
11 #include "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
12 | 12 |
13 class GrIndexBufferAllocPool; | 13 class GrIndexBufferAllocPool; |
14 class GrVertexBufferAllocPool; | 14 class GrVertexBufferAllocPool; |
15 class GrGpu; | 15 class GrGpu; |
16 | 16 |
17 /** | 17 /** |
18 * Base class for draw targets that accumulate index and vertex data in buffers
for deferred. | 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 | 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 | 20 * preallocated vertex/index buffers in the order the requests are made (assumin
g the requests fit |
21 * in the preallocated buffers). | 21 * in the preallocated buffers). |
22 */ | 22 */ |
23 class GrFlushToGpuDrawTarget : public GrClipTarget { | 23 class GrFlushToGpuDrawTarget : public GrClipTarget { |
24 public: | 24 public: |
25 GrFlushToGpuDrawTarget(GrGpu*, GrVertexBufferAllocPool*,GrIndexBufferAllocPo
ol*); | 25 GrFlushToGpuDrawTarget(GrGpu*, GrVertexBufferAllocPool*,GrIndexBufferAllocPo
ol*); |
26 | 26 |
27 ~GrFlushToGpuDrawTarget() SK_OVERRIDE; | 27 ~GrFlushToGpuDrawTarget() override; |
28 | 28 |
29 /** | 29 /** |
30 * Empties the draw buffer of any queued up draws. This must not be called w
hile inside an | 30 * Empties the draw buffer of any queued up draws. This must not be called w
hile inside an |
31 * unbalanced pushGeometrySource(). | 31 * unbalanced pushGeometrySource(). |
32 */ | 32 */ |
33 void reset(); | 33 void reset(); |
34 | 34 |
35 /** | 35 /** |
36 * This plays any queued up draws to its GrGpu target. It also resets this o
bject (i.e. flushing | 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 | 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 | 38 * reserved geometry on the target will be finalized because it's geometry s
ource will be pushed |
39 * before flushing and popped afterwards. | 39 * before flushing and popped afterwards. |
40 */ | 40 */ |
41 void flush(); | 41 void flush(); |
42 | 42 |
43 bool geometryHints(size_t vertexStride, int* vertexCount, int* indexCount) c
onst SK_OVERRIDE; | 43 bool geometryHints(size_t vertexStride, int* vertexCount, int* indexCount) c
onst override; |
44 | 44 |
45 protected: | 45 protected: |
46 GrGpu* getGpu() { return fGpu; } | 46 GrGpu* getGpu() { return fGpu; } |
47 const GrGpu* getGpu() const{ return fGpu; } | 47 const GrGpu* getGpu() const{ return fGpu; } |
48 | 48 |
49 GrVertexBufferAllocPool* getVertexAllocPool() { return fVertexPool; } | 49 GrVertexBufferAllocPool* getVertexAllocPool() { return fVertexPool; } |
50 GrIndexBufferAllocPool* getIndexAllocPool() { return fIndexPool; } | 50 GrIndexBufferAllocPool* getIndexAllocPool() { return fIndexPool; } |
51 | 51 |
52 // TODO all of this goes away when batch is everywhere | 52 // TODO all of this goes away when batch is everywhere |
53 enum { | 53 enum { |
(...skipping 10 matching lines...) Expand all Loading... |
64 // can only do this if there isn't an intervening pushGeometrySource() | 64 // can only do this if there isn't an intervening pushGeometrySource() |
65 size_t fUsedPoolVertexBytes; | 65 size_t fUsedPoolVertexBytes; |
66 size_t fUsedPoolIndexBytes; | 66 size_t fUsedPoolIndexBytes; |
67 }; | 67 }; |
68 | 68 |
69 typedef SkSTArray<kGeoPoolStatePreAllocCnt, GeometryPoolState> GeoPoolStateS
tack; | 69 typedef SkSTArray<kGeoPoolStatePreAllocCnt, GeometryPoolState> GeoPoolStateS
tack; |
70 const GeoPoolStateStack& getGeoPoolStateStack() const { return fGeoPoolState
Stack; } | 70 const GeoPoolStateStack& getGeoPoolStateStack() const { return fGeoPoolState
Stack; } |
71 | 71 |
72 void willReserveVertexAndIndexSpace(int vertexCount, | 72 void willReserveVertexAndIndexSpace(int vertexCount, |
73 size_t vertexStride, | 73 size_t vertexStride, |
74 int indexCount) SK_OVERRIDE; | 74 int indexCount) override; |
75 | 75 |
76 private: | 76 private: |
77 virtual void onReset() = 0; | 77 virtual void onReset() = 0; |
78 | 78 |
79 virtual void onFlush() = 0; | 79 virtual void onFlush() = 0; |
80 | 80 |
81 void setDrawBuffers(DrawInfo*, size_t stride) SK_OVERRIDE; | 81 void setDrawBuffers(DrawInfo*, size_t stride) override; |
82 bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertice
s) SK_OVERRIDE; | 82 bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertice
s) override; |
83 bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE; | 83 bool onReserveIndexSpace(int indexCount, void** indices) override; |
84 void releaseReservedVertexSpace() SK_OVERRIDE; | 84 void releaseReservedVertexSpace() override; |
85 void releaseReservedIndexSpace() SK_OVERRIDE; | 85 void releaseReservedIndexSpace() override; |
86 void geometrySourceWillPush() SK_OVERRIDE; | 86 void geometrySourceWillPush() override; |
87 void geometrySourceWillPop(const GeometrySrcState& restoredState) SK_OVERRID
E; | 87 void geometrySourceWillPop(const GeometrySrcState& restoredState) override; |
88 bool onCanCopySurface(const GrSurface* dst, | 88 bool onCanCopySurface(const GrSurface* dst, |
89 const GrSurface* src, | 89 const GrSurface* src, |
90 const SkIRect& srcRect, | 90 const SkIRect& srcRect, |
91 const SkIPoint& dstPoint) SK_OVERRIDE; | 91 const SkIPoint& dstPoint) override; |
92 bool onInitCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) SK_
OVERRIDE; | 92 bool onInitCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) ove
rride; |
93 | 93 |
94 GeoPoolStateStack fGeoPoolStateStack; | 94 GeoPoolStateStack fGeoPoolStateStack; |
95 SkAutoTUnref<GrGpu> fGpu; | 95 SkAutoTUnref<GrGpu> fGpu; |
96 GrVertexBufferAllocPool* fVertexPool; | 96 GrVertexBufferAllocPool* fVertexPool; |
97 GrIndexBufferAllocPool* fIndexPool; | 97 GrIndexBufferAllocPool* fIndexPool; |
98 bool fFlushing; | 98 bool fFlushing; |
99 | 99 |
100 typedef GrClipTarget INHERITED; | 100 typedef GrClipTarget INHERITED; |
101 }; | 101 }; |
102 | 102 |
103 #endif | 103 #endif |
OLD | NEW |