Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
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 WebGLFramebufferAttachable::AttachmentPoint*
15 WebGLFramebufferAttachable::Contains(const WebGLFramebuffer* fb, GLenum attachment)
16 {
17 AttachmentPoint* first = mAttachmentPoints.begin();
18 AttachmentPoint* last = mAttachmentPoints.end();
20 for (; first != last; ++first) {
21 if (first->mFB == fb && first->mAttachment == attachment)
22 return first;
23 }
25 return nullptr;
26 }
28 void
29 WebGLFramebufferAttachable::AttachTo(WebGLFramebuffer* fb, GLenum attachment)
30 {
31 MOZ_ASSERT(fb);
32 if (!fb)
33 return;
35 if (Contains(fb, attachment))
36 return; // Already attached. Ignore.
38 mAttachmentPoints.append(AttachmentPoint(fb, attachment));
39 }
41 void
42 WebGLFramebufferAttachable::DetachFrom(WebGLFramebuffer* fb, GLenum attachment)
43 {
44 MOZ_ASSERT(fb);
45 if (!fb)
46 return;
48 AttachmentPoint* point = Contains(fb, attachment);
49 if (!point) {
50 MOZ_ASSERT(false, "Is not attached to FB");
51 return;
52 }
54 mAttachmentPoints.erase(point);
55 }
57 void
58 WebGLFramebufferAttachable::NotifyFBsStatusChanged()
59 {
60 AttachmentPoint* first = mAttachmentPoints.begin();
61 AttachmentPoint* last = mAttachmentPoints.end();
62 for ( ; first != last; ++first)
63 first->mFB->NotifyAttachableChanged();
64 }