2014-03-03 23:14:35 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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 "WebGLFramebuffer.h"
|
|
|
|
#include "WebGLRenderbuffer.h"
|
|
|
|
#include "WebGLTexture.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
|
|
|
|
void
|
2014-09-25 08:21:33 -07:00
|
|
|
WebGLFramebufferAttachable::AttachTo(WebGLFramebuffer* fb, FBAttachment attachment)
|
2014-03-03 23:14:35 -08:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(fb);
|
|
|
|
if (!fb)
|
|
|
|
return;
|
|
|
|
|
2014-07-30 12:52:06 -07:00
|
|
|
if (mAttachmentPoints.Contains(AttachmentPoint(fb, attachment)))
|
2014-03-03 23:14:35 -08:00
|
|
|
return; // Already attached. Ignore.
|
|
|
|
|
2014-07-30 12:52:06 -07:00
|
|
|
mAttachmentPoints.AppendElement(AttachmentPoint(fb, attachment));
|
2014-03-03 23:14:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-09-25 08:21:33 -07:00
|
|
|
WebGLFramebufferAttachable::DetachFrom(WebGLFramebuffer* fb, FBAttachment attachment)
|
2014-03-03 23:14:35 -08:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(fb);
|
|
|
|
if (!fb)
|
|
|
|
return;
|
|
|
|
|
2014-07-30 12:52:06 -07:00
|
|
|
const size_t i = mAttachmentPoints.IndexOf(AttachmentPoint(fb, attachment));
|
|
|
|
if (i == mAttachmentPoints.NoIndex) {
|
2014-03-03 23:14:35 -08:00
|
|
|
MOZ_ASSERT(false, "Is not attached to FB");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-30 12:52:06 -07:00
|
|
|
mAttachmentPoints.RemoveElementAt(i);
|
2014-03-03 23:14:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WebGLFramebufferAttachable::NotifyFBsStatusChanged()
|
|
|
|
{
|
2014-07-30 12:52:07 -07:00
|
|
|
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");
|
2014-07-30 12:52:06 -07:00
|
|
|
mAttachmentPoints[i].mFB->NotifyAttachableChanged();
|
2014-07-30 12:52:07 -07:00
|
|
|
}
|
2014-03-03 23:14:35 -08:00
|
|
|
}
|