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

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

Issue 1164373003: Revert of change SkDraw and all Blitters to use pixmap instead of bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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/effects/SkLayerRasterizer.cpp ('k') | src/gpu/GrSWMaskHelper.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 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrAADistanceFieldPathRenderer.h" 9 #include "GrAADistanceFieldPathRenderer.h"
10 10
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 drawMatrix.postScale(scale, scale); 347 drawMatrix.postScale(scale, scale);
348 drawMatrix.postTranslate(kAntiAliasPad, kAntiAliasPad); 348 drawMatrix.postTranslate(kAntiAliasPad, kAntiAliasPad);
349 349
350 // setup bitmap backing 350 // setup bitmap backing
351 // Now translate so the bound's UL corner is at the origin 351 // Now translate so the bound's UL corner is at the origin
352 drawMatrix.postTranslate(-devPathBounds.fLeft * SK_Scalar1, 352 drawMatrix.postTranslate(-devPathBounds.fLeft * SK_Scalar1,
353 -devPathBounds.fTop * SK_Scalar1); 353 -devPathBounds.fTop * SK_Scalar1);
354 SkIRect pathBounds = SkIRect::MakeWH(devPathBounds.width(), 354 SkIRect pathBounds = SkIRect::MakeWH(devPathBounds.width(),
355 devPathBounds.height()); 355 devPathBounds.height());
356 356
357 SkAutoPixmapStorage dst; 357 SkBitmap bmp;
358 if (!dst.tryAlloc(SkImageInfo::MakeA8(pathBounds.width(), 358 const SkImageInfo bmImageInfo = SkImageInfo::MakeA8(pathBounds.fRight,
359 pathBounds.height()))) { 359 pathBounds.fBottom);
360 if (!bmp.tryAllocPixels(bmImageInfo)) {
360 return false; 361 return false;
361 } 362 }
362 sk_bzero(dst.writable_addr(), dst.getSafeSize()); 363
364 sk_bzero(bmp.getPixels(), bmp.getSafeSize());
363 365
364 // rasterize path 366 // rasterize path
365 SkPaint paint; 367 SkPaint paint;
366 if (stroke.isHairlineStyle()) { 368 if (stroke.isHairlineStyle()) {
367 paint.setStyle(SkPaint::kStroke_Style); 369 paint.setStyle(SkPaint::kStroke_Style);
368 paint.setStrokeWidth(SK_Scalar1); 370 paint.setStrokeWidth(SK_Scalar1);
369 } else { 371 } else {
370 if (stroke.isFillStyle()) { 372 if (stroke.isFillStyle()) {
371 paint.setStyle(SkPaint::kFill_Style); 373 paint.setStyle(SkPaint::kFill_Style);
372 } else { 374 } else {
373 paint.setStyle(SkPaint::kStroke_Style); 375 paint.setStyle(SkPaint::kStroke_Style);
374 paint.setStrokeJoin(stroke.getJoin()); 376 paint.setStrokeJoin(stroke.getJoin());
375 paint.setStrokeCap(stroke.getCap()); 377 paint.setStrokeCap(stroke.getCap());
376 paint.setStrokeWidth(stroke.getWidth()); 378 paint.setStrokeWidth(stroke.getWidth());
377 } 379 }
378 } 380 }
379 paint.setAntiAlias(antiAlias); 381 paint.setAntiAlias(antiAlias);
380 382
381 SkDraw draw; 383 SkDraw draw;
382 sk_bzero(&draw, sizeof(draw)); 384 sk_bzero(&draw, sizeof(draw));
383 385
384 SkRasterClip rasterClip; 386 SkRasterClip rasterClip;
385 rasterClip.setRect(pathBounds); 387 rasterClip.setRect(pathBounds);
386 draw.fRC = &rasterClip; 388 draw.fRC = &rasterClip;
387 draw.fClip = &rasterClip.bwRgn(); 389 draw.fClip = &rasterClip.bwRgn();
388 draw.fMatrix = &drawMatrix; 390 draw.fMatrix = &drawMatrix;
389 draw.fDst = dst; 391 draw.fBitmap = &bmp;
390 392
391 draw.drawPathCoverage(path, paint); 393 draw.drawPathCoverage(path, paint);
392 394
393 // generate signed distance field 395 // generate signed distance field
394 devPathBounds.outset(SK_DistanceFieldPad, SK_DistanceFieldPad); 396 devPathBounds.outset(SK_DistanceFieldPad, SK_DistanceFieldPad);
395 int width = devPathBounds.width(); 397 int width = devPathBounds.width();
396 int height = devPathBounds.height(); 398 int height = devPathBounds.height();
397 // TODO We should really generate this directly into the plot somehow 399 // TODO We should really generate this directly into the plot somehow
398 SkAutoSMalloc<1024> dfStorage(width * height * sizeof(unsigned char)); 400 SkAutoSMalloc<1024> dfStorage(width * height * sizeof(unsigned char));
399 401
400 // Generate signed distance field 402 // Generate signed distance field
401 SkGenerateDistanceFieldFromA8Image((unsigned char*)dfStorage.get(), 403 {
402 (const unsigned char*)dst.addr(), 404 SkAutoLockPixels alp(bmp);
403 dst.width(), dst.height(), dst.rowByt es()); 405
406 SkGenerateDistanceFieldFromA8Image((unsigned char*)dfStorage.get(),
407 (const unsigned char*)bmp.getPixe ls(),
408 bmp.width(), bmp.height(), bmp.ro wBytes());
409 }
404 410
405 // add to atlas 411 // add to atlas
406 SkIPoint16 atlasLocation; 412 SkIPoint16 atlasLocation;
407 GrBatchAtlas::AtlasID id; 413 GrBatchAtlas::AtlasID id;
408 bool success = atlas->addToAtlas(&id, batchTarget, width, height, dfStor age.get(), 414 bool success = atlas->addToAtlas(&id, batchTarget, width, height, dfStor age.get(),
409 &atlasLocation); 415 &atlasLocation);
410 if (!success) { 416 if (!success) {
411 this->flush(batchTarget, flushInfo); 417 this->flush(batchTarget, flushInfo);
412 batchTarget->initDraw(dfProcessor, pipeline); 418 batchTarget->initDraw(dfProcessor, pipeline);
413 419
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 geometry.fPath = GrTest::TestPath(random); 658 geometry.fPath = GrTest::TestPath(random);
653 geometry.fAntiAlias = random->nextBool(); 659 geometry.fAntiAlias = random->nextBool();
654 660
655 return AADistanceFieldPathBatch::Create(geometry, color, viewMatrix, 661 return AADistanceFieldPathBatch::Create(geometry, color, viewMatrix,
656 gTestStruct.fAtlas, 662 gTestStruct.fAtlas,
657 &gTestStruct.fPathCache, 663 &gTestStruct.fPathCache,
658 &gTestStruct.fPathList); 664 &gTestStruct.fPathList);
659 } 665 }
660 666
661 #endif 667 #endif
OLDNEW
« no previous file with comments | « src/effects/SkLayerRasterizer.cpp ('k') | src/gpu/GrSWMaskHelper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698