diff options
author | John Reck <jreck@google.com> | 2021-05-10 13:09:27 -0400 |
---|---|---|
committer | Nader Jawad <njawad@google.com> | 2021-05-10 11:33:20 -0700 |
commit | 8ed00dc56d5af7483ed053eb88c550cc1035b029 (patch) | |
tree | c940d7202f886357ce4e63a0d6be528b8097a426 /libs/hwui/pipeline/skia/RenderNodeDrawable.cpp | |
parent | bc341860f042edb649055042c955cb9e38fd65a6 (diff) |
Add a linear variant of the stretch effect
Supports SurfaceViews & everything
Test: setprop debug.hwui.stretch_mode 1
Bug: 187718492
Change-Id: I9a222fa4c1a40e80a74cdaf75becb9524cbeed9b
Diffstat (limited to 'libs/hwui/pipeline/skia/RenderNodeDrawable.cpp')
-rw-r--r-- | libs/hwui/pipeline/skia/RenderNodeDrawable.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp index 1ae06d082744..509884e23c26 100644 --- a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp +++ b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp @@ -171,11 +171,16 @@ void RenderNodeDrawable::forceDraw(SkCanvas* canvas) const { displayList->mProjectedOutline = nullptr; } +static bool stretchNeedsLayer(const LayerProperties& properties) { + return Properties::stretchEffectBehavior == StretchEffectBehavior::Shader && + !properties.getStretchEffect().isEmpty(); +} + static bool layerNeedsPaint(const sk_sp<SkImage>& snapshotImage, const LayerProperties& properties, float alphaMultiplier, SkPaint* paint) { if (alphaMultiplier < 1.0f || properties.alpha() < 255 || properties.xferMode() != SkBlendMode::kSrcOver || properties.getColorFilter() != nullptr || - properties.getImageFilter() != nullptr || !properties.getStretchEffect().isEmpty()) { + properties.getImageFilter() != nullptr || stretchNeedsLayer(properties)) { paint->setAlpha(properties.alpha() * alphaMultiplier); paint->setBlendMode(properties.xferMode()); paint->setColorFilter(sk_ref_sp(properties.getColorFilter())); @@ -247,7 +252,8 @@ void RenderNodeDrawable::drawContent(SkCanvas* canvas) const { } const StretchEffect& stretch = properties.layerProperties().getStretchEffect(); - if (stretch.isEmpty()) { + if (stretch.isEmpty() || + Properties::stretchEffectBehavior != StretchEffectBehavior::Shader) { // If we don't have any stretch effects, issue the filtered // canvas draw calls to make sure we still punch a hole // with the same canvas transformation + clip into the target @@ -326,6 +332,13 @@ void RenderNodeDrawable::setViewProperties(const RenderProperties& properties, S canvas->concat(*properties.getTransformMatrix()); } } + if (Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale) { + const StretchEffect& stretch = properties.layerProperties().getStretchEffect(); + if (!stretch.isEmpty()) { + canvas->concat( + stretch.makeLinearStretch(properties.getWidth(), properties.getHeight())); + } + } const bool isLayer = properties.effectiveLayerType() != LayerType::None; int clipFlags = properties.getClippingFlags(); if (properties.getAlpha() < 1) { |