SkLocalMatrixImageFilter.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright 2015 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 SkLocalMatrixImageFilter_DEFINED
  8. #define SkLocalMatrixImageFilter_DEFINED
  9. #include "include/core/SkFlattenable.h"
  10. #include "include/core/SkImageFilter.h"
  11. /**
  12. * Wraps another imagefilter + matrix, such that using this filter will give the same result
  13. * as using the wrapped filter with the matrix applied to its context.
  14. */
  15. class SkLocalMatrixImageFilter : public SkImageFilter {
  16. public:
  17. static sk_sp<SkImageFilter> Make(const SkMatrix& localM, sk_sp<SkImageFilter> input);
  18. protected:
  19. void flatten(SkWriteBuffer&) const override;
  20. sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
  21. SkIPoint* offset) const override;
  22. SkIRect onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
  23. MapDirection, const SkIRect* inputRect) const override;
  24. bool onCanHandleComplexCTM() const override { return true; }
  25. private:
  26. SK_FLATTENABLE_HOOKS(SkLocalMatrixImageFilter)
  27. SkLocalMatrixImageFilter(const SkMatrix& localM, sk_sp<SkImageFilter> input);
  28. SkMatrix fLocalM;
  29. typedef SkImageFilter INHERITED;
  30. };
  31. #endif