Home | History | Annotate | Download | only in effects
      1 /*
      2  * Copyright 2012 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 SkBlendImageFilter_DEFINED
      9 #define SkBlendImageFilter_DEFINED
     10 
     11 #include "SkImageFilter.h"
     12 #include "SkBitmap.h"
     13 
     14 class SK_API SkBlendImageFilter : public SkImageFilter {
     15 public:
     16     enum Mode {
     17       kNormal_Mode,
     18       kMultiply_Mode,
     19       kScreen_Mode,
     20       kDarken_Mode,
     21       kLighten_Mode,
     22     };
     23     SkBlendImageFilter(Mode mode, SkImageFilter* background, SkImageFilter* foreground = NULL);
     24 
     25     ~SkBlendImageFilter();
     26 
     27     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlendImageFilter)
     28 
     29     virtual bool onFilterImage(Proxy* proxy,
     30                                const SkBitmap& src,
     31                                const SkMatrix& ctm,
     32                                SkBitmap* dst,
     33                                SkIPoint* offset) SK_OVERRIDE;
     34 #if SK_SUPPORT_GPU
     35     virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; }
     36     virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result) SK_OVERRIDE;
     37 #endif
     38 
     39 protected:
     40     explicit SkBlendImageFilter(SkFlattenableReadBuffer& buffer);
     41     virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
     42 
     43 private:
     44     Mode fMode;
     45     typedef SkImageFilter INHERITED;
     46     SkImageFilter* getBackgroundInput() { return getInput(0); }
     47     SkImageFilter* getForegroundInput() { return getInput(1); }
     48 };
     49 
     50 #endif
     51