blob: 8765665fbf988f7be40d62381839548e6d2ecbdc [file] [log] [blame]
ajuma77b6ba32016-01-08 14:58:35 -08001/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkPaintImageFilter_DEFINED
9#define SkPaintImageFilter_DEFINED
10
Cary Clark4dc5a452018-05-21 11:56:57 -040011#include "SkFlattenable.h"
ajuma77b6ba32016-01-08 14:58:35 -080012#include "SkImageFilter.h"
13#include "SkPaint.h"
14
15class SK_API SkPaintImageFilter : public SkImageFilter {
16public:
17 /** Create a new image filter which fills the given rectangle using the
18 * given paint. If no rectangle is specified, an output is produced with
19 * the same bounds as the input primitive (even though the input
20 * primitive's pixels are not used for processing).
21 * @param paint Paint to use when filling the rect.
22 * @param rect Rectangle of output pixels. If NULL or a given crop edge is
23 * not specified, the source primitive's bounds are used
24 * instead.
25 */
robertphillips225db442016-04-17 14:27:05 -070026 static sk_sp<SkImageFilter> Make(const SkPaint& paint, const CropRect* cropRect = nullptr);
ajuma77b6ba32016-01-08 14:58:35 -080027
senorblanco6db0a7b2016-04-01 16:41:10 -070028 bool affectsTransparentBlack() const override;
ajuma77b6ba32016-01-08 14:58:35 -080029
Cary Clark4dc5a452018-05-21 11:56:57 -040030 Factory getFactory() const override { return CreateProc; }
ajuma77b6ba32016-01-08 14:58:35 -080031
32protected:
33 void flatten(SkWriteBuffer&) const override;
robertphillips2302de92016-03-24 07:26:32 -070034 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
35 SkIPoint* offset) const override;
Matt Sarett31abf1f2017-04-07 16:54:04 -040036 sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer* xformer) const override;
ajuma77b6ba32016-01-08 14:58:35 -080037
38private:
39 SkPaintImageFilter(const SkPaint& paint, const CropRect* rect);
Cary Clark4dc5a452018-05-21 11:56:57 -040040 static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
41 friend class SkFlattenable::PrivateInitializer;
ajuma77b6ba32016-01-08 14:58:35 -080042
43 SkPaint fPaint;
44
45 typedef SkImageFilter INHERITED;
46};
47
48#endif