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

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

Issue 177463003: New approach for GPU font atlas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove unnecessary method declarations. Created 6 years, 9 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') | src/gpu/GrAtlas.cpp » ('J')
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 int getOffsetX() const { return fOffset.fX; } 34 int getOffsetX() const { return fOffset.fX; }
35 int getOffsetY() const { return fOffset.fY; } 35 int getOffsetY() const { return fOffset.fY; }
36 36
37 GrTexture* texture() const { return fTexture; } 37 GrTexture* texture() const { return fTexture; }
38 38
39 bool addSubImage(int width, int height, const void*, GrIPoint16*); 39 bool addSubImage(int width, int height, const void*, GrIPoint16*);
40 40
41 GrDrawTarget::DrawToken drawToken() const { return fDrawToken; } 41 GrDrawTarget::DrawToken drawToken() const { return fDrawToken; }
42 void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; } 42 void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; }
43 43
44 void resetRects();
45
44 private: 46 private:
45 GrPlot(); 47 GrPlot();
46 ~GrPlot(); // does not try to delete the fNext field 48 ~GrPlot(); // does not try to delete the fNext field
47 49
48 // for recycling 50 // for recycling
49 GrDrawTarget::DrawToken fDrawToken; 51 GrDrawTarget::DrawToken fDrawToken;
50 52
53 GrPlot* fPrev; // for the LRU list
51 GrPlot* fNext; 54 GrPlot* fNext;
52 55
53 GrTexture* fTexture; 56 GrTexture* fTexture;
54 GrRectanizer* fRects; 57 GrRectanizer* fRects;
55 GrAtlasMgr* fAtlasMgr; 58 GrAtlasMgr* fAtlasMgr;
56 GrIPoint16 fOffset; 59 GrIPoint16 fOffset;
57 size_t fBytesPerPixel; 60 size_t fBytesPerPixel;
58 61
59 friend class GrAtlasMgr; 62 friend class GrAtlasMgr;
60 }; 63 };
61 64
62 class GrAtlasMgr { 65 class GrAtlasMgr {
63 public: 66 public:
64 GrAtlasMgr(GrGpu*, GrPixelConfig); 67 GrAtlasMgr(GrGpu*, GrPixelConfig);
65 ~GrAtlasMgr(); 68 ~GrAtlasMgr();
66 69
67 // add subimage of width, height dimensions to atlas 70 // add subimage of width, height dimensions to atlas
68 // returns the containing GrPlot and location relative to the backing textur e 71 // returns the containing GrPlot and location relative to the backing textur e
69 GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, GrIPoint16* ); 72 GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, GrIPoint16* );
70 73
71 // free up any plots that are not waiting on a draw call 74 // remove reference to this plot
72 bool removeUnusedPlots(GrAtlas* atlas); 75 bool removePlot(GrAtlas* atlas, const GrPlot* plot);
73 76
74 // to be called by ~GrAtlas() 77 // get a plot that only contains drawn content
75 void deletePlotList(GrPlot* plot); 78 GrPlot* getUnusedPlot();
bsalomon 2014/02/28 16:28:53 This seems a little confusing to me. I read the co
jvanverth1 2014/02/28 19:55:27 I've revised the comment -- I can't think of a bet
76 79
77 GrTexture* getTexture() const { 80 GrTexture* getTexture() const {
78 return fTexture; 81 return fTexture;
79 } 82 }
80 83
81 private: 84 private:
82 GrPlot* allocPlot(); 85 void moveToHead(GrPlot* plot);
83 void freePlot(GrPlot* plot);
84 86
85 GrGpu* fGpu; 87 GrGpu* fGpu;
86 GrPixelConfig fPixelConfig; 88 GrPixelConfig fPixelConfig;
87 GrTexture* fTexture; 89 GrTexture* fTexture;
88 90
89 // allocated array of GrPlots 91 // allocated array of GrPlots
90 GrPlot* fPlots; 92 GrPlot* fPlots;
91 // linked list of free GrPlots 93 // LRU list of GrPlots
92 GrPlot* fFreePlots; 94 GrPlot* fHead;
95 GrPlot* fTail;
93 }; 96 };
94 97
95 class GrAtlas { 98 class GrAtlas {
96 public: 99 public:
97 GrAtlas(GrAtlasMgr* mgr) : fPlots(NULL), fAtlasMgr(mgr) { } 100 GrAtlas(GrAtlasMgr* mgr) : fAtlasMgr(mgr) { }
98 ~GrAtlas() { fAtlasMgr->deletePlotList(fPlots); } 101 ~GrAtlas() { }
99 102
100 bool isEmpty() { return NULL == fPlots; } 103 bool isEmpty() { return 0 == fPlots.count(); }
101 104
102 SkISize getSize() const; 105 SkISize getSize() const;
103 106
104 private: 107 private:
105 GrPlot* fPlots; 108 SkTDArray<GrPlot*> fPlots;
106 GrAtlasMgr* fAtlasMgr; 109 GrAtlasMgr* fAtlasMgr;
107 110
108 friend class GrAtlasMgr; 111 friend class GrAtlasMgr;
109 }; 112 };
110 113
111 #endif 114 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrAtlas.cpp » ('j') | src/gpu/GrAtlas.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698