GrPaint* grp,
const SkStrokeRec& strokeRec,
const SkPath& path) const;
+ /**
+ * Try to directly render a rounded rect mask filter into the target. Returns
+ * true if drawing was successful.
+ */
+ virtual bool directFilterRRectMaskGPU(GrContext* context,
+ GrPaint* grp,
+ const SkStrokeRec& strokeRec,
+ const SkRRect& rrect) const;
/**
* This function is used to implement filters that require an explicit src mask. It should only
return dist <= SkScalarSquare(SkScalarMul(fRadii[index].fX, fRadii[index].fY));
}
+bool SkRRect::allCornersCircular() const {
+ return fRadii[0].fX == fRadii[0].fY &&
+ fRadii[1].fX == fRadii[1].fY &&
+ fRadii[2].fX == fRadii[2].fY &&
+ fRadii[3].fX == fRadii[3].fY;
+}
+
bool SkRRect::contains(const SkRect& rect) const {
if (!this->getBounds().contains(rect)) {
// If 'rect' isn't contained by the RR's bounds then the
GrPaint* grp,
const SkStrokeRec& strokeRec,
const SkPath& path) const SK_OVERRIDE;
+ virtual bool directFilterRRectMaskGPU(GrContext* context,
+ GrPaint* grp,
+ const SkStrokeRec& strokeRec,
+ const SkRRect& rrect) const SK_OVERRIDE;
virtual bool filterMaskGPU(GrTexture* src,
const SkMatrix& ctm,
return true;
}
+bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
+ GrPaint* grp,
+ const SkStrokeRec& strokeRec,
+ const SkRRect& rrect) const {
+ return false;
+}
+
bool SkBlurMaskFilterImpl::canFilterMaskGPU(const SkRect& srcBounds,
const SkIRect& clipBounds,
const SkMatrix& ctm,
#include "SkGrTexturePixelRef.h"
+#include "SkBounder.h"
#include "SkColorFilter.h"
#include "SkDeviceImageFilterProxy.h"
#include "SkDrawProcs.h"
#include "SkGlyphCache.h"
#include "SkImageFilter.h"
+#include "SkMaskFilter.h"
#include "SkPathEffect.h"
#include "SkRRect.h"
#include "SkStroke.h"
CHECK_FOR_ANNOTATION(paint);
CHECK_SHOULD_DRAW(draw, false);
+ GrPaint grPaint;
+ if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) {
+ return;
+ }
+
+ SkStrokeRec stroke(paint);
+ if (paint.getMaskFilter()) {
+ // try to hit the fast path for drawing filtered round rects
+
+ SkRRect devRRect;
+ if (rect.transform(fContext->getMatrix(), &devRRect)) {
+ if (devRRect.allCornersCircular()) {
+ SkRect maskRect;
+ if (paint.getMaskFilter()->canFilterMaskGPU(devRRect.rect(),
+ draw.fClip->getBounds(),
+ fContext->getMatrix(),
+ &maskRect)) {
+ SkIRect finalIRect;
+ maskRect.roundOut(&finalIRect);
+ if (draw.fClip->quickReject(finalIRect)) {
+ // clipped out
+ return;
+ }
+ if (NULL != draw.fBounder && !draw.fBounder->doIRect(finalIRect)) {
+ // nothing to draw
+ return;
+ }
+ if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext, &grPaint,
+ stroke, devRRect)) {
+ return;
+ }
+ }
+
+ }
+ }
+
+ }
+
bool usePath = !rect.isSimple();
// another two reasons we might need to call drawPath...
if (paint.getMaskFilter() || paint.getPathEffect()) {
return;
}
- GrPaint grPaint;
- if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) {
- return;
- }
-
- SkStrokeRec stroke(paint);
fContext->drawRRect(grPaint, rect, stroke);
}
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval,
const SkPaint& paint) {
}
if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint,
- SkStrokeRec(paint), *devPathPtr)) {
+ stroke, *devPathPtr)) {
// the mask filter was able to draw itself directly, so there's nothing
// left to do.
return;