SkPaintImageFilter.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef SkPaintImageFilter_DEFINED
  8. #define SkPaintImageFilter_DEFINED
  9. #include "SkFlattenable.h"
  10. #include "SkImageFilter.h"
  11. #include "SkPaint.h"
  12. class SK_API SkPaintImageFilter : public SkImageFilter {
  13. public:
  14. /** Create a new image filter which fills the given rectangle using the
  15. * given paint. If no rectangle is specified, an output is produced with
  16. * the same bounds as the input primitive (even though the input
  17. * primitive's pixels are not used for processing).
  18. * @param paint Paint to use when filling the rect.
  19. * @param rect Rectangle of output pixels. If NULL or a given crop edge is
  20. * not specified, the source primitive's bounds are used
  21. * instead.
  22. */
  23. static sk_sp<SkImageFilter> Make(const SkPaint& paint, const CropRect* cropRect = nullptr);
  24. bool affectsTransparentBlack() const override;
  25. protected:
  26. void flatten(SkWriteBuffer&) const override;
  27. sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
  28. SkIPoint* offset) const override;
  29. sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer* xformer) const override;
  30. private:
  31. SK_FLATTENABLE_HOOKS(SkPaintImageFilter)
  32. SkPaintImageFilter(const SkPaint& paint, const CropRect* rect);
  33. SkPaint fPaint;
  34. typedef SkImageFilter INHERITED;
  35. };
  36. #endif