1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/src/WebGLRenderbuffer.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,81 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef WEBGLRENDERBUFFER_H_ 1.10 +#define WEBGLRENDERBUFFER_H_ 1.11 + 1.12 +#include "WebGLObjectModel.h" 1.13 +#include "WebGLFramebufferAttachable.h" 1.14 + 1.15 +#include "nsWrapperCache.h" 1.16 + 1.17 +#include "mozilla/LinkedList.h" 1.18 + 1.19 +namespace mozilla { 1.20 + 1.21 +class WebGLRenderbuffer MOZ_FINAL 1.22 + : public nsWrapperCache 1.23 + , public WebGLRefCountedObject<WebGLRenderbuffer> 1.24 + , public LinkedListElement<WebGLRenderbuffer> 1.25 + , public WebGLRectangleObject 1.26 + , public WebGLContextBoundObject 1.27 + , public WebGLFramebufferAttachable 1.28 +{ 1.29 +public: 1.30 + WebGLRenderbuffer(WebGLContext *context); 1.31 + 1.32 + ~WebGLRenderbuffer() { 1.33 + DeleteOnce(); 1.34 + } 1.35 + 1.36 + void Delete(); 1.37 + 1.38 + bool HasEverBeenBound() { return mHasEverBeenBound; } 1.39 + void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; } 1.40 + 1.41 + bool HasUninitializedImageData() const { return mImageDataStatus == WebGLImageDataStatus::UninitializedImageData; } 1.42 + void SetImageDataStatus(WebGLImageDataStatus x) { 1.43 + // there is no way to go from having image data to not having any 1.44 + MOZ_ASSERT(x != WebGLImageDataStatus::NoImageData || 1.45 + mImageDataStatus == WebGLImageDataStatus::NoImageData); 1.46 + mImageDataStatus = x; 1.47 + } 1.48 + 1.49 + GLenum InternalFormat() const { return mInternalFormat; } 1.50 + void SetInternalFormat(GLenum aInternalFormat) { mInternalFormat = aInternalFormat; } 1.51 + 1.52 + GLenum InternalFormatForGL() const { return mInternalFormatForGL; } 1.53 + void SetInternalFormatForGL(GLenum aInternalFormatForGL) { mInternalFormatForGL = aInternalFormatForGL; } 1.54 + 1.55 + int64_t MemoryUsage() const; 1.56 + 1.57 + WebGLContext *GetParentObject() const { 1.58 + return Context(); 1.59 + } 1.60 + 1.61 + void BindRenderbuffer() const; 1.62 + void RenderbufferStorage(GLenum internalFormat, GLsizei width, GLsizei height) const; 1.63 + void FramebufferRenderbuffer(GLenum attachment) const; 1.64 + // Only handles a subset of `pname`s. 1.65 + GLint GetRenderbufferParameter(GLenum target, GLenum pname) const; 1.66 + 1.67 + virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE; 1.68 + 1.69 + NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLRenderbuffer) 1.70 + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLRenderbuffer) 1.71 + 1.72 +protected: 1.73 + GLuint mPrimaryRB; 1.74 + GLuint mSecondaryRB; 1.75 + GLenum mInternalFormat; 1.76 + GLenum mInternalFormatForGL; 1.77 + bool mHasEverBeenBound; 1.78 + WebGLImageDataStatus mImageDataStatus; 1.79 + 1.80 + friend class WebGLFramebuffer; 1.81 +}; 1.82 +} // namespace mozilla 1.83 + 1.84 +#endif