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

Public Member Functions

 RuntimeColorFilterGM ()=default
 
- 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
 

Protected Attributes

sk_sp< SkImagefImg
 

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 89 of file runtimecolorfilter.cpp.

Constructor & Destructor Documentation

◆ RuntimeColorFilterGM()

RuntimeColorFilterGM::RuntimeColorFilterGM ( )
default

Member Function Documentation

◆ getISize()

SkISize RuntimeColorFilterGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 96 of file runtimecolorfilter.cpp.

96{ return SkISize::Make(256 * 3, 256 * 2); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString RuntimeColorFilterGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 94 of file runtimecolorfilter.cpp.

94{ return SkString("runtimecolorfilter"); }

◆ onDraw()

void RuntimeColorFilterGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 102 of file runtimecolorfilter.cpp.

102 {
103 auto draw_filter = [&](const char* src) {
104 auto [effect, err] = SkRuntimeEffect::MakeForColorFilter(SkString(src));
105 if (!effect) {
106 SkDebugf("%s\n%s\n", src, err.c_str());
107 }
108 SkASSERT(effect);
109 SkPaint p;
110 p.setColorFilter(effect->makeColorFilter(nullptr));
111 canvas->drawImage(fImg, 0, 0, SkSamplingOptions(), &p);
112 canvas->translate(256, 0);
113 };
114
115 for (const char* src : {gNoop, gLumaSrc}) {
116 draw_filter(src);
117 }
118 canvas->translate(-256*2, 256);
119 for (const char* src : {gTernary, gIfs, gEarlyReturn}) {
120 draw_filter(src);
121 }
122 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static Result MakeForColorFilter(SkString sksl, const Options &)
SkSamplingOptions(SkFilterMode::kLinear))
const char * gTernary
const char * gNoop
const char * gLumaSrc
const char * gIfs
const char * gEarlyReturn

◆ onOnceBeforeDraw()

void RuntimeColorFilterGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 98 of file runtimecolorfilter.cpp.

98 {
99 fImg = ToolUtils::GetResourceAsImage("images/mandrill_256.png");
100 }
sk_sp< SkImage > GetResourceAsImage(const char *resource)
Definition: DecodeUtils.h:25

Member Data Documentation

◆ fImg

sk_sp<SkImage> RuntimeColorFilterGM::fImg
protected

Definition at line 124 of file runtimecolorfilter.cpp.


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