Closed Bug 1049887 Opened 10 years ago Closed 10 years ago

gl::ScopedScissorRect doesn't properly restore scissor rect after Fennec Java code modifies it

Categories

(Core :: Graphics, defect)

All
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla34

People

(Reporter: kats, Assigned: kats)

Details

Attachments

(1 file, 2 obsolete files)

The code at [1] is intended to save the current scissor rect and restore it at the end of the function, so as to guard against changes in the java code at [2].

However, this doesn't work. When the ScopedScissorRect is created, it reads the current scissor rect, which GLContext.h actually provides from the internally-cached mScissorRect [3]. That's fine. When the ScopedScissorRect is destroyed though, it calls fScissor which then compares the value to the cached value and does an early return at [4].

So even though the Java code modifies the scissor rect directly in the GL context, the ScopedScissorRect and GLContext don't know about this, and so don't think it needs to be restored.

[1] http://mxr.mozilla.org/mozilla-central/source/widget/android/nsWindow.cpp?rev=8581ea023552#2267
[2] http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/gfx/LayerRenderer.java?rev=0a020e033338#598
[3] http://mxr.mozilla.org/mozilla-central/source/gfx/gl/GLContext.h?rev=ff07dcb918fd#1157
[4] http://mxr.mozilla.org/mozilla-central/source/gfx/gl/GLContext.h?rev=ff07dcb918fd#1494
Attached patch Patch (obsolete) — Splinter Review
Assignee: nobody → bugmail.mozilla
Attachment #8468773 - Flags: review?(bjacob)
Attached patch Tag-along doc update (obsolete) — Splinter Review
Attachment #8468774 - Flags: review?(bjacob)
I find it very scary to have to add this bool flag here, because if we can't assume that we're the only ones making GL calls on this GL context, then many other assumptions made in GLContext are wrong.

Why does the GL work in [2] have to be made in java? Can't it be made in C++ code going through GLContext instead?
Flags: needinfo?(bugmail.mozilla)
Or if GL state changes have to be made direcly in Java, at least restore state locally in that Java code before reverting back to C++ code.
Comment on attachment 8468773 [details] [diff] [review]
Patch

OK, I'll look at other options here.
Attachment #8468773 - Flags: review?(bjacob) → review-
Flags: needinfo?(bugmail.mozilla)
Attachment #8468774 - Flags: review?(bjacob)
How about this?
Attachment #8468773 - Attachment is obsolete: true
Attachment #8468774 - Attachment is obsolete: true
Attachment #8475165 - Flags: review?(bjacob)
(Feel free to bounce the review to snorp if you think he's a more appropriate reviewer)
Comment on attachment 8475165 [details] [diff] [review]
Reset GL state in java before returning to c++

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

Yes, snorp may be a more appropriate reviewer for this, since this turned out to be a patch in Android-specific code. Also, I'm totally swamped (just moved to a new house, on top of lots of work).
Attachment #8475165 - Flags: review?(bjacob) → review?(snorp)
Comment on attachment 8475165 [details] [diff] [review]
Reset GL state in java before returning to c++

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

Ugh. I really wish we could ditch all the Java GL code.
Attachment #8475165 - Flags: review?(snorp) → review+
https://hg.mozilla.org/mozilla-central/rev/d60356c72b78
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: