Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Skia and FBO
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Anthony Catel  
View profile  
 More options Oct 8 2012, 7:23 pm
From: Anthony Catel <a.ca...@weelya.com>
Date: Mon, 8 Oct 2012 16:23:09 -0700 (PDT)
Local: Mon, Oct 8 2012 7:23 pm
Subject: Re: Skia and FBO

Thanks for your patience. I'll try this solution.
(FWIW, I've "resolved" my initial issue by unsetting the current shader
(glUseProgram(0)). I'm now seeing my texture with some distortion :)).

On Tuesday, October 9, 2012 1:02:10 AM UTC+2, Brian Salomon wrote:

> If you create an SkGpuDevice using the constructor that takes a config,
> width, and height then it will be FBO-backed. You can then install that
> device on the layerCanvas using SkCanvas::setDevice. It should just work
> and you don't need to call SkCanvas::flush when you switch from one canvas
> to the other.
> On Oct 8, 2012 5:44 PM, "Anthony Catel" <a.c...@weelya.com <javascript:>>
> wrote:

>> this is the idea. But layerCanvas can't be backed by another GL device
>> right? Or may be if :

>> - mainCanvas is attached to a GL device on the window framebuffer
>> - layerCanvas is attached to the same GL context but attached to an FBO
>> - mainCanvas->drawBitmap(layerCanvas->getDevice()->accessBitmap(false))
>> will tell OpenGL to draw layerCanvas texture onto mainCanvas buffer without
>> performing CPU operation?

>> On Monday, October 8, 2012 11:22:51 PM UTC+2, Brian Salomon wrote:

>>> I'm not totally sure I get what you're trying to do but you can draw
>>> from one canvas to another:

>>>    layerCanvas->clear();
>>>    layerCanvas->draw();
>>>    mainCanvas->drawBitmap(**layerCanvas->getDevice()->**
>>> accessBitmap(false)).
>>>    // layerCanvas's contents are preserved here

>>> On Mon, Oct 8, 2012 at 5:18 PM, Anthony Catel <a.c...@weelya.com> wrote:

>>>> Or can I do this : ?

>>>> - create a new layer;
>>>> - draw to the new layer
>>>> - composite it to the root layer
>>>> - draw on the same layer
>>>> - compose
>>>> - etc...

>>>> So that the layer and its memory are not lost like on the
>>>> saveLayer()/restore() flow.

>>>> On Monday, October 8, 2012 11:10:01 PM UTC+2, Anthony Catel wrote:

>>>>> Already tried to use saveLayer but the performances are undermined. I
>>>>> have to do one saveLayer per frame.
>>>>> Because :

>>>>> - I need xfer modes to be applied like I'm on a transparent surface
>>>>> - I want a white background.

>>>>> I can't find a reliable solution for this.

>>>>> The flow would be :

>>>>> loop() { // frame loop
>>>>>   saveLayer();
>>>>>   Skia Call 1;
>>>>>   Skia Call 2;
>>>>>   ...
>>>>>   restore() /* and compose to a white background */
>>>>> }

>>>>> On the second frame I want to keep my object on the screen with the
>>>>> transparent background. The next saveLayer() would be unaware of what is
>>>>> already on the screen unless I redraw what's on the screen after the
>>>>> saveLayer() which seems to be very expensive. SkPicture() is maybe a
>>>>> solution?

>>>>> Using FBO seems less painful to me.

>>>>> Anthony

>>>>> On Monday, October 8, 2012 11:02:02 PM UTC+2, Brian Salomon wrote:

>>>>>> On Mon, Oct 8, 2012 at 4:46 PM, Anthony Catel <a.c...@weelya.com>wrote:

>>>>>>> That's what I also though.

>>>>>>> Basically what I'm trying to achieve is :

>>>>>>> Composing a layer with some transparent part onto a white (or any
>>>>>>> other color) surface. Something like a browser's <canvas> element would do
>>>>>>> on the document body surface.
>>>>>>> I could't achieve this efficiently using skia API (I have to keep a
>>>>>>> decent frame rate). Do you think using FBO is a good plan for this task? Or
>>>>>>> is there a Skia API in order to manage layers I'm not aware of?

>>>>>> Is the stuff underneath the layer also rendered by Skia? If so you
>>>>>> can use SkCanvas's saveLayer mechanism. It switches the canvas to an
>>>>>> offscreen target and draws it back to the main target when
>>>>>> SkCanvas::restore is called. Check out the code comment in SkCanvas.h at
>>>>>> line 267.

>>>>>>> Thanks,

>>>>>>> Anthony

>>>>>>> On Monday, October 8, 2012 10:38:50 PM UTC+2, Brian Salomon wrote:

>>>>>>>> Skia will definitely mess with the OpenGL state quite a bit. It
>>>>>>>> will change the bound textures, program, array buffers, enable/disable
>>>>>>>> states, etc. Since you're using GL_QUADS it sounds like you're on a non-ES
>>>>>>>> ("desktop") OpenGL. You could use glPush[Client]Attrib to save state before
>>>>>>>> invoking Skia and then pop it afterwards. The other options are to give
>>>>>>>> Skia its own GL context (with shared ids) or make your other GL code able
>>>>>>>> to cope with the Skia's state changes.

>>>>>>>> Brian

>>>>>>>> On Mon, Oct 8, 2012 at 4:22 PM, Anthony Catel <a.c...@weelya.com>wrote:

>>>>>>>>> Hey,

>>>>>>>>> I'm trying to draw into an FBO instead of directly drawing into
>>>>>>>>> the window frame buffer.

>>>>>>>>> So what I've done :

>>>>>>>>> - Generate a framebuffer object
>>>>>>>>> - Generate a texture
>>>>>>>>> - Attach the texture to the FBO
>>>>>>>>> - Bind the FBO
>>>>>>>>> - Pass the FBO id to skia : desc.fRenderTargetHandle = fbo_handle;
>>>>>>>>> [...]
>>>>>>>>> - Do usual skia calls + SkCanvas::flush.
>>>>>>>>> - Unbind the FBO (glBindFramebuffer(GL_**FRAMEBUF****FER, 0)) +
>>>>>>>>> glBindTexture(GL_TEXTURE_2D, fbo_texture);
>>>>>>>>> - Trying to draw a GL_QUADS using the texture : I got either a
>>>>>>>>> black screen or a red screen depending on what I do with skia. But the
>>>>>>>>> texture is not drawn.

>>>>>>>>> Using gDebugger I can see that the FBO's texture is filled with
>>>>>>>>> what I want but I'm unable to paint it on a rectancle. What Am I doing
>>>>>>>>> wrong? Does skia enable some state I should disable before painting the
>>>>>>>>> texture?

>>>>>>>>> Here is a screen of gDebugger with my rendered texture :
>>>>>>>>> http://p.nf/debug.png
>>>>>>>>> FBO 1 is the one I created. Others are created by Skia I guess.

>>>>>>>>> Thanks !

>>>>>>>>>  --
>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>> Groups "skia-discuss" group.
>>>>>>>>> To view this discussion on the web visit
>>>>>>>>> https://groups.google.com/d/**ms****g/skia-discuss/-/UZY4zK_**
>>>>>>>>> 3oNkJ<https://groups.google.com/d/msg/skia-discuss/-/UZY4zK_3oNkJ>
>>>>>>>>> .
>>>>>>>>>  To post to this group, send email to skia-d...@googlegroups.com.
>>>>>>>>> To unsubscribe from this group, send email to skia-discuss...@**
>>>>>>>>> googlegroups.**c**om.

>>>>>>>>> For more options, visit this group at http://groups.google.com/**
>>>>>>>>> group****/skia-discuss?hl=en<http://groups.google.com/group/skia-discuss?hl=en>
>>>>>>>>> .

>>>>>>>>  --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "skia-discuss" group.
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/**ms**g/skia-discuss/-/**Xh7MHbwl1YMJ<https://groups.google.com/d/msg/skia-discuss/-/Xh7MHbwl1YMJ>
>>>>>>> .

>>>>>>> To post to this group, send email to skia-d...@googlegroups.com.
>>>>>>> To unsubscribe from this group, send email to
>>>>>>> skia-discuss...@googlegroups.**c**om.
>>>>>>> For more options, visit this group at http://groups.google.com/**
>>>>>>> group**/skia-discuss?hl=en<http://groups.google.com/group/skia-discuss?hl=en>
>>>>>>> .

>>>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "skia-discuss" group.
>>>> To view this discussion on the web visit https://groups.google.com/d/**
>>>> msg/skia-discuss/-/**byuPM4DLLskJ<https://groups.google.com/d/msg/skia-discuss/-/byuPM4DLLskJ>
>>>> .

>>>> To post to this group, send email to skia-d...@googlegroups.com.
>>>> To unsubscribe from this group, send email to skia-discuss...@**
>>>> googlegroups.com.
>>>> For more options, visit this group at http://groups.google.com/**
>>>> group/skia-discuss?hl=en<http://groups.google.com/group/skia-discuss?hl=en>
>>>> .

>>>  --
>> You received this message because you are subscribed to the Google Groups
>> "skia-discuss" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/skia-discuss/-/jOV_BVae6mkJ.
>> To post to this group, send email to skia-d...@googlegroups.com<javascript:>
>> .
>> To unsubscribe from this group, send email to
>> skia-discuss...@googlegroups.com <javascript:>.
>> For more options, visit this group at
>> http://groups.google.com/group/skia-discuss?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.