| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The Android Open Source Project | 2 * Copyright 2015 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkLocalMatrixImageFilter_DEFINED | 8 #ifndef SkLocalMatrixImageFilter_DEFINED |
| 9 #define SkLocalMatrixImageFilter_DEFINED | 9 #define SkLocalMatrixImageFilter_DEFINED |
| 10 | 10 |
| 11 #include "SkImageFilter.h" | 11 #include "SkImageFilter.h" |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Wraps another imagefilter + matrix, such that using this filter will give th
e same result | 14 * Wraps another imagefilter + matrix, such that using this filter will give th
e same result |
| 15 * as using the wrapped filter with the matrix applied to its context. | 15 * as using the wrapped filter with the matrix applied to its context. |
| 16 */ | 16 */ |
| 17 class SkLocalMatrixImageFilter : public SkImageFilter { | 17 class SkLocalMatrixImageFilter : public SkImageFilter { |
| 18 public: | 18 public: |
| 19 static sk_sp<SkImageFilter> Make(const SkMatrix& localM, sk_sp<SkImageFilter
> input) { | 19 static sk_sp<SkImageFilter> Make(const SkMatrix& localM, sk_sp<SkImageFilter
> input); |
| 20 if (!input) { | |
| 21 return nullptr; | |
| 22 } | |
| 23 if (localM.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_
Mask)) { | |
| 24 return nullptr; | |
| 25 } | |
| 26 if (localM.isIdentity()) { | |
| 27 return input; | |
| 28 } | |
| 29 return sk_sp<SkImageFilter>(new SkLocalMatrixImageFilter(localM, input))
; | |
| 30 } | |
| 31 | 20 |
| 32 SK_TO_STRING_OVERRIDE() | 21 SK_TO_STRING_OVERRIDE() |
| 33 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLocalMatrixImageFilter
) | 22 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLocalMatrixImageFilter
) |
| 34 | 23 |
| 35 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR | 24 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR |
| 36 static SkImageFilter* Create(const SkMatrix& localM, SkImageFilter* input) { | 25 static SkImageFilter* Create(const SkMatrix& localM, SkImageFilter* input) { |
| 37 return Make(localM, sk_sp<SkImageFilter>(SkSafeRef(input))).release(); | 26 return Make(localM, sk_sp<SkImageFilter>(SkSafeRef(input))).release(); |
| 38 } | 27 } |
| 39 #endif | 28 #endif |
| 40 | 29 |
| 41 protected: | 30 protected: |
| 42 void flatten(SkWriteBuffer&) const override; | 31 void flatten(SkWriteBuffer&) const override; |
| 43 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, | 32 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, |
| 44 SkIPoint* offset) const override; | 33 SkIPoint* offset) const override; |
| 45 SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, MapDirection) co
nst override; | 34 SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, MapDirection) co
nst override; |
| 46 | 35 |
| 47 private: | 36 private: |
| 48 SkLocalMatrixImageFilter(const SkMatrix& localM, sk_sp<SkImageFilter> input)
; | 37 SkLocalMatrixImageFilter(const SkMatrix& localM, sk_sp<SkImageFilter> input)
; |
| 49 | 38 |
| 50 SkMatrix fLocalM; | 39 SkMatrix fLocalM; |
| 51 | 40 |
| 52 typedef SkImageFilter INHERITED; | 41 typedef SkImageFilter INHERITED; |
| 53 }; | 42 }; |
| 54 | 43 |
| 55 #endif | 44 #endif |
| OLD | NEW |