Home | History | Annotate | Download | only in libGLES_CM
      1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //    http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 // ResourceManager.h : Defines the ResourceManager class, which tracks objects
     16 // shared by multiple GL contexts.
     17 
     18 #ifndef LIBGLES_CM_RESOURCEMANAGER_H_
     19 #define LIBGLES_CM_RESOURCEMANAGER_H_
     20 
     21 #include "common/NameSpace.hpp"
     22 
     23 #include <GLES/gl.h>
     24 
     25 #include <map>
     26 
     27 namespace es1
     28 {
     29 class Buffer;
     30 class Texture;
     31 class Renderbuffer;
     32 
     33 enum TextureType
     34 {
     35 	TEXTURE_2D,
     36 	TEXTURE_CUBE,
     37 	TEXTURE_EXTERNAL,
     38 
     39 	TEXTURE_TYPE_COUNT,
     40 	TEXTURE_UNKNOWN
     41 };
     42 
     43 class ResourceManager
     44 {
     45 public:
     46 	ResourceManager();
     47 	~ResourceManager();
     48 
     49 	void addRef();
     50 	void release();
     51 
     52 	GLuint createBuffer();
     53 	GLuint createTexture();
     54 	GLuint createRenderbuffer();
     55 
     56 	void deleteBuffer(GLuint buffer);
     57 	void deleteTexture(GLuint texture);
     58 	void deleteRenderbuffer(GLuint renderbuffer);
     59 
     60 	Buffer *getBuffer(GLuint handle);
     61 	Texture *getTexture(GLuint handle);
     62 	Renderbuffer *getRenderbuffer(GLuint handle);
     63 
     64 	void checkBufferAllocation(unsigned int buffer);
     65 	void checkTextureAllocation(GLuint texture, TextureType type);
     66 	void checkRenderbufferAllocation(GLuint handle);
     67 
     68 private:
     69 	std::size_t mRefCount;
     70 
     71 	gl::NameSpace<Buffer> mBufferNameSpace;
     72 	gl::NameSpace<Texture> mTextureNameSpace;
     73 	gl::NameSpace<Renderbuffer> mRenderbufferNameSpace;
     74 };
     75 
     76 }
     77 
     78 #endif // LIBGLES_CM_RESOURCEMANAGER_H_
     79