#include <SkShadowUtils.h>
|
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) |
|
static bool | GetLocalBounds (const SkMatrix &ctm, const SkPath &path, const SkPoint3 &zPlaneParams, const SkPoint3 &lightPos, SkScalar lightRadius, uint32_t flags, SkRect *bounds) |
|
static void | ComputeTonalColors (SkColor inAmbientColor, SkColor inSpotColor, SkColor *outAmbientColor, SkColor *outSpotColor) |
|
Definition at line 38 of file SkShadowUtils.h.
◆ ComputeTonalColors()
Helper routine to compute color values for one-pass tonal alpha.
- Parameters
-
inAmbientColor | Original ambient color |
inSpotColor | Original spot color |
outAmbientColor | Modified ambient color |
outSpotColor | Modified spot color |
Definition at line 478 of file SkShadowUtils.cpp.
479 {
480
481
482
483
485
486
494
495
496
497
498
499
500
501
502
503
504
505 SkScalar alphaAdjust = (2.6f + (-2.66667f + 1.06667f*origA)*origA)*origA;
506 SkScalar colorAlpha = (3.544762f + (-4.891428f + 2.3466f*luminance)*luminance)*luminance;
507 colorAlpha =
SkTPin(alphaAdjust*colorAlpha, 0.0f, 1.0f);
508
509
510
511
512
513 SkScalar greyscaleAlpha =
SkTPin(origA*(1 - 0.4f*luminance), 0.0f, 1.0f);
514
515
516
517
518
519
520
521
522
523
525 SkScalar tonalAlpha = colorScale + greyscaleAlpha;
526 SkScalar unPremulScale = colorScale / tonalAlpha;
528 unPremulScale*spotR,
529 unPremulScale*spotG,
530 unPremulScale*spotB);
531}
#define SkColorGetR(color)
#define SkColorGetG(color)
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
#define SkColorGetA(color)
#define SkColorGetB(color)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
static float max(float r, float g, float b)
static float min(float r, float g, float b)
◆ DrawShadow()
Draw an offset spot shadow and outlining ambient shadow for the given path using a disc light. The shadow may be cached, depending on the path type and canvas matrix. If the matrix is perspective or the path is volatile, it will not be cached.
- Parameters
-
canvas | The canvas on which to draw the shadows. |
path | The occluder used to generate the shadows. |
zPlaneParams | Values for the plane function which returns the Z offset of the occluder from the canvas based on local x and y values (the current matrix is not applied). |
lightPos | Generally, the 3D position of the light relative to the canvas plane. If kDirectionalLight_ShadowFlag is set, this specifies a vector pointing towards the light. |
lightRadius | Generally, the radius of the disc light. If DirectionalLight_ShadowFlag is set, this specifies the amount of blur when the occluder is at Z offset == 1. The blur will grow linearly as the Z value increases. |
ambientColor | The color of the ambient shadow. |
spotColor | The color of the spot shadow. |
flags | Options controlling opaque occluder optimizations, shadow appearance, and light position. See SkShadowFlags. |
Definition at line 559 of file SkShadowUtils.cpp.
562 {
566 return;
567 }
568
570}
static bool fill_shadow_rec(const SkPath &path, const SkPoint3 &zPlaneParams, const SkPoint3 &lightPos, SkScalar lightRadius, SkColor ambientColor, SkColor spotColor, uint32_t flags, const SkMatrix &ctm, SkDrawShadowRec *rec)
void private_draw_shadow_rec(const SkPath &, const SkDrawShadowRec &)
SkMatrix getTotalMatrix() const
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
◆ GetLocalBounds()
Generate bounding box for shadows relative to path. Includes both the ambient and spot shadow bounds.
- Parameters
-
ctm | Current transformation matrix to device space. |
path | The occluder used to generate the shadows. |
zPlaneParams | Values for the plane function which returns the Z offset of the occluder from the canvas based on local x and y values (the current matrix is not applied). |
lightPos | Generally, the 3D position of the light relative to the canvas plane. If kDirectionalLight_ShadowFlag is set, this specifies a vector pointing towards the light. |
lightRadius | Generally, the radius of the disc light. If DirectionalLight_ShadowFlag is set, this specifies the amount of blur when the occluder is at Z offset == 1. The blur will grow linearly as the Z value increases. |
flags | Options controlling opaque occluder optimizations, shadow appearance, and light position. See SkShadowFlags. |
bounds | Return value for shadow bounding box. |
- Returns
- Returns true if successful, false otherwise.
Definition at line 572 of file SkShadowUtils.cpp.
574 {
578 return false;
579 }
580
582
583 return true;
584}
constexpr SkColor SK_ColorBLACK
void GetLocalBounds(const SkPath &path, const SkDrawShadowRec &rec, const SkMatrix &ctm, SkRect *bounds)
Optional< SkRect > bounds
The documentation for this class was generated from the following files: