Bug 1017865 - Refactor attach/detach for FB attachments. - r=kamidphish
This commit is contained in:
@@ -3,35 +3,28 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "WebGLContext.h"
|
||||
#include "WebGLFramebufferAttachable.h"
|
||||
|
||||
#include "WebGLContext.h"
|
||||
#include "WebGLFramebuffer.h"
|
||||
#include "WebGLRenderbuffer.h"
|
||||
#include "WebGLTexture.h"
|
||||
|
||||
using namespace mozilla;
|
||||
namespace mozilla {
|
||||
|
||||
void
|
||||
WebGLFramebufferAttachable::AttachTo(WebGLFramebuffer* fb, FBAttachment attachment)
|
||||
WebGLFramebufferAttachable::MarkAttachment(const WebGLFramebuffer::AttachPoint& attachment)
|
||||
{
|
||||
MOZ_ASSERT(fb);
|
||||
if (!fb)
|
||||
return;
|
||||
|
||||
if (mAttachmentPoints.Contains(AttachmentPoint(fb, attachment)))
|
||||
if (mAttachmentPoints.Contains(&attachment))
|
||||
return; // Already attached. Ignore.
|
||||
|
||||
mAttachmentPoints.AppendElement(AttachmentPoint(fb, attachment));
|
||||
mAttachmentPoints.AppendElement(&attachment);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLFramebufferAttachable::DetachFrom(WebGLFramebuffer* fb, FBAttachment attachment)
|
||||
WebGLFramebufferAttachable::UnmarkAttachment(const WebGLFramebuffer::AttachPoint& attachment)
|
||||
{
|
||||
MOZ_ASSERT(fb);
|
||||
if (!fb)
|
||||
return;
|
||||
|
||||
const size_t i = mAttachmentPoints.IndexOf(AttachmentPoint(fb, attachment));
|
||||
const size_t i = mAttachmentPoints.IndexOf(&attachment);
|
||||
if (i == mAttachmentPoints.NoIndex) {
|
||||
MOZ_ASSERT(false, "Is not attached to FB");
|
||||
return;
|
||||
@@ -41,11 +34,13 @@ WebGLFramebufferAttachable::DetachFrom(WebGLFramebuffer* fb, FBAttachment attach
|
||||
}
|
||||
|
||||
void
|
||||
WebGLFramebufferAttachable::NotifyFBsStatusChanged()
|
||||
WebGLFramebufferAttachable::InvalidateStatusOfAttachedFBs() const
|
||||
{
|
||||
for (size_t i = 0; i < mAttachmentPoints.Length(); ++i) {
|
||||
MOZ_ASSERT(mAttachmentPoints[i].mFB,
|
||||
"Unexpected null pointer; seems that a WebGLFramebuffer forgot to call DetachFrom before dying");
|
||||
mAttachmentPoints[i].mFB->NotifyAttachableChanged();
|
||||
const size_t count = mAttachmentPoints.Length();
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
MOZ_ASSERT(mAttachmentPoints[i]->mFB);
|
||||
mAttachmentPoints[i]->mFB->InvalidateFramebufferStatus();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
Reference in New Issue
Block a user