RESOLVED FIXED68501
[skia] Optimize ImageBuffer constructor when accelerated
https://bugs.webkit.org/show_bug.cgi?id=68501
Summary [skia] Optimize ImageBuffer constructor when accelerated
Ben Wells
Reported 2011-09-20 21:13:46 PDT
The ImageBuffer constructor creates a SkDevice for a non-accelerated canvas first. Then, if an accelerated buffer is requested it will try to create an accelerated SkDevice, if successful overwriting the non-accelerated device. This can be optimized to first try, if requested, to create an accelerated SkDevice and only create the non-accelerated device if that fails.
Attachments
Patch (4.47 KB, patch)
2011-09-21 07:20 PDT, Stephen White
no flags
Updated per comments (6.36 KB, patch)
2011-09-21 11:53 PDT, Stephen White
jamesr: review+
Stephen White
Comment 1 2011-09-21 07:20:04 PDT
James Robinson
Comment 2 2011-09-21 11:10:47 PDT
Comment on attachment 108153 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=108153&action=review R=me, left some comments > Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:69 > + GraphicsContext3D* context3D = SharedGraphicsContext3D::create(0); we really should remove the parameter from SharedGraphicsContext3D::create(), it's not useful > Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:76 > + SkCanvas* canvas = new SkCanvas(); nit: if you move this down below line 83 I think you can avoid having to manually delete this if the texture thingy fails also, if you make this function return a PassOwnPtr<> then you can make this an OwnPtr<SkCanvas>, have the return value be canvas.release() and not have to worry about saying 'delete' at all
Alok Priyadarshi
Comment 3 2011-09-21 11:23:27 PDT
Comment on attachment 108153 [details] Patch lgtm. I like James' suggestion about moving the creation of canvas after creating the texture.
Stephen White
Comment 4 2011-09-21 11:53:26 PDT
Created attachment 108198 [details] Updated per comments
Stephen White
Comment 5 2011-09-21 11:56:59 PDT
Thanks for your review. (In reply to comment #2) > (From update of attachment 108153 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=108153&action=review > > R=me, left some comments > > > Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:69 > > + GraphicsContext3D* context3D = SharedGraphicsContext3D::create(0); > > we really should remove the parameter from SharedGraphicsContext3D::create(), it's not useful Done. Also renamed SharedGraphicsContext3D::create() to get(), since it's only a create the first time. > > Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:76 > > + SkCanvas* canvas = new SkCanvas(); > > nit: if you move this down below line 83 I think you can avoid having to manually delete this if the texture thingy fails Done. > also, if you make this function return a PassOwnPtr<> then you can make this an OwnPtr<SkCanvas>, have the return value be canvas.release() and not have to worry about saying 'delete' at all I tried that, but it meant all the early-returns needed to return a PassRefPtr<SkCanvas*>(0), which looked ugly.
James Robinson
Comment 6 2011-09-21 11:57:56 PDT
Comment on attachment 108198 [details] Updated per comments View in context: https://bugs.webkit.org/attachment.cgi?id=108198&action=review > Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h:37 > + static GraphicsContext3D* get(); this header file is kind of hilariously tiny now. I actually think you can remove the three #include lines and just leave a forward declaration of GraphicsContext3D. > Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:85 > + SkCanvas* canvas = new SkCanvas(); I think I'd still mildly prefer having this function be: PassOwnPtr<SkCanvas> createAcceleratedCanvas(...) and this line being OwnPtr<SkCanvas> canvas = adoptPtr(new SkCanvas()) just to try to keep the raw pointers down. it's not a very practical concern
James Robinson
Comment 7 2011-09-21 11:58:15 PDT
(In reply to comment #5) > > also, if you make this function return a PassOwnPtr<> then you can make this an OwnPtr<SkCanvas>, have the return value be canvas.release() and not have to worry about saying 'delete' at all > > I tried that, but it meant all the early-returns needed to return a PassRefPtr<SkCanvas*>(0), which looked ugly. Aha! You want nullptr
Stephen White
Comment 8 2011-09-21 12:10:44 PDT
Note You need to log in before you can comment on or make changes to this bug.