Closed Bug 962392 Opened 11 years ago Closed 11 years ago

WebGLFramebuffer generally exposes RectangleObject getter as nullable, even if it can only be null in some cases

Categories

(Core :: Graphics: CanvasWebGL, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29

People

(Reporter: jgilbert, Assigned: jgilbert)

References

Details

Attachments

(3 files, 2 obsolete files)

Going through bug 948002, I saw a number of uses of RectangleObject() that didn't really check if it was null, even if the function returning null has a very specific meaning. Generally, this means that things fail quietly. I want to make them more fragile so we can be more confident we're asking the right questions.
Attached patch sharp-fb-rects (obsolete) (deleted) — Splinter Review
I only need one reviewer, really. I'm sure you guys are both jumping to review this sort of patch, so I'll offer it to both of you. :P There's a bunch of style normalizations in here. Splitting it out can probably be done, but will be a pain for me. Let me know if the inter-mingled style changes are too much. One change here is use of return-by-reference for non-nullable retvals. Another is a refactor of the CheckFramebufferStatus code, and condensing the two parallel implementations into Framebuffer::CheckFramebufferStatus. Another is a clarification (largely via asserts) of when an FB actually has a consistent valid RectObject. An FB basically has to be FB-complete in order to get anything useful for a RectObject. In line with the previous change is paring back the assumption that colorAttach[0] is always present. I don't think it's gone, but it should be closer to being gone.
Assignee: nobody → jgilbert
Attachment #8363400 - Flags: review?(dglastonbury)
Attachment #8363400 - Flags: review?(bjacob)
Comment on attachment 8363400 [details] [diff] [review] sharp-fb-rects Review of attachment 8363400 [details] [diff] [review]: ----------------------------------------------------------------- ::: content/canvas/src/WebGLFramebuffer.cpp @@ +402,5 @@ > bool > +WebGLFramebuffer::HasDefinedAttachments() const > +{ > + bool hasAttachments = false; > + I'm leaving a ton of empty whitespace here. My bad.
Attached patch wsfix-pre (deleted) — Splinter Review
This is just stripping end-of-line whitespace.
Attachment #8363400 - Attachment is obsolete: true
Attachment #8363400 - Flags: review?(dglastonbury)
Attachment #8363400 - Flags: review?(bjacob)
Attachment #8363408 - Flags: review?(dglastonbury)
Attached patch patch (deleted) — Splinter Review
Maybe I'll give bjacob a break for once. Feel free to reassign review, Dan.
Attachment #8363409 - Flags: review?(dglastonbury)
Comment on attachment 8363408 [details] [diff] [review] wsfix-pre Double plus good. But I've already cleaned up the whitespace in a patch in 948002, so we have to decide in which order to land these patches.
Attachment #8363408 - Flags: review?(dglastonbury) → review+
Comment on attachment 8363409 [details] [diff] [review] patch Review of attachment 8363409 [details] [diff] [review]: ----------------------------------------------------------------- Only nits. ::: content/canvas/src/WebGLFramebuffer.cpp @@ +74,5 @@ > return false; > + > + if (Renderbuffer()) { > + return Renderbuffer()->HasUninitializedImageData(); > + } else if (Texture()) { No else after return. Occurs throughout this file. @@ +108,5 @@ > + return true; > + else if (Renderbuffer()) > + return true; > + > + return false; No else after return, but I don't prefer this style. bool WebGLFramebuffer::Attachment::HasImage() const { return (Texture() && Texture()->HasImageInfoAt(mTexImageTarget, mTexImageLevel)) || Renderbuffer(); } Is more concise and, IMHO, easier to read. @@ +123,5 @@ > + } else if (Renderbuffer()) { > + return *Renderbuffer(); > + } > + > + MOZ_CRASH("Should not get here."); Is this overly paranoid? (double check of the assert at the top of function) @@ +176,3 @@ > return IsValidAttachedTextureColorFormat(format); > } > + MOZ_ASSERT(false, "Invalid WebGL attachment point?"); What is the difference because MOZ_CRASH(...) and MOZ_ASSERT(false, ...)? @@ +365,5 @@ > > void > +WebGLFramebuffer::DetachTexture(const WebGLTexture* tex) > +{ > + for (size_t i = 0; i < mColorAttachments.Length(); i++) { I'm not a fan of calling container class "size" methods on every iteration. @@ +518,5 @@ > + if (HasIncompleteAttachments()) > + return LOCAL_GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; > + > + if (!AllImageRectsMatch()) > + return LOCAL_GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; // No consistent size // Inconsistent size ::: content/canvas/src/WebGLFramebuffer.h @@ +126,5 @@ > int(mStencilAttachment.IsDefined()) + > int(mDepthStencilAttachment.IsDefined()) >= 2; > } > > + size_t ColorAttachmentCount() const { This is only called in once in the code. To me appears to be a go candidate to remove.
Attachment #8363409 - Flags: review?(dglastonbury) → review+
Blocks: 948002
Attached patch fixups (obsolete) (deleted) — Splinter Review
More fixups of nits.
Attachment #8364148 - Flags: review?(dglastonbury)
Comment on attachment 8364148 [details] [diff] [review] fixups Review of attachment 8364148 [details] [diff] [review]: ----------------------------------------------------------------- M-x delete-trailing-whitespace
Attachment #8364148 - Flags: review?(dglastonbury) → review-
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
Attached patch fixups (deleted) — Splinter Review
Attachment #8364148 - Attachment is obsolete: true
Attachment #8365327 - Flags: review?(dglastonbury)
Comment on attachment 8365327 [details] [diff] [review] fixups Review of attachment 8365327 [details] [diff] [review]: ----------------------------------------------------------------- GTG.
Attachment #8365327 - Flags: review?(dglastonbury) → review+
Attachment #8363408 - Flags: checkin+
Attachment #8363409 - Flags: checkin+
Attachment #8365327 - Flags: checkin?
Status: RESOLVED → REOPENED
Keywords: checkin-needed
Resolution: FIXED → ---
Comment on attachment 8365327 [details] [diff] [review] fixups Doesn't apply cleanly. Please rebase.
Attachment #8365327 - Flags: checkin? → checkin-
> What is the difference because MOZ_CRASH(...) and MOZ_ASSERT(false, ...)? MOZ_ASSERT is debug-only.
By using MOZ_ASSERT instead of MOZ_CRASH, bug 974744 doesn't bring down the browser, for example ;)
Status: REOPENED → RESOLVED
Closed: 11 years ago11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: