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

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

Issue 269423007: Add CPU backing store for GrAtlas to reduce texture uploads (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Turn on texture update for distance fields Created 6 years, 7 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 22 matching lines...) Expand all
33 public: 33 public:
34 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrPlot); 34 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrPlot);
35 35
36 GrTexture* texture() const { return fTexture; } 36 GrTexture* texture() const { return fTexture; }
37 37
38 bool addSubImage(int width, int height, const void*, GrIPoint16*); 38 bool addSubImage(int width, int height, const void*, GrIPoint16*);
39 39
40 GrDrawTarget::DrawToken drawToken() const { return fDrawToken; } 40 GrDrawTarget::DrawToken drawToken() const { return fDrawToken; }
41 void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; } 41 void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; }
42 42
43 void uploadToTexture();
44
43 void resetRects(); 45 void resetRects();
44 46
45 private: 47 private:
46 GrPlot(); 48 GrPlot();
47 ~GrPlot(); // does not try to delete the fNext field 49 ~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); 50 void init(GrAtlasMgr* mgr, int offX, int offY, int width, int height, size_t bpp);
49 51
50 // for recycling 52 // for recycling
51 GrDrawTarget::DrawToken fDrawToken; 53 GrDrawTarget::DrawToken fDrawToken;
52 54
55 unsigned char* fPlotData;
53 GrTexture* fTexture; 56 GrTexture* fTexture;
54 GrRectanizer* fRects; 57 GrRectanizer* fRects;
55 GrAtlasMgr* fAtlasMgr; 58 GrAtlasMgr* fAtlasMgr;
56 GrIPoint16 fOffset; // the offset of the plot in the bac king texture 59 GrIPoint16 fOffset; // the offset of the plot in the bac king texture
57 size_t fBytesPerPixel; 60 size_t fBytesPerPixel;
61 SkIRect fDirtyRect;
62 bool fDirty;
58 63
59 friend class GrAtlasMgr; 64 friend class GrAtlasMgr;
60 }; 65 };
61 66
62 typedef SkTInternalLList<GrPlot> GrPlotList; 67 typedef SkTInternalLList<GrPlot> GrPlotList;
63 68
64 class GrAtlasMgr { 69 class GrAtlasMgr {
65 public: 70 public:
66 GrAtlasMgr(GrGpu*, GrPixelConfig, const SkISize& backingTextureSize, 71 GrAtlasMgr(GrGpu*, GrPixelConfig, const SkISize& backingTextureSize,
67 int numPlotsX, int numPlotsY); 72 int numPlotsX, int numPlotsY);
68 ~GrAtlasMgr(); 73 ~GrAtlasMgr();
69 74
70 // add subimage of width, height dimensions to atlas 75 // add subimage of width, height dimensions to atlas
71 // returns the containing GrPlot and location relative to the backing textur e 76 // returns the containing GrPlot and location relative to the backing textur e
72 GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, GrIPoint16* ); 77 GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, GrIPoint16* );
73 78
74 // remove reference to this plot 79 // remove reference to this plot
75 bool removePlot(GrAtlas* atlas, const GrPlot* plot); 80 bool removePlot(GrAtlas* atlas, const GrPlot* plot);
76 81
77 // get a plot that's not being used by the current draw 82 // get a plot that's not being used by the current draw
78 // this allows us to overwrite this plot without flushing 83 // this allows us to overwrite this plot without flushing
79 GrPlot* getUnusedPlot(); 84 GrPlot* getUnusedPlot();
80 85
81 GrTexture* getTexture() const { 86 GrTexture* getTexture() const {
82 return fTexture; 87 return fTexture;
83 } 88 }
84 89
90 void uploadPlotsToTexture();
91
85 private: 92 private:
86 void moveToHead(GrPlot* plot); 93 void moveToHead(GrPlot* plot);
87 94
88 GrGpu* fGpu; 95 GrGpu* fGpu;
89 GrPixelConfig fPixelConfig; 96 GrPixelConfig fPixelConfig;
90 GrTexture* fTexture; 97 GrTexture* fTexture;
91 SkISize fBackingTextureSize; 98 SkISize fBackingTextureSize;
92 int fNumPlotsX; 99 int fNumPlotsX;
93 int fNumPlotsY; 100 int fNumPlotsY;
94 101
(...skipping 10 matching lines...) Expand all
105 112
106 bool isEmpty() { return 0 == fPlots.count(); } 113 bool isEmpty() { return 0 == fPlots.count(); }
107 114
108 private: 115 private:
109 SkTDArray<GrPlot*> fPlots; 116 SkTDArray<GrPlot*> fPlots;
110 117
111 friend class GrAtlasMgr; 118 friend class GrAtlasMgr;
112 }; 119 };
113 120
114 #endif 121 #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