Bug 111333

Summary: [EFL] Ensure right format is used in SnapshotImageGL.
Product: WebKit Reporter: Kalyan <kalyan.kondapally>
Component: WebKit EFLAssignee: Kalyan <kalyan.kondapally>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, gyuyoung.kim, laszlo.gombos, lucas.de.marchi, ostap73, rakuco, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Bug Depends on:    
Bug Blocks: 105659    
Attachments:
Description Flags
patch
none
patchv2
benjamin: review-
patchv3 none

Description Kalyan 2013-03-04 08:24:58 PST
In SnapshotImageGL we use GL_BGRA as the format with glReadPixels. This is not the standard format on OpenGLES2.0. With GLES we should use GL_RGBA as the format and convert the result to BGRA.
Comment 1 Kalyan 2013-03-04 09:58:05 PST
Created attachment 191264 [details]
patch
Comment 2 Kenneth Rohde Christiansen 2013-03-04 10:39:22 PST
Comment on attachment 191264 [details]
patch

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

> Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp:60
> +
> +        for (int i = 0; i < totalBytes; i += 4)
> +            std::swap(buf[i], buf[i + 2]);

why this indentation?
Comment 3 Kalyan 2013-03-04 15:37:38 PST
Created attachment 191328 [details]
patchv2
Comment 4 Kalyan 2013-03-04 15:38:54 PST
(In reply to comment #2)
> (From update of attachment 191264 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=191264&action=review
> 
> > +            std::swap(buf[i], buf[i + 2]);
> 
> why this indentation?

oops, fixed it now.
Comment 5 Benjamin Poulain 2013-03-05 17:10:38 PST
Comment on attachment 191328 [details]
patchv2

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

> Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp:62
> +#if USE(OPENGL_ES_2)
> +    // Convert to BGRA.
> +    int totalBytes = width * height * 4;
> +
> +    for (int i = 0; i < totalBytes; i += 4)
> +        std::swap(buf[i], buf[i + 2]);
> +#endif
> +

It is hard to believe you must do something so inefficient. :(

Here: std::swap(buf[i], buf[i + 2]);
You swap to 32bits pixels, not 2 * 8 bits component.
Comment 6 Kalyan 2013-03-05 18:16:51 PST
Created attachment 191629 [details]
patchv3
Comment 7 Kalyan 2013-03-05 18:19:11 PST
(In reply to comment #5)
> (From update of attachment 191328 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=191328&action=review
> It is hard to believe you must do something so inefficient. :(
> 
> Here: std::swap(buf[i], buf[i + 2]);
> You swap to 32bits pixels, not 2 * 8 bits component.

Thanks for highlighting this. Fixed it now.
Comment 8 WebKit Review Bot 2013-03-05 23:39:14 PST
Comment on attachment 191629 [details]
patchv3

Clearing flags on attachment: 191629

Committed r144887: <http://trac.webkit.org/changeset/144887>
Comment 9 WebKit Review Bot 2013-03-05 23:39:18 PST
All reviewed patches have been landed.  Closing bug.