return true;
}
-static bool draw_with_mask_filter(GrDrawContext* drawContext,
- GrTextureProvider* textureProvider,
- const GrClip& clipData,
- const SkMatrix& viewMatrix,
- const SkPath& devPath,
- const SkMaskFilter* filter,
- const SkIRect& clipBounds,
- GrPaint* grp,
- SkPaint::Style style) {
+static bool sw_draw_with_mask_filter(GrDrawContext* drawContext,
+ GrTextureProvider* textureProvider,
+ const GrClip& clipData,
+ const SkMatrix& viewMatrix,
+ const SkPath& devPath,
+ const SkMaskFilter* filter,
+ const SkIRect& clipBounds,
+ GrPaint* grp,
+ SkPaint::Style style) {
SkMask srcM, dstM;
if (!SkDraw::DrawToMask(devPath, &clipBounds, filter, &viewMatrix, &srcM,
static const SkRect* cullRect = nullptr; // TODO: what is our bounds?
- if (!strokeInfo.isDashed() && pathEffect && pathEffect->filterPath(tmpPath.init(), *pathPtr,
- &strokeInfo, cullRect)) {
- pathPtr = tmpPath.get();
- pathPtr->setIsVolatile(true);
- pathIsMutable = true;
- }
+ SkASSERT(strokeInfo.isDashed() || !pathEffect);
+
if (!strokeInfo.isHairlineStyle()) {
SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init();
if (strokeInfo.isDashed()) {
strokeInfo.removeDash();
}
if (strokeInfo.applyToPath(strokedPath, *pathPtr)) {
+ // Apply the stroke to the path if there is one
pathPtr = strokedPath;
pathPtr->setIsVolatile(true);
pathIsMutable = true;
// GPU path fails
SkPaint::Style style = strokeInfo.isHairlineStyle() ? SkPaint::kStroke_Style :
SkPaint::kFill_Style;
- draw_with_mask_filter(drawContext, context->textureProvider(),
- clip, viewMatrix, *devPathPtr,
- maskFilter, clipBounds, paint, style);
+ sw_draw_with_mask_filter(drawContext, context->textureProvider(),
+ clip, viewMatrix, *devPathPtr,
+ maskFilter, clipBounds, paint, style);
}
void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
GrPaint* paint,
const SkMatrix& viewMatrix,
const SkMaskFilter* mf,
- const SkPathEffect* pe,
- const GrStrokeInfo& strokeInfo) {
- SkPath* path = const_cast<SkPath*>(&origPath);
- draw_path_with_mask_filter(context, drawContext, rt, clip, paint, viewMatrix, mf, pe,
- strokeInfo, path, false);
+ const SkPathEffect* pathEffect,
+ const GrStrokeInfo& origStrokeInfo,
+ bool pathIsMutable) {
+ SkPath* pathPtr = const_cast<SkPath*>(&origPath);
+
+ SkTLazy<SkPath> tmpPath;
+ GrStrokeInfo strokeInfo(origStrokeInfo);
+
+ if (!strokeInfo.isDashed() && pathEffect && pathEffect->filterPath(tmpPath.init(), *pathPtr,
+ &strokeInfo, nullptr)) {
+ pathPtr = tmpPath.get();
+ pathPtr->setIsVolatile(true);
+ pathIsMutable = true;
+ pathEffect = nullptr;
+ }
+
+ draw_path_with_mask_filter(context, drawContext, rt, clip, paint, viewMatrix, mf, pathEffect,
+ strokeInfo, pathPtr, pathIsMutable);
}
void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
// at this point we're done with prePathMatrix
SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;)
+ SkTLazy<SkPath> tmpPath2;
+
+ if (!strokeInfo.isDashed() && pathEffect &&
+ pathEffect->filterPath(tmpPath2.init(), *pathPtr, &strokeInfo, nullptr)) {
+ pathPtr = tmpPath2.get();
+ pathPtr->setIsVolatile(true);
+ pathIsMutable = true;
+ pathEffect = nullptr;
+ }
+
GrPaint grPaint;
if (!SkPaintToGrPaint(context, paint, viewMatrix, &grPaint)) {
return;
if (paint.getMaskFilter()) {
draw_path_with_mask_filter(context, drawContext, renderTarget, clip, &grPaint, viewMatrix,
- paint.getMaskFilter(), paint.getPathEffect(), strokeInfo,
+ paint.getMaskFilter(), pathEffect, strokeInfo,
pathPtr, pathIsMutable);
} else {
- SkTLazy<SkPath> tmpPath2;
- if (!strokeInfo.isDashed() && pathEffect &&
- pathEffect->filterPath(tmpPath2.init(), *pathPtr, &strokeInfo, nullptr)) {
- pathPtr = tmpPath2.get();
- pathPtr->setIsVolatile(true);
- pathIsMutable = true;
- }
drawContext->drawPath(clip, grPaint, viewMatrix, *pathPtr, strokeInfo);
}
}
void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, const SkPaint& paint) {
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRect", fContext);
-
CHECK_FOR_ANNOTATION(paint);
CHECK_SHOULD_DRAW(draw);
void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
const SkRRect& inner, const SkPaint& paint) {
- SkStrokeRec stroke(paint);
- if (stroke.isFillStyle()) {
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawDRRect", fContext);
+ CHECK_FOR_ANNOTATION(paint);
+ CHECK_SHOULD_DRAW(draw);
- CHECK_FOR_ANNOTATION(paint);
- CHECK_SHOULD_DRAW(draw);
+ SkStrokeRec stroke(paint);
+ if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()) {
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
return;
}
- if (nullptr == paint.getMaskFilter() && nullptr == paint.getPathEffect()) {
- fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner);
- return;
- }
+ fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner);
+ return;
}
SkPath path;
path.addRRect(inner);
path.setFillType(SkPath::kEvenOdd_FillType);
- this->drawPath(draw, path, paint, nullptr, true);
+ GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, fRenderTarget,
+ fClip, path, paint,
+ *draw.fMatrix, nullptr,
+ draw.fClip->getBounds(), true);
}