Bug 38236 - getFramebufferAttachmentParameter should return the original WebGLTexture/WebGLRenderbuffer instead of creating new ones sharing names.
Summary: getFramebufferAttachmentParameter should return the original WebGLTexture/Web...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Zhenyao Mo
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-27 17:31 PDT by Zhenyao Mo
Modified: 2010-05-04 17:30 PDT (History)
6 users (show)

See Also:


Attachments
patch (17.06 KB, patch)
2010-04-29 09:53 PDT, Zhenyao Mo
no flags Details | Formatted Diff | Diff
revised patch : responding to Darin Adler's review (17.31 KB, patch)
2010-04-30 13:51 PDT, Zhenyao Mo
no flags Details | Formatted Diff | Diff
revised patch: responding to Ken Russell's review (17.28 KB, patch)
2010-05-04 10:13 PDT, Zhenyao Mo
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zhenyao Mo 2010-04-27 17:31:16 PDT
Having multiple CanvasObject share the same resource name makes it very difficult to track the resources.
Comment 1 Zhenyao Mo 2010-04-29 09:53:05 PDT
Created attachment 54716 [details]
patch
Comment 2 Darin Adler 2010-04-30 13:18:56 PDT
Comment on attachment 54716 [details]
patch

Generally speaking member functions should be as private as possible. If you already have a WebGLFramebuffer* it's a programming error to call isFramebuffer, so it's better to make the WebGLFramebuffer::isFramebuffer private even though the function it is overriding in the base class, CanvasObject::isFramebuffer, is public.
Comment 3 Zhenyao Mo 2010-04-30 13:51:03 PDT
Created attachment 54825 [details]
revised patch : responding to Darin Adler's review
Comment 4 Kenneth Russell 2010-05-03 17:30:34 PDT
Comment on attachment 54825 [details]
revised patch : responding to Darin Adler's review

Looks good overall. It's good that you were able to reuse the m_canvasObjects table to reduce the risk of changing the memory management of the WebGLRenderingContext class. I think that we should reexamine the lifetime of the CanvasObjects / WebGLObjects, but that should wait for a subsequent bug.

One comment:
WebCore/html/canvas/WebGLRenderingContext.cpp:2844
 +              RefPtr<WebGLTexture> tex = reinterpret_cast<WebGLTexture*>((*it).get());
Can you try to write instead:

return reinterpret_cast<RefPtr<WebGLTexture> >(*it).release();

Perhaps you've already tried this and it doesn't work.


WebCore/html/canvas/WebGLRenderingContext.cpp:2856
 +              RefPtr<WebGLRenderbuffer> buffer = reinterpret_cast<WebGLRenderbuffer*>((*it).get());
If the above suggestion works, please use it here too.
Comment 5 Zhenyao Mo 2010-05-04 09:21:02 PDT
(In reply to comment #4)
> (From update of attachment 54825 [details])
> Looks good overall. It's good that you were able to reuse the m_canvasObjects
> table to reduce the risk of changing the memory management of the
> WebGLRenderingContext class. I think that we should reexamine the lifetime of
> the CanvasObjects / WebGLObjects, but that should wait for a subsequent bug.
> 
> One comment:
> WebCore/html/canvas/WebGLRenderingContext.cpp:2844
>  +              RefPtr<WebGLTexture> tex =
> reinterpret_cast<WebGLTexture*>((*it).get());
> Can you try to write instead:
> 
> return reinterpret_cast<RefPtr<WebGLTexture> >(*it).release();
> 

I tried.  The cast is invalid.

> Perhaps you've already tried this and it doesn't work.
> 
> 
> WebCore/html/canvas/WebGLRenderingContext.cpp:2856
>  +              RefPtr<WebGLRenderbuffer> buffer =
> reinterpret_cast<WebGLRenderbuffer*>((*it).get());
> If the above suggestion works, please use it here too.
Comment 6 Kenneth Russell 2010-05-04 09:40:31 PDT
(In reply to comment #5)
> (In reply to comment #4)
> > (From update of attachment 54825 [details] [details])
> > Looks good overall. It's good that you were able to reuse the m_canvasObjects
> > table to reduce the risk of changing the memory management of the
> > WebGLRenderingContext class. I think that we should reexamine the lifetime of
> > the CanvasObjects / WebGLObjects, but that should wait for a subsequent bug.
> > 
> > One comment:
> > WebCore/html/canvas/WebGLRenderingContext.cpp:2844
> >  +              RefPtr<WebGLTexture> tex =
> > reinterpret_cast<WebGLTexture*>((*it).get());
> > Can you try to write instead:
> > 
> > return reinterpret_cast<RefPtr<WebGLTexture> >(*it).release();
> > 
> 
> I tried.  The cast is invalid.

OK. You can still write "return tex.release();" instead of explicitly constructing the PassRefPtr out of the RefPtr. In fact I think you should do this to reduce churn on the reference counts.

> 
> > Perhaps you've already tried this and it doesn't work.
> > 
> > 
> > WebCore/html/canvas/WebGLRenderingContext.cpp:2856
> >  +              RefPtr<WebGLRenderbuffer> buffer =
> > reinterpret_cast<WebGLRenderbuffer*>((*it).get());
> > If the above suggestion works, please use it here too.
Comment 7 Zhenyao Mo 2010-05-04 10:13:05 PDT
Created attachment 55025 [details]
revised patch: responding to Ken Russell's review
Comment 8 Kenneth Russell 2010-05-04 10:34:53 PDT
Comment on attachment 55025 [details]
revised patch: responding to Ken Russell's review

Looks good. Thanks for cleaning this up.
Comment 9 Dimitri Glazkov (Google) 2010-05-04 11:38:27 PDT
Comment on attachment 55025 [details]
revised patch: responding to Ken Russell's review

ok.
Comment 10 WebKit Commit Bot 2010-05-04 17:30:44 PDT
Comment on attachment 55025 [details]
revised patch: responding to Ken Russell's review

Clearing flags on attachment: 55025

Committed r58790: <http://trac.webkit.org/changeset/58790>
Comment 11 WebKit Commit Bot 2010-05-04 17:30:50 PDT
All reviewed patches have been landed.  Closing bug.