Last Comment Bug 597207 - WebGL canvases print upsidedown
: WebGL canvases print upsidedown
Product: Core
Classification: Components
Component: Canvas: WebGL (show other bugs)
: Trunk
: x86 Windows 7
-- normal (vote)
: ---
Assigned To: Benoit Jacob [:bjacob] (mostly away)
: Milan Sreckovic [:milan]
: 614150 (view as bug list)
Depends on:
  Show dependency treegraph
Reported: 2010-09-16 14:45 PDT by Gregg Tavares
Modified: 2011-01-31 08:36 PST (History)
4 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

fix upside-down bug (2.85 KB, patch)
2010-11-23 10:16 PST, Benoit Jacob [:bjacob] (mostly away)
vladimir: review-
Details | Diff | Splinter Review

Description User image Gregg Tavares 2010-09-16 14:45:32 PDT
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.55 Safari/534.3
Build Identifier: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:2.0b6pre) Gecko/20100911 Firefox/4.0b6pre

Go to any page with a WebGL canvas. Print the page.

The image on the canvas will be upside down.

Reproducible: Always

Steps to Reproduce:
1. Go to any page with a WebGL Canvas
2. Print the page

Actual Results:  
The WebGL canvas will be printed upside down

Expected Results:  
The WebGL canvas is printed right side up

You can avoid wasting paper by using the print preview feature.
Comment 1 User image Kevin Brosnan 2010-09-16 15:07:33 PDT
Confirmed. Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b7pre) Gecko/20100916 Firefox/4.0b7pre
Comment 2 User image Benoit Jacob [:bjacob] (mostly away) 2010-11-23 10:10:54 PST
*** Bug 614150 has been marked as a duplicate of this bug. ***
Comment 3 User image Benoit Jacob [:bjacob] (mostly away) 2010-11-23 10:16:41 PST
Created attachment 492698 [details] [diff] [review]
fix upside-down bug

Move the flipping (required for GL<->Thebes interop) from WebGLContext::Render
to GLContext::ReadPixelsIntoImageSurface.

Indeed this was not a WebGL-specific bug as far as I can see,
GLContext::ReadPixelsIntoImageSurface was wrong, and for WebGL this patch makes
both 'View image' and 'print preview' work for me.

The flipping is done in the same pass as the RGBA->BGRA swizzling for better
performance. I didn't check the generated code but the __restrict qualifiers
should allow the compiler to do a good job.
Comment 4 User image Joe Drew (not getting mail) 2010-11-26 13:20:35 PST
Make sure the __restrict stuff passes through try!
Comment 5 User image Benoit Jacob [:bjacob] (mostly away) 2010-11-26 13:39:02 PST
It does: we already use __restrict e.g. in

It also passes on every other compiler that I know of e.g. Sun, XLC, LLVM, QCC...

^ Gregg: by the way, this is the file that we borrowed originally from WebKit and you might want to have a look at our improvements there (__restrict and removing a few divisions).
Comment 6 User image Vladimir Vukicevic [:vlad] [:vladv] 2010-11-29 13:25:05 PST
Comment on attachment 492698 [details] [diff] [review]
fix upside-down bug

There are other callers of ReadPixelsIntoImageSurface -- I find it hard to believe that they'll still remain correct if the image is flipped from what it was before :-)

I'd suggest that ReadPixelsIntoImageSurface gets an option to specify whether to flip the image or not (since it has to do RGB swapping anyway, it can do it more efficiently) -- defaulting to FALSE.  The View Image bug is because WebGLContext::GetInputStream was calling ReadPixelsIntoImageSurface and not flipping it.  Not sure why the print issue is happening, but I'm guessing similar...
Comment 7 User image Vladimir Vukicevic [:vlad] [:vladv] 2010-12-13 15:01:06 PST
print-preview looks right-side-up for me currently; I believe this was fixed with a number of image-getting changes.  reopen if still broken..
Comment 8 User image Benoit Jacob [:bjacob] (mostly away) 2011-01-31 08:36:57 PST
Indeed it is working now -- despite bug 625353!

Note You need to log in before you can comment on or make changes to this bug.