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

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

Issue 1275393003: Fix for 510931, merge to m44 (Closed) Base URL: https://skia.googlesource.com/skia.git@m44
Patch Set: Created 5 years, 4 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/GrAtlasTextContext.cpp ('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
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 class BatchPlot; 16 class BatchPlot;
17 class GrBatchTarget; 17 class GrBatchTarget;
18 class GrRectanizer; 18 class GrRectanizer;
19 19
20 typedef SkTInternalLList<BatchPlot> GrBatchPlotList; 20 typedef SkTInternalLList<BatchPlot> GrBatchPlotList;
21 21
22 class GrBatchAtlas { 22 class GrBatchAtlas {
23 public: 23 public:
24 typedef uint64_t BatchToken; 24 typedef uint64_t BatchToken;
25 // An AtlasID is an opaque handle which callers can use to determine if the atlas contains 25 // An AtlasID is an opaque handle which callers can use to determine if the atlas contains
26 // a specific piece of data 26 // a specific piece of data
27 typedef uint32_t AtlasID; 27 typedef uint64_t AtlasID;
28 static const uint32_t kInvalidAtlasID = 0; 28 static const uint32_t kInvalidAtlasID = 0;
29 static const uint64_t kInvalidAtlasGeneration = 0; 29 static const uint64_t kInvalidAtlasGeneration = 0;
30 30
31 // A function pointer for use as a callback during eviction. Whenever GrBat chAtlas evicts a 31 // A function pointer for use as a callback during eviction. Whenever GrBat chAtlas evicts a
32 // specific AtlasID, it will call all of the registered listeners so they ca n optionally process 32 // specific AtlasID, it will call all of the registered listeners so they ca n optionally process
33 // the eviction 33 // the eviction
34 typedef void (*EvictionFunc)(GrBatchAtlas::AtlasID, void*); 34 typedef void (*EvictionFunc)(GrBatchAtlas::AtlasID, void*);
35 35
36 GrBatchAtlas(GrTexture*, int numPlotsX, int numPlotsY); 36 GrBatchAtlas(GrTexture*, int numPlotsX, int numPlotsY);
37 ~GrBatchAtlas(); 37 ~GrBatchAtlas();
(...skipping 22 matching lines...) Expand all
60 } 60 }
61 61
62 /* 62 /*
63 * A class which can be handed back to GrBatchAtlas for updating in bulk las t use tokens. The 63 * A class which can be handed back to GrBatchAtlas for updating in bulk las t use tokens. The
64 * current max number of plots the GrBatchAtlas can handle is 32, if in the future this is 64 * current max number of plots the GrBatchAtlas can handle is 32, if in the future this is
65 * insufficient then we can move to a 64 bit int 65 * insufficient then we can move to a 64 bit int
66 */ 66 */
67 class BulkUseTokenUpdater { 67 class BulkUseTokenUpdater {
68 public: 68 public:
69 BulkUseTokenUpdater() : fPlotAlreadyUpdated(0) {} 69 BulkUseTokenUpdater() : fPlotAlreadyUpdated(0) {}
70 BulkUseTokenUpdater(const BulkUseTokenUpdater& that)
71 : fPlotsToUpdate(that.fPlotsToUpdate)
72 , fPlotAlreadyUpdated(that.fPlotAlreadyUpdated) {
73 }
74
70 void add(AtlasID id) { 75 void add(AtlasID id) {
71 int index = GrBatchAtlas::GetIndexFromID(id); 76 int index = GrBatchAtlas::GetIndexFromID(id);
72 if (!this->find(index)) { 77 if (!this->find(index)) {
73 this->set(index); 78 this->set(index);
74 } 79 }
75 } 80 }
76 81
77 void reset() { 82 void reset() {
78 fPlotsToUpdate.reset(); 83 fPlotsToUpdate.reset();
79 fPlotAlreadyUpdated = 0; 84 fPlotAlreadyUpdated = 0;
(...skipping 20 matching lines...) Expand all
100 }; 105 };
101 106
102 void setLastUseTokenBulk(const BulkUseTokenUpdater& reffer, BatchToken); 107 void setLastUseTokenBulk(const BulkUseTokenUpdater& reffer, BatchToken);
103 108
104 static const int kGlyphMaxDim = 256; 109 static const int kGlyphMaxDim = 256;
105 static bool GlyphTooLargeForAtlas(int width, int height) { 110 static bool GlyphTooLargeForAtlas(int width, int height) {
106 return width > kGlyphMaxDim || height > kGlyphMaxDim; 111 return width > kGlyphMaxDim || height > kGlyphMaxDim;
107 } 112 }
108 113
109 private: 114 private:
110 static int GetIndexFromID(AtlasID id) { 115 static uint32_t GetIndexFromID(AtlasID id) {
111 return id & 0xffff; 116 return id & 0xffff;
112 } 117 }
113 118
114 static int GetGenerationFromID(AtlasID id) { 119 // top 48 bits are reserved for the generation ID
115 return (id >> 16) & 0xffff; 120 static uint64_t GetGenerationFromID(AtlasID id) {
121 return (id >> 16) & 0xffffffffffff;
116 } 122 }
117 123
118 inline void updatePlot(GrBatchTarget*, AtlasID*, BatchPlot*); 124 inline void updatePlot(GrBatchTarget*, AtlasID*, BatchPlot*);
119 125
120 inline void makeMRU(BatchPlot* plot); 126 inline void makeMRU(BatchPlot* plot);
121 127
122 inline void processEviction(AtlasID); 128 inline void processEviction(AtlasID);
123 129
124 GrTexture* fTexture; 130 GrTexture* fTexture;
125 int fNumPlotsX; 131 uint32_t fNumPlotsX;
126 int fNumPlotsY; 132 uint32_t fNumPlotsY;
127 int fPlotWidth; 133 uint32_t fPlotWidth;
128 int fPlotHeight; 134 uint32_t fPlotHeight;
129 size_t fBPP; 135 size_t fBPP;
130 uint64_t fAtlasGeneration; 136 uint64_t fAtlasGeneration;
131 137
132 struct EvictionData { 138 struct EvictionData {
133 EvictionFunc fFunc; 139 EvictionFunc fFunc;
134 void* fData; 140 void* fData;
135 }; 141 };
136 142
137 SkTDArray<EvictionData> fEvictionCallbacks; 143 SkTDArray<EvictionData> fEvictionCallbacks;
138 // allocated array of GrBatchPlots 144 // allocated array of GrBatchPlots
139 SkAutoTUnref<BatchPlot>* fPlotArray; 145 SkAutoTUnref<BatchPlot>* fPlotArray;
140 // LRU list of GrPlots (MRU at head - LRU at tail) 146 // LRU list of GrPlots (MRU at head - LRU at tail)
141 GrBatchPlotList fPlotList; 147 GrBatchPlotList fPlotList;
142 }; 148 };
143 149
144 #endif 150 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAtlasTextContext.cpp ('k') | src/gpu/GrBatchAtlas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698