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, const SkISize& backingTextureSize, | 84 GrAtlas(GrGpu*, GrPixelConfig, GrTextureFlags flags, |
| 85 const SkISize& backingTextureSize, |
85 int numPlotsX, int numPlotsY, bool batchUploads); | 86 int numPlotsX, int numPlotsY, bool batchUploads); |
86 ~GrAtlas(); | 87 ~GrAtlas(); |
87 | 88 |
88 // add subimage of width, height dimensions to atlas | 89 // Adds a width x height subimage to the atlas. Upon success it returns |
89 // returns the containing GrPlot and location relative to the backing textur
e | 90 // the containing GrPlot and absolute location in the backing texture. |
90 GrPlot* addToAtlas(ClientPlotUsage*, int width, int height, const void*, SkI
Point16*); | 91 // NULL is returned if the subimage cannot fit in the atlas. |
| 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); |
91 | 95 |
92 // remove reference to this plot | 96 // remove reference to this plot |
93 void removePlot(ClientPlotUsage* usage, const GrPlot* plot); | 97 void removePlot(ClientPlotUsage* usage, const GrPlot* plot); |
94 | 98 |
95 // get a plot that's not being used by the current draw | 99 // get a plot that's not being used by the current draw |
96 // this allows us to overwrite this plot without flushing | 100 // this allows us to overwrite this plot without flushing |
97 GrPlot* getUnusedPlot(); | 101 GrPlot* getUnusedPlot(); |
98 | 102 |
99 GrTexture* getTexture() const { | 103 GrTexture* getTexture() const { |
100 return fTexture; | 104 return fTexture; |
101 } | 105 } |
102 | 106 |
103 void uploadPlotsToTexture(); | 107 void uploadPlotsToTexture(); |
104 | 108 |
105 private: | 109 private: |
106 void makeMRU(GrPlot* plot); | 110 void makeMRU(GrPlot* plot); |
107 | 111 |
108 GrGpu* fGpu; | 112 GrGpu* fGpu; |
109 GrPixelConfig fPixelConfig; | 113 GrPixelConfig fPixelConfig; |
110 GrTexture* fTexture; | 114 GrTextureFlags fFlags; |
111 SkISize fBackingTextureSize; | 115 GrTexture* fTexture; |
112 int fNumPlotsX; | 116 SkISize fBackingTextureSize; |
113 int fNumPlotsY; | 117 int fNumPlotsX; |
114 bool fBatchUploads; | 118 int fNumPlotsY; |
| 119 bool fBatchUploads; |
115 | 120 |
116 // allocated array of GrPlots | 121 // allocated array of GrPlots |
117 GrPlot* fPlotArray; | 122 GrPlot* fPlotArray; |
118 // LRU list of GrPlots (MRU at head - LRU at tail) | 123 // LRU list of GrPlots (MRU at head - LRU at tail) |
119 GrPlotList fPlotList; | 124 GrPlotList fPlotList; |
120 }; | 125 }; |
121 | 126 |
122 #endif | 127 #endif |
OLD | NEW |