Home | History | Annotate | Download | only in core
      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 "SkImageFilter.h"
     12 #include "SkMatrix.h"
     13 
     14 /*! \class SkMatrixImageFilter
     15     Matrix transformation image filter.  This filter draws its source
     16     input transformed by the given matrix.
     17  */
     18 
     19 class SkMatrixImageFilter : public SkImageFilter {
     20 public:
     21     /** Construct a 2D transformation image filter.
     22      *  @param transform     The matrix to apply when drawing the src bitmap
     23      *  @param filterQuality The quality of filtering to apply when scaling.
     24      *  @param input         The input image filter.  If nullptr, the src bitmap
     25      *                       passed to filterImage() is used instead.
     26      */
     27 
     28     static sk_sp<SkImageFilter> Make(const SkMatrix& transform,
     29                                      SkFilterQuality filterQuality,
     30                                      sk_sp<SkImageFilter> input);
     31 
     32     SkRect computeFastBounds(const SkRect&) const override;
     33 
     34     SK_TO_STRING_OVERRIDE()
     35     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixImageFilter)
     36 
     37 protected:
     38     SkMatrixImageFilter(const SkMatrix& transform,
     39                         SkFilterQuality,
     40                         sk_sp<SkImageFilter> input);
     41     void flatten(SkWriteBuffer&) const override;
     42 
     43     sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
     44                                         SkIPoint* offset) const override;
     45     sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
     46     SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
     47 
     48 private:
     49     SkMatrix              fTransform;
     50     SkFilterQuality       fFilterQuality;
     51     typedef SkImageFilter INHERITED;
     52 };
     53 
     54 #endif
     55