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

RESOLVED DUPLICATE of bug 528042

Status

()

Core
Canvas: WebGL
RESOLVED DUPLICATE of bug 528042
9 years ago
6 years ago

People

(Reporter: Ilmari Heikkinen, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

9 years ago
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.
(Reporter)

Comment 1

9 years ago
Created attachment 364512 [details] [diff] [review]
Makes nsHTMLCanvasElement::ToDataURLImpl use mCurrentContextId for getting the context to read from

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.
(Reporter)

Comment 3

9 years ago
Created attachment 364687 [details] [diff] [review]
context id fix, now errors if there's no current context id
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 ?
(Reporter)

Comment 5

8 years ago
Yeah, this is a dup.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 528042

Updated

6 years ago
Attachment #364687 - Flags: review?(vladimir)
You need to log in before you can comment on or make changes to this bug.