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

Side by Side Diff: src/gpu/batches/GrBatch.h

Issue 1355353002: Create GrDraw and start fast pathing src over rects (Closed) Base URL: https://skia.googlesource.com/skia.git@strokerect2
Patch Set: rebase Created 5 years, 3 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 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 GrBatch_DEFINED 8 #ifndef GrBatch_DEFINED
9 #define GrBatch_DEFINED 9 #define GrBatch_DEFINED
10 10
11 #include <new> 11 #include <new>
12 #include "GrNonAtomicRef.h" 12 #include "GrNonAtomicRef.h"
13 13
14 #include "SkRect.h" 14 #include "SkRect.h"
15 #include "SkString.h" 15 #include "SkString.h"
16 16
17 #include "draws/GrDraw.h"
18
17 class GrCaps; 19 class GrCaps;
18 class GrBatchFlushState; 20 class GrBatchFlushState;
19 21
20 /** 22 /**
21 * GrBatch is the base class for all Ganesh deferred geometry generators. To fa cilitate 23 * GrBatch is the base class for all Ganesh deferred geometry generators. To fa cilitate
22 * reorderable batching, Ganesh does not generate geometry inline with draw call s. Instead, it 24 * reorderable batching, Ganesh does not generate geometry inline with draw call s. Instead, it
23 * captures the arguments to the draw and then generates the geometry on demand. This gives GrBatch 25 * captures the arguments to the draw and then generates the geometry on demand. This gives GrBatch
24 * subclasses complete freedom to decide how / what they can batch. 26 * subclasses complete freedom to decide how / what they can batch.
25 * 27 *
26 * Batches are created when GrContext processes a draw call. Batches of the same subclass may be 28 * Batches are created when GrContext processes a draw call. Batches of the same subclass may be
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 /** Issues the batches commands to GrGpu. */ 104 /** Issues the batches commands to GrGpu. */
103 void draw(GrBatchFlushState* state) { this->onDraw(state); } 105 void draw(GrBatchFlushState* state) { this->onDraw(state); }
104 106
105 /** Used to block batching across render target changes. Remove this once we store 107 /** Used to block batching across render target changes. Remove this once we store
106 GrBatches for different RTs in different targets. */ 108 GrBatches for different RTs in different targets. */
107 virtual uint32_t renderTargetUniqueID() const = 0; 109 virtual uint32_t renderTargetUniqueID() const = 0;
108 110
109 /** Used for spewing information about batches when debugging. */ 111 /** Used for spewing information about batches when debugging. */
110 virtual SkString dumpInfo() const = 0; 112 virtual SkString dumpInfo() const = 0;
111 113
114 // TODO put on stack
115 template <class T> T* getSnapStorage() {
bsalomon 2015/09/23 13:49:38 Can we do anything here with var args to forward c
joshualitt 2015/09/25 18:17:12 Acknowledged.
116 SkASSERT(sizeof(T) < fSnapStorage.size());
117 fSnap = reinterpret_cast<GrDrawSnap*>(fSnapStorage.get());
118 return reinterpret_cast<T*>(fSnap);
119 }
120 const GrDrawSnap* drawSnap() const { return fSnap; }
121
112 protected: 122 protected:
113 // NOTE, compute some bounds, even if extremely conservative. Do *NOT* setL argest on the bounds 123 // NOTE, compute some bounds, even if extremely conservative. Do *NOT* setL argest on the bounds
114 // rect because we outset it for dst copy textures 124 // rect because we outset it for dst copy textures
115 void setBounds(const SkRect& newBounds) { fBounds = newBounds; } 125 void setBounds(const SkRect& newBounds) { fBounds = newBounds; }
116 126
117 void joinBounds(const SkRect& otherBounds) { 127 void joinBounds(const SkRect& otherBounds) {
118 return fBounds.joinPossiblyEmptyRect(otherBounds); 128 return fBounds.joinPossiblyEmptyRect(otherBounds);
119 } 129 }
120 130
121 static uint32_t GenBatchClassID() { return GenID(&gCurrBatchClassID); } 131 static uint32_t GenBatchClassID() { return GenID(&gCurrBatchClassID); }
(...skipping 21 matching lines...) Expand all
143 kIllegalBatchID = 0, 153 kIllegalBatchID = 0,
144 }; 154 };
145 155
146 SkDEBUGCODE(bool fUsed;) 156 SkDEBUGCODE(bool fUsed;)
147 const uint32_t fClassID; 157 const uint32_t fClassID;
148 #if GR_BATCH_SPEW 158 #if GR_BATCH_SPEW
149 static uint32_t GenBatchID() { return GenID(&gCurrBatchUniqueID); } 159 static uint32_t GenBatchID() { return GenID(&gCurrBatchUniqueID); }
150 const uint32_t fUniqueID; 160 const uint32_t fUniqueID;
151 static int32_t gCurrBatchUniqueID; 161 static int32_t gCurrBatchUniqueID;
152 #endif 162 #endif
163 GrDrawSnap* fSnap;
bsalomon 2015/09/23 13:49:38 alignment
robertphillips 2015/09/25 12:48:48 How was 256 arrived at ?
joshualitt 2015/09/25 18:17:12 magic! I'll add a comment
joshualitt 2015/09/25 18:17:12 Acknowledged.
164 SkAlignedSStorage<256> fSnapStorage;
165
153 static int32_t gCurrBatchClassID; 166 static int32_t gCurrBatchClassID;
154 typedef GrNonAtomicRef INHERITED; 167 typedef GrNonAtomicRef INHERITED;
155 }; 168 };
156 169
157 #endif 170 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698