Home | History | Annotate | Download | only in effects
      1 /*
      2  * Copyright 2016 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 
      8 #ifndef SkPaintImageFilter_DEFINED
      9 #define SkPaintImageFilter_DEFINED
     10 
     11 #include "SkImageFilter.h"
     12 #include "SkPaint.h"
     13 
     14 class SK_API SkPaintImageFilter : public SkImageFilter {
     15 public:
     16     /** Create a new image filter which fills the given rectangle using the
     17      *  given paint. If no rectangle is specified, an output is produced with
     18      *  the same bounds as the input primitive (even though the input
     19      *  primitive's pixels are not used for processing).
     20      *  @param paint  Paint to use when filling the rect.
     21      *  @param rect   Rectangle of output pixels. If NULL or a given crop edge is
     22      *                not specified, the source primitive's bounds are used
     23      *                instead.
     24      */
     25     static SkImageFilter* Create(const SkPaint& paint, const CropRect* rect = NULL);
     26 
     27     bool canComputeFastBounds() const override;
     28 
     29     SK_TO_STRING_OVERRIDE()
     30     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPaintImageFilter)
     31 
     32 protected:
     33     void flatten(SkWriteBuffer&) const override;
     34     bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
     35                                  SkIPoint* loc) const override;
     36 
     37 private:
     38     SkPaintImageFilter(const SkPaint& paint, const CropRect* rect);
     39 
     40     SkPaint fPaint;
     41 
     42     typedef SkImageFilter INHERITED;
     43 };
     44 
     45 #endif
     46