content/canvas/src/WebGLFramebufferAttachable.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 }

mercurial