Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions | Variables
tablecolorfilter.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorFilter.h"
#include "include/core/SkImageFilter.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/SkImageFilters.h"
#include <math.h>
#include <utility>

Go to the source code of this file.

Classes

class  TableColorFilterGM
 
class  ComposeColorFilterGM
 

Functions

static sk_sp< SkShadermake_shader0 (int w, int h)
 
static void make_bm0 (SkBitmap *bm)
 
static sk_sp< SkShadermake_shader1 (int w, int h)
 
static void make_bm1 (SkBitmap *bm)
 
static void make_table0 (uint8_t table[])
 
static void make_table1 (uint8_t table[])
 
static void make_table2 (uint8_t table[])
 
static sk_sp< SkColorFiltermake_null_cf ()
 
static sk_sp< SkColorFiltermake_cf0 ()
 
static sk_sp< SkColorFiltermake_cf1 ()
 
static sk_sp< SkColorFiltermake_cf2 ()
 
static sk_sp< SkColorFiltermake_cf3 ()
 

Variables

const SkColor gColors0 [] = { SK_ColorCYAN, SK_ColorMAGENTA, SK_ColorYELLOW }
 
const SkBlendMode gModes0 []
 
const SkColor gColors1 [] = { 0x80FF0000, 0x8000FF00, 0x800000FF }
 
const SkBlendMode gModes1 []
 

Function Documentation

◆ make_bm0()

static void make_bm0 ( SkBitmap bm)
static

Definition at line 40 of file tablecolorfilter.cpp.

40 {
41 int W = 120;
42 int H = 120;
43 bm->allocN32Pixels(W, H);
45
46 SkCanvas canvas(*bm);
48 paint.setShader(make_shader0(W, H));
49 canvas.drawPaint(paint);
50}
constexpr SkColor SK_ColorTRANSPARENT
Definition SkColor.h:99
#define W
Definition aaa.cpp:17
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition SkBitmap.cpp:232
void eraseColor(SkColor4f) const
Definition SkBitmap.cpp:442
const Paint & paint
Definition SkMD5.cpp:130
static sk_sp< SkShader > make_shader0(int w, int h)

◆ make_bm1()

static void make_bm1 ( SkBitmap bm)
static

Definition at line 60 of file tablecolorfilter.cpp.

60 {
61 int W = 120;
62 int H = 120;
63 SkScalar cx = SkIntToScalar(W)/2;
64 SkScalar cy = SkIntToScalar(H)/2;
65 bm->allocN32Pixels(W, H);
67
68 SkCanvas canvas(*bm);
70 paint.setShader(make_shader1(W, H));
71 paint.setAntiAlias(true);
72 canvas.drawCircle(cx, cy, cx, paint);
73}
#define SkIntToScalar(x)
Definition SkScalar.h:57
float SkScalar
Definition extension.cpp:12
static sk_sp< SkShader > make_shader1(int w, int h)

◆ make_cf0()

static sk_sp< SkColorFilter > make_cf0 ( )
static

Definition at line 97 of file tablecolorfilter.cpp.

97 {
98 uint8_t table[256]; make_table0(table);
100}
SI F table(const skcms_Curve *curve, F v)
static sk_sp< SkColorFilter > Table(const uint8_t table[256])
static void make_table0(uint8_t table[])

◆ make_cf1()

static sk_sp< SkColorFilter > make_cf1 ( )
static

Definition at line 101 of file tablecolorfilter.cpp.

101 {
102 uint8_t table[256]; make_table1(table);
104}
static void make_table1(uint8_t table[])

◆ make_cf2()

static sk_sp< SkColorFilter > make_cf2 ( )
static

Definition at line 105 of file tablecolorfilter.cpp.

105 {
106 uint8_t table[256]; make_table2(table);
108}
static void make_table2(uint8_t table[])

◆ make_cf3()

static sk_sp< SkColorFilter > make_cf3 ( )
static

Definition at line 109 of file tablecolorfilter.cpp.

109 {
110 uint8_t table0[256]; make_table0(table0);
111 uint8_t table1[256]; make_table1(table1);
112 uint8_t table2[256]; make_table2(table2);
113 return SkColorFilters::TableARGB(nullptr, table0, table1, table2);
114}
static sk_sp< SkColorFilter > TableARGB(const uint8_t tableA[256], const uint8_t tableR[256], const uint8_t tableG[256], const uint8_t tableB[256])

◆ make_null_cf()

static sk_sp< SkColorFilter > make_null_cf ( )
static

Definition at line 93 of file tablecolorfilter.cpp.

93 {
94 return nullptr;
95}

◆ make_shader0()

static sk_sp< SkShader > make_shader0 ( int  w,
int  h 
)
static

Definition at line 31 of file tablecolorfilter.cpp.

31 {
32 SkPoint pts[] = { {0, 0}, {SkIntToScalar(w), SkIntToScalar(h)} };
33 SkColor colors[] = {
36 };
37 return SkGradientShader::MakeLinear(pts, colors, nullptr, std::size(colors),
39}
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorCYAN
Definition SkColor.h:143
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
PODArray< SkColor > colors
Definition SkRecords.h:276
SkScalar w
SkScalar h

◆ make_shader1()

static sk_sp< SkShader > make_shader1 ( int  w,
int  h 
)
static

Definition at line 51 of file tablecolorfilter.cpp.

51 {
52 SkScalar cx = SkIntToScalar(w)/2;
53 SkScalar cy = SkIntToScalar(h)/2;
54 SkColor colors[] = {
56 };
57 return SkGradientShader::MakeRadial(SkPoint::Make(cx, cy), cx, colors, nullptr,
58 std::size(colors), SkTileMode::kClamp);
59}
static sk_sp< SkShader > MakeRadial(const SkPoint &center, SkScalar radius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
static constexpr SkPoint Make(float x, float y)

◆ make_table0()

static void make_table0 ( uint8_t  table[])
static

Definition at line 75 of file tablecolorfilter.cpp.

75 {
76 for (int i = 0; i < 256; ++i) {
77 int n = i >> 5;
78 table[i] = (n << 5) | (n << 2) | (n >> 1);
79 }
80}

◆ make_table1()

static void make_table1 ( uint8_t  table[])
static

Definition at line 81 of file tablecolorfilter.cpp.

81 {
82 for (int i = 0; i < 256; ++i) {
83 table[i] = i * i / 255;
84 }
85}

◆ make_table2()

static void make_table2 ( uint8_t  table[])
static

Definition at line 86 of file tablecolorfilter.cpp.

86 {
87 for (int i = 0; i < 256; ++i) {
88 float fi = i / 255.0f;
89 table[i] = static_cast<uint8_t>(sqrtf(fi) * 255);
90 }
91}

Variable Documentation

◆ gColors0

Definition at line 281 of file tablecolorfilter.cpp.

constexpr SkColor SK_ColorYELLOW
Definition SkColor.h:139
constexpr SkColor SK_ColorMAGENTA
Definition SkColor.h:147

◆ gColors1

const SkColor gColors1[] = { 0x80FF0000, 0x8000FF00, 0x800000FF }

Definition at line 290 of file tablecolorfilter.cpp.

290{ 0x80FF0000, 0x8000FF00, 0x800000FF };

◆ gModes0

const SkBlendMode gModes0[]
Initial value:
= {
}
@ kExclusion
rc = s + d - two(s*d), ra = kSrcOver
@ kColorBurn
darken destination to reflect source
@ kOverlay
multiply or screen, depending on destination
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver

Definition at line 282 of file tablecolorfilter.cpp.

◆ gModes1

const SkBlendMode gModes1[]
Initial value:
= {
}
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstOut
r = d * (1-sa)

Definition at line 291 of file tablecolorfilter.cpp.