gfx/angle/src/libGLESv2/ResourceManager.h

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.

michael@0 1 //
michael@0 2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
michael@0 3 // Use of this source code is governed by a BSD-style license that can be
michael@0 4 // found in the LICENSE file.
michael@0 5 //
michael@0 6
michael@0 7 // ResourceManager.h : Defines the ResourceManager class, which tracks objects
michael@0 8 // shared by multiple GL contexts.
michael@0 9
michael@0 10 #ifndef LIBGLESV2_RESOURCEMANAGER_H_
michael@0 11 #define LIBGLESV2_RESOURCEMANAGER_H_
michael@0 12
michael@0 13 #define GL_APICALL
michael@0 14 #include <GLES2/gl2.h>
michael@0 15
michael@0 16 #ifdef _MSC_VER
michael@0 17 #include <hash_map>
michael@0 18 #else
michael@0 19 #include <unordered_map>
michael@0 20 #endif
michael@0 21
michael@0 22 #include "common/angleutils.h"
michael@0 23 #include "libGLESv2/angletypes.h"
michael@0 24 #include "libGLESv2/HandleAllocator.h"
michael@0 25
michael@0 26 namespace rx
michael@0 27 {
michael@0 28 class Renderer;
michael@0 29 }
michael@0 30
michael@0 31 namespace gl
michael@0 32 {
michael@0 33 class Buffer;
michael@0 34 class Shader;
michael@0 35 class Program;
michael@0 36 class Texture;
michael@0 37 class Renderbuffer;
michael@0 38
michael@0 39 class ResourceManager
michael@0 40 {
michael@0 41 public:
michael@0 42 explicit ResourceManager(rx::Renderer *renderer);
michael@0 43 ~ResourceManager();
michael@0 44
michael@0 45 void addRef();
michael@0 46 void release();
michael@0 47
michael@0 48 GLuint createBuffer();
michael@0 49 GLuint createShader(GLenum type);
michael@0 50 GLuint createProgram();
michael@0 51 GLuint createTexture();
michael@0 52 GLuint createRenderbuffer();
michael@0 53
michael@0 54 void deleteBuffer(GLuint buffer);
michael@0 55 void deleteShader(GLuint shader);
michael@0 56 void deleteProgram(GLuint program);
michael@0 57 void deleteTexture(GLuint texture);
michael@0 58 void deleteRenderbuffer(GLuint renderbuffer);
michael@0 59
michael@0 60 Buffer *getBuffer(GLuint handle);
michael@0 61 Shader *getShader(GLuint handle);
michael@0 62 Program *getProgram(GLuint handle);
michael@0 63 Texture *getTexture(GLuint handle);
michael@0 64 Renderbuffer *getRenderbuffer(GLuint handle);
michael@0 65
michael@0 66 void setRenderbuffer(GLuint handle, Renderbuffer *renderbuffer);
michael@0 67
michael@0 68 void checkBufferAllocation(unsigned int buffer);
michael@0 69 void checkTextureAllocation(GLuint texture, TextureType type);
michael@0 70 void checkRenderbufferAllocation(GLuint renderbuffer);
michael@0 71
michael@0 72 private:
michael@0 73 DISALLOW_COPY_AND_ASSIGN(ResourceManager);
michael@0 74
michael@0 75 std::size_t mRefCount;
michael@0 76 rx::Renderer *mRenderer;
michael@0 77
michael@0 78 #ifndef HASH_MAP
michael@0 79 # ifdef _MSC_VER
michael@0 80 # define HASH_MAP stdext::hash_map
michael@0 81 # else
michael@0 82 # define HASH_MAP std::unordered_map
michael@0 83 # endif
michael@0 84 #endif
michael@0 85
michael@0 86 typedef HASH_MAP<GLuint, Buffer*> BufferMap;
michael@0 87 BufferMap mBufferMap;
michael@0 88 HandleAllocator mBufferHandleAllocator;
michael@0 89
michael@0 90 typedef HASH_MAP<GLuint, Shader*> ShaderMap;
michael@0 91 ShaderMap mShaderMap;
michael@0 92
michael@0 93 typedef HASH_MAP<GLuint, Program*> ProgramMap;
michael@0 94 ProgramMap mProgramMap;
michael@0 95 HandleAllocator mProgramShaderHandleAllocator;
michael@0 96
michael@0 97 typedef HASH_MAP<GLuint, Texture*> TextureMap;
michael@0 98 TextureMap mTextureMap;
michael@0 99 HandleAllocator mTextureHandleAllocator;
michael@0 100
michael@0 101 typedef HASH_MAP<GLuint, Renderbuffer*> RenderbufferMap;
michael@0 102 RenderbufferMap mRenderbufferMap;
michael@0 103 HandleAllocator mRenderbufferHandleAllocator;
michael@0 104 };
michael@0 105
michael@0 106 }
michael@0 107
michael@0 108 #endif // LIBGLESV2_RESOURCEMANAGER_H_

mercurial