| Index: src/gpu/GrDrawContext.cpp
|
| diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
|
| index d057984f9c67b61e399cfc967437091aad4230f7..5474707191178bd7fda41fd19a91ac714574dc6e 100644
|
| --- a/src/gpu/GrDrawContext.cpp
|
| +++ b/src/gpu/GrDrawContext.cpp
|
| @@ -311,11 +311,12 @@ void GrDrawContext::drawRect(const GrClip& clip,
|
| AutoCheckFlush acf(fDrawingManager);
|
|
|
| const SkStrokeRec& stroke = style->strokeRec();
|
| - SkScalar width = stroke.getWidth();
|
| -
|
| - // 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?
|
| @@ -339,32 +340,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) {
|
| + 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:
|
| + // 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));
|
| }
|
| }
|
|
|
|
|