1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "WebGLContext.h"
7 #include "WebGLFramebufferAttachable.h"
8 #include "WebGLFramebuffer.h"
9 #include "WebGLRenderbuffer.h"
10 #include "WebGLTexture.h"
12 using namespace mozilla
;
15 WebGLFramebufferAttachable::AttachTo(WebGLFramebuffer
* fb
, GLenum attachment
)
21 if (mAttachmentPoints
.Contains(AttachmentPoint(fb
, attachment
)))
22 return; // Already attached. Ignore.
24 mAttachmentPoints
.AppendElement(AttachmentPoint(fb
, attachment
));
28 WebGLFramebufferAttachable::DetachFrom(WebGLFramebuffer
* fb
, GLenum attachment
)
34 const size_t i
= mAttachmentPoints
.IndexOf(AttachmentPoint(fb
, attachment
));
35 if (i
== mAttachmentPoints
.NoIndex
) {
36 MOZ_ASSERT(false, "Is not attached to FB");
40 mAttachmentPoints
.RemoveElementAt(i
);
44 WebGLFramebufferAttachable::NotifyFBsStatusChanged()
46 for (size_t i
= 0; i
< mAttachmentPoints
.Length(); ++i
) {
47 MOZ_ASSERT(mAttachmentPoints
[i
].mFB
,
48 "Unexpected null pointer; seems that a WebGLFramebuffer forgot to call DetachFrom before dying");
49 mAttachmentPoints
[i
].mFB
->NotifyAttachableChanged();