You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TLDR: The surface type of the graphics context you end up with inside druid is different from what's used in piet's test cases, so functions that work fine in standalone piet do not work in druid when you're using the provided PaintCtx. This is the case for capture_image_area under piet-coregraphics.
There is a very similar issue with Windows under piet-direct2d (#2216), but the fix is simple enough (linebender/piet#526). With macOS it's considerably trickier: In piet-coregraphics, capture_image_area passes the active CGContextRef pointer to CGBitmapContextCreateImage. This works fine in the test case where the graphics context is a CGBitmapContext, but it does not work when CGContextRef points to a screen-type context. As far as I can tell there is no universal or appropriate alternate method to cache a region of a context -- the closest you get is this one for bitmap contexts. Even attempting to identify context types and respond accordingly is tricky, you can call CGContextGetTypeID on it to get a type id but unless I'm missing something major there's not a supported approach to mapping the returned id to any particular type of CGContext.
Unless there's a simple fix I'm completely missing (some sort of NS* magic, perhaps), the way forward could be a macOS-specific ext trait or env flag to give the option of caching all drawing in a CGBitmapContext rather than drawing directly to the CGContextRef we get from NSGraphicsContext::currentContext. Barring a better fix I'll submit a PR with this approach once I get the bugs worked out, but it'd be nice to have a cleaner solution than having to take a performance hit just to get this one function working.
The text was updated successfully, but these errors were encountered:
TLDR: The surface type of the graphics context you end up with inside druid is different from what's used in piet's test cases, so functions that work fine in standalone piet do not work in druid when you're using the provided
PaintCtx
. This is the case forcapture_image_area
underpiet-coregraphics
.There is a very similar issue with Windows under
piet-direct2d
(#2216), but the fix is simple enough (linebender/piet#526). With macOS it's considerably trickier: Inpiet-coregraphics
,capture_image_area
passes the activeCGContextRef
pointer toCGBitmapContextCreateImage
. This works fine in the test case where the graphics context is aCGBitmapContext
, but it does not work whenCGContextRef
points to a screen-type context. As far as I can tell there is no universal or appropriate alternate method to cache a region of a context -- the closest you get is this one for bitmap contexts. Even attempting to identify context types and respond accordingly is tricky, you can callCGContextGetTypeID
on it to get a type id but unless I'm missing something major there's not a supported approach to mapping the returned id to any particular type ofCGContext
.Unless there's a simple fix I'm completely missing (some sort of
NS*
magic, perhaps), the way forward could be a macOS-specificext
trait orenv
flag to give the option of caching all drawing in aCGBitmapContext
rather than drawing directly to theCGContextRef
we get fromNSGraphicsContext::currentContext
. Barring a better fix I'll submit a PR with this approach once I get the bugs worked out, but it'd be nice to have a cleaner solution than having to take a performance hit just to get this one function working.The text was updated successfully, but these errors were encountered: