aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/effects/SkPaintImageFilter.h
diff options
context:
space:
mode:
authorGravatar ajuma <ajuma@chromium.org>2016-01-08 14:58:35 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-08 14:58:35 -0800
commit77b6ba3b6e23b84a3a4f3a62812e4a9eb6de4c23 (patch)
treee567bf7da5cadf68009bbd21d2e65fb01895663a /include/effects/SkPaintImageFilter.h
parentc146aa6fd45dffe29b4f565aafd4ec3a16d9f73b (diff)
Implement an SkPaint-based image filter
This implements SkPaintImageFilter, and is intended to replace SkRectShaderImageFilter. By allowing a paint and not just a shader as input, this allows consumers to control dithering. BUG=skia:4780 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1556553002 Review URL: https://codereview.chromium.org/1556553002
Diffstat (limited to 'include/effects/SkPaintImageFilter.h')
-rw-r--r--include/effects/SkPaintImageFilter.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/include/effects/SkPaintImageFilter.h b/include/effects/SkPaintImageFilter.h
new file mode 100644
index 0000000000..eee3630f31
--- /dev/null
+++ b/include/effects/SkPaintImageFilter.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkPaintImageFilter_DEFINED
+#define SkPaintImageFilter_DEFINED
+
+#include "SkImageFilter.h"
+#include "SkPaint.h"
+
+class SK_API SkPaintImageFilter : public SkImageFilter {
+public:
+ /** Create a new image filter which fills the given rectangle using the
+ * given paint. If no rectangle is specified, an output is produced with
+ * the same bounds as the input primitive (even though the input
+ * primitive's pixels are not used for processing).
+ * @param paint Paint to use when filling the rect.
+ * @param rect Rectangle of output pixels. If NULL or a given crop edge is
+ * not specified, the source primitive's bounds are used
+ * instead.
+ */
+ static SkImageFilter* Create(const SkPaint& paint, const CropRect* rect = NULL);
+
+ bool canComputeFastBounds() const override;
+
+ SK_TO_STRING_OVERRIDE()
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPaintImageFilter)
+
+protected:
+ void flatten(SkWriteBuffer&) const override;
+ bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
+ SkIPoint* loc) const override;
+
+private:
+ SkPaintImageFilter(const SkPaint& paint, const CropRect* rect);
+
+ SkPaint fPaint;
+
+ typedef SkImageFilter INHERITED;
+};
+
+#endif