Closed Bug 480305 Opened 15 years ago Closed 14 years ago

[c3d] glReadPixels support

Categories

(Core :: Graphics: CanvasWebGL, enhancement)

x86
Linux
enhancement
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: ilmari.heikkinen, Unassigned)

Details

Attachments

(2 files, 2 obsolete files)

User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2a1pre) Gecko/20090226 Minefield/3.2a1pre
Build Identifier: 

There's no gl.readPixels in the canvas3d extension. readPixels is useful for reading from the currently bound framebuffer (not necessarily the visible image), which makes it useful for things like picking by unique color and reading back results of off-screen computation.

Reproducible: Always

Steps to Reproduce:
1. gl.readPixels(0,0,1,1, gl.RGBA, gl.UNSIGNED_BYTE)

Actual Results:  
Error, no method named readPixels.

Expected Results:  
Should return an ImageData object {width: 1, height: 1, data: [r,g,b,a]}.
Attached patch gl.readPixels implementation (obsolete) — Splinter Review
Attached file Testcase for gl.readPixels (obsolete) —
Renders to an FBO, reads from it and uses putImageData to draw the read image on a 2D canvas. Should have a large blank canvas on the left and a small canvas with a clipped downwards-pointing green rectangle on a yellow field.
s/rectangle/triangle
The above patch copies PRBool IsCallerTrustedForRead() over from nsContentUtils.cpp, as I had no luck with #include "nsContentUtils.h". If someone more familiar with the system manages to make the include work, they shall be praised, and the copied implementation removed.

Another issue is that glReadPixels returns an y-flipped image. I don't know if it should be flipped or left to user.

And I don't know if the data array pixel component order remains r,g,b,a on big-endian, so that should be tested.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attachment #364311 - Attachment is obsolete: true
Attachment #365145 - Flags: review?(vladimir)
Component: Canvas: 2D → Canvas: WebGL
Closing FIXED as the WebGL support in Gecko does support a readPixels function.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Resolution: FIXED → WORKSFORME
Attachment #365145 - Flags: review?(vladimir)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: