Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
ColorMatrixGM Class Reference
Inheritance diagram for ColorMatrixGM:
skiagm::GM

Public Member Functions

 ColorMatrixGM ()
 
- Public Member Functions inherited from skiagm::GM
 GM (SkColor backgroundColor=SK_ColorWHITE)
 
virtual ~GM ()
 
void setMode (Mode mode)
 
Mode getMode () const
 
DrawResult gpuSetup (SkCanvas *, SkString *errorMsg, GraphiteTestContext *=nullptr)
 
void gpuTeardown ()
 
void onceBeforeDraw ()
 
DrawResult draw (SkCanvas *canvas)
 
DrawResult draw (SkCanvas *, SkString *errorMsg)
 
void drawBackground (SkCanvas *)
 
DrawResult drawContent (SkCanvas *canvas)
 
DrawResult drawContent (SkCanvas *, SkString *errorMsg)
 
virtual SkISize getISize ()=0
 
virtual SkString getName () const =0
 
virtual bool runAsBench () const
 
SkScalar width ()
 
SkScalar height ()
 
SkColor getBGColor () const
 
void setBGColor (SkColor)
 
void drawSizeBounds (SkCanvas *, SkColor)
 
bool animate (double)
 
virtual bool onChar (SkUnichar)
 
bool getControls (SkMetaData *controls)
 
void setControls (const SkMetaData &controls)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual void modifyGraphiteContextOptions (skgpu::graphite::ContextOptions *) const
 
virtual bool isBazelOnly () const
 
virtual std::map< std::string, std::string > getGoldKeys () const
 

Protected Member Functions

SkString getName () const override
 
SkISize getISize () override
 
void onOnceBeforeDraw () override
 
void onDraw (SkCanvas *canvas) override
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual void onOnceBeforeDraw ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
virtual void onDraw (SkCanvas *)
 
virtual bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Static Protected Member Functions

static sk_sp< SkImageCreateSolidBitmap (int width, int height)
 
static sk_sp< SkImageCreateTransparentBitmap (int width, int height)
 

Additional Inherited Members

- Public Types inherited from skiagm::GM
enum  Mode { kGM_Mode , kSample_Mode , kBench_Mode }
 
using DrawResult = skiagm::DrawResult
 
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 39 of file colormatrix.cpp.

Constructor & Destructor Documentation

◆ ColorMatrixGM()

ColorMatrixGM::ColorMatrixGM ( )
inline

Definition at line 41 of file colormatrix.cpp.

41 {
42 this->setBGColor(0xFF808080);
43 }
void setBGColor(SkColor)
Definition: gm.cpp:159

Member Function Documentation

◆ CreateSolidBitmap()

static sk_sp< SkImage > ColorMatrixGM::CreateSolidBitmap ( int  width,
int  height 
)
inlinestaticprotected

Definition at line 55 of file colormatrix.cpp.

55 {
56 SkBitmap bm;
58 SkCanvas canvas(bm);
59 canvas.clear(0x0);
60 for (int y = 0; y < height; ++y) {
61 for (int x = 0; x < width; ++x) {
63 paint.setColor(SkColorSetARGB(255, x * 255 / width, y * 255 / height, 0));
64 canvas.drawRect(SkRect::MakeXYWH(SkIntToScalar(x),
66 }
67 }
68 return bm.asImage();
69 }
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColor.h:49
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkIntToScalar(x)
Definition: SkScalar.h:57
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition: SkBitmap.cpp:232
SkScalar width()
Definition: gm.h:159
SkScalar height()
Definition: gm.h:162
const Paint & paint
Definition: color_source.cc:38
double y
double x
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ CreateTransparentBitmap()

static sk_sp< SkImage > ColorMatrixGM::CreateTransparentBitmap ( int  width,
int  height 
)
inlinestaticprotected

Definition at line 72 of file colormatrix.cpp.

72 {
73 SkBitmap bm;
75 SkCanvas canvas(bm);
76 canvas.clear(0x0);
77
78 SkPoint pts[] = {{0, 0}, {SkIntToScalar(width), SkIntToScalar(height)}};
79 SkColor colors[] = {0x00000000, 0xFFFFFFFF};
81 paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2,
84 return bm.asImage();
85 }
uint32_t SkColor
Definition: SkColor.h:37
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
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ getISize()

SkISize ColorMatrixGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 48 of file colormatrix.cpp.

48{ return SkISize::Make(WIDTH, HEIGHT); }
#define WIDTH
Definition: colormatrix.cpp:28
#define HEIGHT
Definition: colormatrix.cpp:29
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString ColorMatrixGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 46 of file colormatrix.cpp.

46{ return SkString("colormatrix"); }

◆ onDraw()

void ColorMatrixGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 87 of file colormatrix.cpp.

87 {
90
91 paint.setBlendMode(SkBlendMode::kSrc);
92 const SkImage* bmps[] = { fSolidImg.get(), fTransparentImg.get() };
93
94 for (size_t i = 0; i < std::size(bmps); ++i) {
95 matrix.setIdentity();
97 canvas->drawImage(bmps[i], 0, 0, SkSamplingOptions(), &paint);
98
99 ///////////////////////////////////////////////
100
101 matrix.setSaturation(0.0f);
103 canvas->drawImage(bmps[i], 80, 0, SkSamplingOptions(), &paint);
104
105 matrix.setSaturation(0.5f);
107 canvas->drawImage(bmps[i], 160, 0, SkSamplingOptions(), &paint);
108
109 matrix.setSaturation(1.0f);
111 canvas->drawImage(bmps[i], 240, 0, SkSamplingOptions(), &paint);
112
113 matrix.setSaturation(2.0f);
115 canvas->drawImage(bmps[i], 320, 0, SkSamplingOptions(), &paint);
116
117 ///////////////////////////////////////////////
118
119 // Move red into alpha, set color to white
120 float data[20] = {
121 0, 0, 0, 0, 1,
122 0, 0, 0, 0, 1,
123 0, 0, 0, 0, 1,
124 1, 0, 0, 0, 0,
125 };
126
128 canvas->drawImage(bmps[i], 400, 0, SkSamplingOptions(), &paint);
129 ///////////////////////////////////////////////
130 canvas->translate(0, 80);
131 }
132 }
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
T * get() const
Definition: SkRefCnt.h:303
static void set_array(SkPaint *paint, const float array[])
Definition: colormatrix.cpp:35
static void set_color_matrix(SkPaint *paint, const SkColorMatrix &matrix)
Definition: colormatrix.cpp:31
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SkSamplingOptions(SkFilterMode::kLinear))
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ onOnceBeforeDraw()

void ColorMatrixGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 50 of file colormatrix.cpp.

50 {
51 fSolidImg = CreateSolidBitmap(64, 64);
52 fTransparentImg = CreateTransparentBitmap(64, 64);
53 }
static sk_sp< SkImage > CreateSolidBitmap(int width, int height)
Definition: colormatrix.cpp:55
static sk_sp< SkImage > CreateTransparentBitmap(int width, int height)
Definition: colormatrix.cpp:72

The documentation for this class was generated from the following file: