Closed Bug 871094 Opened 11 years ago Closed 11 years ago

Add warning for gl.clear(0)

Categories

(Core :: Graphics: CanvasWebGL, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla26

People

(Reporter: jgilbert, Assigned: guillaume.abadie)

Details

Attachments

(1 file, 2 obsolete files)

Calling `gl.clear(0)` is never cheaper than not calling it at all.

The real danger is that `gl.clear(gl.GARBAGE)` is coerced to `gl.clear(0)`, which is an otherwise valid call.

We should warn about this, so (totally hypothetically) someone doesn't waste time trying to figure out why `gl.clear(gl.CLEAR_BUFFER_BIT)` doesn't work, when they mean `gl.clear(gl.COLOR_BUFFER_BIT)`.
Assignee: nobody → gabadie
Attached patch patch for landing (obsolete) — Splinter Review
patch adding a warning message when calling gl.clear(0)
Attachment #766061 - Flags: review?(bjacob)
Comment on attachment 766061 [details] [diff] [review]
patch for landing

Review of attachment 766061 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/canvas/src/WebGLContextGL.cpp
@@ +592,5 @@
>      if (mask != m)
>          return ErrorInvalidValue("clear: invalid mask bits");
>  
> +    if (mask == 0) {
> +        GenerateWarning("useless call gl.clear(0)");

I would reword this to something like 'Calling gl.clear(0) has no effect.'.
Attached patch patch revision 1 (obsolete) — Splinter Review
Attachment #766061 - Attachment is obsolete: true
Attachment #766061 - Flags: review?(bjacob)
Attachment #766114 - Flags: review?(jgilbert)
Comment on attachment 766114 [details] [diff] [review]
patch revision 1

Review of attachment 766114 [details] [diff] [review]:
-----------------------------------------------------------------

That should be good enough. It should at least make people ask themselves if they really meant to call it with 0.
Attachment #766114 - Flags: review?(jgilbert) → review+
Keywords: checkin-needed
This doesn't apply to inbound. Please rebase.
Keywords: checkin-needed
Attached patch clear-zero.patchSplinter Review
Actually we shouldn't bail at this warning. Clear() should still trigger any GL errors it's supposed to, even if won't be doing anything.
Attachment #766114 - Attachment is obsolete: true
Attachment #786054 - Flags: review?(gabadie)
Attachment #786054 - Flags: review?(gabadie) → review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/4a638ac362cb
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: