SkMatrixImageFilter.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright 2014 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 SkMatrixImageFilter_DEFINED
  8. #define SkMatrixImageFilter_DEFINED
  9. #include "include/core/SkFlattenable.h"
  10. #include "include/core/SkImageFilter.h"
  11. #include "include/core/SkMatrix.h"
  12. /*! \class SkMatrixImageFilter
  13. Matrix transformation image filter. This filter draws its source
  14. input transformed by the given matrix.
  15. */
  16. class SkMatrixImageFilter : public SkImageFilter {
  17. public:
  18. /** Construct a 2D transformation image filter.
  19. * @param transform The matrix to apply when drawing the src bitmap
  20. * @param filterQuality The quality of filtering to apply when scaling.
  21. * @param input The input image filter. If nullptr, the src bitmap
  22. * passed to filterImage() is used instead.
  23. */
  24. static sk_sp<SkImageFilter> Make(const SkMatrix& transform,
  25. SkFilterQuality filterQuality,
  26. sk_sp<SkImageFilter> input);
  27. SkRect computeFastBounds(const SkRect&) const override;
  28. protected:
  29. SkMatrixImageFilter(const SkMatrix& transform,
  30. SkFilterQuality,
  31. sk_sp<SkImageFilter> input);
  32. void flatten(SkWriteBuffer&) const override;
  33. sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
  34. SkIPoint* offset) const override;
  35. SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
  36. MapDirection, const SkIRect* inputRect) const override;
  37. private:
  38. SK_FLATTENABLE_HOOKS(SkMatrixImageFilter)
  39. SkMatrix fTransform;
  40. SkFilterQuality fFilterQuality;
  41. typedef SkImageFilter INHERITED;
  42. };
  43. #endif