Chromium Code Reviews| Index: src/gpu/GrDrawContext.cpp |
| diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp |
| index dc24fb54390a82fb7eba556aa046c3a4020e0ab2..38fcd2ff85656a1bb56eb5399c694edf4f00651d 100644 |
| --- a/src/gpu/GrDrawContext.cpp |
| +++ b/src/gpu/GrDrawContext.cpp |
| @@ -322,11 +322,21 @@ void GrDrawContext::drawRect(const GrClip& clip, |
| AutoCheckFlush acf(fDrawingManager); |
| const SkStrokeRec& stroke = style->strokeRec(); |
|
robertphillips
2016/07/06 15:01:47
Do we still need this code? If so, I think it need
bsalomon
2016/07/06 15:57:53
Oh no, left it by accident. Removed.
|
| - SkScalar width = stroke.getWidth(); |
| +#if 0 |
| + // We have no special cases for stroke-and-fill. |
| + if (stroke.getStyle() == SkStrokeRec::kStrokeAndFill_Style) { |
| + SkPath path; |
| + path.addRect(rect); |
| + this->internalDrawPath(clip, paint, viewMatrix, path, *style); |
| + } |
| +#endif |
| - // Check if this is a full RT draw and can be replaced with a clear. We don't bother checking |
| - // cases where the RT is fully inside a stroke. |
| - if (width < 0) { |
| + bool useHWAA; |
| + bool snapToPixelCenters = false; |
| + SkAutoTUnref<GrDrawBatch> batch; |
| + if (stroke.getStyle() == SkStrokeRec::kFill_Style) { |
| + // Check if this is a full RT draw and can be replaced with a clear. We don't bother |
| + // checking cases where the RT is fully inside a stroke. |
| SkRect rtRect; |
| fRenderTarget->getBoundsRect(&rtRect); |
| // Does the clip contain the entire RT? |
| @@ -350,32 +360,54 @@ void GrDrawContext::drawRect(const GrClip& clip, |
| } |
| } |
| } |
| - } |
| - |
| - bool useHWAA; |
| - bool snapToPixelCenters = false; |
| - SkAutoTUnref<GrDrawBatch> batch; |
| - if (width < 0) { |
| batch.reset(this->getFillRectBatch(paint, viewMatrix, rect, &useHWAA)); |
| - } else { |
| + } else if (stroke.getStyle() == SkStrokeRec::kStroke_Style || |
| + stroke.getStyle() == SkStrokeRec::kHairline_Style) { |
|
robertphillips
2016/07/06 15:01:47
// Handle special case where the stroked rect dege
bsalomon
2016/07/06 15:57:53
That seems to me a bit like rewriting "if (!width
|
| + if ((!rect.width() || !rect.height()) && |
| + SkStrokeRec::kHairline_Style != stroke.getStyle()) { |
| + SkScalar r = stroke.getWidth() / 2; |
| + // TODO: Move these stroke->fill fallbacks to GrShape? |
| + switch (stroke.getJoin()) { |
| + case SkPaint::kMiter_Join: |
| + this->drawRect(clip, paint, viewMatrix, |
| + {rect.fLeft - r, rect.fTop - r, |
| + rect.fRight + r, rect.fBottom + r}, |
| + &GrStyle::SimpleFill()); |
| + return; |
| + case SkPaint::kRound_Join: |
|
robertphillips
2016/07/06 15:01:47
Isn't that a bug in raster though ?
bsalomon
2016/07/06 15:57:53
I'm not sure. Will check with reed@
|
| + // Raster draws nothing when both dimensions are empty. |
| + if (rect.width() || rect.height()){ |
| + SkRRect rrect = SkRRect::MakeRectXY(rect.makeOutset(r, r), r, r); |
| + this->drawRRect(clip, paint, viewMatrix, rrect, GrStyle::SimpleFill()); |
| + return; |
| + } |
| + case SkPaint::kBevel_Join: |
| + if (!rect.width()) { |
| + this->drawRect(clip, paint, viewMatrix, |
| + {rect.fLeft - r, rect.fTop, rect.fRight + r, rect.fBottom}, |
| + &GrStyle::SimpleFill()); |
| + } else { |
| + this->drawRect(clip, paint, viewMatrix, |
| + {rect.fLeft, rect.fTop - r, rect.fRight, rect.fBottom + r}, |
| + &GrStyle::SimpleFill()); |
| + } |
| + return; |
| + } |
| + } |
| GrColor color = paint.getColor(); |
| - |
| if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { |
| // The stroke path needs the rect to remain axis aligned (no rotation or skew). |
| if (viewMatrix.rectStaysRect()) { |
| - batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix, rect, |
| - stroke)); |
| + batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix, rect, stroke)); |
| } |
| } else { |
| - // Non-AA hairlines are snapped to pixel centers to make which pixels are hit |
| - // deterministic |
| - snapToPixelCenters = (0 == width && !fRenderTarget->isUnifiedMultisampled()); |
| - batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect, |
| - width, snapToPixelCenters)); |
| - |
| // Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of |
| // hairline rects. We jam all the vertices to pixel centers to avoid this, but not |
| // when MSAA is enabled because it can cause ugly artifacts. |
| + snapToPixelCenters = stroke.getStyle() == SkStrokeRec::kHairline_Style && |
| + !fRenderTarget->isUnifiedMultisampled(); |
| + batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect, |
| + stroke, snapToPixelCenters)); |
| } |
| } |