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 | 9 |
10 | 10 |
11 #ifndef GrAtlas_DEFINED | 11 #ifndef GrAtlas_DEFINED |
12 #define GrAtlas_DEFINED | 12 #define GrAtlas_DEFINED |
13 | 13 |
14 #include "GrPoint.h" | 14 #include "GrPoint.h" |
15 #include "GrTexture.h" | 15 #include "GrTexture.h" |
| 16 #include "GrDrawTarget.h" |
16 | 17 |
17 class GrGpu; | 18 class GrGpu; |
18 class GrRectanizer; | 19 class GrRectanizer; |
19 class GrAtlasMgr; | 20 class GrAtlasMgr; |
20 | 21 |
21 class GrAtlas { | 22 class GrAtlas { |
22 public: | 23 public: |
23 int getPlotX() const { return fPlot.fX; } | 24 int getPlotX() const { return fPlot.fX; } |
24 int getPlotY() const { return fPlot.fY; } | 25 int getPlotY() const { return fPlot.fY; } |
25 GrMaskFormat getMaskFormat() const { return fMaskFormat; } | 26 GrMaskFormat getMaskFormat() const { return fMaskFormat; } |
26 | 27 |
27 GrTexture* texture() const { return fTexture; } | 28 GrTexture* texture() const { return fTexture; } |
28 | 29 |
29 bool addSubImage(int width, int height, const void*, GrIPoint16*); | 30 bool addSubImage(int width, int height, const void*, GrIPoint16*); |
30 | 31 |
31 static void FreeLList(GrAtlas* atlas) { | 32 static void FreeLList(GrAtlas* atlas) { |
32 while (NULL != atlas) { | 33 while (NULL != atlas) { |
33 GrAtlas* next = atlas->fNext; | 34 GrAtlas* next = atlas->fNext; |
34 delete atlas; | 35 delete atlas; |
35 atlas = next; | 36 atlas = next; |
36 } | 37 } |
37 } | 38 } |
38 | 39 |
39 static void MarkAllUnused(GrAtlas* atlas) { | |
40 while (NULL != atlas) { | |
41 atlas->fUsed = false; | |
42 atlas = atlas->fNext; | |
43 } | |
44 } | |
45 | |
46 static bool RemoveUnusedAtlases(GrAtlasMgr* atlasMgr, GrAtlas** startAtlas); | 40 static bool RemoveUnusedAtlases(GrAtlasMgr* atlasMgr, GrAtlas** startAtlas); |
47 | 41 |
48 bool used() const { return fUsed; } | 42 GrDrawTarget::DrawToken drawToken() const { return fDrawToken; } |
49 void setUsed(bool used) { fUsed = used; } | 43 void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; } |
50 | 44 |
51 private: | 45 private: |
52 GrAtlas(GrAtlasMgr*, int plotX, int plotY, GrMaskFormat format); | 46 GrAtlas(GrAtlasMgr*, int plotX, int plotY, GrMaskFormat format); |
53 ~GrAtlas(); // does not try to delete the fNext field | 47 ~GrAtlas(); // does not try to delete the fNext field |
54 | 48 |
55 GrAtlas* fNext; | 49 // for recycling |
| 50 GrDrawTarget::DrawToken fDrawToken; |
56 | 51 |
57 // for recycling | 52 GrAtlas* fNext; |
58 bool fUsed; | |
59 | 53 |
60 GrTexture* fTexture; | 54 GrTexture* fTexture; |
61 GrRectanizer* fRects; | 55 GrRectanizer* fRects; |
62 GrAtlasMgr* fAtlasMgr; | 56 GrAtlasMgr* fAtlasMgr; |
63 GrIPoint16 fPlot; | 57 GrIPoint16 fPlot; |
64 GrMaskFormat fMaskFormat; | 58 GrMaskFormat fMaskFormat; |
65 | 59 |
66 friend class GrAtlasMgr; | 60 friend class GrAtlasMgr; |
67 }; | 61 }; |
68 | 62 |
69 class GrPlotMgr; | 63 class GrPlotMgr; |
70 | 64 |
71 class GrAtlasMgr { | 65 class GrAtlasMgr { |
72 public: | 66 public: |
73 GrAtlasMgr(GrGpu*); | 67 GrAtlasMgr(GrGpu*); |
74 ~GrAtlasMgr(); | 68 ~GrAtlasMgr(); |
(...skipping 10 matching lines...) Expand all Loading... |
85 // to be called by ~GrAtlas() | 79 // to be called by ~GrAtlas() |
86 void freePlot(GrMaskFormat format, int x, int y); | 80 void freePlot(GrMaskFormat format, int x, int y); |
87 | 81 |
88 private: | 82 private: |
89 GrGpu* fGpu; | 83 GrGpu* fGpu; |
90 GrTexture* fTexture[kCount_GrMaskFormats]; | 84 GrTexture* fTexture[kCount_GrMaskFormats]; |
91 GrPlotMgr* fPlotMgr; | 85 GrPlotMgr* fPlotMgr; |
92 }; | 86 }; |
93 | 87 |
94 #endif | 88 #endif |
OLD | NEW |