Pass the Renderer to the ResourceManager at construction time.

TRAC #22000 Signed-off-by: Daniel Koch Author: Shannon Woods git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1404 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent ad62987f
...@@ -123,7 +123,7 @@ Context::Context(const gl::Context *shareContext, rx::Renderer *renderer, bool n ...@@ -123,7 +123,7 @@ Context::Context(const gl::Context *shareContext, rx::Renderer *renderer, bool n
} }
else else
{ {
mResourceManager = new ResourceManager(); mResourceManager = new ResourceManager(mRenderer);
} }
// [OpenGL ES 2.0.24] section 3.7 page 83: // [OpenGL ES 2.0.24] section 3.7 page 83:
...@@ -132,8 +132,8 @@ Context::Context(const gl::Context *shareContext, rx::Renderer *renderer, bool n ...@@ -132,8 +132,8 @@ Context::Context(const gl::Context *shareContext, rx::Renderer *renderer, bool n
// In order that access to these initial textures not be lost, they are treated as texture // In order that access to these initial textures not be lost, they are treated as texture
// objects all of whose names are 0. // objects all of whose names are 0.
mTexture2DZero.set(new Texture2D(0)); mTexture2DZero.set(new Texture2D(mRenderer, 0));
mTextureCubeMapZero.set(new TextureCubeMap(0)); mTextureCubeMapZero.set(new TextureCubeMap(mRenderer, 0));
mState.activeSampler = 0; mState.activeSampler = 0;
bindArrayBuffer(0); bindArrayBuffer(0);
...@@ -3679,7 +3679,7 @@ Texture *Context::getIncompleteTexture(TextureType type) ...@@ -3679,7 +3679,7 @@ Texture *Context::getIncompleteTexture(TextureType type)
case TEXTURE_2D: case TEXTURE_2D:
{ {
Texture2D *incomplete2d = new Texture2D(Texture::INCOMPLETE_TEXTURE_ID); Texture2D *incomplete2d = new Texture2D(mRenderer, Texture::INCOMPLETE_TEXTURE_ID);
incomplete2d->setImage(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color); incomplete2d->setImage(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
t = incomplete2d; t = incomplete2d;
} }
...@@ -3687,7 +3687,7 @@ Texture *Context::getIncompleteTexture(TextureType type) ...@@ -3687,7 +3687,7 @@ Texture *Context::getIncompleteTexture(TextureType type)
case TEXTURE_CUBE: case TEXTURE_CUBE:
{ {
TextureCubeMap *incompleteCube = new TextureCubeMap(Texture::INCOMPLETE_TEXTURE_ID); TextureCubeMap *incompleteCube = new TextureCubeMap(mRenderer, Texture::INCOMPLETE_TEXTURE_ID);
incompleteCube->setImagePosX(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color); incompleteCube->setImagePosX(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
incompleteCube->setImageNegX(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color); incompleteCube->setImageNegX(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
......
...@@ -14,12 +14,14 @@ ...@@ -14,12 +14,14 @@
#include "libGLESv2/Renderbuffer.h" #include "libGLESv2/Renderbuffer.h"
#include "libGLESv2/Shader.h" #include "libGLESv2/Shader.h"
#include "libGLESv2/Texture.h" #include "libGLESv2/Texture.h"
#include "libGLESv2/renderer/Renderer.h"
namespace gl namespace gl
{ {
ResourceManager::ResourceManager() ResourceManager::ResourceManager(rx::Renderer *renderer)
{ {
mRefCount = 1; mRefCount = 1;
mRenderer = renderer;
} }
ResourceManager::~ResourceManager() ResourceManager::~ResourceManager()
...@@ -290,11 +292,11 @@ void ResourceManager::checkTextureAllocation(GLuint texture, TextureType type) ...@@ -290,11 +292,11 @@ void ResourceManager::checkTextureAllocation(GLuint texture, TextureType type)
if (type == TEXTURE_2D) if (type == TEXTURE_2D)
{ {
textureObject = new Texture2D(texture); textureObject = new Texture2D(mRenderer, texture);
} }
else if (type == TEXTURE_CUBE) else if (type == TEXTURE_CUBE)
{ {
textureObject = new TextureCubeMap(texture); textureObject = new TextureCubeMap(mRenderer, texture);
} }
else else
{ {
......
...@@ -23,6 +23,11 @@ ...@@ -23,6 +23,11 @@
#include "libGLESv2/EnumTypes.h" #include "libGLESv2/EnumTypes.h"
#include "libGLESv2/HandleAllocator.h" #include "libGLESv2/HandleAllocator.h"
namespace rx
{
class Renderer;
}
namespace gl namespace gl
{ {
class Buffer; class Buffer;
...@@ -34,7 +39,7 @@ class Renderbuffer; ...@@ -34,7 +39,7 @@ class Renderbuffer;
class ResourceManager class ResourceManager
{ {
public: public:
ResourceManager(); explicit ResourceManager(rx::Renderer *renderer);
~ResourceManager(); ~ResourceManager();
void addRef(); void addRef();
...@@ -68,6 +73,7 @@ class ResourceManager ...@@ -68,6 +73,7 @@ class ResourceManager
DISALLOW_COPY_AND_ASSIGN(ResourceManager); DISALLOW_COPY_AND_ASSIGN(ResourceManager);
std::size_t mRefCount; std::size_t mRefCount;
rx::Renderer *mRenderer;
#ifndef HASH_MAP #ifndef HASH_MAP
# ifdef _MSC_VER # ifdef _MSC_VER
......
...@@ -25,8 +25,10 @@ ...@@ -25,8 +25,10 @@
namespace gl namespace gl
{ {
Texture::Texture(GLuint id) : RefCountObject(id) Texture::Texture(rx::Renderer *renderer, GLuint id) : RefCountObject(id)
{ {
mRenderer = renderer;
mSamplerState.minFilter = GL_NEAREST_MIPMAP_LINEAR; mSamplerState.minFilter = GL_NEAREST_MIPMAP_LINEAR;
mSamplerState.magFilter = GL_LINEAR; mSamplerState.magFilter = GL_LINEAR;
mSamplerState.wrapS = GL_REPEAT; mSamplerState.wrapS = GL_REPEAT;
...@@ -330,7 +332,7 @@ Blit *Texture::getBlitter() ...@@ -330,7 +332,7 @@ Blit *Texture::getBlitter()
return context->getBlitter(); return context->getBlitter();
} }
Texture2D::Texture2D(GLuint id) : Texture(id) Texture2D::Texture2D(rx::Renderer *renderer, GLuint id) : Texture(renderer, id)
{ {
mTexStorage = NULL; mTexStorage = NULL;
mSurface = NULL; mSurface = NULL;
...@@ -900,7 +902,7 @@ TextureStorage *Texture2D::getStorage(bool renderTarget) ...@@ -900,7 +902,7 @@ TextureStorage *Texture2D::getStorage(bool renderTarget)
return mTexStorage; return mTexStorage;
} }
TextureCubeMap::TextureCubeMap(GLuint id) : Texture(id) TextureCubeMap::TextureCubeMap(rx::Renderer *renderer, GLuint id) : Texture(renderer, id)
{ {
mTexStorage = NULL; mTexStorage = NULL;
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
......
...@@ -29,6 +29,11 @@ namespace egl ...@@ -29,6 +29,11 @@ namespace egl
class Surface; class Surface;
} }
namespace rx
{
class Renderer;
}
namespace gl namespace gl
{ {
class Blit; class Blit;
...@@ -58,7 +63,7 @@ struct SamplerState ...@@ -58,7 +63,7 @@ struct SamplerState
class Texture : public RefCountObject class Texture : public RefCountObject
{ {
public: public:
explicit Texture(GLuint id); Texture(rx::Renderer *renderer, GLuint id);
virtual ~Texture(); virtual ~Texture();
...@@ -120,6 +125,8 @@ class Texture : public RefCountObject ...@@ -120,6 +125,8 @@ class Texture : public RefCountObject
static Blit *getBlitter(); static Blit *getBlitter();
rx::Renderer *mRenderer;
SamplerState mSamplerState; SamplerState mSamplerState;
bool mDirtyParameters; bool mDirtyParameters;
GLenum mUsage; GLenum mUsage;
...@@ -137,7 +144,7 @@ class Texture : public RefCountObject ...@@ -137,7 +144,7 @@ class Texture : public RefCountObject
class Texture2D : public Texture class Texture2D : public Texture
{ {
public: public:
explicit Texture2D(GLuint id); Texture2D(rx::Renderer *renderer, GLuint id);
~Texture2D(); ~Texture2D();
...@@ -205,7 +212,7 @@ class Texture2D : public Texture ...@@ -205,7 +212,7 @@ class Texture2D : public Texture
class TextureCubeMap : public Texture class TextureCubeMap : public Texture
{ {
public: public:
explicit TextureCubeMap(GLuint id); TextureCubeMap(rx::Renderer *renderer, GLuint id);
~TextureCubeMap(); ~TextureCubeMap();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment