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

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

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT Created 5 years, 3 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 | « src/gpu/GrAllocator.h ('k') | src/gpu/GrAtlasTextContext.h » ('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 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 15 matching lines...) Expand all
26 , fRects(NULL) 26 , fRects(NULL)
27 , fAtlas(NULL) 27 , fAtlas(NULL)
28 , fBytesPerPixel(1) 28 , fBytesPerPixel(1)
29 , fDirty(false) 29 , fDirty(false)
30 , fBatchUploads(false) 30 , fBatchUploads(false)
31 { 31 {
32 fOffset.set(0, 0); 32 fOffset.set(0, 0);
33 } 33 }
34 34
35 GrPlot::~GrPlot() { 35 GrPlot::~GrPlot() {
36 SkDELETE_ARRAY(fPlotData); 36 delete[] fPlotData;
37 fPlotData = NULL; 37 fPlotData = NULL;
38 delete fRects; 38 delete fRects;
39 } 39 }
40 40
41 void GrPlot::init(GrAtlas* atlas, int id, int offX, int offY, int width, int hei ght, size_t bpp, 41 void GrPlot::init(GrAtlas* atlas, int id, int offX, int offY, int width, int hei ght, size_t bpp,
42 bool batchUploads) { 42 bool batchUploads) {
43 fID = id; 43 fID = id;
44 fRects = GrRectanizer::Factory(width, height); 44 fRects = GrRectanizer::Factory(width, height);
45 fAtlas = atlas; 45 fAtlas = atlas;
46 fOffset.set(offX * width, offY * height); 46 fOffset.set(offX * width, offY * height);
(...skipping 13 matching lines...) Expand all
60 float percentFull = fRects->percentFull(); 60 float percentFull = fRects->percentFull();
61 if (!fRects->addRect(width, height, loc)) { 61 if (!fRects->addRect(width, height, loc)) {
62 return false; 62 return false;
63 } 63 }
64 64
65 // if batching uploads, create backing memory on first use 65 // if batching uploads, create backing memory on first use
66 // once the plot is nearly full we will revert to uploading each subimage in dividually 66 // once the plot is nearly full we will revert to uploading each subimage in dividually
67 int plotWidth = fRects->width(); 67 int plotWidth = fRects->width();
68 int plotHeight = fRects->height(); 68 int plotHeight = fRects->height();
69 if (fBatchUploads && NULL == fPlotData && 0.0f == percentFull) { 69 if (fBatchUploads && NULL == fPlotData && 0.0f == percentFull) {
70 fPlotData = SkNEW_ARRAY(unsigned char, fBytesPerPixel*plotWidth*plotHeig ht); 70 fPlotData = new unsigned char[fBytesPerPixel * plotWidth * plotHeight];
71 memset(fPlotData, 0, fBytesPerPixel*plotWidth*plotHeight); 71 memset(fPlotData, 0, fBytesPerPixel*plotWidth*plotHeight);
72 } 72 }
73 73
74 // if we have backing memory, copy to the memory and set for future upload 74 // if we have backing memory, copy to the memory and set for future upload
75 if (fPlotData) { 75 if (fPlotData) {
76 const unsigned char* imagePtr = (const unsigned char*) image; 76 const unsigned char* imagePtr = (const unsigned char*) image;
77 // point ourselves at the right starting spot 77 // point ourselves at the right starting spot
78 unsigned char* dataPtr = fPlotData; 78 unsigned char* dataPtr = fPlotData;
79 dataPtr += fBytesPerPixel*plotWidth*loc->fY; 79 dataPtr += fBytesPerPixel*plotWidth*loc->fY;
80 dataPtr += fBytesPerPixel*loc->fX; 80 dataPtr += fBytesPerPixel*loc->fX;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 int plotHeight = textureHeight / fNumPlotsY; 131 int plotHeight = textureHeight / fNumPlotsY;
132 132
133 SkASSERT(plotWidth * fNumPlotsX == textureWidth); 133 SkASSERT(plotWidth * fNumPlotsX == textureWidth);
134 SkASSERT(plotHeight * fNumPlotsY == textureHeight); 134 SkASSERT(plotHeight * fNumPlotsY == textureHeight);
135 135
136 // We currently do not support compressed atlases... 136 // We currently do not support compressed atlases...
137 SkASSERT(!GrPixelConfigIsCompressed(config)); 137 SkASSERT(!GrPixelConfigIsCompressed(config));
138 138
139 // set up allocated plots 139 // set up allocated plots
140 size_t bpp = GrBytesPerPixel(fPixelConfig); 140 size_t bpp = GrBytesPerPixel(fPixelConfig);
141 fPlotArray = SkNEW_ARRAY(GrPlot, (fNumPlotsX*fNumPlotsY)); 141 fPlotArray = new GrPlot[(fNumPlotsX * fNumPlotsY)];
142 142
143 GrPlot* currPlot = fPlotArray; 143 GrPlot* currPlot = fPlotArray;
144 for (int y = numPlotsY-1; y >= 0; --y) { 144 for (int y = numPlotsY-1; y >= 0; --y) {
145 for (int x = numPlotsX-1; x >= 0; --x) { 145 for (int x = numPlotsX-1; x >= 0; --x) {
146 currPlot->init(this, y*numPlotsX+x, x, y, plotWidth, plotHeight, bpp , batchUploads); 146 currPlot->init(this, y*numPlotsX+x, x, y, plotWidth, plotHeight, bpp , batchUploads);
147 147
148 // build LRU list 148 // build LRU list
149 fPlotList.addToHead(currPlot); 149 fPlotList.addToHead(currPlot);
150 ++currPlot; 150 ++currPlot;
151 } 151 }
152 } 152 }
153 } 153 }
154 154
155 GrAtlas::~GrAtlas() { 155 GrAtlas::~GrAtlas() {
156 SkSafeUnref(fTexture); 156 SkSafeUnref(fTexture);
157 SkDELETE_ARRAY(fPlotArray); 157 delete[] fPlotArray;
158 158
159 fGpu->unref(); 159 fGpu->unref();
160 #if FONT_CACHE_STATS 160 #if FONT_CACHE_STATS
161 SkDebugf("Num uploads: %d\n", g_UploadCount); 161 SkDebugf("Num uploads: %d\n", g_UploadCount);
162 #endif 162 #endif
163 } 163 }
164 164
165 void GrAtlas::makeMRU(GrPlot* plot) { 165 void GrAtlas::makeMRU(GrPlot* plot) {
166 if (fPlotList.head() == plot) { 166 if (fPlotList.head() == plot) {
167 return; 167 return;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // If the above fails, then the current plot list has no room 220 // If the above fails, then the current plot list has no room
221 return NULL; 221 return NULL;
222 } 222 }
223 223
224 void GrAtlas::RemovePlot(ClientPlotUsage* usage, const GrPlot* plot) { 224 void GrAtlas::RemovePlot(ClientPlotUsage* usage, const GrPlot* plot) {
225 int index = usage->fPlots.find(const_cast<GrPlot*>(plot)); 225 int index = usage->fPlots.find(const_cast<GrPlot*>(plot));
226 if (index >= 0) { 226 if (index >= 0) {
227 usage->fPlots.remove(index); 227 usage->fPlots.remove(index);
228 } 228 }
229 } 229 }
OLDNEW
« no previous file with comments | « src/gpu/GrAllocator.h ('k') | src/gpu/GrAtlasTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698