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

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

Issue 1142273002: Revert of small cleanup of GrAtlas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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/GrAtlas.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 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifndef GrAtlas_DEFINED 9 #ifndef GrAtlas_DEFINED
10 #define GrAtlas_DEFINED 10 #define GrAtlas_DEFINED
(...skipping 23 matching lines...) Expand all
34 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrPlot); 34 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrPlot);
35 35
36 // This returns a plot ID unique to each plot in a given GrAtlas. They are 36 // This returns a plot ID unique to each plot in a given GrAtlas. They are
37 // consecutive and start at 0. 37 // consecutive and start at 0.
38 int id() const { return fID; } 38 int id() const { return fID; }
39 39
40 GrTexture* texture() const { return fTexture; } 40 GrTexture* texture() const { return fTexture; }
41 41
42 bool addSubImage(int width, int height, const void*, SkIPoint16*); 42 bool addSubImage(int width, int height, const void*, SkIPoint16*);
43 43
44 GrDrawTarget::DrawToken drawToken() const { return fDrawToken; }
45 void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; }
46
47 void uploadToTexture();
48
44 void resetRects(); 49 void resetRects();
45 50
46 private: 51 private:
47 GrPlot(); 52 GrPlot();
48 ~GrPlot(); // does not try to delete the fNext field 53 ~GrPlot(); // does not try to delete the fNext field
49 void init(GrAtlas* atlas, int id, int offX, int offY, int width, int height, size_t bpp, 54 void init(GrAtlas* atlas, int id, int offX, int offY, int width, int height, size_t bpp,
50 bool batchUploads); 55 bool batchUploads);
51 56
57 // for recycling
58 GrDrawTarget::DrawToken fDrawToken;
59
52 int fID; 60 int fID;
53 unsigned char* fPlotData; 61 unsigned char* fPlotData;
54 GrTexture* fTexture; 62 GrTexture* fTexture;
55 GrRectanizer* fRects; 63 GrRectanizer* fRects;
56 GrAtlas* fAtlas; 64 GrAtlas* fAtlas;
57 SkIPoint16 fOffset; // the offset of the plot in the bac king texture 65 SkIPoint16 fOffset; // the offset of the plot in the bac king texture
58 size_t fBytesPerPixel; 66 size_t fBytesPerPixel;
59 SkIRect fDirtyRect; 67 SkIRect fDirtyRect;
60 bool fDirty; 68 bool fDirty;
61 bool fBatchUploads; 69 bool fBatchUploads;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // Adds a width x height subimage to the atlas. Upon success it returns 101 // Adds a width x height subimage to the atlas. Upon success it returns
94 // the containing GrPlot and absolute location in the backing texture. 102 // the containing GrPlot and absolute location in the backing texture.
95 // NULL is returned if the subimage cannot fit in the atlas. 103 // NULL is returned if the subimage cannot fit in the atlas.
96 // If provided, the image data will either be immediately uploaded or 104 // If provided, the image data will either be immediately uploaded or
97 // written to the CPU-side backing bitmap. 105 // written to the CPU-side backing bitmap.
98 GrPlot* addToAtlas(ClientPlotUsage*, int width, int height, const void* imag e, SkIPoint16* loc); 106 GrPlot* addToAtlas(ClientPlotUsage*, int width, int height, const void* imag e, SkIPoint16* loc);
99 107
100 // remove reference to this plot 108 // remove reference to this plot
101 static void RemovePlot(ClientPlotUsage* usage, const GrPlot* plot); 109 static void RemovePlot(ClientPlotUsage* usage, const GrPlot* plot);
102 110
111 // get a plot that's not being used by the current draw
112 // this allows us to overwrite this plot without flushing
113 GrPlot* getUnusedPlot();
114
103 GrTexture* getTexture() const { 115 GrTexture* getTexture() const {
104 return fTexture; 116 return fTexture;
105 } 117 }
106 118
119 void uploadPlotsToTexture();
120
107 enum IterOrder { 121 enum IterOrder {
108 kLRUFirst_IterOrder, 122 kLRUFirst_IterOrder,
109 kMRUFirst_IterOrder 123 kMRUFirst_IterOrder
110 }; 124 };
111 125
112 typedef GrPlotList::Iter PlotIter; 126 typedef GrPlotList::Iter PlotIter;
113 GrPlot* iterInit(PlotIter* iter, IterOrder order) { 127 GrPlot* iterInit(PlotIter* iter, IterOrder order) {
114 return iter->init(fPlotList, kLRUFirst_IterOrder == order 128 return iter->init(fPlotList, kLRUFirst_IterOrder == order
115 ? GrPlotList::Iter::kTail _IterStart 129 ? GrPlotList::Iter::kTail _IterStart
116 : GrPlotList::Iter::kHead _IterStart); 130 : GrPlotList::Iter::kHead _IterStart);
117 } 131 }
118 132
119 private: 133 private:
120 void makeMRU(GrPlot* plot); 134 void makeMRU(GrPlot* plot);
121 135
122 GrGpu* fGpu; 136 GrGpu* fGpu;
123 GrPixelConfig fPixelConfig; 137 GrPixelConfig fPixelConfig;
124 GrSurfaceFlags fFlags; 138 GrSurfaceFlags fFlags;
125 GrTexture* fTexture; 139 GrTexture* fTexture;
126 SkISize fBackingTextureSize; 140 SkISize fBackingTextureSize;
127 int fNumPlotsX; 141 int fNumPlotsX;
128 int fNumPlotsY; 142 int fNumPlotsY;
129 bool fBatchUploads; 143 bool fBatchUploads;
130 144
131 // allocated array of GrPlots 145 // allocated array of GrPlots
132 GrPlot* fPlotArray; 146 GrPlot* fPlotArray;
133 // LRU list of GrPlots (MRU at head - LRU at tail) 147 // LRU list of GrPlots (MRU at head - LRU at tail)
134 GrPlotList fPlotList; 148 GrPlotList fPlotList;
135 }; 149 };
136 150
137 #endif 151 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrAtlas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698