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

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

Issue 975303005: Creation of GrBatchAtlas and Distancefieldpathrenderer batch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 5 years, 9 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 | « src/gpu/GrBatch.h ('k') | 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
(Empty)
1 /*
2 * Copyright 2015 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 GrBatchAtlas_DEFINED
9 #define GrBatchAtlas_DEFINED
10
11 #include "GrTexture.h"
12 #include "SkPoint.h"
13 #include "SkTDArray.h"
14 #include "SkTInternalLList.h"
15
16 class BatchPlot;
17 class GrBatchTarget;
18 class GrRectanizer;
19
20 typedef SkTInternalLList<BatchPlot> GrBatchPlotList;
21
22 class GrBatchAtlas {
23 public:
24 typedef uint64_t BatchToken;
25 // An AtlasID is an opaque handle which callers can use to determine if the atlas contains
26 // a specific piece of data
27 typedef uint32_t AtlasID;
28
29 // A function pointer for use as a callback during eviction. Whenever GrBat chAtlas evicts a
30 // specific AtlasID, it will call all of the registered listeners so they ca n optionally process
31 // the eviction
32 typedef void (*EvictionFunc)(GrBatchAtlas::AtlasID, void*);
33
34 GrBatchAtlas(GrTexture*, int numPlotsX, int numPlotsY);
35 ~GrBatchAtlas();
36
37 // Adds a width x height subimage to the atlas. Upon success it returns
38 // the containing GrPlot and absolute location in the backing texture.
39 // NULL is returned if the subimage cannot fit in the atlas.
40 // If provided, the image data will be written to the CPU-side backing bitma p.
41 bool addToAtlas(AtlasID*, GrBatchTarget*, int width, int height, const void* image,
42 SkIPoint16* loc);
43
44 GrTexture* getTexture() const { return fTexture; }
45
46 bool hasID(AtlasID id);
47 void setLastRefToken(AtlasID id, BatchToken batchToken);
48 void registerEvictionCallback(EvictionFunc func, void* userData) {
49 EvictionData* data = fEvictionCallbacks.append();
50 data->fFunc = func;
51 data->fData = userData;
52 }
53
54 private:
55 int getIndexFromID(AtlasID id) {
56 return id & 0xffff;
57 }
58
59 int getGenerationFromID(AtlasID id) {
60 return (id >> 16) & 0xffff;
61 }
62
63 inline void updatePlot(GrBatchTarget*, AtlasID*, BatchPlot*);
64
65 inline void makeMRU(BatchPlot* plot);
66
67 inline void processEviction(AtlasID);
68
69 GrTexture* fTexture;
70 int fNumPlotsX;
71 int fNumPlotsY;
72 int fPlotWidth;
73 int fPlotHeight;
74 size_t fBPP;
75
76 struct EvictionData {
77 EvictionFunc fFunc;
78 void* fData;
79 };
80
81 SkTDArray<EvictionData> fEvictionCallbacks;
82 // allocated array of GrBatchPlots
83 SkAutoTUnref<BatchPlot>* fPlotArray;
84 // LRU list of GrPlots (MRU at head - LRU at tail)
85 GrBatchPlotList fPlotList;
86 };
87
88 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrBatch.h ('k') | src/gpu/GrBatchAtlas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698