aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/SkDraw.cpp23
-rw-r--r--src/core/SkMaskFilter.cpp7
-rw-r--r--src/core/SkRasterizer.cpp3
-rw-r--r--src/effects/SkBlurMaskFilter.cpp2
-rw-r--r--src/effects/SkLayerRasterizer.cpp3
-rw-r--r--src/gpu/GrBlurUtils.cpp33
-rw-r--r--src/xps/SkXPSDevice.cpp7
7 files changed, 45 insertions, 33 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 0cdd3a19dc..d2c6bb131e 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -992,8 +992,7 @@ void SkDraw::drawRRect(const SkRRect& rrect, const SkPaint& paint) const {
SkRRect devRRect;
if (rrect.transform(*fMatrix, &devRRect)) {
SkAutoBlitterChoose blitter(fDst, *fMatrix, paint);
- if (paint.getMaskFilter()->filterRRect(devRRect, *fMatrix, *fRC, blitter.get(),
- SkPaint::kFill_Style)) {
+ if (paint.getMaskFilter()->filterRRect(devRRect, *fMatrix, *fRC, blitter.get())) {
return; // filterRRect() called the blitter, so we're done
}
}
@@ -1117,8 +1116,8 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint,
}
if (paint->getMaskFilter()) {
- SkPaint::Style style = doFill ? SkPaint::kFill_Style :
- SkPaint::kStroke_Style;
+ SkStrokeRec::InitStyle style = doFill ? SkStrokeRec::kFill_InitStyle
+ : SkStrokeRec::kHairline_InitStyle;
if (paint->getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fRC, blitter, style)) {
return; // filterPath() called the blitter, so we're done
}
@@ -2025,7 +2024,8 @@ static bool compute_bounds(const SkPath& devPath, const SkIRect* clipBounds,
return true;
}
-static void draw_into_mask(const SkMask& mask, const SkPath& devPath, SkPaint::Style style) {
+static void draw_into_mask(const SkMask& mask, const SkPath& devPath,
+ SkStrokeRec::InitStyle style) {
SkDraw draw;
if (!draw.fDst.reset(mask)) {
return;
@@ -2042,14 +2042,23 @@ static void draw_into_mask(const SkMask& mask, const SkPath& devPath, SkPaint::S
draw.fRC = &clip;
draw.fMatrix = &matrix;
paint.setAntiAlias(true);
- paint.setStyle(style);
+ switch (style) {
+ case SkStrokeRec::kHairline_InitStyle:
+ SkASSERT(!paint.getStrokeWidth());
+ paint.setStyle(SkPaint::kStroke_Style);
+ break;
+ case SkStrokeRec::kFill_InitStyle:
+ SkASSERT(paint.getStyle() == SkPaint::kFill_Style);
+ break;
+
+ }
draw.drawPath(devPath, paint);
}
bool SkDraw::DrawToMask(const SkPath& devPath, const SkIRect* clipBounds,
const SkMaskFilter* filter, const SkMatrix* filterMatrix,
SkMask* mask, SkMask::CreateMode mode,
- SkPaint::Style style) {
+ SkStrokeRec::InitStyle style) {
if (SkMask::kJustRenderImage_CreateMode != mode) {
if (!compute_bounds(devPath, clipBounds, filter, filterMatrix, &mask->fBounds))
return false;
diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp
index cacc052414..8f8e70901f 100644
--- a/src/core/SkMaskFilter.cpp
+++ b/src/core/SkMaskFilter.cpp
@@ -214,8 +214,7 @@ static int countNestedRects(const SkPath& path, SkRect rects[2]) {
}
bool SkMaskFilter::filterRRect(const SkRRect& devRRect, const SkMatrix& matrix,
- const SkRasterClip& clip, SkBlitter* blitter,
- SkPaint::Style style) const {
+ const SkRasterClip& clip, SkBlitter* blitter) const {
// Attempt to speed up drawing by creating a nine patch. If a nine patch
// cannot be used, return false to allow our caller to recover and perform
// the drawing another way.
@@ -233,10 +232,10 @@ bool SkMaskFilter::filterRRect(const SkRRect& devRRect, const SkMatrix& matrix,
bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix,
const SkRasterClip& clip, SkBlitter* blitter,
- SkPaint::Style style) const {
+ SkStrokeRec::InitStyle style) const {
SkRect rects[2];
int rectCount = 0;
- if (SkPaint::kFill_Style == style) {
+ if (SkStrokeRec::kFill_InitStyle == style) {
rectCount = countNestedRects(devPath, rects);
}
if (rectCount > 0) {
diff --git a/src/core/SkRasterizer.cpp b/src/core/SkRasterizer.cpp
index 60176b8446..994fb7f4b3 100644
--- a/src/core/SkRasterizer.cpp
+++ b/src/core/SkRasterizer.cpp
@@ -10,6 +10,7 @@
#include "SkDraw.h"
#include "SkMaskFilter.h"
#include "SkPath.h"
+#include "SkStrokeRec.h"
bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix,
const SkIRect* clipBounds, SkMaskFilter* filter,
@@ -41,5 +42,5 @@ bool SkRasterizer::onRasterize(const SkPath& fillPath, const SkMatrix& matrix,
fillPath.transform(matrix, &devPath);
return SkDraw::DrawToMask(devPath, clipBounds, nullptr, nullptr, mask, mode,
- SkPaint::kFill_Style);
+ SkStrokeRec::kFill_InitStyle);
}
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 0215c3b169..37d6c960d7 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -991,7 +991,7 @@ const GrFragmentProcessor* GrRRectBlurEffect::Create(GrTextureProvider* texProvi
path.addRRect(smallRRect);
SkDraw::DrawToMask(path, &mask.fBounds, nullptr, nullptr, &mask,
- SkMask::kJustRenderImage_CreateMode, SkPaint::kFill_Style);
+ SkMask::kJustRenderImage_CreateMode, SkStrokeRec::kFill_InitStyle);
SkMask blurredMask;
if (!SkBlurMask::BoxBlur(&blurredMask, mask, sigma, kNormal_SkBlurStyle,
diff --git a/src/effects/SkLayerRasterizer.cpp b/src/effects/SkLayerRasterizer.cpp
index 39e3e231ef..71d7fb63c5 100644
--- a/src/effects/SkLayerRasterizer.cpp
+++ b/src/effects/SkLayerRasterizer.cpp
@@ -16,6 +16,7 @@
#include "SkPath.h"
#include "SkPathEffect.h"
#include "../core/SkRasterClip.h"
+#include "../core/SkStrokeRec.h"
#include "SkXfermode.h"
#include <new>
@@ -78,7 +79,7 @@ static bool compute_bounds(const SkDeque& layers, const SkPath& path,
if (!SkDraw::DrawToMask(devPath, clipBounds, paint.getMaskFilter(),
&matrix, &mask,
SkMask::kJustComputeBounds_CreateMode,
- SkPaint::kFill_Style)) {
+ SkStrokeRec::kFill_InitStyle)) {
return false;
}
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 59a3dfcd08..aee158113b 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -54,7 +54,7 @@ static bool sw_draw_with_mask_filter(GrDrawContext* drawContext,
const SkMaskFilter* filter,
const SkIRect& clipBounds,
GrPaint* grp,
- SkPaint::Style style) {
+ SkStrokeRec::InitStyle style) {
SkMask srcM, dstM;
if (!SkDraw::DrawToMask(devPath, &clipBounds, filter, &viewMatrix, &srcM,
@@ -96,7 +96,7 @@ static bool sw_draw_with_mask_filter(GrDrawContext* drawContext,
static sk_sp<GrTexture> create_mask_GPU(GrContext* context,
SkRect* maskRect,
const SkPath& devPath,
- const GrStrokeInfo& strokeInfo,
+ SkStrokeRec::InitStyle style,
bool doAA,
int sampleCnt) {
// This mask will ultimately be drawn as a non-AA rect (see draw_mask).
@@ -139,7 +139,7 @@ static sk_sp<GrTexture> create_mask_GPU(GrContext* context,
// the origin using tempPaint.
SkMatrix translate;
translate.setTranslate(-maskRect->fLeft, -maskRect->fTop);
- drawContext->drawPath(clip, tempPaint, translate, devPath, strokeInfo);
+ drawContext->drawPath(clip, tempPaint, translate, devPath, GrStrokeInfo(style));
return drawContext->asTexture();;
}
@@ -150,7 +150,7 @@ static void draw_path_with_mask_filter(GrContext* context,
const SkMatrix& viewMatrix,
const SkMaskFilter* maskFilter,
const SkPathEffect* pathEffect,
- const GrStrokeInfo& origStrokeInfo,
+ const GrStrokeInfo& strokeInfo,
SkPath* pathPtr,
bool pathIsMutable) {
SkASSERT(maskFilter);
@@ -158,29 +158,30 @@ static void draw_path_with_mask_filter(GrContext* context,
SkIRect clipBounds;
clip.getConservativeBounds(drawContext->width(), drawContext->height(), &clipBounds);
SkTLazy<SkPath> tmpPath;
- GrStrokeInfo strokeInfo(origStrokeInfo);
static const SkRect* cullRect = nullptr; // TODO: what is our bounds?
SkASSERT(strokeInfo.isDashed() || !pathEffect);
-
- if (!strokeInfo.isHairlineStyle()) {
+ SkStrokeRec::InitStyle maskStyle;
+ if (strokeInfo.isHairlineStyle()) {
+ maskStyle = SkStrokeRec::kHairline_InitStyle;
+ } else {
SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init();
+ SkStrokeRec rec = strokeInfo;
if (strokeInfo.isDashed()) {
- if (pathEffect->filterPath(strokedPath, *pathPtr, &strokeInfo, cullRect)) {
+ if (pathEffect->filterPath(strokedPath, *pathPtr, &rec, cullRect)) {
pathPtr = strokedPath;
pathPtr->setIsVolatile(true);
pathIsMutable = true;
}
- strokeInfo.removeDash();
}
- if (strokeInfo.applyToPath(strokedPath, *pathPtr)) {
+ if (rec.applyToPath(strokedPath, *pathPtr)) {
// Apply the stroke to the path if there is one
pathPtr = strokedPath;
pathPtr->setIsVolatile(true);
pathIsMutable = true;
- strokeInfo.setFillStyle();
}
+ maskStyle = SkStrokeRec::kFill_InitStyle;
}
// avoid possibly allocating a new path in transform if we can
@@ -209,7 +210,7 @@ static void draw_path_with_mask_filter(GrContext* context,
paint,
clip,
viewMatrix,
- strokeInfo,
+ SkStrokeRec(maskStyle),
*devPathPtr)) {
// the mask filter was able to draw itself directly, so there's nothing
// left to do.
@@ -219,7 +220,7 @@ static void draw_path_with_mask_filter(GrContext* context,
sk_sp<GrTexture> mask(create_mask_GPU(context,
&maskRect,
*devPathPtr,
- strokeInfo,
+ maskStyle,
paint->isAntiAlias(),
drawContext->numColorSamples()));
if (mask) {
@@ -236,13 +237,9 @@ static void draw_path_with_mask_filter(GrContext* context,
}
}
- // draw the mask on the CPU - this is a fallthrough path in case the
- // GPU path fails
- SkPaint::Style style = strokeInfo.isHairlineStyle() ? SkPaint::kStroke_Style :
- SkPaint::kFill_Style;
sw_draw_with_mask_filter(drawContext, context->textureProvider(),
clip, viewMatrix, *devPathPtr,
- maskFilter, clipBounds, paint, style);
+ maskFilter, clipBounds, paint, maskStyle);
}
void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
diff --git a/src/xps/SkXPSDevice.cpp b/src/xps/SkXPSDevice.cpp
index 90fc68091c..aef9dc8baf 100644
--- a/src/xps/SkXPSDevice.cpp
+++ b/src/xps/SkXPSDevice.cpp
@@ -1657,6 +1657,11 @@ void SkXPSDevice::drawPath(const SkDraw& d,
SkMask* mask = nullptr;
+ SkASSERT(SkPaint::kFill_Style == paint->getStyle() ||
+ (SkPaint::kStroke_Style == paint->getStyle() && 0 == paint->getStrokeWidth()));
+ SkStrokeRec::InitStyle style = (SkPaint::kFill_Style == paint->getStyle())
+ ? SkStrokeRec::kFill_InitStyle
+ : SkStrokeRec::kHairline_InitStyle;
//[Pixel-path -> Mask]
SkMask rasteredMask;
if (SkDraw::DrawToMask(
@@ -1666,7 +1671,7 @@ void SkXPSDevice::drawPath(const SkDraw& d,
&matrix,
&rasteredMask,
SkMask::kComputeBoundsAndRenderImage_CreateMode,
- paint->getStyle())) {
+ style)) {
SkAutoMaskFreeImage rasteredAmi(rasteredMask.fImage);
mask = &rasteredMask;