diff options
Diffstat (limited to 'libs/hwui/DamageAccumulator.cpp')
-rw-r--r-- | libs/hwui/DamageAccumulator.cpp | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/libs/hwui/DamageAccumulator.cpp b/libs/hwui/DamageAccumulator.cpp index 0bf948006ea0..94fe243378b1 100644 --- a/libs/hwui/DamageAccumulator.cpp +++ b/libs/hwui/DamageAccumulator.cpp @@ -197,6 +197,27 @@ static void applyTransforms(DirtyStack* frame, DirtyStack* end) { } } +static void computeTransformImpl(const DirtyStack* frame, const DirtyStack* end, + Matrix4* outMatrix) { + while (frame != end) { + switch (frame->type) { + case TransformRenderNode: + frame->renderNode->applyViewPropertyTransforms(*outMatrix); + break; + case TransformMatrix4: + outMatrix->multiply(*frame->matrix4); + break; + case TransformNone: + // nothing to be done + break; + default: + LOG_ALWAYS_FATAL("Tried to compute transform with an invalid type: %d", + frame->type); + } + frame = frame->prev; + } +} + void DamageAccumulator::applyRenderNodeTransform(DirtyStack* frame) { if (frame->pendingDirty.isEmpty()) { return; @@ -249,19 +270,38 @@ void DamageAccumulator::finish(SkRect* totalDirty) { mHead->pendingDirty.setEmpty(); } -const StretchEffect* DamageAccumulator::findNearestStretchEffect() const { +DamageAccumulator::StretchResult DamageAccumulator::findNearestStretchEffect() const { DirtyStack* frame = mHead; while (frame->prev != frame) { - frame = frame->prev; if (frame->type == TransformRenderNode) { + const auto& renderNode = frame->renderNode; + const auto& frameRenderNodeProperties = renderNode->properties(); const auto& effect = - frame->renderNode->properties().layerProperties().getStretchEffect(); + frameRenderNodeProperties.layerProperties().getStretchEffect(); + const float width = (float) renderNode->getWidth(); + const float height = (float) renderNode->getHeight(); if (!effect.isEmpty()) { - return &effect; + Matrix4 stretchMatrix; + computeTransformImpl(mHead, frame, &stretchMatrix); + Rect stretchRect = Rect(0.f, 0.f, width, height); + stretchMatrix.mapRect(stretchRect); + + return StretchResult{ + .stretchEffect = &effect, + .childRelativeBounds = SkRect::MakeLTRB( + stretchRect.left, + stretchRect.top, + stretchRect.right, + stretchRect.bottom + ), + .width = width, + .height = height + }; } } + frame = frame->prev; } - return nullptr; + return StretchResult{}; } } /* namespace uirenderer */ |