[cairo] Blitting surfaces onto each other with coordinate translation
psychon at znc.in
Fri Jul 26 06:37:05 UTC 2019
On 24.07.19 23:07, Johannes Bauer wrote:
> When I create the individual layer surfaces, I translate the Y
> coordinates appropriately:
> matrix = cairo.Matrix()
> matrix.scale(1, -1)
> matrix.translate(0, -height)
> matrix.translate(-offset.x, -offset.y)
> This allows me to convert from hardware to pixels by just dpi
> multiplication and then just draw on the surface.
When you draw via this onto some surface, you flip the y-axis, right?
Meaning that the resulting image will be upside down.
> When I want to create the final surface that all others are merged onto,
> I originally had the same setup (i.e., also the final surface would have
> an inverted Y axis). But then, for some weird reason, when trying to
> blit the sub-surfaces on the destination:
> final_cctx.set_source_surface(sub.ctx, sub.offset.x, sub.offset.y)
> Then the Y-axis would again be inverted. I'm guessing because it's
> inverted again through the projection matrix of the final destination
Well, yeah. Why shouldn't this flip the y-axis again?
> Now in my testcases I cannot reproduce any of this, there the double
> inversion does not happen and, for the life of me, I cannot figure out
> what is going on or even how I would start debugging this.
Usually, I debug rendering issues via cairo_surface_write_to_png() on
all the indermediate states and then checking if these surfaces look the
way I expect them to. I'm not sure if this is really helpful, but I am
also not sure what else to answer to your request. Sorry.
“Cold. Cold. Cold. Cold. Cold. Cold. Cold. Cold. Cold. Cold.” – Anna
More information about the cairo