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
Buffer::Buffer(GLuint id) : RefCountObject(id)
{
mRenderer = getDisplay()->getRenderer();
mContents = NULL;
mSize = 0;
mUsage = GL_DYNAMIC_DRAW;
......@@ -61,8 +62,8 @@ void Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage)
if (usage == GL_STATIC_DRAW)
{
mStaticVertexBuffer = new StaticVertexBuffer(getDevice());
mStaticIndexBuffer = new StaticIndexBuffer(getDevice());
mStaticVertexBuffer = new StaticVertexBuffer(mRenderer->getDevice()); // D3D9_REPLACE
mStaticIndexBuffer = new StaticIndexBuffer(mRenderer->getDevice()); // D3D9_REPLACE
}
}
......@@ -108,8 +109,8 @@ void Buffer::promoteStaticUsage(int dataSize)
if (mUnmodifiedDataUse > 3 * mSize)
{
mStaticVertexBuffer = new StaticVertexBuffer(getDevice());
mStaticIndexBuffer = new StaticIndexBuffer(getDevice());
mStaticVertexBuffer = new StaticVertexBuffer(mRenderer->getDevice()); // D3D9_REPLACE
mStaticIndexBuffer = new StaticIndexBuffer(mRenderer->getDevice()); // D3D9_REPLACE
}
}
}
......
......@@ -19,6 +19,7 @@
#include "common/angleutils.h"
#include "common/RefCountObject.h"
#include "libGLESv2/renderer/Renderer.h"
namespace gl
{
......@@ -47,6 +48,7 @@ class Buffer : public RefCountObject
private:
DISALLOW_COPY_AND_ASSIGN(Buffer);
renderer::Renderer *mRenderer;
GLubyte *mContents;
GLsizeiptr mSize;
GLenum mUsage;
......
......@@ -398,7 +398,7 @@ Colorbuffer::Colorbuffer(IDirect3DSurface9 *renderTarget) : mRenderTarget(render
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);
int supportedSamples = getContext()->getNearestSupportedSamples(requestedFormat, samples);
......@@ -471,7 +471,7 @@ DepthStencilbuffer::DepthStencilbuffer(IDirect3DSurface9 *depthStencil) : mDepth
DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples)
{
IDirect3DDevice9 *device = getDevice();
IDirect3DDevice9 *device = getDisplay()->getRenderer()->getDevice(); // D3D9_REPLACE
mDepthStencil = NULL;
......
......@@ -231,7 +231,8 @@ void Image::createSurface()
MakeValidSize(true, IsCompressed(mInternalFormat), &requestWidth, &requestHeight, &levelToFetch);
// 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);
if (FAILED(result))
......@@ -350,7 +351,8 @@ void Image::updateSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint y
{
// UpdateSurface: source must be SYSTEMMEM, dest must be DEFAULT pools
// 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));
}
}
......@@ -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
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;
D3DSURFACE_DESC description;
renderTarget->GetDesc(&description);
......@@ -1644,8 +1646,7 @@ bool Texture::copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *sou
}
else
{
egl::Display *display = getDisplay();
renderer::Renderer *renderer = display->getRenderer();
renderer::Renderer *renderer = getDisplay()->getRenderer();
IDirect3DDevice9 *device = renderer->getDevice(); // D3D9_REPLACE
renderer->endScene();
......@@ -1675,7 +1676,7 @@ TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, DWORD usage, in
// we handle that here by skipping the d3d texture creation
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);
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
// we handle that here by skipping the d3d texture creation
if (size > 0)
{
IDirect3DDevice9 *device = getDevice(); // D3D9_REPLACE
IDirect3DDevice9 *device = getDisplay()->getRenderer()->getDevice(); // D3D9_REPLACE
int height = size;
MakeValidSize(false, dx::IsCompressedFormat(format), &size, &height, &mLodOffset);
HRESULT result = device->CreateCubeTexture(size, levels ? levels + mLodOffset : 0, getUsage(), format, getPool(), &mTexture, NULL);
......
......@@ -120,14 +120,6 @@ egl::Display *getDisplay()
return current->display;
}
// D3D9_REPLACE
IDirect3DDevice9 *getDevice()
{
egl::Display *display = getDisplay();
return display->getRenderer()->getDevice();
}
bool checkDeviceLost(HRESULT errorCode)
{
egl::Display *display = NULL;
......
......@@ -32,8 +32,6 @@ Context *getContext();
Context *getNonLostContext();
egl::Display *getDisplay();
IDirect3DDevice9 *getDevice();
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