Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
MaterialShadowsSlide Class Reference
Inheritance diagram for MaterialShadowsSlide:
Slide SkRefCnt SkRefCntBase

Public Member Functions

 MaterialShadowsSlide ()
 
void load (SkScalar w, SkScalar h) override
 
void drawShadowedPath (SkCanvas *canvas, const SkPath &path, const SkPoint3 &zPlaneParams, const SkPaint &paint, SkScalar ambientAlpha, const SkPoint3 &lightPos, SkScalar lightRadius, SkScalar spotAlpha)
 
void draw (SkCanvas *canvas) override
 
- Public Member Functions inherited from Slide
virtual SkISize getDimensions () const
 
virtual void gpuTeardown ()
 
virtual void draw (SkCanvas *canvas)=0
 
virtual bool animate (double nanos)
 
virtual void load (SkScalar winWidth, SkScalar winHeight)
 
virtual void resize (SkScalar winWidth, SkScalar winHeight)
 
virtual void unload ()
 
virtual bool onChar (SkUnichar c)
 
virtual bool onMouse (SkScalar x, SkScalar y, skui::InputState state, skui::ModifierKey modifiers)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
const SkStringgetName ()
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Additional Inherited Members

- Protected Attributes inherited from Slide
SkString fName
 

Detailed Description

Definition at line 23 of file MaterialShadowsSlide.cpp.

Constructor & Destructor Documentation

◆ MaterialShadowsSlide()

MaterialShadowsSlide::MaterialShadowsSlide ( )
inline

Definition at line 32 of file MaterialShadowsSlide.cpp.

32{ fName = "MaterialShadows"; }
SkString fName
Definition: Slide.h:54

Member Function Documentation

◆ draw()

void MaterialShadowsSlide::draw ( SkCanvas canvas)
inlineoverridevirtual

Implements Slide.

Definition at line 58 of file MaterialShadowsSlide.cpp.

58 {
59 canvas->drawColor(0xFFFFFFFF);
60
61 const SkScalar kLightRadius = 1.1f;
62 const SkScalar kAmbientAlpha = 0.05f;
63 const SkScalar kSpotAlpha = 0.35f;
64
65 const SkScalar elevations[] = { 1, 3, 6, 8, 12, 24 };
66
68 paint.setAntiAlias(true);
69
70 SkPoint3 lightPos = fLightPos;
71 SkPoint3 zPlaneParams = SkPoint3::Make(0, 0, 0);
72
73 paint.setColor(SK_ColorWHITE);
74 canvas->save();
75 canvas->translate(80, 80);
76 for (unsigned int i = 0; i < std::size(elevations); ++i) {
77 zPlaneParams.fZ = elevations[i];
78 this->drawShadowedPath(canvas, fCirclePath, zPlaneParams, paint, kAmbientAlpha,
79 lightPos, kLightRadius, kSpotAlpha);
80 canvas->translate(80, 0);
81 }
82 canvas->restore();
83
84 canvas->save();
85 canvas->translate(120, 175);
86 for (unsigned int i = 0; i < std::size(elevations); ++i) {
87 zPlaneParams.fZ = elevations[i];
88 this->drawShadowedPath(canvas, fCapsulePath, zPlaneParams, paint, kAmbientAlpha,
89 lightPos, kLightRadius, kSpotAlpha);
90 canvas->translate(160, 0);
91 }
92 canvas->restore();
93
94 canvas->save();
95 canvas->translate(120, 320);
96 for (unsigned int i = 0; i < std::size(elevations); ++i) {
97 zPlaneParams.fZ = elevations[i];
98 this->drawShadowedPath(canvas, fLargeRRPath, zPlaneParams, paint, kAmbientAlpha,
99 lightPos, kLightRadius, kSpotAlpha);
100 canvas->translate(160, 0);
101 }
102 canvas->restore();
103
104 canvas->save();
105 canvas->translate(100, 475);
106 for (unsigned int i = 0; i < std::size(elevations); ++i) {
107 zPlaneParams.fZ = elevations[i];
108 this->drawShadowedPath(canvas, fSmallRRPath, zPlaneParams, paint, kAmbientAlpha,
109 lightPos, kLightRadius, kSpotAlpha);
110 canvas->translate(160, 0);
111 }
112 canvas->restore();
113
114 canvas->save();
115 canvas->translate(100, 600);
116 for (unsigned int i = 0; i < std::size(elevations); ++i) {
117 canvas->save();
118 zPlaneParams.fZ = elevations[i];
119 canvas->rotate(10);
120 this->drawShadowedPath(canvas, fSmallRRPath, zPlaneParams, paint, kAmbientAlpha,
121 lightPos, kLightRadius, kSpotAlpha);
122 canvas->restore();
123 canvas->translate(160, 0);
124 }
125 canvas->restore();
126
127 canvas->save();
128 canvas->translate(100, 725);
129 for (unsigned int i = 0; i < std::size(elevations); ++i) {
130 canvas->save();
131 zPlaneParams.fZ = elevations[i];
132 canvas->rotate(45);
133 this->drawShadowedPath(canvas, fSmallRRPath, zPlaneParams, paint, kAmbientAlpha,
134 lightPos, kLightRadius, kSpotAlpha);
135 canvas->restore();
136 canvas->translate(160, 0);
137 }
138 canvas->restore();
139
140 }
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
void drawShadowedPath(SkCanvas *canvas, const SkPath &path, const SkPoint3 &zPlaneParams, const SkPaint &paint, SkScalar ambientAlpha, const SkPoint3 &lightPos, SkScalar lightRadius, SkScalar spotAlpha)
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
void rotate(SkScalar degrees)
Definition: SkCanvas.cpp:1300
int save()
Definition: SkCanvas.cpp:447
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
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 SkPoint3 Make(SkScalar x, SkScalar y, SkScalar z)
Definition: SkPoint3.h:18
SkScalar fZ
Definition: SkPoint3.h:16

◆ drawShadowedPath()

void MaterialShadowsSlide::drawShadowedPath ( SkCanvas canvas,
const SkPath path,
const SkPoint3 zPlaneParams,
const SkPaint paint,
SkScalar  ambientAlpha,
const SkPoint3 lightPos,
SkScalar  lightRadius,
SkScalar  spotAlpha 
)
inline

Definition at line 43 of file MaterialShadowsSlide.cpp.

46 {
47 uint32_t flags = 0;
49
50 SkColor ambientColor = SkColorSetARGB(ambientAlpha * 255, 0, 0, 0);
51 SkColor spotColor = SkColorSetARGB(spotAlpha * 255, 0, 0, 0);
52 SkShadowUtils::DrawShadow(canvas, path, zPlaneParams, lightPos, lightRadius,
53 ambientColor, spotColor, flags);
54
55 canvas->drawPath(path, paint);
56 }
uint32_t SkColor
Definition: SkColor.h:37
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColor.h:49
@ kDirectionalLight_ShadowFlag
Definition: SkShadowUtils.h:31
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
static void DrawShadow(SkCanvas *canvas, const SkPath &path, const SkPoint3 &zPlaneParams, const SkPoint3 &lightPos, SkScalar lightRadius, SkColor ambientColor, SkColor spotColor, uint32_t flags=SkShadowFlags::kNone_ShadowFlag)
FlutterSemanticsFlag flags
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57

◆ load()

void MaterialShadowsSlide::load ( SkScalar  w,
SkScalar  h 
)
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 34 of file MaterialShadowsSlide.cpp.

34 {
35 fCirclePath.addCircle(0, 0, 56/2);
36 fCapsulePath.addRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(-64, -24, 128, 48), 24, 24));
37 fLargeRRPath.addRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(-64, -64, 128, 128), 4, 4));
38 fSmallRRPath.addRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(-40, -40, 80, 80), 4, 4));
39
40 fLightPos = SkPoint3::Make(0, -700, 700);
41 }
SkPath & addCircle(SkScalar x, SkScalar y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1213
SkPath & addRRect(const SkRRect &rrect, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1000
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Definition: SkRRect.h:180
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

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