daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 7 | // Renderbuffer.h: Defines the wrapper class gl::Renderbuffer, as well as the |
| 8 | // class hierarchy used to store its contents: RenderbufferStorage, Colorbuffer, |
| 9 | // DepthStencilbuffer, Depthbuffer and Stencilbuffer. Implements GL renderbuffer |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 10 | // objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108. |
| 11 | |
| 12 | #ifndef LIBGLESV2_RENDERBUFFER_H_ |
| 13 | #define LIBGLESV2_RENDERBUFFER_H_ |
| 14 | |
shannon.woods%transgaming.com@gtempaccount.com | f26ddae | 2013-04-13 03:29:13 +0000 | [diff] [blame] | 15 | #include <GLES3/gl3.h> |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 16 | #include <GLES2/gl2.h> |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 17 | |
alokp@chromium.org | ea0e1af | 2010-03-22 19:33:14 +0000 | [diff] [blame] | 18 | #include "common/angleutils.h" |
apatrick@chromium.org | b66a701 | 2012-01-23 20:04:48 +0000 | [diff] [blame] | 19 | #include "common/RefCountObject.h" |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame^] | 20 | #include "libGLESv2/FramebufferAttachment.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 21 | |
daniel@transgaming.com | 70062c9 | 2012-11-28 19:32:30 +0000 | [diff] [blame] | 22 | namespace rx |
| 23 | { |
| 24 | class Renderer; |
shannon.woods@transgaming.com | d2811d6 | 2013-02-28 23:11:19 +0000 | [diff] [blame] | 25 | class SwapChain; |
| 26 | class RenderTarget; |
Geoff Lang | 391c8c5 | 2013-09-17 17:05:51 -0400 | [diff] [blame] | 27 | class TextureStorage; |
daniel@transgaming.com | 70062c9 | 2012-11-28 19:32:30 +0000 | [diff] [blame] | 28 | } |
| 29 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 30 | namespace gl |
| 31 | { |
Geoff Lang | d5d8e39 | 2013-07-25 16:53:03 -0400 | [diff] [blame] | 32 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 33 | // A class derived from RenderbufferStorage is created whenever glRenderbufferStorage |
| 34 | // is called. The specific concrete type depends on whether the internal format is |
| 35 | // colour depth, stencil or packed depth/stencil. |
Jamie Madill | 3c7fa22 | 2014-06-05 13:08:51 -0400 | [diff] [blame] | 36 | class RenderbufferStorage : public FramebufferAttachmentInterface |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 37 | { |
| 38 | public: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 39 | RenderbufferStorage(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 40 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 41 | virtual ~RenderbufferStorage() = 0; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 42 | |
daniel@transgaming.com | d186dc7 | 2012-11-28 19:40:16 +0000 | [diff] [blame] | 43 | virtual rx::RenderTarget *getRenderTarget(); |
| 44 | virtual rx::RenderTarget *getDepthStencil(); |
Geoff Lang | 391c8c5 | 2013-09-17 17:05:51 -0400 | [diff] [blame] | 45 | virtual rx::TextureStorage *getTextureStorage(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 46 | |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 47 | virtual GLsizei getWidth() const; |
| 48 | virtual GLsizei getHeight() const; |
| 49 | virtual GLenum getInternalFormat() const; |
daniel@transgaming.com | 20d3666 | 2012-10-31 19:51:43 +0000 | [diff] [blame] | 50 | virtual GLenum getActualFormat() const; |
daniel@transgaming.com | d14558a | 2011-11-09 17:46:18 +0000 | [diff] [blame] | 51 | virtual GLsizei getSamples() const; |
daniel@transgaming.com | 092bd48 | 2010-05-12 03:39:36 +0000 | [diff] [blame] | 52 | |
daniel@transgaming.com | fbc3952 | 2011-11-11 04:10:28 +0000 | [diff] [blame] | 53 | virtual unsigned int getSerial() const; |
Geoff Lang | 784371d | 2014-05-16 12:39:04 -0400 | [diff] [blame] | 54 | |
| 55 | virtual bool isTexture() const; |
| 56 | virtual unsigned int getTextureSerial() const; |
daniel@transgaming.com | fbc3952 | 2011-11-11 04:10:28 +0000 | [diff] [blame] | 57 | |
Geoff Lang | 8040f57 | 2013-07-25 16:49:54 -0400 | [diff] [blame] | 58 | static unsigned int issueSerials(GLuint count); |
daniel@transgaming.com | fbc3952 | 2011-11-11 04:10:28 +0000 | [diff] [blame] | 59 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 60 | protected: |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 61 | GLsizei mWidth; |
| 62 | GLsizei mHeight; |
| 63 | GLenum mInternalFormat; |
daniel@transgaming.com | 20d3666 | 2012-10-31 19:51:43 +0000 | [diff] [blame] | 64 | GLenum mActualFormat; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 65 | GLsizei mSamples; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 66 | |
| 67 | private: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 68 | DISALLOW_COPY_AND_ASSIGN(RenderbufferStorage); |
daniel@transgaming.com | fbc3952 | 2011-11-11 04:10:28 +0000 | [diff] [blame] | 69 | |
| 70 | const unsigned int mSerial; |
| 71 | |
| 72 | static unsigned int mCurrentSerial; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 73 | }; |
| 74 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 75 | class Colorbuffer : public RenderbufferStorage |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 76 | { |
| 77 | public: |
daniel@transgaming.com | 70062c9 | 2012-11-28 19:32:30 +0000 | [diff] [blame] | 78 | Colorbuffer(rx::Renderer *renderer, rx::SwapChain *swapChain); |
| 79 | Colorbuffer(rx::Renderer *renderer, GLsizei width, GLsizei height, GLenum format, GLsizei samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 80 | |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 81 | virtual ~Colorbuffer(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 82 | |
daniel@transgaming.com | d186dc7 | 2012-11-28 19:40:16 +0000 | [diff] [blame] | 83 | virtual rx::RenderTarget *getRenderTarget(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 84 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 85 | private: |
| 86 | DISALLOW_COPY_AND_ASSIGN(Colorbuffer); |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 87 | |
daniel@transgaming.com | 042d1b4 | 2012-11-28 19:37:09 +0000 | [diff] [blame] | 88 | rx::RenderTarget *mRenderTarget; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 89 | }; |
| 90 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 91 | class DepthStencilbuffer : public RenderbufferStorage |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 92 | { |
| 93 | public: |
daniel@transgaming.com | 70062c9 | 2012-11-28 19:32:30 +0000 | [diff] [blame] | 94 | DepthStencilbuffer(rx::Renderer *renderer, rx::SwapChain *swapChain); |
| 95 | DepthStencilbuffer(rx::Renderer *renderer, GLsizei width, GLsizei height, GLsizei samples); |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 96 | |
| 97 | ~DepthStencilbuffer(); |
| 98 | |
daniel@transgaming.com | d186dc7 | 2012-11-28 19:40:16 +0000 | [diff] [blame] | 99 | virtual rx::RenderTarget *getDepthStencil(); |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 100 | |
daniel@transgaming.com | d14558a | 2011-11-09 17:46:18 +0000 | [diff] [blame] | 101 | protected: |
daniel@transgaming.com | 042d1b4 | 2012-11-28 19:37:09 +0000 | [diff] [blame] | 102 | rx::RenderTarget *mDepthStencil; |
daniel@transgaming.com | d14558a | 2011-11-09 17:46:18 +0000 | [diff] [blame] | 103 | |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 104 | private: |
| 105 | DISALLOW_COPY_AND_ASSIGN(DepthStencilbuffer); |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | class Depthbuffer : public DepthStencilbuffer |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 109 | { |
| 110 | public: |
daniel@transgaming.com | 70062c9 | 2012-11-28 19:32:30 +0000 | [diff] [blame] | 111 | Depthbuffer(rx::Renderer *renderer, GLsizei width, GLsizei height, GLsizei samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 112 | |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 113 | virtual ~Depthbuffer(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 114 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 115 | private: |
| 116 | DISALLOW_COPY_AND_ASSIGN(Depthbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 117 | }; |
| 118 | |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 119 | class Stencilbuffer : public DepthStencilbuffer |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 120 | { |
| 121 | public: |
daniel@transgaming.com | 70062c9 | 2012-11-28 19:32:30 +0000 | [diff] [blame] | 122 | Stencilbuffer(rx::Renderer *renderer, GLsizei width, GLsizei height, GLsizei samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 123 | |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 124 | virtual ~Stencilbuffer(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 125 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 126 | private: |
| 127 | DISALLOW_COPY_AND_ASSIGN(Stencilbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 128 | }; |
| 129 | } |
| 130 | |
| 131 | #endif // LIBGLESV2_RENDERBUFFER_H_ |