37 SkDebugf(
"Unable to load mandrill_512 from resources directory");
45 SkDebugf(
"Unable to load ripple shader from resources directory");
51 SkDebugf(
"Ripple shader failed to compile\n\n%s\n",
error.c_str());
59 fMillis = nanos / (1000. * 1000.);
73 constexpr float ANIM_DURATION = 1500.0f;
74 constexpr float NOISE_ANIMATION_DURATION = 7000.0f;
75 constexpr float MAX_NOISE_PHASE = NOISE_ANIMATION_DURATION / 214.0f;
76 constexpr float PI_ROTATE_RIGHT =
SK_ScalarPI * 0.0078125f;
77 constexpr float PI_ROTATE_LEFT =
SK_ScalarPI * -0.0078125f;
83 builder.uniform(
"in_maxRadius") = 400.0f;
86 builder.uniform(
"in_hasMask") = 1.0f;
88 float phase = this->
sawtoothLerp(0, MAX_NOISE_PHASE, NOISE_ANIMATION_DURATION);
89 builder.uniform(
"in_noisePhase") = phase;
90 builder.uniform(
"in_turbulencePhase") = phase * 1000.0f;
92 const float scale = 1.5f;
94 scale * .5f + (phase * 0.01f * sinf(
scale * .55f))};
96 scale * .2f + (phase * -.0066f * sinf(
scale * .45f))};
98 scale + (phase * -.0066f * sinf(
scale * .35f))};
100 float rotation1 = phase * PI_ROTATE_RIGHT + 1.7f *
SK_ScalarPI;
101 builder.uniform(
"in_tRotation1") =
SkV2{cosf(rotation1), sinf(rotation1)};
103 float rotation2 = phase * PI_ROTATE_LEFT + 2.0f *
SK_ScalarPI;
104 builder.uniform(
"in_tRotation2") =
SkV2{cosf(rotation2), sinf(rotation2)};
106 float rotation3 = phase * PI_ROTATE_RIGHT + 2.75f *
SK_ScalarPI;
107 builder.uniform(
"in_tRotation3") =
SkV2{cosf(rotation3), sinf(rotation3)};
109 builder.uniform(
"in_color") =
SkV4{0.0f, 0.6f, 0.0f, 1.0f};
110 builder.uniform(
"in_sparkleColor") =
SkV4{1.0f, 1.0f, 1.0f, 1.0f};
119 float t = std::fmod(
fMillis, windowMs) / windowMs;
120 return a * (1. - t) +
b * t;
sk_sp< SkData > GetResourceAsData(const char *resource)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
float sawtoothLerp(float a, float b, float windowMs)
bool onAnimate(double nanos) override
SkISize getISize() override
sk_sp< SkRuntimeEffect > fEffect
void onDraw(SkCanvas *canvas) override
SkString getName() const override
sk_sp< SkShader > fMandrill
static constexpr SkISize kSize
void onOnceBeforeDraw() override
void drawRect(const SkRect &rect, const SkPaint &paint)
const void * data() const
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
void setShader(sk_sp< SkShader > shader)
static Result MakeForShader(SkString sksl, const Options &)
const uint8_t uint32_t uint32_t GError ** error
SkSamplingOptions(SkFilterMode::kLinear))
constexpr int32_t width() const
constexpr int32_t height() const
static constexpr SkRect MakeWH(float w, float h)