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 SkMergeImageFilter_DEFINED
      9 #define SkMergeImageFilter_DEFINED
     10 
     11 #include "SkImageFilter.h"
     12 
     13 #include "SkXfermode.h"
     14 
     15 class SK_API SkMergeImageFilter : public SkImageFilter {
     16 public:
     17     SkMergeImageFilter(SkImageFilter* first, SkImageFilter* second,
     18                        SkXfermode::Mode = SkXfermode::kSrcOver_Mode,
     19                        const CropRect* cropRect = NULL);
     20     SkMergeImageFilter(SkImageFilter* filters[], int count,
     21                        const SkXfermode::Mode modes[] = NULL,
     22                        const CropRect* cropRect = NULL);
     23     virtual ~SkMergeImageFilter();
     24 
     25     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter)
     26 
     27 protected:
     28     SkMergeImageFilter(SkFlattenableReadBuffer& buffer);
     29     virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
     30 
     31     virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
     32                                SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
     33     virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) SK_OVERRIDE;
     34 
     35 private:
     36     uint8_t*            fModes; // SkXfermode::Mode
     37 
     38     // private storage, to avoid dynamically allocating storage for our copy
     39     // of the modes (unless the count is so large we can't fit).
     40     intptr_t    fStorage[16];
     41 
     42     void initAllocModes();
     43     void initModes(const SkXfermode::Mode []);
     44 
     45     typedef SkImageFilter INHERITED;
     46 };
     47 
     48 #endif
     49