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

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

Issue 224903012: Don't try to render color fonts using distance fields (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add comments; windows compile error Created 6 years, 8 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/GrDistanceFieldTextContext.cpp ('k') | no next file » | 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 325
326 // alloc storage for distance field glyph 326 // alloc storage for distance field glyph
327 size_t dfSize = dfWidth * dfHeight * bytesPerPixel; 327 size_t dfSize = dfWidth * dfHeight * bytesPerPixel;
328 SkAutoSMalloc<1024> dfStorage(dfSize); 328 SkAutoSMalloc<1024> dfStorage(dfSize);
329 329
330 if (1 == bytesPerPixel) { 330 if (1 == bytesPerPixel) {
331 (void) SkGenerateDistanceFieldFromImage((unsigned char*)dfStorage.ge t(), 331 (void) SkGenerateDistanceFieldFromImage((unsigned char*)dfStorage.ge t(),
332 (unsigned char*)storage.get( ), 332 (unsigned char*)storage.get( ),
333 width, height, DISTANCE_FIEL D_RANGE); 333 width, height, DISTANCE_FIEL D_RANGE);
334 } else { 334 } else {
335 // TODO: Fix color emoji 335 // distance fields should only be used to represent alpha masks
336 // for now, copy glyph into distance field storage 336 SkASSERT(false);
337 // this is not correct, but it won't crash 337 return false;
338 sk_bzero(dfStorage.get(), dfSize);
339 unsigned char* ptr = (unsigned char*) storage.get();
340 unsigned char* dfPtr = (unsigned char*) dfStorage.get();
341 size_t dfStride = dfWidth*bytesPerPixel;
342 dfPtr += DISTANCE_FIELD_RANGE*dfStride;
343 dfPtr += DISTANCE_FIELD_RANGE*bytesPerPixel;
344
345 for (int i = 0; i < height; ++i) {
346 memcpy(dfPtr, ptr, stride);
347
348 dfPtr += dfStride;
349 ptr += stride;
350 }
351 } 338 }
352 339
353 // copy to atlas 340 // copy to atlas
354 plot = fAtlasMgr->addToAtlas(&fAtlas, dfWidth, dfHeight, dfStorage.get() , 341 plot = fAtlasMgr->addToAtlas(&fAtlas, dfWidth, dfHeight, dfStorage.get() ,
355 &glyph->fAtlasLocation); 342 &glyph->fAtlasLocation);
356 343
357 } else { 344 } else {
358 size_t size = glyph->fBounds.area() * bytesPerPixel; 345 size_t size = glyph->fBounds.area() * bytesPerPixel;
359 SkAutoSMalloc<1024> storage(size); 346 SkAutoSMalloc<1024> storage(size);
360 if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(), 347 if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(),
361 glyph->height(), 348 glyph->height(),
362 glyph->width() * bytesPerPixel, 349 glyph->width() * bytesPerPixel,
363 storage.get())) { 350 storage.get())) {
364 return false; 351 return false;
365 } 352 }
366 353
367 plot = fAtlasMgr->addToAtlas(&fAtlas, glyph->width(), 354 plot = fAtlasMgr->addToAtlas(&fAtlas, glyph->width(),
368 glyph->height(), storage.get(), 355 glyph->height(), storage.get(),
369 &glyph->fAtlasLocation); 356 &glyph->fAtlasLocation);
370 } 357 }
371 358
372 if (NULL == plot) { 359 if (NULL == plot) {
373 return false; 360 return false;
374 } 361 }
375 362
376 glyph->fPlot = plot; 363 glyph->fPlot = plot;
377 return true; 364 return true;
378 } 365 }
OLDNEW
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698