2011-12-10 19:36:56 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkArithmeticMode_DEFINED
|
|
|
|
#define SkArithmeticMode_DEFINED
|
|
|
|
|
2013-10-23 17:06:21 +00:00
|
|
|
#include "SkFlattenable.h"
|
|
|
|
#include "SkScalar.h"
|
2016-03-29 18:32:50 +00:00
|
|
|
#include "SkXfermode.h"
|
2013-10-23 17:06:21 +00:00
|
|
|
|
|
|
|
class SK_API SkArithmeticMode {
|
2011-12-10 19:36:56 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* result = clamp[k1 * src * dst + k2 * src + k3 * dst + k4]
|
|
|
|
*
|
|
|
|
* k1=k2=k3=0, k4=1.0 results in returning opaque white
|
|
|
|
* k1=k3=k4=0, k2=1.0 results in returning the src
|
|
|
|
* k1=k2=k4=0, k3=1.0 results in returning the dst
|
|
|
|
*/
|
2016-03-29 18:32:50 +00:00
|
|
|
static sk_sp<SkXfermode> Make(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4,
|
|
|
|
bool enforcePMColor = true);
|
|
|
|
#ifdef SK_SUPPORT_LEGACY_XFERMODE_PTR
|
2011-12-10 19:36:56 +00:00
|
|
|
static SkXfermode* Create(SkScalar k1, SkScalar k2,
|
2014-04-02 19:32:15 +00:00
|
|
|
SkScalar k3, SkScalar k4,
|
2016-03-29 18:32:50 +00:00
|
|
|
bool enforcePMColor = true) {
|
|
|
|
return Make(k1, k2, k3, k4, enforcePMColor).release();
|
|
|
|
}
|
|
|
|
#endif
|
2013-01-22 14:32:09 +00:00
|
|
|
|
2013-05-29 20:55:09 +00:00
|
|
|
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP();
|
|
|
|
|
2013-01-22 14:32:09 +00:00
|
|
|
private:
|
2013-10-23 17:06:21 +00:00
|
|
|
SkArithmeticMode(); // can't be instantiated
|
2011-12-10 19:36:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|