| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkPixelXorXfermode_DEFINED | 8 #ifndef SkPixelXorXfermode_DEFINED |
| 9 #define SkPixelXorXfermode_DEFINED | 9 #define SkPixelXorXfermode_DEFINED |
| 10 | 10 |
| 11 #include "SkXfermode.h" | 11 #include "SkXfermode.h" |
| 12 | 12 |
| 13 /** SkPixelXorXfermode implements a simple pixel xor (op ^ src ^ dst). | 13 /** SkPixelXorXfermode implements a simple pixel xor (op ^ src ^ dst). |
| 14 This transformation does not follow premultiplied conventions, therefore | 14 This transformation does not follow premultiplied conventions, therefore |
| 15 this proc *always* returns an opaque color (alpha == 255). Thus it is | 15 this proc *always* returns an opaque color (alpha == 255). Thus it is |
| 16 not really usefull for operating on blended colors. | 16 not really usefull for operating on blended colors. |
| 17 */ | 17 */ |
| 18 class SK_API SkPixelXorXfermode : public SkXfermode { | 18 class SK_API SkPixelXorXfermode : public SkXfermode { |
| 19 public: | 19 public: |
| 20 static sk_sp<SkXfermode> Make(SkColor opColor) { |
| 21 return sk_sp<SkXfermode>(new SkPixelXorXfermode(opColor)); |
| 22 } |
| 23 #ifdef SK_SUPPORT_LEGACY_XFERMODE_PTR |
| 20 static SkXfermode* Create(SkColor opColor) { | 24 static SkXfermode* Create(SkColor opColor) { |
| 21 return new SkPixelXorXfermode(opColor); | 25 return Make(opColor).release(); |
| 22 } | 26 } |
| 27 #endif |
| 23 | 28 |
| 24 #if SK_SUPPORT_GPU | 29 #if SK_SUPPORT_GPU |
| 25 const GrFragmentProcessor* getFragmentProcessorForImageFilter( | 30 const GrFragmentProcessor* getFragmentProcessorForImageFilter( |
| 26 const GrFragmentProcessor* d
st) const override; | 31 const GrFragmentProcessor* d
st) const override; |
| 27 GrXPFactory* asXPFactory() const override; | 32 GrXPFactory* asXPFactory() const override; |
| 28 #endif | 33 #endif |
| 29 | 34 |
| 30 SK_TO_STRING_OVERRIDE() | 35 SK_TO_STRING_OVERRIDE() |
| 31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPixelXorXfermode) | 36 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPixelXorXfermode) |
| 32 | 37 |
| 33 protected: | 38 protected: |
| 34 void flatten(SkWriteBuffer&) const override; | 39 void flatten(SkWriteBuffer&) const override; |
| 35 SkPMColor xferColor(SkPMColor src, SkPMColor dst) const override; | 40 SkPMColor xferColor(SkPMColor src, SkPMColor dst) const override; |
| 36 | 41 |
| 37 private: | 42 private: |
| 38 explicit SkPixelXorXfermode(SkColor opColor) { | 43 explicit SkPixelXorXfermode(SkColor opColor) { |
| 39 fOpColor = SkPreMultiplyColor(opColor | 0xFF000000); | 44 fOpColor = SkPreMultiplyColor(opColor | 0xFF000000); |
| 40 } | 45 } |
| 41 | 46 |
| 42 SkPMColor fOpColor; | 47 SkPMColor fOpColor; |
| 43 | 48 |
| 44 typedef SkXfermode INHERITED; | 49 typedef SkXfermode INHERITED; |
| 45 }; | 50 }; |
| 46 | 51 |
| 47 #endif | 52 #endif |
| OLD | NEW |