Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
mixercolorfilter.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorFilter.h"
#include "include/core/SkImage.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkShader.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTileMode.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkGradientShader.h"
#include "include/effects/SkLumaColorFilter.h"
#include "tools/Resources.h"
#include <math.h>

Go to the source code of this file.

Functions

static sk_sp< SkColorFilterMakeTintColorFilter (SkColor lo, SkColor hi)
 

Function Documentation

◆ MakeTintColorFilter()

static sk_sp< SkColorFilter > MakeTintColorFilter ( SkColor  lo,
SkColor  hi 
)
static

Definition at line 36 of file mixercolorfilter.cpp.

36 {
37 const auto r_lo = SkColorGetR(lo),
38 g_lo = SkColorGetG(lo),
39 b_lo = SkColorGetB(lo),
40 a_lo = SkColorGetA(lo),
41 r_hi = SkColorGetR(hi),
42 g_hi = SkColorGetG(hi),
43 b_hi = SkColorGetB(hi),
44 a_hi = SkColorGetA(hi);
45
46 // We map component-wise:
47 //
48 // r' = lo.r + (hi.r - lo.r) * luma
49 // g' = lo.g + (hi.g - lo.g) * luma
50 // b' = lo.b + (hi.b - lo.b) * luma
51 // a' = lo.a + (hi.a - lo.a) * luma
52 //
53 // The input luminance is stored in the alpha channel
54 // (and RGB are cleared -- see SkLumaColorFilter). Thus:
55 const float tint_matrix[] = {
56 0, 0, 0, (r_hi - r_lo) / 255.0f, SkIntToScalar(r_lo) / 255.0f,
57 0, 0, 0, (g_hi - g_lo) / 255.0f, SkIntToScalar(g_lo) / 255.0f,
58 0, 0, 0, (b_hi - b_lo) / 255.0f, SkIntToScalar(b_lo) / 255.0f,
59 0, 0, 0, (a_hi - a_lo) / 255.0f, SkIntToScalar(a_lo) / 255.0f,
60 };
61
63}
#define SkColorGetR(color)
Definition SkColor.h:65
#define SkColorGetG(color)
Definition SkColor.h:69
#define SkColorGetA(color)
Definition SkColor.h:61
#define SkColorGetB(color)
Definition SkColor.h:73
#define SkIntToScalar(x)
Definition SkScalar.h:57
sk_sp< SkColorFilter > makeComposed(sk_sp< SkColorFilter > inner) const
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
static sk_sp< SkColorFilter > Make()