Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / dom / canvas / WebGLFramebufferAttachable.cpp
blob252f1ff7cdb1b8f08479faf11a01d05053c7a4db
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;
14 void
15 WebGLFramebufferAttachable::AttachTo(WebGLFramebuffer* fb, GLenum attachment)
17 MOZ_ASSERT(fb);
18 if (!fb)
19 return;
21 if (mAttachmentPoints.Contains(AttachmentPoint(fb, attachment)))
22 return; // Already attached. Ignore.
24 mAttachmentPoints.AppendElement(AttachmentPoint(fb, attachment));
27 void
28 WebGLFramebufferAttachable::DetachFrom(WebGLFramebuffer* fb, GLenum attachment)
30 MOZ_ASSERT(fb);
31 if (!fb)
32 return;
34 const size_t i = mAttachmentPoints.IndexOf(AttachmentPoint(fb, attachment));
35 if (i == mAttachmentPoints.NoIndex) {
36 MOZ_ASSERT(false, "Is not attached to FB");
37 return;
40 mAttachmentPoints.RemoveElementAt(i);
43 void
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();