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 8 #ifndef SkLocalMatrixImageFilter_DEFINED 9 #define SkLocalMatrixImageFilter_DEFINED 10 11 #include "include/core/SkFlattenable.h" 12 #include "src/core/SkImageFilter_Base.h" 13 14 /** 15 * Wraps another imagefilter + matrix, such that using this filter will give the same result 16 * as using the wrapped filter with the matrix applied to its context. 17 */ 18 class SkLocalMatrixImageFilter : public SkImageFilter_Base { 19 public: 20 static sk_sp<SkImageFilter> Make(const SkMatrix& localM, sk_sp<SkImageFilter> input); 21 22 SkRect computeFastBounds(const SkRect&) const override; 23 24 protected: 25 void flatten(SkWriteBuffer&) const override; 26 sk_sp<SkSpecialImage> onFilterImage(const Context&, SkIPoint* offset) const override; 27 SkIRect onFilterBounds(const SkIRect& src, const SkMatrix& ctm, 28 MapDirection, const SkIRect* inputRect) const override; 29 onGetCTMCapability()30 MatrixCapability onGetCTMCapability() const override { return MatrixCapability::kComplex; } 31 32 private: 33 SK_FLATTENABLE_HOOKS(SkLocalMatrixImageFilter) 34 35 SkLocalMatrixImageFilter(const SkMatrix& localM, sk_sp<SkImageFilter> input); 36 37 SkMatrix fLocalM; 38 39 using INHERITED = SkImageFilter_Base; 40 }; 41 42 #endif 43