[skottie] Harden motion blur

1) don't attempt to attach the effect when the layer is null

2) sksg::onRender can receive a null context - handle it gracefully

TBR=

Change-Id: I4fae08b15d448849c7c99b17df6811ad31f190c8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/237276
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
Florin Malita 2019-08-26 19:44:41 -04:00 committed by Skia Commit-Bot
parent 30cd12e814
commit 3c8f9cb45d
3 changed files with 4 additions and 3 deletions

View File

@ -496,7 +496,7 @@ sk_sp<sksg::RenderNode> AnimationBuilder::attachLayer(const skjson::ObjectValue*
layer_info.fOutPoint); layer_info.fOutPoint);
// Optional motion blur. // Optional motion blur.
if (has_animators && layerCtx->hasMotionBlur(*jlayer)) { if (layer && has_animators && layerCtx->hasMotionBlur(*jlayer)) {
SkASSERT(layerCtx->fMotionBlurAngle >= 0); SkASSERT(layerCtx->fMotionBlurAngle >= 0);
// Wrap both the layer node and the controller. // Wrap both the layer node and the controller.

View File

@ -88,7 +88,7 @@ void MotionBlurEffect::onRender(SkCanvas* canvas, const RenderContext* ctx) cons
ScopedRenderContext frame_ctx(canvas, ctx); ScopedRenderContext frame_ctx(canvas, ctx);
SkPaint frame_paint; SkPaint frame_paint;
const auto isolate_frames = ctx->fBlendMode != SkBlendMode::kSrcOver; const auto isolate_frames = frame_ctx->fBlendMode != SkBlendMode::kSrcOver;
if (isolate_frames) { if (isolate_frames) {
frame_paint.setAlphaf(frame_alpha); frame_paint.setAlphaf(frame_alpha);
frame_paint.setBlendMode(SkBlendMode::kPlus); frame_paint.setBlendMode(SkBlendMode::kPlus);

View File

@ -83,7 +83,8 @@ protected:
return *this; return *this;
} }
operator const RenderContext* () const { return &fCtx; } operator const RenderContext* () const { return &fCtx; }
const RenderContext* operator->() const { return &fCtx; }
// Add (cumulative) paint overrides to a render node sub-DAG. // Add (cumulative) paint overrides to a render node sub-DAG.
ScopedRenderContext&& modulateOpacity(float opacity); ScopedRenderContext&& modulateOpacity(float opacity);