SkPictureImageFilter.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 "SkFlattenable.h"
  10. #include "SkImageFilter.h"
  11. #include "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. sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
  34. private:
  35. SK_FLATTENABLE_HOOKS(SkPictureImageFilter)
  36. explicit SkPictureImageFilter(sk_sp<SkPicture> picture);
  37. SkPictureImageFilter(sk_sp<SkPicture> picture, const SkRect& cropRect, sk_sp<SkColorSpace>);
  38. sk_sp<SkPicture> fPicture;
  39. SkRect fCropRect;
  40. // Should never be set by a public constructor. This is only used when onMakeColorSpace()
  41. // forces a deferred color space xform.
  42. sk_sp<SkColorSpace> fColorSpace;
  43. typedef SkImageFilter INHERITED;
  44. };
  45. #endif