Closed Bug 480535 Opened 15 years ago Closed 14 years ago

[c3d] canvas.toDataURL doesn't work for non-2d contexts

Categories

(Core :: Graphics: CanvasWebGL, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 528042

People

(Reporter: ilmari.heikkinen, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

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

canvas.toDataURL doesn't work for non-2d contexts because nsHTMLCanvasElement::ToDataURLImpl uses "2d" as the context id to get the context to GetInputStream from.

It should rather use mCurrentContextId as the context id for getting the context.

Reproducible: Always

Steps to Reproduce:
1. canvas.getContext("moz-glweb20")
2. canvas.toDataURL()

Actual Results:  
Error in JavaScript console, due to it trying to get the 2d context for the canvas to read from. Which fails.

Expected Results:  
It should return the image/png data URL for the contents of the GL canvas.
Makes toDataURL work for non-2d contexts.
Comment on attachment 364512 [details] [diff] [review]
Makes nsHTMLCanvasElement::ToDataURLImpl use mCurrentContextId for getting the context to read from

Thanks for catching this..  also feel free to set review? on me (:vlad) on patches that are ready to go, and I'll give them a look over :)

This looks fine, though I'm wondering what we should do if there's no attached context to the canvas.  I'd probably rather throw an error, so maybe check is mCurrentContextId.IsEmpty() and just return NS_ERROR_FAILURE... then mCurrentContextId can be used instead of ctxId.
Attachment #364512 - Attachment is obsolete: true
Attachment #364687 - Flags: review?(vladimir)
Component: Canvas: 2D → Canvas: WebGL
what's the status of this? is this a dup with 528042 ?
Yeah, this is a dup.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
Attachment #364687 - Flags: review?(vladimir)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: