Commit c2df1257 by Nicolas Capens Committed by Nicolas Capens

Eliminate the glBindTexImage dependency.

BUG=18110152 Change-Id: I7c7e8aa5ff52de794aacef557769f130d039c1a5 Reviewed-on: https://swiftshader-review.googlesource.com/1242Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 6899f6c8
#ifndef egl_Context_hpp
#define egl_Context_hpp
namespace egl
{
class Surface;
class Context
{
public:
virtual void destroy() = 0;
virtual void bindTexImage(Surface *surface) = 0;
};
}
#endif // egl_Context_hpp
......@@ -17,8 +17,9 @@
#include "main.h"
#include "libGLESv2/mathutil.h"
#include "libGLESv2/Context.h"
#include "libGLESv2/Device.hpp"
#include "libEGL/Surface.h"
#include "libEGL/Context.hpp"
#include "common/debug.h"
#include <algorithm>
......@@ -404,7 +405,7 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, const EGLint *attri
return success(surface);
}
EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *shareContext)
EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *shareContext)
{
if(!mDevice)
{
......@@ -416,7 +417,7 @@ EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *sha
const egl::Config *config = mConfigSet.get(configHandle);
gl::Context *context = gl::createContext(config, shareContext);
egl::Context *context = gl::createContext(config, shareContext);
mContextSet.insert(context);
return context;
......@@ -428,7 +429,7 @@ void Display::destroySurface(egl::Surface *surface)
mSurfaceSet.erase(surface);
}
void Display::destroyContext(gl::Context *context)
void Display::destroyContext(egl::Context *context)
{
context->destroy();
mContextSet.erase(context);
......@@ -444,7 +445,7 @@ bool Display::isValidConfig(EGLConfig config)
return mConfigSet.get(config) != NULL;
}
bool Display::isValidContext(gl::Context *context)
bool Display::isValidContext(egl::Context *context)
{
return mContextSet.find(context) != mContextSet.end();
}
......
......@@ -17,18 +17,19 @@
#define INCLUDE_DISPLAY_H_
#include "Config.h"
#include "Surface.h"
#include <set>
namespace gl
{
class Context;
class Device;
}
namespace egl
{
class Surface;
class Context;
class Display
{
public:
......@@ -44,15 +45,15 @@ namespace egl
EGLSurface createWindowSurface(EGLNativeWindowType window, EGLConfig config, const EGLint *attribList);
EGLSurface createOffscreenSurface(EGLConfig config, const EGLint *attribList);
EGLContext createContext(EGLConfig configHandle, const gl::Context *shareContext);
EGLContext createContext(EGLConfig configHandle, const Context *shareContext);
void destroySurface(egl::Surface *surface);
void destroyContext(gl::Context *context);
void destroySurface(Surface *surface);
void destroyContext(Context *context);
bool isInitialized() const;
bool isValidConfig(EGLConfig config);
bool isValidContext(gl::Context *context);
bool isValidSurface(egl::Surface *surface);
bool isValidContext(Context *context);
bool isValidSurface(Surface *surface);
bool isValidWindow(EGLNativeWindowType window);
bool hasExistingWindowSurface(EGLNativeWindowType window);
......@@ -80,7 +81,7 @@ namespace egl
ConfigSet mConfigSet;
typedef std::set<gl::Context*> ContextSet;
typedef std::set<Context*> ContextSet;
ContextSet mContextSet;
bool createDevice();
......
......@@ -13,6 +13,7 @@
#include "main.h"
#include "Display.h"
#include "Surface.h"
#include "libGLESv2/Context.h"
#include "libGLESv2/Texture.h"
#include "common/debug.h"
......@@ -50,7 +51,7 @@ static bool validateConfig(egl::Display *display, EGLConfig config)
return true;
}
static bool validateContext(egl::Display *display, gl::Context *context)
static bool validateContext(egl::Display *display, egl::Context *context)
{
if(!validateDisplay(display))
{
......@@ -661,7 +662,12 @@ EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLin
return error(EGL_BAD_MATCH, EGL_FALSE);
}
gl::bindTexImage(eglSurface);
egl::Context *context = static_cast<egl::Context*>(egl::getCurrentContext());
if(context)
{
context->bindTexImage(eglSurface);
}
return success(EGL_TRUE);
}
......@@ -787,7 +793,7 @@ EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLCon
return EGL_NO_CONTEXT;
}
EGLContext context = display->createContext(config, static_cast<gl::Context*>(share_context));
EGLContext context = display->createContext(config, static_cast<egl::Context*>(share_context));
return success(context);
}
......@@ -806,7 +812,7 @@ EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
try
{
egl::Display *display = static_cast<egl::Display*>(dpy);
gl::Context *context = static_cast<gl::Context*>(ctx);
egl::Context *context = static_cast<egl::Context*>(ctx);
if(!validateContext(display, context))
{
......
......@@ -161,6 +161,7 @@ copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Comman
<ClInclude Include="..\include\EGL\eglext.h" />
<ClInclude Include="..\include\EGL\eglplatform.h" />
<ClInclude Include="Config.h" />
<ClInclude Include="Context.hpp" />
<ClInclude Include="Display.h" />
<ClInclude Include="main.h" />
<ClInclude Include="resource.h" />
......
......@@ -58,6 +58,9 @@
<ClInclude Include="..\common\debug.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Context.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="libEGL.rc" />
......
......@@ -89,7 +89,7 @@ CONSTRUCTOR static bool eglAttachProcess()
libGLESv2 = loadLibrary(libGLESv2_lib);
gl::createDevice = (gl::Device*(*)())getProcAddress(libGLESv2, "createDevice");
gl::createContext = (gl::Context *(*)(const egl::Config*, const gl::Context*))getProcAddress(libGLESv2, "glCreateContext");
gl::createContext = (egl::Context *(*)(const egl::Config*, const egl::Context*))getProcAddress(libGLESv2, "glCreateContext");
gl::makeCurrent = (void (*)(gl::Context*, egl::Display*, egl::Surface*))getProcAddress(libGLESv2, "glMakeCurrent");
gl::getProcAddress = (__eglMustCastToProperFunctionPointerType (*)(const char*))getProcAddress(libGLESv2, "glGetProcAddress");
gl::createBackBuffer = (gl::Image *(*)(int, int, const egl::Config*))getProcAddress(libGLESv2, "createBackBuffer");
......@@ -260,7 +260,7 @@ void error(EGLint errorCode)
namespace gl
{
Device *(*createDevice)() = 0;
Context *(*createContext)(const egl::Config *config, const Context *shareContext) = 0;
egl::Context *(*createContext)(const egl::Config *config, const egl::Context *shareContext) = 0;
void (*bindTexImage)(egl::Surface *surface) = 0;
void (*makeCurrent)(Context *context, egl::Display *display, egl::Surface *surface) = 0;
Context *(*getCurrentContext)() = 0;
......
......@@ -72,6 +72,7 @@ namespace egl
class Config;
class Surface;
class Display;
class Context;
}
namespace sw
......@@ -87,8 +88,7 @@ namespace gl
class Image;
extern Device *(*createDevice)();
extern Context *(*createContext)(const egl::Config *config, const Context *shareContext);
extern void (*bindTexImage)(egl::Surface *surface);
extern egl::Context *(*createContext)(const egl::Config *config, const egl::Context *shareContext);
extern void (*makeCurrent)(Context *context, egl::Display *display, egl::Surface *surface);
extern __eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname);
extern Image *(*createBackBuffer)(int width, int height, const egl::Config *config);
......
......@@ -26,6 +26,7 @@
#include "VertexDataManager.h"
#include "IndexDataManager.h"
#include "libEGL/Display.h"
#include "libEGL/Surface.h"
#include "Common/Half.hpp"
#undef near
......@@ -2217,6 +2218,16 @@ void Context::setVertexAttrib(GLuint index, const GLfloat *values)
mVertexDataManager->dirtyCurrentValue(index);
}
void Context::bindTexImage(egl::Surface *surface)
{
gl::Texture2D *textureObject = getTexture2D();
if(textureObject)
{
textureObject->bindTexImage(surface);
}
}
}
// Exported functions for use by EGL
......
......@@ -15,6 +15,7 @@
#ifndef LIBGLES_CM_CONTEXT_H_
#define LIBGLES_CM_CONTEXT_H_
#include "libEGL/Context.hpp"
#include "ResourceManager.h"
#include "HandleAllocator.h"
#include "RefCountObject.h"
......@@ -217,7 +218,7 @@ struct State
GLint packAlignment;
};
class Context
class Context : public egl::Context
{
public:
Context(const egl::Config *config, const Context *shareContext);
......@@ -366,6 +367,8 @@ public:
static int getSupportedMultiSampleDepth(sw::Format format, int requested);
virtual void bindTexImage(egl::Surface *surface);
private:
virtual ~Context();
......
......@@ -20,6 +20,7 @@
#include "Framebuffer.h"
#include "Device.hpp"
#include "libEGL/Display.h"
#include "libEGL/Surface.h"
#include "common/debug.h"
#include <algorithm>
......
......@@ -3697,31 +3697,6 @@ __eglMustCastToProperFunctionPointerType glGetProcAddress(const char *procname)
return NULL;
}
void glBindTexImage(egl::Surface *surface)
{
TRACE("(egl::Surface* surface = 0x%0.8p)",
surface);
try
{
gl::Context *context = gl::getContext();
if(context)
{
gl::Texture2D *textureObject = context->getTexture2D();
if(textureObject)
{
textureObject->bindTexImage(surface);
}
}
}
catch(std::bad_alloc&)
{
return error(GL_OUT_OF_MEMORY);
}
}
void GL_APIENTRY Register(const char *licenseKey)
{
RegisterLicenseKey(licenseKey);
......
......@@ -149,7 +149,6 @@ EXPORTS
glCreateContext @144
glMakeCurrent @146
glGetProcAddress @148
glBindTexImage @158
createFrameBuffer @172
createBackBuffer @173
......
......@@ -29,6 +29,7 @@
#include "VertexDataManager.h"
#include "IndexDataManager.h"
#include "libEGL/Display.h"
#include "libEGL/Surface.h"
#include "Common/Half.hpp"
#undef near
......@@ -3030,6 +3031,16 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1
}
}
void Context::bindTexImage(egl::Surface *surface)
{
gl::Texture2D *textureObject = getTexture2D();
if(textureObject)
{
textureObject->bindTexImage(surface);
}
}
}
// Exported functions for use by EGL
......
......@@ -15,6 +15,7 @@
#ifndef LIBGLESV2_CONTEXT_H_
#define LIBGLESV2_CONTEXT_H_
#include "libEGL/Context.hpp"
#include "ResourceManager.h"
#include "HandleAllocator.h"
#include "RefCountObject.h"
......@@ -235,7 +236,7 @@ struct State
GLint packAlignment;
};
class Context
class Context : public egl::Context
{
public:
Context(const egl::Config *config, const Context *shareContext);
......@@ -418,6 +419,8 @@ public:
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask);
virtual void bindTexImage(egl::Surface *surface);
private:
virtual ~Context();
......
......@@ -20,6 +20,7 @@
#include "Framebuffer.h"
#include "Device.hpp"
#include "libEGL/Display.h"
#include "libEGL/Surface.h"
#include "common/debug.h"
#include <algorithm>
......
......@@ -6182,31 +6182,6 @@ __eglMustCastToProperFunctionPointerType glGetProcAddress(const char *procname)
return NULL;
}
void glBindTexImage(egl::Surface *surface)
{
TRACE("(egl::Surface* surface = 0x%0.8p)",
surface);
try
{
gl::Context *context = gl::getContext();
if(context)
{
gl::Texture2D *textureObject = context->getTexture2D();
if(textureObject)
{
textureObject->bindTexImage(surface);
}
}
}
catch(std::bad_alloc&)
{
return error(GL_OUT_OF_MEMORY);
}
}
void GL_APIENTRY Register(const char *licenseKey)
{
RegisterLicenseKey(licenseKey);
......
......@@ -172,7 +172,6 @@ EXPORTS
glCreateContext @144
glMakeCurrent @146
glGetProcAddress @148
glBindTexImage @158
createFrameBuffer @172
createBackBuffer @173
......
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