Fix stroked round capped circular arc batched with filled circle.

A stroked arc with round caps was batched with a filled circle. The circle op
code would choose a GeometryProcessor configuration that expected round cap
centers as vertex attributes. However, the tessellation code for the filled
circle would not put in dummy round cap centers and then didn't advance the
pointer into which vertex data was being written by the expected vertex
stride.

Bug: b/119394958
Change-Id: I6fe95b32d750599e775ed96e656757fe3087795a
Reviewed-on: https://skia-review.googlesource.com/c/177881
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2018-12-14 16:03:38 -05:00 committed by Skia Commit-Bot
parent 16d00eeef7
commit 5ceda554f5
3 changed files with 31 additions and 1 deletions

27
gm/b_119394958.cpp Normal file
View File

@ -0,0 +1,27 @@
/*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
DEF_SIMPLE_GM(b_119394958, canvas, 100, 100) {
// The root cause of this bug was that a stroked arc with round caps was batched with a filled
// circle. The circle op code would choose a GeometryProcessor configuration that expected round
// cap centers as vertex attributes. However, the tessellation code for the filled circle would
// not put in dummy round cap centers and then didn't advance the pointer into which vertex data
// was being written by the expected vertex stride.
SkPaint paint;
paint.setColor(SK_ColorBLUE);
paint.setAntiAlias(true);
canvas->drawCircle(50, 50, 45, paint);
paint.setColor(SK_ColorGREEN);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(5);
canvas->drawCircle(50, 50, 35, paint);
paint.setColor(SK_ColorRED);
paint.setStrokeCap(SkPaint::kRound_Cap);
canvas->drawArc(SkRect::MakeLTRB(30, 30, 70, 70), 0, 110, false, paint);
}

View File

@ -26,6 +26,7 @@ gm_sources = [
"$_gm/arcto.cpp",
"$_gm/arithmode.cpp",
"$_gm/atlastext.cpp",
"$_gm/b_119394958.cpp",
"$_gm/badpaint.cpp",
"$_gm/beziereffects.cpp",
"$_gm/beziers.cpp",

View File

@ -1268,7 +1268,9 @@ private:
if (fClipPlaneUnion) {
vertices.write(circle.fUnionPlane);
}
SkASSERT(!fRoundCaps);
if (fRoundCaps) {
vertices.write(circle.fRoundCapCenters);
}
}
const uint16_t* primIndices = circle_type_to_indices(circle.fStroked);