OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 GrDrawBatch_DEFINED | 8 #ifndef GrDrawBatch_DEFINED |
9 #define GrDrawBatch_DEFINED | 9 #define GrDrawBatch_DEFINED |
10 | 10 |
11 #include "GrBatch.h" | 11 #include "GrBatch.h" |
12 #include "GrPipeline.h" | 12 #include "GrPipeline.h" |
13 | 13 |
14 struct GrInitInvariantOutput; | 14 struct GrInitInvariantOutput; |
15 | 15 |
16 /** | 16 /** |
| 17 * GrDrawBatches are flushed in two phases (preDraw, and draw). In preDraw uploa
ds to GrGpuResources |
| 18 * and draws are determined and scheduled. They are issued in the draw phase. Gr
BatchToken is used |
| 19 * to sequence the uploads relative to each other and to draws. |
| 20 **/ |
| 21 |
| 22 typedef uint64_t GrBatchToken; |
| 23 |
| 24 class GrBatchUploader : public SkRefCnt { |
| 25 public: |
| 26 class TextureUploader; |
| 27 |
| 28 GrBatchUploader(GrBatchToken lastUploadToken) : fLastUploadToken(lastUploadT
oken) {} |
| 29 GrBatchToken lastUploadToken() const { return fLastUploadToken; } |
| 30 virtual void upload(TextureUploader*)=0; |
| 31 |
| 32 private: |
| 33 GrBatchToken fLastUploadToken; |
| 34 }; |
| 35 |
| 36 /** |
17 * Base class for GrBatches that draw. These batches have a GrPipeline installed
by GrDrawTarget. | 37 * Base class for GrBatches that draw. These batches have a GrPipeline installed
by GrDrawTarget. |
18 */ | 38 */ |
19 class GrDrawBatch : public GrBatch { | 39 class GrDrawBatch : public GrBatch { |
20 public: | 40 public: |
| 41 class Target; |
| 42 |
21 GrDrawBatch(); | 43 GrDrawBatch(); |
22 ~GrDrawBatch() override; | 44 ~GrDrawBatch() override; |
23 | 45 |
24 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0; | 46 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0; |
25 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const =
0; | 47 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const =
0; |
26 | 48 |
27 const GrPipeline* pipeline() const { | 49 const GrPipeline* pipeline() const { |
28 SkASSERT(fPipelineInstalled); | 50 SkASSERT(fPipelineInstalled); |
29 return reinterpret_cast<const GrPipeline*>(fPipelineStorage.get()); | 51 return reinterpret_cast<const GrPipeline*>(fPipelineStorage.get()); |
30 } | 52 } |
31 | 53 |
32 bool installPipeline(const GrPipeline::CreateArgs&); | 54 bool installPipeline(const GrPipeline::CreateArgs&); |
33 | 55 |
34 // TODO no GrPrimitiveProcessors yet read fragment position | 56 // TODO no GrPrimitiveProcessors yet read fragment position |
35 bool willReadFragmentPosition() const { return false; } | 57 bool willReadFragmentPosition() const { return false; } |
36 | 58 |
37 private: | 59 private: |
38 /** | 60 /** |
39 * initBatchTracker is a hook for the some additional overrides / optimizati
on possibilities | 61 * initBatchTracker is a hook for the some additional overrides / optimizati
on possibilities |
40 * from the GrXferProcessor. | 62 * from the GrXferProcessor. |
41 */ | 63 */ |
42 virtual void initBatchTracker(const GrPipelineOptimizations&) = 0; | 64 virtual void initBatchTracker(const GrPipelineOptimizations&) = 0; |
43 | 65 |
44 SkAlignedSTStorage<1, GrPipeline> fPipelineStorage; | 66 protected: |
45 bool fPipelineInstalled; | 67 SkTArray<SkAutoTUnref<GrBatchUploader>, true> fInlineUploads; |
| 68 |
| 69 private: |
| 70 SkAlignedSTStorage<1, GrPipeline> fPipelineStorage; |
| 71 bool fPipelineInstalled; |
46 typedef GrBatch INHERITED; | 72 typedef GrBatch INHERITED; |
47 }; | 73 }; |
48 | 74 |
49 #endif | 75 #endif |
OLD | NEW |