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 8 #ifndef SkMatrixImageFilter_DEFINED 9 #define SkMatrixImageFilter_DEFINED 10 11 #include "include/core/SkFlattenable.h" 12 #include "include/core/SkMatrix.h" 13 #include "src/core/SkImageFilter_Base.h" 14 15 /*! \class SkMatrixImageFilter 16 Matrix transformation image filter. This filter draws its source 17 input transformed by the given matrix. 18 */ 19 20 // TODO(michaelludwig): Once SkCanvas no longer relies on this for handling complex CTMs with 21 // filters, this class declaration can be hidden in its cpp file, header deleted, and cpp moved 22 // into src/effects/imagefilters along with all the other image filters. 23 class SkMatrixImageFilter : public SkImageFilter_Base { 24 public: 25 /** Construct a 2D transformation image filter. 26 * @param transform The matrix to apply when drawing the src bitmap 27 * @param sampling What sampling technique to apply when scaling. 28 * @param input The input image filter. If nullptr, the src bitmap 29 * passed to filterImage() is used instead. 30 */ 31 32 static sk_sp<SkImageFilter> Make(const SkMatrix& transform, 33 const SkSamplingOptions& sampling, 34 sk_sp<SkImageFilter> input); 35 36 SkRect computeFastBounds(const SkRect&) const override; 37 38 protected: 39 SkMatrixImageFilter(const SkMatrix& transform, 40 const SkSamplingOptions&, 41 sk_sp<SkImageFilter> input); 42 void flatten(SkWriteBuffer&) const override; 43 44 sk_sp<SkSpecialImage> onFilterImage(const Context&, SkIPoint* offset) const override; 45 SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, 46 MapDirection, const SkIRect* inputRect) const override; 47 48 private: 49 SK_FLATTENABLE_HOOKS(SkMatrixImageFilter) 50 51 SkMatrix fTransform; 52 SkSamplingOptions fSampling; 53 using INHERITED = SkImageFilter_Base; 54 }; 55 56 #endif 57