Fix GrConvexPolyEffect to deal with line paths.
BUG=skia:4727 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1839743002 Review URL: https://codereview.chromium.org/1839743002
This commit is contained in:
parent
5cd0ed38ab
commit
7888de0db7
@ -135,6 +135,11 @@ protected:
|
||||
ngon.transform(scaleM);
|
||||
fPaths.addToTail(ngon);
|
||||
|
||||
SkPath linePath;
|
||||
linePath.moveTo(5.f, 5.f);
|
||||
linePath.lineTo(6.f, 6.f);
|
||||
fPaths.addToTail(linePath);
|
||||
|
||||
// integer edges
|
||||
fRects.addToTail(SkRect::MakeLTRB(5.f, 1.f, 30.f, 25.f));
|
||||
// half-integer edges
|
||||
@ -175,6 +180,7 @@ protected:
|
||||
GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I()));
|
||||
|
||||
SkScalar y = 0;
|
||||
static const SkScalar kDX = 12.f;
|
||||
for (PathList::Iter iter(fPaths, PathList::Iter::kHead_IterStart);
|
||||
iter.get();
|
||||
iter.next()) {
|
||||
@ -207,7 +213,7 @@ protected:
|
||||
|
||||
drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch);
|
||||
|
||||
x += SkScalarCeilToScalar(path->getBounds().width() + 10.f);
|
||||
x += SkScalarCeilToScalar(path->getBounds().width() + kDX);
|
||||
}
|
||||
|
||||
// Draw AA and non AA paths using normal API for reference.
|
||||
@ -254,7 +260,7 @@ protected:
|
||||
|
||||
drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch);
|
||||
|
||||
x += SkScalarCeilToScalar(rect.width() + 10.f);
|
||||
x += SkScalarCeilToScalar(rect.width() + kDX);
|
||||
}
|
||||
|
||||
// Draw rect without and with AA using normal API for reference
|
||||
@ -262,7 +268,7 @@ protected:
|
||||
canvas->translate(x, y);
|
||||
SkPaint paint;
|
||||
canvas->drawRect(*iter.get(), paint);
|
||||
x += SkScalarCeilToScalar(iter.get()->width() + 10.f);
|
||||
x += SkScalarCeilToScalar(iter.get()->width() + kDX);
|
||||
paint.setAntiAlias(true);
|
||||
canvas->drawRect(*iter.get(), paint);
|
||||
canvas->restore();
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "GrConvexPolyEffect.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "SkPathPriv.h"
|
||||
#include "effects/GrConstColorProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
@ -254,7 +255,16 @@ GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType type, const
|
||||
SkScalar edges[3 * kMaxEdges];
|
||||
|
||||
SkPathPriv::FirstDirection dir;
|
||||
SkAssertResult(SkPathPriv::CheapComputeFirstDirection(path, &dir));
|
||||
// The only way this should fail is if the clip is effectively a infinitely thin line. In that
|
||||
// case nothing is inside the clip. It'd be nice to detect this at a higher level and either
|
||||
// skip the draw or omit the clip element.
|
||||
if (!SkPathPriv::CheapComputeFirstDirection(path, &dir)) {
|
||||
if (GrProcessorEdgeTypeIsInverseFill(type)) {
|
||||
return GrConstColorProcessor::Create(0xFFFFFFFF,
|
||||
GrConstColorProcessor::kModulateRGBA_InputMode);
|
||||
}
|
||||
return GrConstColorProcessor::Create(0, GrConstColorProcessor::kIgnore_InputMode);
|
||||
}
|
||||
|
||||
SkVector t;
|
||||
if (nullptr == offset) {
|
||||
|
Loading…
Reference in New Issue
Block a user