SkSurface::draw() to itself?

89 views
Skip to first unread message

Luboš Luňák

unread,
Apr 15, 2020, 1:37:15 PM4/15/20
to skia-d...@googlegroups.com

Hello,

I need to copy a rectangle of SkSurface inside itself (scrolling) and
SkSurface::draw() seemed like the right optimized tool for it (both Raster
and GPU seem to try to avoid needless copying).

But doing "surface->draw( surface->getCanvas(), ..." ) such as in
https://fiddle.skia.org/c/6ce6bce5427b03a2e356a5b8172919a1 apparently doesn't
work:
- with raster it segfaults at fiddle.skia.org (not sure why, locally it works
for me)
- my local Vulkan code eventually asserts
with 'skia/src/gpu/vk/GrVkOpsRenderPass.cpp:505: fatal
error: "assert(vkTex->currentLayout() ==
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)"' (relevant part of backtrace
attached)
- looking at the GPU fiddle output, it doesn't handle overlapping areas
correctly

Are those bugs or are they (undocumented as far as I can tell) limitations of
SkSurface::draw()? And if they are limitations, what is the purpose of
SkSurface::draw() as compared to SkCanvas::drawImage()?

Thank you.

--
Luboš Luňák
l.l...@collabora.com
bt.txt

Luboš Luňák

unread,
Apr 20, 2020, 5:21:31 AM4/20/20
to skia-d...@googlegroups.com

Ping? Is this a difficult question to answer, or should I be asking it
elsewhere?
--
Luboš Luňák
l.l...@collabora.com

Mike Reed

unread,
Apr 20, 2020, 10:38:05 AM4/20/20
to skia-d...@googlegroups.com
Looks like a bug. We're investigating.

As a test, if you snap an image from the surface, and draw that, it works, yes?

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/202004201121.26761.l.lunak%40collabora.com.

Brian Osman

unread,
Apr 20, 2020, 10:42:00 AM4/20/20
to skia-d...@googlegroups.com
It's also worth pointing out that you will need a temporary copy in this scenario (which should be handled automatically, barring any bugs we might find).

Luboš Luňák

unread,
Apr 20, 2020, 11:21:41 AM4/20/20
to skia-d...@googlegroups.com
On Monday 20 of April 2020, 'Mike Reed' via skia-discuss wrote:
> Looks like a bug. We're investigating.

Ok, thanks. I wasn't sure when it wasn't commented on while other mails were.

> As a test, if you snap an image from the surface, and draw that, it works,
> yes?

You mean surface->getCanvas()->drawImage( surface->makeImageSnapshot(), ...?
Yes, that works without problems. Even SkSurface::draw() between distinct
surfaces is fine.
--
Luboš Luňák
l.l...@collabora.com

Luboš Luňák

unread,
Apr 20, 2020, 11:32:32 AM4/20/20
to skia-d...@googlegroups.com
On Monday 20 of April 2020, 'Brian Osman' via skia-discuss wrote:
> It's also worth pointing out that you will need a temporary copy in this
> scenario (which should be handled automatically, barring any bugs we might
> find).

It could do without a copy if the destination and source areas were not
intersecting or the copy was done in the proper direction (a la memmove), no?
Assuming there would be a simple way to get those or API was added to accept
those (I currently fake this by clipping).
> > https://groups.google.com/d/msgid/skia-discuss/CAERTzqyjodM0b_EitZ9ZwUXYW
> >VVBZQrMXWkqXow4_HXh7CEFoA%40mail.gmail.com
> > <https://groups.google.com/d/msgid/skia-discuss/CAERTzqyjodM0b_EitZ9ZwUXY
> >WVVBZQrMXWkqXow4_HXh7CEFoA%40mail.gmail.com?utm_medium=email&utm_source=fo
> >oter> .



--
Luboš Luňák
l.l...@collabora.com
Reply all
Reply to author
Forward
0 new messages