Eliminate use of global getDevice() function.

Trac #21727 Everything must go through the renderer. Conflicts: src/libGLESv2/Texture.cpp git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1334 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent e4733d7e
...@@ -19,6 +19,7 @@ namespace gl ...@@ -19,6 +19,7 @@ namespace gl
Buffer::Buffer(GLuint id) : RefCountObject(id) Buffer::Buffer(GLuint id) : RefCountObject(id)
{ {
mRenderer = getDisplay()->getRenderer();
mContents = NULL; mContents = NULL;
mSize = 0; mSize = 0;
mUsage = GL_DYNAMIC_DRAW; mUsage = GL_DYNAMIC_DRAW;
...@@ -61,8 +62,8 @@ void Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage) ...@@ -61,8 +62,8 @@ void Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage)
if (usage == GL_STATIC_DRAW) if (usage == GL_STATIC_DRAW)
{ {
mStaticVertexBuffer = new StaticVertexBuffer(getDevice()); mStaticVertexBuffer = new StaticVertexBuffer(mRenderer->getDevice()); // D3D9_REPLACE
mStaticIndexBuffer = new StaticIndexBuffer(getDevice()); mStaticIndexBuffer = new StaticIndexBuffer(mRenderer->getDevice()); // D3D9_REPLACE
} }
} }
...@@ -108,8 +109,8 @@ void Buffer::promoteStaticUsage(int dataSize) ...@@ -108,8 +109,8 @@ void Buffer::promoteStaticUsage(int dataSize)
if (mUnmodifiedDataUse > 3 * mSize) if (mUnmodifiedDataUse > 3 * mSize)
{ {
mStaticVertexBuffer = new StaticVertexBuffer(getDevice()); mStaticVertexBuffer = new StaticVertexBuffer(mRenderer->getDevice()); // D3D9_REPLACE
mStaticIndexBuffer = new StaticIndexBuffer(getDevice()); mStaticIndexBuffer = new StaticIndexBuffer(mRenderer->getDevice()); // D3D9_REPLACE
} }
} }
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/RefCountObject.h" #include "common/RefCountObject.h"
#include "libGLESv2/renderer/Renderer.h"
namespace gl namespace gl
{ {
...@@ -47,6 +48,7 @@ class Buffer : public RefCountObject ...@@ -47,6 +48,7 @@ class Buffer : public RefCountObject
private: private:
DISALLOW_COPY_AND_ASSIGN(Buffer); DISALLOW_COPY_AND_ASSIGN(Buffer);
renderer::Renderer *mRenderer;
GLubyte *mContents; GLubyte *mContents;
GLsizeiptr mSize; GLsizeiptr mSize;
GLenum mUsage; GLenum mUsage;
......
...@@ -398,7 +398,7 @@ Colorbuffer::Colorbuffer(IDirect3DSurface9 *renderTarget) : mRenderTarget(render ...@@ -398,7 +398,7 @@ Colorbuffer::Colorbuffer(IDirect3DSurface9 *renderTarget) : mRenderTarget(render
Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples) : mRenderTarget(NULL) Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples) : mRenderTarget(NULL)
{ {
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDisplay()->getRenderer()->getDevice(); // D3D9_REPLACE
D3DFORMAT requestedFormat = es2dx::ConvertRenderbufferFormat(format); D3DFORMAT requestedFormat = es2dx::ConvertRenderbufferFormat(format);
int supportedSamples = getContext()->getNearestSupportedSamples(requestedFormat, samples); int supportedSamples = getContext()->getNearestSupportedSamples(requestedFormat, samples);
...@@ -471,7 +471,7 @@ DepthStencilbuffer::DepthStencilbuffer(IDirect3DSurface9 *depthStencil) : mDepth ...@@ -471,7 +471,7 @@ DepthStencilbuffer::DepthStencilbuffer(IDirect3DSurface9 *depthStencil) : mDepth
DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples) DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples)
{ {
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDisplay()->getRenderer()->getDevice(); // D3D9_REPLACE
mDepthStencil = NULL; mDepthStencil = NULL;
......
...@@ -231,7 +231,8 @@ void Image::createSurface() ...@@ -231,7 +231,8 @@ void Image::createSurface()
MakeValidSize(true, IsCompressed(mInternalFormat), &requestWidth, &requestHeight, &levelToFetch); MakeValidSize(true, IsCompressed(mInternalFormat), &requestWidth, &requestHeight, &levelToFetch);
// D3D9_REPLACE // D3D9_REPLACE
HRESULT result = getDevice()->CreateTexture(requestWidth, requestHeight, levelToFetch + 1, NULL, d3dFormat, IDirect3DDevice9 *device = getDisplay()->getRenderer()->getDevice();
HRESULT result = device->CreateTexture(requestWidth, requestHeight, levelToFetch + 1, NULL, d3dFormat,
poolToUse, &newTexture, NULL); poolToUse, &newTexture, NULL);
if (FAILED(result)) if (FAILED(result))
...@@ -350,7 +351,8 @@ void Image::updateSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint y ...@@ -350,7 +351,8 @@ void Image::updateSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint y
{ {
// UpdateSurface: source must be SYSTEMMEM, dest must be DEFAULT pools // UpdateSurface: source must be SYSTEMMEM, dest must be DEFAULT pools
// D3D9_REPLACE // D3D9_REPLACE
HRESULT result = getDevice()->UpdateSurface(sourceSurface, &rect, destSurface, &point); IDirect3DDevice9 *device = getDisplay()->getRenderer()->getDevice();
HRESULT result = device->UpdateSurface(sourceSurface, &rect, destSurface, &point);
ASSERT(SUCCEEDED(result)); ASSERT(SUCCEEDED(result));
} }
} }
...@@ -867,7 +869,7 @@ void Image::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsi ...@@ -867,7 +869,7 @@ void Image::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsi
// This implements glCopyTex[Sub]Image2D for non-renderable internal texture formats and incomplete textures // This implements glCopyTex[Sub]Image2D for non-renderable internal texture formats and incomplete textures
void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, IDirect3DSurface9 *renderTarget) void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, IDirect3DSurface9 *renderTarget)
{ {
IDirect3DDevice9 *device = getDevice(); // D3D9_REPLACE IDirect3DDevice9 *device = getDisplay()->getRenderer()->getDevice(); // D3D9_REPLACE
IDirect3DSurface9 *renderTargetData = NULL; IDirect3DSurface9 *renderTargetData = NULL;
D3DSURFACE_DESC description; D3DSURFACE_DESC description;
renderTarget->GetDesc(&description); renderTarget->GetDesc(&description);
...@@ -1644,8 +1646,7 @@ bool Texture::copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *sou ...@@ -1644,8 +1646,7 @@ bool Texture::copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *sou
} }
else else
{ {
egl::Display *display = getDisplay(); renderer::Renderer *renderer = getDisplay()->getRenderer();
renderer::Renderer *renderer = display->getRenderer();
IDirect3DDevice9 *device = renderer->getDevice(); // D3D9_REPLACE IDirect3DDevice9 *device = renderer->getDevice(); // D3D9_REPLACE
renderer->endScene(); renderer->endScene();
...@@ -1675,7 +1676,7 @@ TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, DWORD usage, in ...@@ -1675,7 +1676,7 @@ TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, DWORD usage, in
// we handle that here by skipping the d3d texture creation // we handle that here by skipping the d3d texture creation
if (width > 0 && height > 0) if (width > 0 && height > 0)
{ {
IDirect3DDevice9 *device = getDevice(); // D3D9_REPLACE IDirect3DDevice9 *device = getDisplay()->getRenderer()->getDevice(); // D3D9_REPLACE
MakeValidSize(false, dx::IsCompressedFormat(format), &width, &height, &mLodOffset); MakeValidSize(false, dx::IsCompressedFormat(format), &width, &height, &mLodOffset);
HRESULT result = device->CreateTexture(width, height, levels ? levels + mLodOffset : 0, getUsage(), format, getPool(), &mTexture, NULL); HRESULT result = device->CreateTexture(width, height, levels ? levels + mLodOffset : 0, getUsage(), format, getPool(), &mTexture, NULL);
...@@ -2386,7 +2387,7 @@ TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, DWORD ...@@ -2386,7 +2387,7 @@ TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, DWORD
// we handle that here by skipping the d3d texture creation // we handle that here by skipping the d3d texture creation
if (size > 0) if (size > 0)
{ {
IDirect3DDevice9 *device = getDevice(); // D3D9_REPLACE IDirect3DDevice9 *device = getDisplay()->getRenderer()->getDevice(); // D3D9_REPLACE
int height = size; int height = size;
MakeValidSize(false, dx::IsCompressedFormat(format), &size, &height, &mLodOffset); MakeValidSize(false, dx::IsCompressedFormat(format), &size, &height, &mLodOffset);
HRESULT result = device->CreateCubeTexture(size, levels ? levels + mLodOffset : 0, getUsage(), format, getPool(), &mTexture, NULL); HRESULT result = device->CreateCubeTexture(size, levels ? levels + mLodOffset : 0, getUsage(), format, getPool(), &mTexture, NULL);
......
...@@ -120,14 +120,6 @@ egl::Display *getDisplay() ...@@ -120,14 +120,6 @@ egl::Display *getDisplay()
return current->display; return current->display;
} }
// D3D9_REPLACE
IDirect3DDevice9 *getDevice()
{
egl::Display *display = getDisplay();
return display->getRenderer()->getDevice();
}
bool checkDeviceLost(HRESULT errorCode) bool checkDeviceLost(HRESULT errorCode)
{ {
egl::Display *display = NULL; egl::Display *display = NULL;
......
...@@ -32,8 +32,6 @@ Context *getContext(); ...@@ -32,8 +32,6 @@ Context *getContext();
Context *getNonLostContext(); Context *getNonLostContext();
egl::Display *getDisplay(); egl::Display *getDisplay();
IDirect3DDevice9 *getDevice();
bool checkDeviceLost(HRESULT errorCode); bool checkDeviceLost(HRESULT errorCode);
} }
......
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