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

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

Issue 205343008: Distance field fixes for Android (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix int->float conversion issues 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
184 filename.printf("fontcache_%d%d.png", gDumpCount, i); 187 filename.printf("fontcache_%d%d.png", gDumpCount, i);
188 #endif
185 texture->savePixels(filename.c_str()); 189 texture->savePixels(filename.c_str());
186 } 190 }
187 } 191 }
188 } 192 }
189 ++gDumpCount; 193 ++gDumpCount;
190 } 194 }
191 #endif 195 #endif
192 196
193 /////////////////////////////////////////////////////////////////////////////// 197 ///////////////////////////////////////////////////////////////////////////////
194 198
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 245
242 GrGlyph* GrTextStrike::generateGlyph(GrGlyph::PackedID packed, 246 GrGlyph* GrTextStrike::generateGlyph(GrGlyph::PackedID packed,
243 GrFontScaler* scaler) { 247 GrFontScaler* scaler) {
244 SkIRect bounds; 248 SkIRect bounds;
245 if (!scaler->getPackedGlyphBounds(packed, &bounds)) { 249 if (!scaler->getPackedGlyphBounds(packed, &bounds)) {
246 return NULL; 250 return NULL;
247 } 251 }
248 252
249 GrGlyph* glyph = fPool.alloc(); 253 GrGlyph* glyph = fPool.alloc();
250 // expand bounds to hold full distance field data 254 // expand bounds to hold full distance field data
255 // + room for bilerp
256 int pad = DISTANCE_FIELD_RANGE+1;
251 if (fUseDistanceField) { 257 if (fUseDistanceField) {
252 bounds.fLeft -= DISTANCE_FIELD_RANGE; 258 bounds.fLeft -= pad;
253 bounds.fRight += DISTANCE_FIELD_RANGE; 259 bounds.fRight += pad;
254 bounds.fTop -= DISTANCE_FIELD_RANGE; 260 bounds.fTop -= pad;
255 bounds.fBottom += DISTANCE_FIELD_RANGE; 261 bounds.fBottom += pad;
256 } 262 }
257 glyph->init(packed, bounds); 263 glyph->init(packed, bounds);
258 fCache.insert(packed, glyph); 264 fCache.insert(packed, glyph);
259 return glyph; 265 return glyph;
260 } 266 }
261 267
262 void GrTextStrike::removePlot(const GrPlot* plot) { 268 void GrTextStrike::removePlot(const GrPlot* plot) {
263 SkTDArray<GrGlyph*>& glyphArray = fCache.getArray(); 269 SkTDArray<GrGlyph*>& glyphArray = fCache.getArray();
264 for (int i = 0; i < glyphArray.count(); ++i) { 270 for (int i = 0; i < glyphArray.count(); ++i) {
265 if (plot == glyphArray[i]->fPlot) { 271 if (plot == glyphArray[i]->fPlot) {
(...skipping 19 matching lines...) Expand all
285 SkAutoRef ar(scaler); 291 SkAutoRef ar(scaler);
286 292
287 int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat); 293 int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat);
288 294
289 GrPlot* plot; 295 GrPlot* plot;
290 if (fUseDistanceField) { 296 if (fUseDistanceField) {
291 // we've already expanded the glyph dimensions to match the final size 297 // we've already expanded the glyph dimensions to match the final size
292 // but must shrink back down to get the packed glyph data 298 // but must shrink back down to get the packed glyph data
293 int dfWidth = glyph->width(); 299 int dfWidth = glyph->width();
294 int dfHeight = glyph->height(); 300 int dfHeight = glyph->height();
295 int width = dfWidth - 2*DISTANCE_FIELD_RANGE; 301 int pad = DISTANCE_FIELD_RANGE+1;
296 int height = dfHeight - 2*DISTANCE_FIELD_RANGE; 302 int width = dfWidth - 2*pad;
303 int height = dfHeight - 2*pad;
297 int stride = width*bytesPerPixel; 304 int stride = width*bytesPerPixel;
298 305
299 size_t size = width * height * bytesPerPixel; 306 size_t size = width * height * bytesPerPixel;
300 SkAutoSMalloc<1024> storage(size); 307 SkAutoSMalloc<1024> storage(size);
301 if (!scaler->getPackedGlyphImage(glyph->fPackedID, width, height, stride , storage.get())) { 308 if (!scaler->getPackedGlyphImage(glyph->fPackedID, width, height, stride , storage.get())) {
302 return false; 309 return false;
303 } 310 }
304 311
305 // alloc storage for distance field glyph 312 // alloc storage for distance field glyph
306 size_t dfSize = dfWidth * dfHeight * bytesPerPixel; 313 size_t dfSize = dfWidth * dfHeight * bytesPerPixel;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 &glyph->fAtlasLocation); 355 &glyph->fAtlasLocation);
349 } 356 }
350 357
351 if (NULL == plot) { 358 if (NULL == plot) {
352 return false; 359 return false;
353 } 360 }
354 361
355 glyph->fPlot = plot; 362 glyph->fPlot = plot;
356 return true; 363 return true;
357 } 364 }
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