Athens/Cairo Canvas rendering

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Athens/Cairo Canvas rendering

Fernando olivero-2
Igor, i'm curious on how you plan to implement the actual real usage
of a Cairo Canvas, besides the toy examples that Javier implemented
(writing to png , and then to a form, then to image morph).


I recently been playing with Cairo, and found out the following options:

1)  Rendering to a bitmapped quartz context, then getting the data and
blitting to the display.
2) Rendering to a windowed quartz context, see the example below,
hooking up cairo on the drawRect: of a NSView of Cocoa window.

- (void) drawRect: (NSRect) rect{

    CGContextRef cgContext = [[NSGraphicsContext currentContext] graphicsPort];
    cairo_surface_t *  surface= cairo_quartz_surface_create_for_cg_context(
        cgContext,
        (int) self.bounds.size.width,
        (int) self.bounds.size.height);

    cairo_t *cr = cairo_create(surface);
  "do some cairo rendering here"
    cairo_destroy(cr);
    cairo_surface_destroy(surface);
 }

Would it be possible to reach the [[NSGraphicsContext currentContext]
graphicsPort], using Native Boost?
So we could render to that OS window, using Athens within Pharo?
(Assuming the NSWindow holding the above NSView on the example is the
main window).


Fernando
pd:...3) Surface plugin, and still be using Forms again?

Reply | Threaded
Open this post in threaded view
|

Re: Athens/Cairo Canvas rendering

Igor Stasenko
On 8 December 2011 03:34, Fernando Olivero <[hidden email]> wrote:

> Igor, i'm curious on how you plan to implement the actual real usage
> of a Cairo Canvas, besides the toy examples that Javier implemented
> (writing to png , and then to a form, then to image morph).
>
>
> I recently been playing with Cairo, and found out the following options:
>
> 1)  Rendering to a bitmapped quartz context, then getting the data and
> blitting to the display.
> 2) Rendering to a windowed quartz context, see the example below,
> hooking up cairo on the drawRect: of a NSView of Cocoa window.
>
> - (void) drawRect: (NSRect) rect{
>
>    CGContextRef cgContext = [[NSGraphicsContext currentContext] graphicsPort];
>    cairo_surface_t *  surface= cairo_quartz_surface_create_for_cg_context(
>        cgContext,
>        (int) self.bounds.size.width,
>        (int) self.bounds.size.height);
>
>    cairo_t *cr = cairo_create(surface);
>  "do some cairo rendering here"
>    cairo_destroy(cr);
>    cairo_surface_destroy(surface);
>  }
>
> Would it be possible to reach the [[NSGraphicsContext currentContext]
> graphicsPort], using Native Boost?
> So we could render to that OS window, using Athens within Pharo?
> (Assuming the NSWindow holding the above NSView on the example is the
> main window).
>
>
i have to render to memory and then blit form to window, whatever it is.
Of course it would be more optimal to render directly to OS window,
but it means that you need to
support all OSes with all their different window managing -> tedious task. :(
Besides of that, the above code is Objective C, and not sure you can
so easily make FFI calls to it.
At least you have to implement it before can use.

> Fernando
> pd:...3) Surface plugin, and still be using Forms again?
>



--
Best regards,
Igor Stasenko.