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

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

Issue 1904723003: Revert of Use transfer buffer for BatchAtlas texture copies (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | src/gpu/GrBatchAtlas.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 GrBatchAtlas_DEFINED 8 #ifndef GrBatchAtlas_DEFINED
9 #define GrBatchAtlas_DEFINED 9 #define GrBatchAtlas_DEFINED
10 10
11 #include "GrTexture.h" 11 #include "GrTexture.h"
12 #include "SkPoint.h" 12 #include "SkPoint.h"
13 #include "SkTDArray.h" 13 #include "SkTDArray.h"
14 #include "SkTInternalLList.h" 14 #include "SkTInternalLList.h"
15 15
16 #include "batches/GrDrawBatch.h" 16 #include "batches/GrDrawBatch.h"
17 17
18 class GrRectanizer; 18 class GrRectanizer;
19 class GrResourceProvider;
20 class GrBuffer;
21 19
22 struct GrBatchAtlasConfig { 20 struct GrBatchAtlasConfig {
23 int numPlotsX() const { return fWidth / fPlotWidth; } 21 int numPlotsX() const { return fWidth / fPlotWidth; }
24 int numPlotsY() const { return fHeight / fPlotWidth; } 22 int numPlotsY() const { return fHeight / fPlotWidth; }
25 int fWidth; 23 int fWidth;
26 int fHeight; 24 int fHeight;
27 int fLog2Width; 25 int fLog2Width;
28 int fLog2Height; 26 int fLog2Height;
29 int fPlotWidth; 27 int fPlotWidth;
30 int fPlotHeight; 28 int fPlotHeight;
31 }; 29 };
32 30
33 class GrBatchAtlas { 31 class GrBatchAtlas {
34 public: 32 public:
35 // An AtlasID is an opaque handle which callers can use to determine if the atlas contains 33 // An AtlasID is an opaque handle which callers can use to determine if the atlas contains
36 // a specific piece of data 34 // a specific piece of data
37 typedef uint64_t AtlasID; 35 typedef uint64_t AtlasID;
38 static const uint32_t kInvalidAtlasID = 0; 36 static const uint32_t kInvalidAtlasID = 0;
39 static const uint64_t kInvalidAtlasGeneration = 0; 37 static const uint64_t kInvalidAtlasGeneration = 0;
40 38
41 // A function pointer for use as a callback during eviction. Whenever GrBat chAtlas evicts a 39 // A function pointer for use as a callback during eviction. Whenever GrBat chAtlas evicts a
42 // specific AtlasID, it will call all of the registered listeners so they ca n optionally process 40 // specific AtlasID, it will call all of the registered listeners so they ca n optionally process
43 // the eviction 41 // the eviction
44 typedef void (*EvictionFunc)(GrBatchAtlas::AtlasID, void*); 42 typedef void (*EvictionFunc)(GrBatchAtlas::AtlasID, void*);
45 43
46 GrBatchAtlas(GrResourceProvider*, GrTexture*, int numPlotsX, int numPlotsY); 44 GrBatchAtlas(GrTexture*, int numPlotsX, int numPlotsY);
47 ~GrBatchAtlas(); 45 ~GrBatchAtlas();
48 46
49 // Adds a width x height subimage to the atlas. Upon success it returns 47 // Adds a width x height subimage to the atlas. Upon success it returns
50 // the containing GrPlot and absolute location in the backing texture. 48 // the containing GrPlot and absolute location in the backing texture.
51 // nullptr is returned if the subimage cannot fit in the atlas. 49 // nullptr is returned if the subimage cannot fit in the atlas.
52 // If provided, the image data will be written to the CPU-side backing bitma p. 50 // If provided, the image data will be written to the CPU-side backing bitma p.
53 // NOTE: If the client intends to refer to the atlas, they should immediatel y call 'setUseToken' 51 // NOTE: If the client intends to refer to the atlas, they should immediatel y call 'setUseToken'
54 // with the currentToken from the batch target, otherwise the next call to a ddToAtlas might 52 // with the currentToken from the batch target, otherwise the next call to a ddToAtlas might
55 // cause an eviction 53 // cause an eviction
56 bool addToAtlas(AtlasID*, GrDrawBatch::Target*, int width, int height, const void* image, 54 bool addToAtlas(AtlasID*, GrDrawBatch::Target*, int width, int height, const void* image,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // To manage the lifetime of a plot, we use two tokens. We use the last upload token to 165 // To manage the lifetime of a plot, we use two tokens. We use the last upload token to
168 // know when we can 'piggy back' uploads, ie if the last upload hasn't b een flushed to gpu, 166 // know when we can 'piggy back' uploads, ie if the last upload hasn't b een flushed to gpu,
169 // we don't need to issue a new upload even if we update the cpu backing store. We use 167 // we don't need to issue a new upload even if we update the cpu backing store. We use
170 // lastUse to determine when we can evict a plot from the cache, ie if t he last use has 168 // lastUse to determine when we can evict a plot from the cache, ie if t he last use has
171 // already flushed through the gpu then we can reuse the plot. 169 // already flushed through the gpu then we can reuse the plot.
172 GrBatchDrawToken lastUploadToken() const { return fLastUpload; } 170 GrBatchDrawToken lastUploadToken() const { return fLastUpload; }
173 GrBatchDrawToken lastUseToken() const { return fLastUse; } 171 GrBatchDrawToken lastUseToken() const { return fLastUse; }
174 void setLastUploadToken(GrBatchDrawToken batchToken) { fLastUpload = bat chToken; } 172 void setLastUploadToken(GrBatchDrawToken batchToken) { fLastUpload = bat chToken; }
175 void setLastUseToken(GrBatchDrawToken batchToken) { fLastUse = batchToke n; } 173 void setLastUseToken(GrBatchDrawToken batchToken) { fLastUse = batchToke n; }
176 174
177 void uploadToTexture(GrDrawBatch::WritePixelsFn&, GrDrawBatch::TransferP ixelsFn&, 175 void uploadToTexture(GrDrawBatch::WritePixelsFn&, GrTexture* texture);
178 GrTexture* texture);
179 void resetRects(); 176 void resetRects();
180 177
181 private: 178 private:
182 BatchPlot(int index, uint64_t genID, int offX, int offY, int width, int height, 179 BatchPlot(int index, uint64_t genID, int offX, int offY, int width, int height,
183 GrPixelConfig config, GrResourceProvider* rp); 180 GrPixelConfig config);
184 181
185 ~BatchPlot() override; 182 ~BatchPlot() override;
186 183
187 // Create a clone of this plot. The cloned plot will take the place of t he 184 // Create a clone of this plot. The cloned plot will take the place of t he
188 // current plot in the atlas. 185 // current plot in the atlas.
189 BatchPlot* clone() const { 186 BatchPlot* clone() const {
190 return new BatchPlot(fIndex, fGenID+1, fX, fY, fWidth, fHeight, fCon fig, 187 return new BatchPlot(fIndex, fGenID+1, fX, fY, fWidth, fHeight, fCon fig);
191 fResourceProvider);
192 } 188 }
193 189
194 static GrBatchAtlas::AtlasID CreateId(uint32_t index, uint64_t generatio n) { 190 static GrBatchAtlas::AtlasID CreateId(uint32_t index, uint64_t generatio n) {
195 SkASSERT(index < (1 << 16)); 191 SkASSERT(index < (1 << 16));
196 SkASSERT(generation < ((uint64_t)1 << 48)); 192 SkASSERT(generation < ((uint64_t)1 << 48));
197 return generation << 16 | index; 193 return generation << 16 | index;
198 } 194 }
199 195
200 // used to create transfer buffers
201 GrResourceProvider* fResourceProvider;
202 GrBatchDrawToken fLastUpload; 196 GrBatchDrawToken fLastUpload;
203 GrBatchDrawToken fLastUse; 197 GrBatchDrawToken fLastUse;
204 198
205 const uint32_t fIndex; 199 const uint32_t fIndex;
206 uint64_t fGenID; 200 uint64_t fGenID;
207 GrBatchAtlas::AtlasID fID; 201 GrBatchAtlas::AtlasID fID;
208 unsigned char* fDataPtr; 202 unsigned char* fData;
209 GrBuffer* fTransferBuffer;
210 const int fWidth; 203 const int fWidth;
211 const int fHeight; 204 const int fHeight;
212 const int fX; 205 const int fX;
213 const int fY; 206 const int fY;
214 GrRectanizer* fRects; 207 GrRectanizer* fRects;
215 const SkIPoint16 fOffset; // the offset of the plot in the b acking texture 208 const SkIPoint16 fOffset; // the offset of the plot in the b acking texture
216 const GrPixelConfig fConfig; 209 const GrPixelConfig fConfig;
217 const size_t fBytesPerPixel; 210 const size_t fBytesPerPixel;
218 SkIRect fDirtyRect; 211 SkIRect fDirtyRect;
219 SkDEBUGCODE(bool fDirty;) 212 SkDEBUGCODE(bool fDirty;)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 }; 251 };
259 252
260 SkTDArray<EvictionData> fEvictionCallbacks; 253 SkTDArray<EvictionData> fEvictionCallbacks;
261 // allocated array of GrBatchPlots 254 // allocated array of GrBatchPlots
262 SkAutoTUnref<BatchPlot>* fPlotArray; 255 SkAutoTUnref<BatchPlot>* fPlotArray;
263 // LRU list of GrPlots (MRU at head - LRU at tail) 256 // LRU list of GrPlots (MRU at head - LRU at tail)
264 GrBatchPlotList fPlotList; 257 GrBatchPlotList fPlotList;
265 }; 258 };
266 259
267 #endif 260 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrBatchAtlas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698