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

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

Issue 212953008: Revert of Distance field fixes for Android (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « src/gpu/GrTextStrike.h ('k') | src/gpu/effects/GrDistanceFieldTextureEffect.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 * Copyright 2010 Google Inc. 2 * Copyright 2010 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrAtlas.h" 8 #include "GrAtlas.h"
9 #include "GrGpu.h" 9 #include "GrGpu.h"
10 #include "GrRectanizer.h" 10 #include "GrRectanizer.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 #endif 174 #endif
175 175
176 #ifdef SK_DEVELOPER 176 #ifdef SK_DEVELOPER
177 void GrFontCache::dump() const { 177 void GrFontCache::dump() const {
178 static int gDumpCount = 0; 178 static int gDumpCount = 0;
179 for (int i = 0; i < kAtlasCount; ++i) { 179 for (int i = 0; i < kAtlasCount; ++i) {
180 if (NULL != fAtlasMgr[i]) { 180 if (NULL != fAtlasMgr[i]) {
181 GrTexture* texture = fAtlasMgr[i]->getTexture(); 181 GrTexture* texture = fAtlasMgr[i]->getTexture();
182 if (NULL != texture) { 182 if (NULL != texture) {
183 SkString filename; 183 SkString filename;
184 #ifdef SK_BUILD_FOR_ANDROID
185 filename.printf("/sdcard/fontcache_%d%d.png", gDumpCount, i);
186 #else
187 filename.printf("fontcache_%d%d.png", gDumpCount, i); 184 filename.printf("fontcache_%d%d.png", gDumpCount, i);
188 #endif
189 texture->savePixels(filename.c_str()); 185 texture->savePixels(filename.c_str());
190 } 186 }
191 } 187 }
192 } 188 }
193 ++gDumpCount; 189 ++gDumpCount;
194 } 190 }
195 #endif 191 #endif
196 192
197 /////////////////////////////////////////////////////////////////////////////// 193 ///////////////////////////////////////////////////////////////////////////////
198 194
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 241
246 GrGlyph* GrTextStrike::generateGlyph(GrGlyph::PackedID packed, 242 GrGlyph* GrTextStrike::generateGlyph(GrGlyph::PackedID packed,
247 GrFontScaler* scaler) { 243 GrFontScaler* scaler) {
248 SkIRect bounds; 244 SkIRect bounds;
249 if (!scaler->getPackedGlyphBounds(packed, &bounds)) { 245 if (!scaler->getPackedGlyphBounds(packed, &bounds)) {
250 return NULL; 246 return NULL;
251 } 247 }
252 248
253 GrGlyph* glyph = fPool.alloc(); 249 GrGlyph* glyph = fPool.alloc();
254 // expand bounds to hold full distance field data 250 // expand bounds to hold full distance field data
255 // + room for bilerp
256 int pad = DISTANCE_FIELD_RANGE+1;
257 if (fUseDistanceField) { 251 if (fUseDistanceField) {
258 bounds.fLeft -= pad; 252 bounds.fLeft -= DISTANCE_FIELD_RANGE;
259 bounds.fRight += pad; 253 bounds.fRight += DISTANCE_FIELD_RANGE;
260 bounds.fTop -= pad; 254 bounds.fTop -= DISTANCE_FIELD_RANGE;
261 bounds.fBottom += pad; 255 bounds.fBottom += DISTANCE_FIELD_RANGE;
262 } 256 }
263 glyph->init(packed, bounds); 257 glyph->init(packed, bounds);
264 fCache.insert(packed, glyph); 258 fCache.insert(packed, glyph);
265 return glyph; 259 return glyph;
266 } 260 }
267 261
268 void GrTextStrike::removePlot(const GrPlot* plot) { 262 void GrTextStrike::removePlot(const GrPlot* plot) {
269 SkTDArray<GrGlyph*>& glyphArray = fCache.getArray(); 263 SkTDArray<GrGlyph*>& glyphArray = fCache.getArray();
270 for (int i = 0; i < glyphArray.count(); ++i) { 264 for (int i = 0; i < glyphArray.count(); ++i) {
271 if (plot == glyphArray[i]->fPlot) { 265 if (plot == glyphArray[i]->fPlot) {
(...skipping 19 matching lines...) Expand all
291 SkAutoRef ar(scaler); 285 SkAutoRef ar(scaler);
292 286
293 int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat); 287 int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat);
294 288
295 GrPlot* plot; 289 GrPlot* plot;
296 if (fUseDistanceField) { 290 if (fUseDistanceField) {
297 // we've already expanded the glyph dimensions to match the final size 291 // we've already expanded the glyph dimensions to match the final size
298 // but must shrink back down to get the packed glyph data 292 // but must shrink back down to get the packed glyph data
299 int dfWidth = glyph->width(); 293 int dfWidth = glyph->width();
300 int dfHeight = glyph->height(); 294 int dfHeight = glyph->height();
301 int pad = DISTANCE_FIELD_RANGE+1; 295 int width = dfWidth - 2*DISTANCE_FIELD_RANGE;
302 int width = dfWidth - 2*pad; 296 int height = dfHeight - 2*DISTANCE_FIELD_RANGE;
303 int height = dfHeight - 2*pad;
304 int stride = width*bytesPerPixel; 297 int stride = width*bytesPerPixel;
305 298
306 size_t size = width * height * bytesPerPixel; 299 size_t size = width * height * bytesPerPixel;
307 SkAutoSMalloc<1024> storage(size); 300 SkAutoSMalloc<1024> storage(size);
308 if (!scaler->getPackedGlyphImage(glyph->fPackedID, width, height, stride , storage.get())) { 301 if (!scaler->getPackedGlyphImage(glyph->fPackedID, width, height, stride , storage.get())) {
309 return false; 302 return false;
310 } 303 }
311 304
312 // alloc storage for distance field glyph 305 // alloc storage for distance field glyph
313 size_t dfSize = dfWidth * dfHeight * bytesPerPixel; 306 size_t dfSize = dfWidth * dfHeight * bytesPerPixel;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 &glyph->fAtlasLocation); 348 &glyph->fAtlasLocation);
356 } 349 }
357 350
358 if (NULL == plot) { 351 if (NULL == plot) {
359 return false; 352 return false;
360 } 353 }
361 354
362 glyph->fPlot = plot; 355 glyph->fPlot = plot;
363 return true; 356 return true;
364 } 357 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextStrike.h ('k') | src/gpu/effects/GrDistanceFieldTextureEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698