Home | History | Annotate | Download | only in android
      1 /*
      2  * Copyright 2007 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 SkPixelXorXfermode_DEFINED
      9 #define SkPixelXorXfermode_DEFINED
     10 
     11 #include "SkXfermode.h"
     12 
     13 /** SkPixelXorXfermode implements a simple pixel xor (op ^ src ^ dst).
     14     This transformation does not follow premultiplied conventions, therefore
     15     this proc *always* returns an opaque color (alpha == 255). Thus it is
     16     not really usefull for operating on blended colors.
     17 */
     18 class SK_API SkPixelXorXfermode : public SkXfermode {
     19 public:
     20     static SkXfermode* Create(SkColor opColor) {
     21         return new SkPixelXorXfermode(opColor);
     22     }
     23 
     24 #if SK_SUPPORT_GPU
     25     const GrFragmentProcessor* getFragmentProcessorForImageFilter(
     26                                                     const GrFragmentProcessor* dst) const override;
     27     GrXPFactory* asXPFactory() const override;
     28 #endif
     29 
     30     SK_TO_STRING_OVERRIDE()
     31     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPixelXorXfermode)
     32 
     33 protected:
     34     void flatten(SkWriteBuffer&) const override;
     35     SkPMColor xferColor(SkPMColor src, SkPMColor dst) const override;
     36 
     37 private:
     38     explicit SkPixelXorXfermode(SkColor opColor) {
     39         fOpColor = SkPreMultiplyColor(opColor | 0xFF000000);
     40     }
     41 
     42     SkPMColor fOpColor;
     43 
     44     typedef SkXfermode INHERITED;
     45 };
     46 
     47 #endif
     48