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 SkArithmeticModePriv_DEFINED 9 #define SkArithmeticModePriv_DEFINED 10 11 #include "SkScalar.h" 12 #include "SkXfermodePriv.h" 13 14 class SkXfermode; 15 16 struct SkArithmeticParams { 17 float fK[4]; 18 bool fEnforcePMColor; 19 }; 20 21 // This only exists to unflatten instances that were serialized into old pictures as part of 22 // SkXfermodeImageFilter before the advent of SkBlendMode. 23 class SK_API SkArithmeticMode { 24 public: 25 /** 26 * result = clamp[k1 * src * dst + k2 * src + k3 * dst + k4] 27 * 28 * k1=k2=k3=0, k4=1.0 results in returning opaque white 29 * k1=k3=k4=0, k2=1.0 results in returning the src 30 * k1=k2=k4=0, k3=1.0 results in returning the dst 31 */ 32 static sk_sp<SkXfermode> Make(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4, 33 bool enforcePMColor = true); 34 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP(); 35 36 private: 37 SkArithmeticMode(); // can't be instantiated 38 }; 39 40 #endif 41