SkImageFilterPriv.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright 2017 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 SkImageFilterPriv_DEFINED
  8. #define SkImageFilterPriv_DEFINED
  9. #include "include/core/SkImageFilter.h"
  10. /**
  11. * Helper to unflatten the common data, and return nullptr if we fail.
  12. */
  13. #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \
  14. Common localVar; \
  15. do { \
  16. if (!localVar.unflatten(buffer, expectedCount)) { \
  17. return nullptr; \
  18. } \
  19. } while (0)
  20. /**
  21. * Return an image filter representing this filter applied with the given ctm. This will modify the
  22. * DAG as needed if this filter does not support complex CTMs and 'ctm' is not simple. The ctm
  23. * matrix will be decomposed such that ctm = A*B; B will be incorporated directly into the DAG and A
  24. * must be the ctm set on the context passed to filterImage(). 'remainder' will be set to A.
  25. *
  26. * If this filter supports complex ctms, or 'ctm' is not complex, then A = ctm and B = I. When the
  27. * filter does not support complex ctms, and the ctm is complex, then A represents the extracted
  28. * simple portion of the ctm, and the complex portion is baked into a new DAG using a matrix filter.
  29. *
  30. * This will never return null.
  31. */
  32. sk_sp<SkImageFilter> SkApplyCTMToFilter(const SkImageFilter* filter, const SkMatrix& ctm,
  33. SkMatrix* remainder);
  34. /**
  35. * Similar to SkApplyCTMToFilter except this assumes the input content is an existing backdrop image
  36. * to be filtered. As such, the input to this filter will also be transformed by B^-1 if the filter
  37. * can't support complex CTMs, since backdrop content is already in device space and must be
  38. * transformed back into the CTM's local space.
  39. */
  40. sk_sp<SkImageFilter> SkApplyCTMToBackdropFilter(const SkImageFilter* filter, const SkMatrix& ctm,
  41. SkMatrix* remainder);
  42. bool SkIsSameFilter(const SkImageFilter* a, const SkImageFilter* b);
  43. // Exposes just the behavior of the protected SkImageFilter::onFilterNodeBounds()
  44. SkIRect SkFilterNodeBounds(const SkImageFilter* filter, const SkIRect& srcRect, const SkMatrix& ctm,
  45. SkImageFilter::MapDirection dir, const SkIRect* inputRect);
  46. #endif