diff options
author | Nader Jawad <njawad@google.com> | 2021-04-19 19:45:13 -0700 |
---|---|---|
committer | Nader Jawad <njawad@google.com> | 2021-05-03 18:08:47 -0700 |
commit | 197743ff9c6ffb7bc96004c38b518fd3941948b0 (patch) | |
tree | 833d7f67ff16d4bf478710e0c711fe4ffce06844 /libs/hwui/pipeline/skia/RenderNodeDrawable.cpp | |
parent | 9443a3e84d73d3423ede16e158b641fb320910dd (diff) |
Update hole punch logic in HWUI
--Updated HWUI holepunch logic for SurfaceView to
also apply the stretch to the hole punch
--Updated RenderNode callbacks to also include
an offset from the ancestor RenderNode that also
has a stretch configured on it
--Added new test activity to verify hole punch
logic
Bug: 179047472
Test: manual
Change-Id: Ibbaf8248a31839ba9dc352ecb9fef54e1276918e
Diffstat (limited to 'libs/hwui/pipeline/skia/RenderNodeDrawable.cpp')
-rw-r--r-- | libs/hwui/pipeline/skia/RenderNodeDrawable.cpp | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp index 77d99a67b602..1ae06d082744 100644 --- a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp +++ b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp @@ -16,6 +16,7 @@ #include "RenderNodeDrawable.h" #include <SkPaintFilterCanvas.h> +#include "StretchMask.h" #include "RenderNode.h" #include "SkiaDisplayList.h" #include "TransformCanvas.h" @@ -245,17 +246,37 @@ void RenderNodeDrawable::drawContent(SkCanvas* canvas) const { "SurfaceID|%" PRId64, renderNode->uniqueId()).c_str(), nullptr); } - if (renderNode->hasHolePunches()) { - TransformCanvas transformCanvas(canvas); - displayList->draw(&transformCanvas); - } - const StretchEffect& stretch = properties.layerProperties().getStretchEffect(); if (stretch.isEmpty()) { + // 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 + // canvas then draw the layer on top + if (renderNode->hasHolePunches()) { + TransformCanvas transformCanvas(canvas, SkBlendMode::kClear); + displayList->draw(&transformCanvas); + } canvas->drawImageRect(snapshotImage, bounds, bounds, sampling, &paint, SkCanvas::kStrict_SrcRectConstraint); } else { - sk_sp<SkShader> stretchShader = stretch.getShader(snapshotImage); + // If we do have stretch effects and have hole punches, + // then create a mask and issue the filtered draw calls to + // get the corresponding hole punches. + // Then apply the stretch to the mask and draw the mask to + // the destination + if (renderNode->hasHolePunches()) { + GrRecordingContext* context = canvas->recordingContext(); + StretchMask& stretchMask = renderNode->getStretchMask(); + stretchMask.draw(context, + stretch, + bounds, + displayList, + canvas); + } + + sk_sp<SkShader> stretchShader = stretch.getShader(bounds.width(), + bounds.height(), + snapshotImage); paint.setShader(stretchShader); canvas->drawRect(bounds, paint); } |