SkPictureImageFilter.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright 2013 The Android Open Source Project
  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 SkPictureImageFilter_DEFINED
  8. #define SkPictureImageFilter_DEFINED
  9. #include "include/core/SkFlattenable.h"
  10. #include "include/core/SkImageFilter.h"
  11. #include "include/core/SkPicture.h"
  12. class SK_API SkPictureImageFilter : public SkImageFilter {
  13. public:
  14. /**
  15. * Refs the passed-in picture.
  16. */
  17. static sk_sp<SkImageFilter> Make(sk_sp<SkPicture> picture);
  18. /**
  19. * Refs the passed-in picture. cropRect can be used to crop or expand the destination rect when
  20. * the picture is drawn. (No scaling is implied by the dest rect; only the CTM is applied.)
  21. */
  22. static sk_sp<SkImageFilter> Make(sk_sp<SkPicture> picture, const SkRect& cropRect);
  23. protected:
  24. /* Constructs an SkPictureImageFilter object from an SkReadBuffer.
  25. * Note: If the SkPictureImageFilter object construction requires bitmap
  26. * decoding, the decoder must be set on the SkReadBuffer parameter by calling
  27. * SkReadBuffer::setBitmapDecoder() before calling this constructor.
  28. * @param SkReadBuffer Serialized picture data.
  29. */
  30. void flatten(SkWriteBuffer&) const override;
  31. sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
  32. SkIPoint* offset) const override;
  33. private:
  34. SK_FLATTENABLE_HOOKS(SkPictureImageFilter)
  35. explicit SkPictureImageFilter(sk_sp<SkPicture> picture);
  36. SkPictureImageFilter(sk_sp<SkPicture> picture, const SkRect& cropRect);
  37. sk_sp<SkPicture> fPicture;
  38. SkRect fCropRect;
  39. typedef SkImageFilter INHERITED;
  40. };
  41. #endif