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

Public Member Functions

 TableColorFilterGM ()
 
- 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 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
 

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 116 of file tablecolorfilter.cpp.

Constructor & Destructor Documentation

◆ TableColorFilterGM()

TableColorFilterGM::TableColorFilterGM ( )
inline

Definition at line 118 of file tablecolorfilter.cpp.

118{}

Member Function Documentation

◆ getISize()

SkISize TableColorFilterGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 123 of file tablecolorfilter.cpp.

123{ return {700, 1650}; }

◆ getName()

SkString TableColorFilterGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 121 of file tablecolorfilter.cpp.

121{ return SkString("tablecolorfilter"); }

◆ onDraw()

void TableColorFilterGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 125 of file tablecolorfilter.cpp.

125 {
126 canvas->drawColor(0xFFDDDDDD);
127 canvas->translate(20, 20);
128
129 static sk_sp<SkColorFilter> (*gColorFilterMakers[])() = {
131 };
132 static void (*gBitmapMakers[])(SkBitmap*) = { make_bm0, make_bm1 };
133
134 // This test will be done once for each bitmap with the results stacked vertically.
135 // For a single bitmap the resulting image will be the following:
136 // - A first line with the original bitmap, followed by the image drawn once
137 // with each of the N color filters
138 // - N lines of the bitmap drawn N times, this will cover all N*N combinations of
139 // pair of color filters in order to test the collapsing of consecutive table
140 // color filters.
141 //
142 // Here is a graphical representation of the result for 2 bitmaps and 2 filters
143 // with the number corresponding to the number of filters the bitmap goes through:
144 //
145 // --bitmap1
146 // 011
147 // 22
148 // 22
149 // --bitmap2
150 // 011
151 // 22
152 // 22
153
154 SkScalar x = 0, y = 0;
155 for (size_t bitmapMaker = 0; bitmapMaker < std::size(gBitmapMakers); ++bitmapMaker) {
156 SkBitmap bm;
157 gBitmapMakers[bitmapMaker](&bm);
158
159 SkScalar xOffset = SkScalar(bm.width() * 9 / 8);
160 SkScalar yOffset = SkScalar(bm.height() * 9 / 8);
161
162 // Draw the first element of the first line
163 x = 0;
166
167 canvas->drawImage(bm.asImage(), x, y);
168
169 // Draws the rest of the first line for this bitmap
170 // each draw being at xOffset of the previous one
171 for (unsigned i = 1; i < std::size(gColorFilterMakers); ++i) {
172 x += xOffset;
173 paint.setColorFilter(gColorFilterMakers[i]());
174 canvas->drawImage(bm.asImage(), x, y, sampling, &paint);
175 }
176
177 paint.setColorFilter(nullptr);
178
179 for (unsigned i = 0; i < std::size(gColorFilterMakers); ++i) {
180 sk_sp<SkColorFilter> colorFilter1(gColorFilterMakers[i]());
182 std::move(colorFilter1), nullptr));
183
184 // Move down to the next line and draw it
185 // each draw being at xOffset of the previous one
186 y += yOffset;
187 x = 0;
188 for (unsigned j = 1; j < std::size(gColorFilterMakers); ++j) {
189 sk_sp<SkColorFilter> colorFilter2(gColorFilterMakers[j]());
191 std::move(colorFilter2), imageFilter1, nullptr));
192 paint.setImageFilter(std::move(imageFilter2));
193 canvas->drawImage(bm.asImage(), x, y, sampling, &paint);
194 x += xOffset;
195 }
196 }
197
198 // Move down one line to the beginning of the block for next bitmap
199 y += yOffset;
200 }
201 }
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
int width() const
Definition: SkBitmap.h:149
int height() const
Definition: SkBitmap.h:158
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static sk_sp< SkImageFilter > ColorFilter(sk_sp< SkColorFilter > cf, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
double y
double x
SkSamplingOptions sampling
Definition: SkRecords.h:337
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
static sk_sp< SkColorFilter > make_null_cf()
static sk_sp< SkColorFilter > make_cf0()
static void make_bm0(SkBitmap *bm)
static sk_sp< SkColorFilter > make_cf1()
static void make_bm1(SkBitmap *bm)
static sk_sp< SkColorFilter > make_cf3()
static sk_sp< SkColorFilter > make_cf2()

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