OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkGpuDevice.h" | 8 #include "SkGpuDevice.h" |
9 | 9 |
10 #include "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 | 388 |
389 fDrawContext->drawPaint(fRenderTarget, fClip, grPaint, *draw.fMatrix); | 389 fDrawContext->drawPaint(fRenderTarget, fClip, grPaint, *draw.fMatrix); |
390 } | 390 } |
391 | 391 |
392 // must be in SkCanvas::PointMode order | 392 // must be in SkCanvas::PointMode order |
393 static const GrPrimitiveType gPointMode2PrimtiveType[] = { | 393 static const GrPrimitiveType gPointMode2PrimtiveType[] = { |
394 kPoints_GrPrimitiveType, | 394 kPoints_GrPrimitiveType, |
395 kLines_GrPrimitiveType, | 395 kLines_GrPrimitiveType, |
396 kLineStrip_GrPrimitiveType | 396 kLineStrip_GrPrimitiveType |
397 }; | 397 }; |
398 | 398 |
robertphillips
2015/07/09 17:20:59
needs_antialiasing since static
| |
399 // suppress antialiasing on axis-aligned integer-coordinate lines | |
400 static bool needsAntiAliasing(SkCanvas::PointMode mode, size_t count, const SkPo int pts[]) { | |
401 if (mode == SkCanvas::PointMode::kPoints_PointMode) { | |
402 return false; | |
403 } | |
404 if (count == 2) { | |
robertphillips
2015/07/09 17:20:59
How does this work if, say, the x coords were equa
ethannicholas
2015/07/09 17:40:20
It will not use antialiasing in that case. That wa
| |
405 if (pts[0].fX == pts[1].fX) { | |
406 return ((int) pts[0].fX) != pts[0].fX; | |
407 } | |
408 if (pts[0].fY == pts[1].fY) { | |
409 return ((int) pts[0].fY) != pts[0].fY; | |
410 } | |
411 } | |
412 return true; | |
413 } | |
414 | |
399 void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, | 415 void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, |
400 size_t count, const SkPoint pts[], const SkPaint& p aint) { | 416 size_t count, const SkPoint pts[], const SkPaint& p aint) { |
401 CHECK_FOR_ANNOTATION(paint); | 417 CHECK_FOR_ANNOTATION(paint); |
402 CHECK_SHOULD_DRAW(draw); | 418 CHECK_SHOULD_DRAW(draw); |
403 | 419 |
404 SkScalar width = paint.getStrokeWidth(); | 420 SkScalar width = paint.getStrokeWidth(); |
405 if (width < 0) { | 421 if (width < 0) { |
406 return; | 422 return; |
407 } | 423 } |
408 | 424 |
409 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod e) { | 425 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod e) { |
410 GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style); | 426 GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style); |
411 GrPaint grPaint; | 427 GrPaint grPaint; |
412 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatri x, true, | 428 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatri x, true, |
413 &grPaint)) { | 429 &grPaint)) { |
414 return; | 430 return; |
415 } | 431 } |
416 SkPath path; | 432 SkPath path; |
417 path.setIsVolatile(true); | 433 path.setIsVolatile(true); |
418 path.moveTo(pts[0]); | 434 path.moveTo(pts[0]); |
419 path.lineTo(pts[1]); | 435 path.lineTo(pts[1]); |
420 fDrawContext->drawPath(fRenderTarget, fClip, grPaint, *draw.fMatrix, pat h, strokeInfo); | 436 fDrawContext->drawPath(fRenderTarget, fClip, grPaint, *draw.fMatrix, pat h, strokeInfo); |
421 return; | 437 return; |
422 } | 438 } |
423 | 439 |
424 // we only handle hairlines and paints without path effects or mask filters, | 440 // we only handle non-antialiased hairlines and paints without path effects or mask filters, |
425 // else we let the SkDraw call our drawPath() | 441 // else we let the SkDraw call our drawPath() |
426 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter()) { | 442 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() || (paint.is AntiAlias() && |
robertphillips
2015/07/09 17:20:59
line this up ?
ethannicholas
2015/07/09 17:40:20
Done.
| |
443 needsAntiAliasing(mode, count, pts))) { | |
427 draw.drawPoints(mode, count, pts, paint, true); | 444 draw.drawPoints(mode, count, pts, paint, true); |
428 return; | 445 return; |
429 } | 446 } |
430 | 447 |
431 GrPaint grPaint; | 448 GrPaint grPaint; |
432 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, t rue, &grPaint)) { | 449 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, t rue, &grPaint)) { |
433 return; | 450 return; |
434 } | 451 } |
435 | 452 |
436 fDrawContext->drawVertices(fRenderTarget, | 453 fDrawContext->drawVertices(fRenderTarget, |
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1847 #endif | 1864 #endif |
1848 } | 1865 } |
1849 | 1866 |
1850 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1867 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1851 // We always return a transient cache, so it is freed after each | 1868 // We always return a transient cache, so it is freed after each |
1852 // filter traversal. | 1869 // filter traversal. |
1853 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1870 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1854 } | 1871 } |
1855 | 1872 |
1856 #endif | 1873 #endif |
OLD | NEW |