Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SpiralRT Class Reference
Inheritance diagram for SpiralRT:
RuntimeShaderGM skiagm::GM

Public Member Functions

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

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 DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
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 193 of file runtimeshader.cpp.

Constructor & Destructor Documentation

◆ SpiralRT()

SpiralRT::SpiralRT ( )
inline

Definition at line 195 of file runtimeshader.cpp.

195 : RuntimeShaderGM("spiral_rt", {512, 512}, R"(
196 uniform float rad_scale;
197 uniform float2 in_center;
198 layout(color) uniform float4 in_colors0;
199 layout(color) uniform float4 in_colors1;
200
201 half4 main(float2 p) {
202 float2 pp = p - in_center;
203 float radius = length(pp);
204 radius = sqrt(radius);
205 float angle = atan(pp.y / pp.x);
206 float t = (angle + 3.1415926/2) / (3.1415926);
207 t += radius * rad_scale;
208 t = fract(t);
209 return in_colors0 * (1-t) + in_colors1 * t;
210 }
@ kAnimate_RTFlag
@ kBench_RTFlag

Member Function Documentation

◆ onDraw()

void SpiralRT::onDraw ( SkCanvas canvas)
inlineoverridevirtual

Reimplemented from skiagm::GM.

Definition at line 213 of file runtimeshader.cpp.

213 {
215
216 builder.uniform("rad_scale") = std::sin(fSecs * 0.5f + 2.0f) / 5;
217 builder.uniform("in_center") = SkV2{256, 256};
218 builder.uniform("in_colors0") = SkColors::kRed;
219 builder.uniform("in_colors1") = SkColors::kGreen;
220
222 paint.setShader(builder.makeShader());
223 canvas->drawRect({0, 0, 512, 512}, paint);
224 }
sk_sp< SkRuntimeEffect > fEffect
void drawRect(const SkRect &rect, const SkPaint &paint)
const Paint & paint
constexpr SkColor4f kGreen
Definition SkColor.h:441
constexpr SkColor4f kRed
Definition SkColor.h:440
Definition SkM44.h:19

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