Chromium Code Reviews| Index: src/gpu/GrDrawContext.cpp |
| diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp |
| index 3b346b6efd302c68541db2a48701360f57aef9e0..1a2808cf3fabe5f2410f1c099da2f55bb6fa17e2 100644 |
| --- a/src/gpu/GrDrawContext.cpp |
| +++ b/src/gpu/GrDrawContext.cpp |
| @@ -26,6 +26,7 @@ |
| #include "batches/GrDrawVerticesBatch.h" |
| #include "batches/GrRectBatchFactory.h" |
| #include "batches/GrNinePatch.h" // TODO Factory |
| +#include "batches/GrRegionBatch.h" |
| #include "effects/GrRRectEffect.h" |
| @@ -944,6 +945,35 @@ void GrDrawContext::drawDRRect(const GrClip& clip, |
| /////////////////////////////////////////////////////////////////////////////// |
| +static inline bool is_int(float x) { |
| + return x == (float) sk_float_round2int(x); |
| +} |
| + |
| +void GrDrawContext::drawRegion(const GrClip& clip, |
| + const GrPaint& paint, |
| + const SkMatrix& viewMatrix, |
| + const SkRegion& region, |
| + const GrStyle& style) { |
| + ASSERT_SINGLE_OWNER |
| + RETURN_IF_ABANDONED |
| + SkDEBUGCODE(this->validate();) |
| + GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRegion"); |
| + |
| + bool isNonTranslate = viewMatrix.getType() & ~(SkMatrix::kTranslate_Mask); |
| + bool complexPaint = !style.isSimpleFill(); |
|
bsalomon
2016/08/25 21:19:50
maybe complexStyle?
msarett
2016/08/25 21:26:35
Done.
|
| + bool antiAlias = paint.isAntiAlias() && (!is_int(viewMatrix.getTranslateX()) || |
| + !is_int(viewMatrix.getTranslateY())); |
| + if (isNonTranslate || complexPaint || antiAlias) { |
| + SkPath path; |
| + region.getBoundaryPath(&path); |
| + return this->drawPath(clip, paint, viewMatrix, path, style); |
| + } |
| + |
| + SkAutoTUnref<GrDrawBatch> batch(GrRegionBatch::Create(paint.getColor(), viewMatrix, region)); |
| + GrPipelineBuilder pipelineBuilder(paint, false); |
| + this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
| +} |
| + |
| void GrDrawContext::drawOval(const GrClip& clip, |
| const GrPaint& paint, |
| const SkMatrix& viewMatrix, |