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

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

Issue 217423014: Minor changes to GrFontCache system (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Addressed code review comments Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkGlyphCache.h ('k') | 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 15 matching lines...) Expand all
26 // GrAtlas can request a new GrPlot via GrAtlasMgr::addToAtlas(). 26 // GrAtlas can request a new GrPlot via GrAtlasMgr::addToAtlas().
27 // 27 //
28 // If all GrPlots are allocated, the replacement strategy is up to the client. T he drawToken is 28 // If all GrPlots are allocated, the replacement strategy is up to the client. T he drawToken is
29 // available to ensure that all draw calls are finished for that particular GrPl ot. 29 // available to ensure that all draw calls are finished for that particular GrPl ot.
30 // GrAtlasMgr::removeUnusedPlots() will free up any finished plots for a given G rAtlas. 30 // GrAtlasMgr::removeUnusedPlots() will free up any finished plots for a given G rAtlas.
31 31
32 class GrPlot { 32 class GrPlot {
33 public: 33 public:
34 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrPlot); 34 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrPlot);
35 35
36 int getOffsetX() const { return fOffset.fX; }
37 int getOffsetY() const { return fOffset.fY; }
38
39 GrTexture* texture() const { return fTexture; } 36 GrTexture* texture() const { return fTexture; }
40 37
41 bool addSubImage(int width, int height, const void*, GrIPoint16*); 38 bool addSubImage(int width, int height, const void*, GrIPoint16*);
42 39
43 GrDrawTarget::DrawToken drawToken() const { return fDrawToken; } 40 GrDrawTarget::DrawToken drawToken() const { return fDrawToken; }
44 void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; } 41 void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; }
45 42
46 void resetRects(); 43 void resetRects();
47 44
48 private: 45 private:
49 GrPlot(); 46 GrPlot();
50 ~GrPlot(); // does not try to delete the fNext field 47 ~GrPlot(); // does not try to delete the fNext field
48 void init(GrAtlasMgr* mgr, int offX, int offY, int width, int height, size_t bpp);
51 49
52 // for recycling 50 // for recycling
53 GrDrawTarget::DrawToken fDrawToken; 51 GrDrawTarget::DrawToken fDrawToken;
54 52
55 GrTexture* fTexture; 53 GrTexture* fTexture;
56 GrRectanizer* fRects; 54 GrRectanizer* fRects;
57 GrAtlasMgr* fAtlasMgr; 55 GrAtlasMgr* fAtlasMgr;
58 GrIPoint16 fOffset; 56 GrIPoint16 fOffset; // the offset of the plot in the bac king texture
59 size_t fBytesPerPixel; 57 size_t fBytesPerPixel;
60 58
61 friend class GrAtlasMgr; 59 friend class GrAtlasMgr;
62 }; 60 };
63 61
64 typedef SkTInternalLList<GrPlot> GrPlotList; 62 typedef SkTInternalLList<GrPlot> GrPlotList;
65 63
66 class GrAtlasMgr { 64 class GrAtlasMgr {
67 public: 65 public:
68 GrAtlasMgr(GrGpu*, GrPixelConfig); 66 GrAtlasMgr(GrGpu*, GrPixelConfig, const SkISize& backingTextureSize,
67 int numPlotsX, int numPlotsY);
69 ~GrAtlasMgr(); 68 ~GrAtlasMgr();
70 69
71 // add subimage of width, height dimensions to atlas 70 // add subimage of width, height dimensions to atlas
72 // 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
73 GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, GrIPoint16* ); 72 GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, GrIPoint16* );
74 73
75 // remove reference to this plot 74 // remove reference to this plot
76 bool removePlot(GrAtlas* atlas, const GrPlot* plot); 75 bool removePlot(GrAtlas* atlas, const GrPlot* plot);
77 76
78 // get a plot that's not being used by the current draw 77 // get a plot that's not being used by the current draw
79 // this allows us to overwrite this plot without flushing 78 // this allows us to overwrite this plot without flushing
80 GrPlot* getUnusedPlot(); 79 GrPlot* getUnusedPlot();
81 80
82 GrTexture* getTexture() const { 81 GrTexture* getTexture() const {
83 return fTexture; 82 return fTexture;
84 } 83 }
85 84
86 private: 85 private:
87 void moveToHead(GrPlot* plot); 86 void moveToHead(GrPlot* plot);
88 87
89 GrGpu* fGpu; 88 GrGpu* fGpu;
90 GrPixelConfig fPixelConfig; 89 GrPixelConfig fPixelConfig;
91 GrTexture* fTexture; 90 GrTexture* fTexture;
91 SkISize fBackingTextureSize;
92 int fNumPlotsX;
93 int fNumPlotsY;
92 94
93 // allocated array of GrPlots 95 // allocated array of GrPlots
94 GrPlot* fPlotArray; 96 GrPlot* fPlotArray;
95 // LRU list of GrPlots 97 // LRU list of GrPlots
96 GrPlotList fPlotList; 98 GrPlotList fPlotList;
97 }; 99 };
98 100
99 class GrAtlas { 101 class GrAtlas {
100 public: 102 public:
101 GrAtlas() { } 103 GrAtlas() { }
102 ~GrAtlas() { } 104 ~GrAtlas() { }
103 105
104 bool isEmpty() { return 0 == fPlots.count(); } 106 bool isEmpty() { return 0 == fPlots.count(); }
105 107
106 private: 108 private:
107 SkTDArray<GrPlot*> fPlots; 109 SkTDArray<GrPlot*> fPlots;
108 110
109 friend class GrAtlasMgr; 111 friend class GrAtlasMgr;
110 }; 112 };
111 113
112 #endif 114 #endif
OLDNEW
« no previous file with comments | « src/core/SkGlyphCache.h ('k') | src/gpu/GrAtlas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698