OLD | NEW |
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 class ClientPlotUsage { | 74 class ClientPlotUsage { |
75 public: | 75 public: |
76 bool isEmpty() const { return 0 == fPlots.count(); } | 76 bool isEmpty() const { return 0 == fPlots.count(); } |
77 | 77 |
78 private: | 78 private: |
79 SkTDArray<GrPlot*> fPlots; | 79 SkTDArray<GrPlot*> fPlots; |
80 | 80 |
81 friend class GrAtlas; | 81 friend class GrAtlas; |
82 }; | 82 }; |
83 | 83 |
84 GrAtlas(GrGpu*, GrPixelConfig, GrTextureFlags flags, | 84 GrAtlas(GrGpu*, GrPixelConfig, const SkISize& backingTextureSize, |
85 const SkISize& backingTextureSize, | |
86 int numPlotsX, int numPlotsY, bool batchUploads); | 85 int numPlotsX, int numPlotsY, bool batchUploads); |
87 ~GrAtlas(); | 86 ~GrAtlas(); |
88 | 87 |
89 // Adds a width x height subimage to the atlas. Upon success it returns | 88 // add subimage of width, height dimensions to atlas |
90 // the containing GrPlot and absolute location in the backing texture. | 89 // returns the containing GrPlot and location relative to the backing textur
e |
91 // NULL is returned if the subimage cannot fit in the atlas. | 90 GrPlot* addToAtlas(ClientPlotUsage*, int width, int height, const void*, SkI
Point16*); |
92 // If provided, the image data will either be immediately uploaded or | |
93 // written to the CPU-side backing bitmap. | |
94 GrPlot* addToAtlas(ClientPlotUsage*, int width, int height, const void* imag
e, SkIPoint16* loc); | |
95 | 91 |
96 // remove reference to this plot | 92 // remove reference to this plot |
97 void removePlot(ClientPlotUsage* usage, const GrPlot* plot); | 93 void removePlot(ClientPlotUsage* usage, const GrPlot* plot); |
98 | 94 |
99 // get a plot that's not being used by the current draw | 95 // get a plot that's not being used by the current draw |
100 // this allows us to overwrite this plot without flushing | 96 // this allows us to overwrite this plot without flushing |
101 GrPlot* getUnusedPlot(); | 97 GrPlot* getUnusedPlot(); |
102 | 98 |
103 GrTexture* getTexture() const { | 99 GrTexture* getTexture() const { |
104 return fTexture; | 100 return fTexture; |
105 } | 101 } |
106 | 102 |
107 void uploadPlotsToTexture(); | 103 void uploadPlotsToTexture(); |
108 | 104 |
109 private: | 105 private: |
110 void makeMRU(GrPlot* plot); | 106 void makeMRU(GrPlot* plot); |
111 | 107 |
112 GrGpu* fGpu; | 108 GrGpu* fGpu; |
113 GrPixelConfig fPixelConfig; | 109 GrPixelConfig fPixelConfig; |
114 GrTextureFlags fFlags; | 110 GrTexture* fTexture; |
115 GrTexture* fTexture; | 111 SkISize fBackingTextureSize; |
116 SkISize fBackingTextureSize; | 112 int fNumPlotsX; |
117 int fNumPlotsX; | 113 int fNumPlotsY; |
118 int fNumPlotsY; | 114 bool fBatchUploads; |
119 bool fBatchUploads; | |
120 | 115 |
121 // allocated array of GrPlots | 116 // allocated array of GrPlots |
122 GrPlot* fPlotArray; | 117 GrPlot* fPlotArray; |
123 // LRU list of GrPlots (MRU at head - LRU at tail) | 118 // LRU list of GrPlots (MRU at head - LRU at tail) |
124 GrPlotList fPlotList; | 119 GrPlotList fPlotList; |
125 }; | 120 }; |
126 | 121 |
127 #endif | 122 #endif |
OLD | NEW |