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

Side by Side Diff: src/gpu/ops/GrAADistanceFieldPathRenderer.cpp

Issue 2580373002: 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 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/GrDistanceFieldGenFromVector.cpp ('k') | src/gpu/text/GrAtlasGlyphCache.cpp » ('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 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * Copyright 2016 ARM Ltd.
4 * 3 *
5 * 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
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9 #include "GrAADistanceFieldPathRenderer.h" 8 #include "GrAADistanceFieldPathRenderer.h"
10 9
11 #include "GrBatchTest.h" 10 #include "GrBatchTest.h"
12 #include "GrBuffer.h" 11 #include "GrBuffer.h"
13 #include "GrContext.h" 12 #include "GrContext.h"
14 #include "GrOpFlushState.h" 13 #include "GrOpFlushState.h"
15 #include "GrPipelineBuilder.h" 14 #include "GrPipelineBuilder.h"
16 #include "GrResourceProvider.h" 15 #include "GrResourceProvider.h"
17 #include "GrSWMaskHelper.h" 16 #include "GrSWMaskHelper.h"
18 #include "GrSurfacePriv.h" 17 #include "GrSurfacePriv.h"
19 #include "GrTexturePriv.h" 18 #include "GrTexturePriv.h"
20 #include "effects/GrDistanceFieldGeoProc.h" 19 #include "effects/GrDistanceFieldGeoProc.h"
21 #include "ops/GrMeshDrawOp.h" 20 #include "ops/GrMeshDrawOp.h"
22 21
23 #include "SkPathOps.h"
24 #include "SkDistanceFieldGen.h" 22 #include "SkDistanceFieldGen.h"
25 #include "GrDistanceFieldGenFromVector.h"
26 23
27 #define ATLAS_TEXTURE_WIDTH 2048 24 #define ATLAS_TEXTURE_WIDTH 2048
28 #define ATLAS_TEXTURE_HEIGHT 2048 25 #define ATLAS_TEXTURE_HEIGHT 2048
29 #define PLOT_WIDTH 512 26 #define PLOT_WIDTH 512
30 #define PLOT_HEIGHT 256 27 #define PLOT_HEIGHT 256
31 28
32 #define NUM_PLOTS_X (ATLAS_TEXTURE_WIDTH / PLOT_WIDTH) 29 #define NUM_PLOTS_X (ATLAS_TEXTURE_WIDTH / PLOT_WIDTH)
33 #define NUM_PLOTS_Y (ATLAS_TEXTURE_HEIGHT / PLOT_HEIGHT) 30 #define NUM_PLOTS_Y (ATLAS_TEXTURE_HEIGHT / PLOT_HEIGHT)
34 31
35 #ifdef DF_PATH_TRACKING 32 #ifdef DF_PATH_TRACKING
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 // place devBounds at origin 328 // place devBounds at origin
332 int width = devPathBounds.width() + 2*intPad; 329 int width = devPathBounds.width() + 2*intPad;
333 int height = devPathBounds.height() + 2*intPad; 330 int height = devPathBounds.height() + 2*intPad;
334 devPathBounds = SkIRect::MakeWH(width, height); 331 devPathBounds = SkIRect::MakeWH(width, height);
335 332
336 // draw path to bitmap 333 // draw path to bitmap
337 SkMatrix drawMatrix; 334 SkMatrix drawMatrix;
338 drawMatrix.setScale(scale, scale); 335 drawMatrix.setScale(scale, scale);
339 drawMatrix.postTranslate(intPad - dx, intPad - dy); 336 drawMatrix.postTranslate(intPad - dx, intPad - dy);
340 337
338 // setup bitmap backing
341 SkASSERT(devPathBounds.fLeft == 0); 339 SkASSERT(devPathBounds.fLeft == 0);
342 SkASSERT(devPathBounds.fTop == 0); 340 SkASSERT(devPathBounds.fTop == 0);
341 SkAutoPixmapStorage dst;
342 if (!dst.tryAlloc(SkImageInfo::MakeA8(devPathBounds.width(),
343 devPathBounds.height()))) {
344 return false;
345 }
346 sk_bzero(dst.writable_addr(), dst.getSafeSize());
343 347
344 // setup signed distance field storage 348 // rasterize path
345 SkIRect dfBounds = devPathBounds.makeOutset(SK_DistanceFieldPad, SK_Dist anceFieldPad); 349 SkPaint paint;
346 width = dfBounds.width(); 350 paint.setStyle(SkPaint::kFill_Style);
347 height = dfBounds.height(); 351 paint.setAntiAlias(true);
352
353 SkDraw draw;
354 sk_bzero(&draw, sizeof(draw));
355
356 SkRasterClip rasterClip;
357 rasterClip.setRect(devPathBounds);
358 draw.fRC = &rasterClip;
359 draw.fMatrix = &drawMatrix;
360 draw.fDst = dst;
361
362 SkPath path;
363 shape.asPath(&path);
364 draw.drawPathCoverage(path, paint);
365
366 // generate signed distance field
367 devPathBounds.outset(SK_DistanceFieldPad, SK_DistanceFieldPad);
368 width = devPathBounds.width();
369 height = devPathBounds.height();
348 // TODO We should really generate this directly into the plot somehow 370 // TODO We should really generate this directly into the plot somehow
349 SkAutoSMalloc<1024> dfStorage(width * height * sizeof(unsigned char)); 371 SkAutoSMalloc<1024> dfStorage(width * height * sizeof(unsigned char));
350 372
351 SkPath path; 373 // Generate signed distance field
352 shape.asPath(&path); 374 SkGenerateDistanceFieldFromA8Image((unsigned char*)dfStorage.get(),
353 #ifndef SK_USE_LEGACY_DISTANCE_FIELDS 375 (const unsigned char*)dst.addr(),
354 // Generate signed distance field directly from SkPath 376 dst.width(), dst.height(), dst.rowByt es());
355 bool succeed = GrGenerateDistanceFieldFromPath((unsigned char*)dfStorage .get(),
356 path, drawMatrix,
357 width, height, width * sizeof(unsigned c har));
358 if (!succeed) {
359 #endif
360 // setup bitmap backing
361 SkAutoPixmapStorage dst;
362 if (!dst.tryAlloc(SkImageInfo::MakeA8(devPathBounds.width(),
363 devPathBounds.height()))) {
364 return false;
365 }
366 sk_bzero(dst.writable_addr(), dst.getSafeSize());
367
368 // rasterize path
369 SkPaint paint;
370 paint.setStyle(SkPaint::kFill_Style);
371 paint.setAntiAlias(true);
372
373 SkDraw draw;
374 sk_bzero(&draw, sizeof(draw));
375
376 SkRasterClip rasterClip;
377 rasterClip.setRect(devPathBounds);
378 draw.fRC = &rasterClip;
379 draw.fMatrix = &drawMatrix;
380 draw.fDst = dst;
381
382 draw.drawPathCoverage(path, paint);
383
384 // Generate signed distance field
385 SkGenerateDistanceFieldFromA8Image((unsigned char*)dfStorage.get(),
386 (const unsigned char*)dst.addr(),
387 dst.width(), dst.height(), dst.ro wBytes());
388 #ifndef SK_USE_LEGACY_DISTANCE_FIELDS
389 }
390 #endif
391 377
392 // add to atlas 378 // add to atlas
393 SkIPoint16 atlasLocation; 379 SkIPoint16 atlasLocation;
394 GrDrawOpAtlas::AtlasID id; 380 GrDrawOpAtlas::AtlasID id;
395 if (!atlas->addToAtlas(&id, target, width, height, dfStorage.get(), &atl asLocation)) { 381 if (!atlas->addToAtlas(&id, target, width, height, dfStorage.get(), &atl asLocation)) {
396 this->flush(target, flushInfo); 382 this->flush(target, flushInfo);
397 if (!atlas->addToAtlas(&id, target, width, height, dfStorage.get(), &atlasLocation)) { 383 if (!atlas->addToAtlas(&id, target, width, height, dfStorage.get(), &atlasLocation)) {
398 return false; 384 return false;
399 } 385 }
400 } 386 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 shape, 606 shape,
621 viewMatrix, 607 viewMatrix,
622 gTestStruct.fAtlas.get(), 608 gTestStruct.fAtlas.get(),
623 &gTestStruct.fShapeCache, 609 &gTestStruct.fShapeCache,
624 &gTestStruct.fShapeList, 610 &gTestStruct.fShapeList,
625 gammaCorrect) 611 gammaCorrect)
626 .release(); 612 .release();
627 } 613 }
628 614
629 #endif 615 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDistanceFieldGenFromVector.cpp ('k') | src/gpu/text/GrAtlasGlyphCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698