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

Side by Side Diff: src/gpu/text/GrBatchFontCache.cpp

Issue 2435753002: Revert of Generate Signed Distance Field directly from vector path (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 2 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/batches/GrAADistanceFieldPathRenderer.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 2015 Google Inc. 2 * Copyright 2015 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 "GrBatchFontCache.h" 8 #include "GrBatchFontCache.h"
9 #include "GrContext.h" 9 #include "GrContext.h"
10 #include "GrGpu.h" 10 #include "GrGpu.h"
11 #include "GrRectanizer.h" 11 #include "GrRectanizer.h"
12 #include "GrResourceProvider.h" 12 #include "GrResourceProvider.h"
13 #include "GrSurfacePriv.h" 13 #include "GrSurfacePriv.h"
14 #include "SkString.h" 14 #include "SkString.h"
15 15
16 #include "SkDistanceFieldGen.h" 16 #include "SkDistanceFieldGen.h"
17 #include "GrDistanceFieldGenFromVector.h"
18 17
19 bool GrBatchFontCache::initAtlas(GrMaskFormat format) { 18 bool GrBatchFontCache::initAtlas(GrMaskFormat format) {
20 int index = MaskFormatToAtlasIndex(format); 19 int index = MaskFormatToAtlasIndex(format);
21 if (!fAtlases[index]) { 20 if (!fAtlases[index]) {
22 GrPixelConfig config = MaskFormatToPixelConfig(format, *fContext->caps() ); 21 GrPixelConfig config = MaskFormatToPixelConfig(format, *fContext->caps() );
23 int width = fAtlasConfigs[index].fWidth; 22 int width = fAtlasConfigs[index].fWidth;
24 int height = fAtlasConfigs[index].fHeight; 23 int height = fAtlasConfigs[index].fHeight;
25 int numPlotsX = fAtlasConfigs[index].numPlotsX(); 24 int numPlotsX = fAtlasConfigs[index].numPlotsX();
26 int numPlotsY = fAtlasConfigs[index].numPlotsY(); 25 int numPlotsY = fAtlasConfigs[index].numPlotsY();
27 26
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 dst = (char*)dst + dstRB; 262 dst = (char*)dst + dstRB;
264 } 263 }
265 } 264 }
266 return true; 265 return true;
267 } 266 }
268 267
269 static bool get_packed_glyph_df_image(SkGlyphCache* cache, const SkGlyph& glyph, 268 static bool get_packed_glyph_df_image(SkGlyphCache* cache, const SkGlyph& glyph,
270 int width, int height, void* dst) { 269 int width, int height, void* dst) {
271 SkASSERT(glyph.fWidth + 2*SK_DistanceFieldPad == width); 270 SkASSERT(glyph.fWidth + 2*SK_DistanceFieldPad == width);
272 SkASSERT(glyph.fHeight + 2*SK_DistanceFieldPad == height); 271 SkASSERT(glyph.fHeight + 2*SK_DistanceFieldPad == height);
273 const SkPath* path = cache->findPath(glyph); 272 const void* image = cache->findImage(glyph);
274 if (nullptr == path) { 273 if (nullptr == image) {
274 return false;
275 }
276 // now generate the distance field
277 SkASSERT(dst);
278 SkMask::Format maskFormat = static_cast<SkMask::Format>(glyph.fMaskFormat);
279 if (SkMask::kA8_Format == maskFormat) {
280 // make the distance field from the image
281 SkGenerateDistanceFieldFromA8Image((unsigned char*)dst,
282 (unsigned char*)image,
283 glyph.fWidth, glyph.fHeight,
284 glyph.rowBytes());
285 } else if (SkMask::kBW_Format == maskFormat) {
286 // make the distance field from the image
287 SkGenerateDistanceFieldFromBWImage((unsigned char*)dst,
288 (unsigned char*)image,
289 glyph.fWidth, glyph.fHeight,
290 glyph.rowBytes());
291 } else {
275 return false; 292 return false;
276 } 293 }
277 294
278 // now generate the distance field 295 return true;
279 SkASSERT(dst);
280 SkMatrix drawMatrix;
281 drawMatrix.setTranslate((SkScalar)-glyph.fLeft, (SkScalar)-glyph.fTop);
282
283 // Generate signed distance field directly from SkPath
284 return GrGenerateDistanceFieldFromPath((unsigned char*)dst,
285 *path, drawMatrix,
286 width, height, width * sizeof(unsigne d char));
287 } 296 }
288 297
289 /////////////////////////////////////////////////////////////////////////////// 298 ///////////////////////////////////////////////////////////////////////////////
290 299
291 /* 300 /*
292 The text strike is specific to a given font/style/matrix setup, which is 301 The text strike is specific to a given font/style/matrix setup, which is
293 represented by the GrHostFontScaler object we are given in getGlyph(). 302 represented by the GrHostFontScaler object we are given in getGlyph().
294 303
295 We map a 32bit glyphID to a GrGlyph record, which in turn points to a 304 We map a 32bit glyphID to a GrGlyph record, which in turn points to a
296 atlas and a position within that texture. 305 atlas and a position within that texture.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 381
373 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, target, expect edMaskFormat, 382 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, target, expect edMaskFormat,
374 glyph->width(), glyph->height(), 383 glyph->width(), glyph->height(),
375 storage.get(), &glyph->fAtlasLoca tion); 384 storage.get(), &glyph->fAtlasLoca tion);
376 if (success) { 385 if (success) {
377 SkASSERT(GrBatchAtlas::kInvalidAtlasID != glyph->fID); 386 SkASSERT(GrBatchAtlas::kInvalidAtlasID != glyph->fID);
378 fAtlasedGlyphs++; 387 fAtlasedGlyphs++;
379 } 388 }
380 return success; 389 return success;
381 } 390 }
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAADistanceFieldPathRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698