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

Public Member Functions

 UnsharpRT ()
 
void onOnceBeforeDraw () override
 
void onDraw (SkCanvas *canvas) override
 
- Public Member Functions inherited from RuntimeShaderGM
 RuntimeShaderGM (const char *name, SkISize size, const char *sksl, uint32_t flags=0)
 
void onOnceBeforeDraw () override
 
bool runAsBench () const override
 
SkString getName () const override
 
SkISize getISize () override
 
bool onAnimate (double nanos) override
 
- 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
 

Public Attributes

sk_sp< SkImagefMandrill
 

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 []
 
- 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 inherited from RuntimeShaderGM
SkString fName
 
SkISize fSize
 
uint32_t fFlags
 
float fSecs = 0.0f
 
SkString fSkSL
 
sk_sp< SkRuntimeEffectfEffect
 

Detailed Description

Definition at line 232 of file runtimeshader.cpp.

Constructor & Destructor Documentation

◆ UnsharpRT()

UnsharpRT::UnsharpRT ( )
inline

Definition at line 234 of file runtimeshader.cpp.

234 : RuntimeShaderGM("unsharp_rt", {512, 256}, R"(
235 uniform shader child;
236 half4 main(float2 xy) {
237 half4 c = child.eval(xy) * 5;
238 c -= child.eval(xy + float2( 1, 0));
239 c -= child.eval(xy + float2(-1, 0));
240 c -= child.eval(xy + float2( 0, 1));
241 c -= child.eval(xy + float2( 0, -1));
242 return c;
243 }
244 )") {}
RuntimeShaderGM(const char *name, SkISize size, const char *sksl, uint32_t flags=0)

Member Function Documentation

◆ onDraw()

void UnsharpRT::onDraw ( SkCanvas canvas)
inlineoverridevirtual

Reimplemented from skiagm::GM.

Definition at line 253 of file runtimeshader.cpp.

253 {
254 // First we draw the unmodified image
255 canvas->drawImage(fMandrill, 0, 0);
256
257 // Now draw the image with our unsharp mask applied
260 builder.child("child") = fMandrill->makeShader(sampling);
261
263 paint.setShader(builder.makeShader());
264 canvas->translate(256, 0);
265 canvas->drawRect({ 0, 0, 256, 256 }, paint);
266 }
sk_sp< SkRuntimeEffect > fEffect
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkImage.cpp:179
sk_sp< SkImage > fMandrill
const Paint & paint
Definition: color_source.cc:38
SkSamplingOptions sampling
Definition: SkRecords.h:337

◆ onOnceBeforeDraw()

void UnsharpRT::onOnceBeforeDraw ( )
inlineoverridevirtual

Reimplemented from RuntimeShaderGM.

Definition at line 248 of file runtimeshader.cpp.

248 {
249 fMandrill = ToolUtils::GetResourceAsImage("images/mandrill_256.png");
251 }
void onOnceBeforeDraw() override
sk_sp< SkImage > GetResourceAsImage(const char *resource)
Definition: DecodeUtils.h:25

Member Data Documentation

◆ fMandrill

sk_sp<SkImage> UnsharpRT::fMandrill

Definition at line 246 of file runtimeshader.cpp.


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