Bug 89867 - [Texmap] Remove platform specific code in BitmapImageGL::updateContents by using GraphicsContext3D::extractImageData.
Summary: [Texmap] Remove platform specific code in BitmapImageGL::updateContents by us...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 89866
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-25 04:25 PDT by Dongseong Hwang
Modified: 2012-06-26 05:58 PDT (History)
9 users (show)

See Also:


Attachments
Patch (6.19 KB, patch)
2012-06-25 04:26 PDT, Dongseong Hwang
no flags Details | Formatted Diff | Diff
patch (7.50 KB, patch)
2012-06-25 04:31 PDT, Dongseong Hwang
noam: review+
webkit-ews: commit-queue-
Details | Formatted Diff | Diff
patch v.3 (8.01 KB, patch)
2012-06-25 16:55 PDT, Dongseong Hwang
no flags Details | Formatted Diff | Diff
patch v.4 (8.06 KB, patch)
2012-06-25 17:00 PDT, Dongseong Hwang
noam: review-
noam: commit-queue-
Details | Formatted Diff | Diff
patch v.5 (7.73 KB, patch)
2012-06-25 19:06 PDT, Dongseong Hwang
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dongseong Hwang 2012-06-25 04:25:38 PDT
[Texmap] Remove platform specific code in BitmapImageGL::updateContents by using GraphicsContext3D::extractImageData.
Comment 1 Dongseong Hwang 2012-06-25 04:26:42 PDT
Created attachment 149272 [details]
Patch
Comment 2 Dongseong Hwang 2012-06-25 04:31:38 PDT
Created attachment 149273 [details]
patch

[Texmap] Remove platform specific code in BitmapImageGL::updateContents by using GraphicsContext3D::extractImageData.
Comment 3 Early Warning System Bot 2012-06-25 04:38:32 PDT
Comment on attachment 149273 [details]
patch

Attachment 149273 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/13103029
Comment 4 Early Warning System Bot 2012-06-25 04:38:42 PDT
Comment on attachment 149273 [details]
patch

Attachment 149273 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/13087142
Comment 5 Gustavo Noronha (kov) 2012-06-25 04:39:06 PDT
Comment on attachment 149273 [details]
patch

Attachment 149273 [details] did not pass gtk-ews (gtk):
Output: http://queues.webkit.org/results/13099052
Comment 6 Dongseong Hwang 2012-06-25 04:43:51 PDT
Oops, I made mistake.
This patch can be compiled after Bug 89866 is accepted.
Comment 7 Noam Rosenthal 2012-06-25 06:06:27 PDT
Comment on attachment 149273 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=149273&action=review

I'd rather if we just moved TExtureMapperGL to use GC3D, see https://bugs.webkit.org/show_bug.cgi?id=78672.
Though this might be a good intermediate step. What do others think?

> Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:526
> +    GraphicsContext3D::extractImageData(image, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, false, premultiplyAlpha, false, imageData);

Add comments near the "false" arguments
Comment 8 Noam Rosenthal 2012-06-25 08:28:47 PDT
Comment on attachment 149273 [details]
patch

Please fix nitpick comment before committing.
Comment 9 Dongseong Hwang 2012-06-25 16:08:24 PDT
Sorry, I recognized that nitpick in subway to go home in yesterday night.
I'll fix it.
Comment 10 Dongseong Hwang 2012-06-25 16:55:33 PDT
Created attachment 149396 [details]
patch v.3
Comment 11 Dongseong Hwang 2012-06-25 17:00:08 PDT
Created attachment 149398 [details]
patch v.4
Comment 12 Noam Rosenthal 2012-06-25 18:20:13 PDT
Comment on attachment 149398 [details]
patch v.4

View in context: https://bugs.webkit.org/attachment.cgi?id=149398&action=review

> Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:523
> +    // The premultiplyAlpha is true, because the default value of alphaOption in ImageSource is AlphaPremultiplied.
> +    bool premultiplyAlpha = true;
> +    // The ignoreGammaAndColorProfile is false, because the default value of gammaAndColorProfileOption in ImageSource is GammaAndColorProfileApplied.
> +    bool ignoreGammaAndColorProfile = false;
> +    GraphicsContext3D::extractImageData(image, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, flipY, premultiplyAlpha, ignoreGammaAndColorProfile, imageData);

Not exactly what I meant...
something like: GraphicsContext3D::extractImageData(image, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, flipY, true /* premultiplyAlpha */, false /* ignoreGammaAndColorProfile */, imageData);
this way there are no magic "false" and "true" around.
Comment 13 Dongseong Hwang 2012-06-25 19:06:20 PDT
Created attachment 149423 [details]
patch v.5

Ok. I'll remember it. :)
Comment 14 Noam Rosenthal 2012-06-25 19:10:45 PDT
The other optimization we need to do, if we're to use this code, is to load the image directly to ARGB32_Premultiplied instead of to ARGB32 and then add a premultiply step.
Comment 15 Dongseong Hwang 2012-06-25 19:18:29 PDT
When I called GraphicsContext3D::extractImageData(image, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, flipY, false /* premultiplyAlpha */, false /* ignoreGammaAndColorProfile */, imageData);
I can not get proper pixel data.

Could you explain briefly how we can get unpremultiplyAlpha pixel using GC3D?
Comment 16 Noam Rosenthal 2012-06-25 19:20:41 PDT
(In reply to comment #15)
> When I called GraphicsContext3D::extractImageData(image, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, flipY, false /* premultiplyAlpha */, false /* ignoreGammaAndColorProfile */, imageData);
> I can not get proper pixel data.
> 
> Could you explain briefly how we can get unpremultiplyAlpha pixel using GC3D?

Sorry, it's inside GRaphicsContext3D::extractImageData. This comment should have been for bug 89865.
Comment 17 Dongseong Hwang 2012-06-25 19:36:00 PDT
After this patch, if we run WebKit Leaves, you can see strange command message.
 libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area

It is because of GraphicsContext3D::extractImageData.
I filed Bug 89938
Comment 18 WebKit Review Bot 2012-06-25 20:59:45 PDT
Comment on attachment 149423 [details]
patch v.5

Clearing flags on attachment: 149423

Committed r121223: <http://trac.webkit.org/changeset/121223>
Comment 19 WebKit Review Bot 2012-06-25 20:59:51 PDT
All reviewed patches have been landed.  Closing bug.
Comment 20 Simon Hausmann 2012-06-25 21:21:10 PDT
This patch broke the minimal Qt build bot ;( 


/usr/bin/gold: /ramdisk/qt-linux-release-minimal/build/WebKitBuild/Release/Source/WebCore/release/libWebCore.a(TextureMapperGL.o): in function WebCore::BitmapTextureGL::updateContents(WebCore::Image*, WebCore::IntRect const&, WebCore::IntPoint const&):TextureMapperGL.cpp(.text._ZN7WebCore15BitmapTextureGL14updateContentsEPNS_5ImageERKNS_7IntRectERKNS_8IntPointE+0x6a): error: undefined reference to 'WebCore::GraphicsContext3D::extractImageData(WebCore::Image*, unsigned int, unsigned int, bool, bool, bool, WTF::Vector<unsigned char, 0u>&)'
Comment 21 Simon Hausmann 2012-06-25 21:33:27 PDT
I'll try to fix the build. Essentially TextureMapperGL now requires WebGL.
Comment 22 Simon Hausmann 2012-06-25 21:44:08 PDT
Minimal build fixed in http://trac.webkit.org/changeset/121226 . The bot however needs a clean rebuild now though, because the DEFINES in WebCore's Target.pri changed and TextureMapperGL.cpp should not be compiled anymore.
Comment 23 Noam Rosenthal 2012-06-25 22:20:35 PDT
(In reply to comment #21)
> I'll try to fix the build. Essentially TextureMapperGL now requires WebGL.

It doesn't require WebGL, it requires GraphicsContext3D (which is a low-level part of WebGL). We should still be able to use TextureMapperGL without WebGL - should we create a separate bug to support this?
Comment 24 Simon Hausmann 2012-06-25 22:30:20 PDT
(In reply to comment #23)
> (In reply to comment #21)
> > I'll try to fix the build. Essentially TextureMapperGL now requires WebGL.
> 
> It doesn't require WebGL, it requires GraphicsContext3D (which is a low-level part of WebGL). We should still be able to use TextureMapperGL without WebGL - should we create a separate bug to support this?

Yes, because GraphicsContext3D.cpp has a big #if ENABLE(WEBGL) at the top :)

I have the feeling that what's missing are some lower level convenience APIs for OpenGL that don't pull in the entire WebGL stuff, i.e. an OpenGL context abstraction and like in this case convenience for getting data out of a texture.
Comment 25 Dongseong Hwang 2012-06-25 23:05:24 PDT
(In reply to comment #22)
> Minimal build fixed in http://trac.webkit.org/changeset/121226 . The bot however needs a clean rebuild now though, because the DEFINES in WebCore's Target.pri changed and TextureMapperGL.cpp should not be compiled anymore.

Thanks for your favor.
I should be more careful.
Comment 26 Ryosuke Niwa 2012-06-25 23:35:32 PDT
It's still broken :(
Comment 27 Simon Hausmann 2012-06-26 00:06:31 PDT
(In reply to comment #26)
> It's still broken :(

Yeah, but that's an issue on the bot. I built it locally and it works. The bot needs a nudge or somebody touching config.h ;)
Comment 28 Csaba Osztrogonác 2012-06-26 00:51:38 PDT
(In reply to comment #27)
> (In reply to comment #26)
> > It's still broken :(
> 
> Yeah, but that's an issue on the bot. I built it locally and it works. The bot needs a nudge or somebody touching config.h ;)

rgabor triggered a clean build on the bot, it's green again. ;-)
Comment 29 Noam Rosenthal 2012-06-26 05:58:05 PDT
(In reply to comment #24)
> (In reply to comment #23)
> > (In reply to comment #21)
> > > I'll try to fix the build. Essentially TextureMapperGL now requires WebGL.
> > 
> > It doesn't require WebGL, it requires GraphicsContext3D (which is a low-level part of WebGL). We should still be able to use TextureMapperGL without WebGL - should we create a separate bug to support this?
> 
> Yes, because GraphicsContext3D.cpp has a big #if ENABLE(WEBGL) at the top :)
> 
> I have the feeling that what's missing are some lower level convenience APIs for OpenGL that don't pull in the entire WebGL stuff, i.e. an OpenGL context abstraction and like in this case convenience for getting data out of a texture.

We're not missing it. GraphicsContext3D is it - we just need to change that ENABLE flag at the top :)