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

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: Add assert to GrPlot::uploadTexture() 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') | 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 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,
51 bool batchUploads);
49 52
50 // for recycling 53 // for recycling
51 GrDrawTarget::DrawToken fDrawToken; 54 GrDrawTarget::DrawToken fDrawToken;
52 55
56 unsigned char* fPlotData;
53 GrTexture* fTexture; 57 GrTexture* fTexture;
54 GrRectanizer* fRects; 58 GrRectanizer* fRects;
55 GrAtlasMgr* fAtlasMgr; 59 GrAtlasMgr* fAtlasMgr;
56 GrIPoint16 fOffset; // the offset of the plot in the bac king texture 60 GrIPoint16 fOffset; // the offset of the plot in the bac king texture
57 size_t fBytesPerPixel; 61 size_t fBytesPerPixel;
62 SkIRect fDirtyRect;
63 bool fDirty;
64 bool fBatchUploads;
58 65
59 friend class GrAtlasMgr; 66 friend class GrAtlasMgr;
60 }; 67 };
61 68
62 typedef SkTInternalLList<GrPlot> GrPlotList; 69 typedef SkTInternalLList<GrPlot> GrPlotList;
63 70
64 class GrAtlasMgr { 71 class GrAtlasMgr {
65 public: 72 public:
66 GrAtlasMgr(GrGpu*, GrPixelConfig, const SkISize& backingTextureSize, 73 GrAtlasMgr(GrGpu*, GrPixelConfig, const SkISize& backingTextureSize,
67 int numPlotsX, int numPlotsY); 74 int numPlotsX, int numPlotsY, bool batchUploads);
68 ~GrAtlasMgr(); 75 ~GrAtlasMgr();
69 76
70 // add subimage of width, height dimensions to atlas 77 // add subimage of width, height dimensions to atlas
71 // returns the containing GrPlot and location relative to the backing textur e 78 // returns the containing GrPlot and location relative to the backing textur e
72 GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, GrIPoint16* ); 79 GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, GrIPoint16* );
73 80
74 // remove reference to this plot 81 // remove reference to this plot
75 bool removePlot(GrAtlas* atlas, const GrPlot* plot); 82 bool removePlot(GrAtlas* atlas, const GrPlot* plot);
76 83
77 // get a plot that's not being used by the current draw 84 // get a plot that's not being used by the current draw
78 // this allows us to overwrite this plot without flushing 85 // this allows us to overwrite this plot without flushing
79 GrPlot* getUnusedPlot(); 86 GrPlot* getUnusedPlot();
80 87
81 GrTexture* getTexture() const { 88 GrTexture* getTexture() const {
82 return fTexture; 89 return fTexture;
83 } 90 }
84 91
92 void uploadPlotsToTexture();
93
85 private: 94 private:
86 void moveToHead(GrPlot* plot); 95 void moveToHead(GrPlot* plot);
87 96
88 GrGpu* fGpu; 97 GrGpu* fGpu;
89 GrPixelConfig fPixelConfig; 98 GrPixelConfig fPixelConfig;
90 GrTexture* fTexture; 99 GrTexture* fTexture;
91 SkISize fBackingTextureSize; 100 SkISize fBackingTextureSize;
92 int fNumPlotsX; 101 int fNumPlotsX;
93 int fNumPlotsY; 102 int fNumPlotsY;
103 bool fBatchUploads;
94 104
95 // allocated array of GrPlots 105 // allocated array of GrPlots
96 GrPlot* fPlotArray; 106 GrPlot* fPlotArray;
97 // LRU list of GrPlots 107 // LRU list of GrPlots
98 GrPlotList fPlotList; 108 GrPlotList fPlotList;
99 }; 109 };
100 110
101 class GrAtlas { 111 class GrAtlas {
102 public: 112 public:
103 GrAtlas() { } 113 GrAtlas() { }
104 ~GrAtlas() { } 114 ~GrAtlas() { }
105 115
106 bool isEmpty() { return 0 == fPlots.count(); } 116 bool isEmpty() { return 0 == fPlots.count(); }
107 117
108 private: 118 private:
109 SkTDArray<GrPlot*> fPlots; 119 SkTDArray<GrPlot*> fPlots;
110 120
111 friend class GrAtlasMgr; 121 friend class GrAtlasMgr;
112 }; 122 };
113 123
114 #endif 124 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrAtlas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698