1 /* 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 11 #include "SkFlattenable.h" 12 #include "SkImageFilter.h" 13 #include "SkPaint.h" 14 15 class SK_API SkPaintImageFilter : public SkImageFilter { 16 public: 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 */ 26 static sk_sp<SkImageFilter> Make(const SkPaint& paint, const CropRect* cropRect = nullptr); 27 28 bool affectsTransparentBlack() const override; 29 30 protected: 31 void flatten(SkWriteBuffer&) const override; 32 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, 33 SkIPoint* offset) const override; 34 sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer* xformer) const override; 35 36 private: 37 SK_FLATTENABLE_HOOKS(SkPaintImageFilter) 38 39 SkPaintImageFilter(const SkPaint& paint, const CropRect* rect); 40 41 SkPaint fPaint; 42 43 typedef SkImageFilter INHERITED; 44 }; 45 46 #endif 47