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

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

Issue 1080673005: small fix for perf regression in GrAtlasTextContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 data->fData = userData; 59 data->fData = userData;
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), fCount(0), fAllocated(kM inItems) {} 69 BulkUseTokenUpdater() : fPlotAlreadyUpdated(0) {}
70 void add(AtlasID id) { 70 void add(AtlasID id) {
71 int index = GrBatchAtlas::GetIndexFromID(id); 71 int index = GrBatchAtlas::GetIndexFromID(id);
72 if (!this->find(index)) { 72 if (!this->find(index)) {
73 this->set(index); 73 this->set(index);
74 } 74 }
75 } 75 }
76 76
77 void reset() { 77 void reset() {
78 fPlotsToUpdate.reset(kMinItems); 78 fPlotsToUpdate.reset();
79 fAllocated = kMinItems;
80 fCount = 0;
81 fPlotAlreadyUpdated = 0; 79 fPlotAlreadyUpdated = 0;
82 } 80 }
83 81
84 private: 82 private:
85 bool find(int index) const { 83 bool find(int index) const {
86 SkASSERT(index < kMaxPlots); 84 SkASSERT(index < kMaxPlots);
87 return (fPlotAlreadyUpdated >> index) & 1; 85 return (fPlotAlreadyUpdated >> index) & 1;
88 } 86 }
89 87
90 void set(int index) { 88 void set(int index) {
91 SkASSERT(!this->find(index)); 89 SkASSERT(!this->find(index));
92 fPlotAlreadyUpdated = fPlotAlreadyUpdated | (1 << index); 90 fPlotAlreadyUpdated = fPlotAlreadyUpdated | (1 << index);
93 fPlotsToUpdate.push_back(index); 91 fPlotsToUpdate.push_back(index);
94 } 92 }
95 93
96 static const int kMinItems = 4; 94 static const int kMinItems = 4;
97 static const int kMaxPlots = 32; 95 static const int kMaxPlots = 32;
98 SkSTArray<kMinItems, int, true> fPlotsToUpdate; 96 SkSTArray<kMinItems, int, true> fPlotsToUpdate;
99 uint32_t fPlotAlreadyUpdated; 97 uint32_t fPlotAlreadyUpdated;
100 int fCount;
101 int fAllocated;
102 98
103 friend class GrBatchAtlas; 99 friend class GrBatchAtlas;
104 }; 100 };
105 101
106 void setLastUseTokenBulk(const BulkUseTokenUpdater& reffer, BatchToken); 102 void setLastUseTokenBulk(const BulkUseTokenUpdater& reffer, BatchToken);
107 103
108 static const int kGlyphMaxDim = 256; 104 static const int kGlyphMaxDim = 256;
109 static bool GlyphTooLargeForAtlas(int width, int height) { 105 static bool GlyphTooLargeForAtlas(int width, int height) {
110 return width > kGlyphMaxDim || height > kGlyphMaxDim; 106 return width > kGlyphMaxDim || height > kGlyphMaxDim;
111 } 107 }
(...skipping 27 matching lines...) Expand all
139 }; 135 };
140 136
141 SkTDArray<EvictionData> fEvictionCallbacks; 137 SkTDArray<EvictionData> fEvictionCallbacks;
142 // allocated array of GrBatchPlots 138 // allocated array of GrBatchPlots
143 SkAutoTUnref<BatchPlot>* fPlotArray; 139 SkAutoTUnref<BatchPlot>* fPlotArray;
144 // LRU list of GrPlots (MRU at head - LRU at tail) 140 // LRU list of GrPlots (MRU at head - LRU at tail)
145 GrBatchPlotList fPlotList; 141 GrBatchPlotList fPlotList;
146 }; 142 };
147 143
148 #endif 144 #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