Edit

kc3-lang/angle/src/libANGLE/Renderbuffer.cpp

Branch :

  • Show log

    Commit

  • Author : Jamie Madill
    Date : 2015-03-20 15:29:42
    Hash : bdd419f9
    Message : Fix ResourceManager create-on-bind reallocations. *re-land with build fix for Clang* We had a funny bug where the Handle Allocator would re-allocate reserved handles after the app layer creates one with Bind rather than using Gen. This affects Textures, Buffers and Renderbuffers. Fix this by using a different allocation scheme. It should still be fast on the "good" case (using Gen) and use tree lookups on the bind case. Also add some unit tests. BUG=angleproject:942 Change-Id: I63ce608fcd6a11f92e2b5421f090551934e729ed Reviewed-on: https://chromium-review.googlesource.com/261591 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>

  • src/libANGLE/Renderbuffer.cpp
  • //
    // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    
    // Renderbuffer.cpp: Implements the renderer-agnostic gl::Renderbuffer class,
    // GL renderbuffer objects and related functionality.
    // [OpenGL ES 2.0.24] section 4.4.3 page 108.
    
    #include "libANGLE/Renderbuffer.h"
    
    #include "common/utilities.h"
    #include "libANGLE/FramebufferAttachment.h"
    #include "libANGLE/Texture.h"
    #include "libANGLE/formatutils.h"
    #include "libANGLE/renderer/d3d/RenderTargetD3D.h"
    #include "libANGLE/renderer/RenderbufferImpl.h"
    
    namespace gl
    {
    Renderbuffer::Renderbuffer(rx::RenderbufferImpl *impl, GLuint id)
      : RefCountObject(id),
        mRenderbuffer(impl),
        mWidth(0),
        mHeight(0),
        mInternalFormat(GL_RGBA4),
        mSamples(0)
    {
    }
    
    Renderbuffer::~Renderbuffer()
    {
        SafeDelete(mRenderbuffer);
    }
    
    Error Renderbuffer::setStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples)
    {
        Error error = mRenderbuffer->setStorage(width, height, internalformat, samples);
        if (error.isError())
        {
            return error;
        }
    
        mWidth = width;
        mHeight = height;
        mInternalFormat = internalformat;
        mSamples = samples;
    
        return Error(GL_NO_ERROR);
    }
    
    rx::RenderbufferImpl *Renderbuffer::getImplementation()
    {
        ASSERT(mRenderbuffer);
        return mRenderbuffer;
    }
    
    GLsizei Renderbuffer::getWidth() const
    {
        return mWidth;
    }
    
    GLsizei Renderbuffer::getHeight() const
    {
        return mHeight;
    }
    
    GLenum Renderbuffer::getInternalFormat() const
    {
        return mInternalFormat;
    }
    
    GLsizei Renderbuffer::getSamples() const
    {
        return mSamples;
    }
    
    GLuint Renderbuffer::getRedSize() const
    {
        return GetInternalFormatInfo(mInternalFormat).redBits;
    }
    
    GLuint Renderbuffer::getGreenSize() const
    {
        return GetInternalFormatInfo(mInternalFormat).greenBits;
    }
    
    GLuint Renderbuffer::getBlueSize() const
    {
        return GetInternalFormatInfo(mInternalFormat).blueBits;
    }
    
    GLuint Renderbuffer::getAlphaSize() const
    {
        return GetInternalFormatInfo(mInternalFormat).alphaBits;
    }
    
    GLuint Renderbuffer::getDepthSize() const
    {
        return GetInternalFormatInfo(mInternalFormat).depthBits;
    }
    
    GLuint Renderbuffer::getStencilSize() const
    {
        return GetInternalFormatInfo(mInternalFormat).stencilBits;
    }
    
    }