Commit 6110763f by Geoff Lang Committed by Commit Bot

Refactor the GL surfaces and framebuffers to not hold renderer objects.

BUG=angleproject:2464 Change-Id: I20aabeef3de6cf1fc13a29b6220e040aa83184d7 Reviewed-on: https://chromium-review.googlesource.com/1039986 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org>
parent a932b6b5
......@@ -432,7 +432,11 @@ Context::Context(rx::EGLImplFactory *implFactory,
egl::Error Context::onDestroy(const egl::Display *display)
{
// Delete the Surface first to trigger a finish() in Vulkan.
SafeDelete(mSurfacelessFramebuffer);
if (mSurfacelessFramebuffer)
{
mSurfacelessFramebuffer->onDestroy(this);
SafeDelete(mSurfacelessFramebuffer);
}
ANGLE_TRY(releaseSurface(display));
......
......@@ -65,8 +65,12 @@ ProgramImpl *ContextGL::createProgram(const gl::ProgramState &data)
FramebufferImpl *ContextGL::createFramebuffer(const gl::FramebufferState &data)
{
return new FramebufferGL(data, getFunctions(), getStateManager(), getWorkaroundsGL(),
mRenderer->getBlitter(), mRenderer->getMultiviewClearer(), false);
const FunctionsGL *funcs = getFunctions();
GLuint fbo = 0;
funcs->genFramebuffers(1, &fbo);
return new FramebufferGL(data, fbo, false);
}
TextureImpl *ContextGL::createTexture(const gl::TextureState &state)
......@@ -412,6 +416,16 @@ const WorkaroundsGL &ContextGL::getWorkaroundsGL() const
return mRenderer->getWorkarounds();
}
BlitGL *ContextGL::getBlitter() const
{
return mRenderer->getBlitter();
}
ClearMultiviewGL *ContextGL::getMultiviewClearer() const
{
return mRenderer->getMultiviewClearer();
}
gl::Error ContextGL::dispatchCompute(const gl::Context *context,
GLuint numGroupsX,
GLuint numGroupsY,
......
......@@ -19,6 +19,8 @@ struct BlockMemberInfo;
namespace rx
{
class BlitGL;
class ClearMultiviewGL;
class FunctionsGL;
class RendererGL;
class StateManagerGL;
......@@ -193,6 +195,8 @@ class ContextGL : public ContextImpl
const FunctionsGL *getFunctions() const;
StateManagerGL *getStateManager();
const WorkaroundsGL &getWorkaroundsGL() const;
BlitGL *getBlitter() const;
ClearMultiviewGL *getMultiviewClearer() const;
gl::Error dispatchCompute(const gl::Context *context,
GLuint numGroupsX,
......
......@@ -23,25 +23,11 @@ struct WorkaroundsGL;
class FramebufferGL : public FramebufferImpl
{
public:
FramebufferGL(const gl::FramebufferState &data,
const FunctionsGL *functions,
StateManagerGL *stateManager,
const WorkaroundsGL &workarounds,
BlitGL *blitter,
ClearMultiviewGL *multiviewClearer,
bool isDefault);
// Constructor called when we need to create a FramebufferGL from an
// existing framebuffer name, for example for the default framebuffer
// on the Mac EGL CGL backend.
FramebufferGL(GLuint id,
const gl::FramebufferState &data,
const FunctionsGL *functions,
const WorkaroundsGL &workarounds,
BlitGL *blitter,
ClearMultiviewGL *multiviewClearer,
StateManagerGL *stateManager);
FramebufferGL(const gl::FramebufferState &data, GLuint id, bool isDefault);
~FramebufferGL() override;
void destroy(const gl::Context *context) override;
gl::Error discard(const gl::Context *context, size_t count, const GLenum *attachments) override;
gl::Error invalidate(const gl::Context *context,
size_t count,
......@@ -97,7 +83,9 @@ class FramebufferGL : public FramebufferImpl
GLuint getFramebufferID() const;
bool isDefault() const;
void maskOutInactiveOutputDrawBuffers(GLenum binding, gl::DrawBufferMask maxSet);
void maskOutInactiveOutputDrawBuffers(const gl::Context *context,
GLenum binding,
gl::DrawBufferMask maxSet);
private:
void syncClearState(const gl::Context *context, GLbitfield mask);
......@@ -123,12 +111,6 @@ class FramebufferGL : public FramebufferImpl
GLubyte *pixels,
bool readLastRowSeparately) const;
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
const WorkaroundsGL &mWorkarounds;
BlitGL *mBlitter;
ClearMultiviewGL *mMultiviewClearer;
GLuint mFramebufferID;
bool mIsDefault;
......
......@@ -1043,7 +1043,8 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::Context *context)
const gl::State &glState = context->getGLState();
FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(glState.getDrawFramebuffer());
auto activeOutputs = glState.getProgram()->getState().getActiveOutputVariables();
framebufferGL->maskOutInactiveOutputDrawBuffers(GL_DRAW_FRAMEBUFFER, activeOutputs);
framebufferGL->maskOutInactiveOutputDrawBuffers(context, GL_DRAW_FRAMEBUFFER,
activeOutputs);
}
ASSERT(
......
......@@ -8,16 +8,17 @@
#include "libANGLE/renderer/gl/SurfaceGL.h"
#include "libANGLE/Context.h"
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/gl/BlitGL.h"
#include "libANGLE/renderer/gl/ContextGL.h"
#include "libANGLE/renderer/gl/FramebufferGL.h"
#include "libANGLE/renderer/gl/RendererGL.h"
namespace rx
{
SurfaceGL::SurfaceGL(const egl::SurfaceState &state, RendererGL *renderer)
: SurfaceImpl(state), mRenderer(renderer)
SurfaceGL::SurfaceGL(const egl::SurfaceState &state) : SurfaceImpl(state)
{
}
......@@ -27,9 +28,7 @@ SurfaceGL::~SurfaceGL()
FramebufferImpl *SurfaceGL::createDefaultFramebuffer(const gl::FramebufferState &data)
{
return new FramebufferGL(data, mRenderer->getFunctions(), mRenderer->getStateManager(),
mRenderer->getWorkarounds(), mRenderer->getBlitter(),
mRenderer->getMultiviewClearer(), true);
return new FramebufferGL(data, 0, true);
}
egl::Error SurfaceGL::getSyncValues(EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc)
......@@ -46,8 +45,12 @@ egl::Error SurfaceGL::unMakeCurrent()
gl::Error SurfaceGL::initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex)
{
FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(mState.defaultFramebuffer);
ANGLE_TRY(mRenderer->getBlitter()->clearFramebuffer(framebufferGL));
FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(context->getFramebuffer(0));
ASSERT(framebufferGL->isDefault());
BlitGL *blitter = GetBlitGL(context);
ANGLE_TRY(blitter->clearFramebuffer(framebufferGL));
return gl::NoError();
}
......
......@@ -14,12 +14,10 @@
namespace rx
{
class RendererGL;
class SurfaceGL : public SurfaceImpl
{
public:
SurfaceGL(const egl::SurfaceState &state, RendererGL *renderer);
SurfaceGL(const egl::SurfaceState &state);
~SurfaceGL() override;
FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &data) override;
......@@ -30,9 +28,6 @@ class SurfaceGL : public SurfaceImpl
virtual egl::Error makeCurrent() = 0;
virtual egl::Error unMakeCurrent();
private:
RendererGL *mRenderer;
};
}
......
......@@ -134,7 +134,7 @@ SurfaceImpl *DisplayCGL::createPbufferFromClientBuffer(const egl::SurfaceState &
{
ASSERT(buftype == EGL_IOSURFACE_ANGLE);
return new IOSurfaceSurfaceCGL(state, this->getRenderer(), this, clientBuffer, attribs);
return new IOSurfaceSurfaceCGL(state, mContext, clientBuffer, attribs);
}
SurfaceImpl *DisplayCGL::createPixmapSurface(const egl::SurfaceState &state,
......
......@@ -11,6 +11,7 @@
#define LIBANGLE_RENDERER_GL_CGL_IOSURFACESURFACECGL_H_
#include "libANGLE/renderer/gl/SurfaceGL.h"
#include "libANGLE/renderer/gl/cgl/DisplayCGL.h"
struct __IOSurface;
typedef __IOSurface *IOSurfaceRef;
......@@ -31,8 +32,7 @@ class IOSurfaceSurfaceCGL : public SurfaceGL
{
public:
IOSurfaceSurfaceCGL(const egl::SurfaceState &state,
RendererGL *renderer,
DisplayCGL *display,
CGLContextObj cglContext,
EGLClientBuffer buffer,
const egl::AttributeMap &attribs);
~IOSurfaceSurfaceCGL() override;
......@@ -62,9 +62,7 @@ class IOSurfaceSurfaceCGL : public SurfaceGL
static bool validateAttributes(EGLClientBuffer buffer, const egl::AttributeMap &attribs);
private:
DisplayCGL *mDisplay;
RendererGL *mRenderer;
StateManagerGL *mStateManager;
CGLContextObj mCGLContext;
IOSurfaceRef mIOSurface;
int mWidth;
int mHeight;
......
......@@ -65,14 +65,11 @@ int FindIOSurfaceFormatIndex(GLenum internalFormat, GLenum type)
} // anonymous namespace
IOSurfaceSurfaceCGL::IOSurfaceSurfaceCGL(const egl::SurfaceState &state,
RendererGL *renderer,
DisplayCGL *display,
CGLContextObj cglContext,
EGLClientBuffer buffer,
const egl::AttributeMap &attribs)
: SurfaceGL(state, renderer),
mDisplay(display),
mRenderer(renderer),
mStateManager(renderer->getStateManager()),
: SurfaceGL(state),
mCGLContext(cglContext),
mIOSurface(nullptr),
mWidth(0),
mHeight(0),
......@@ -140,14 +137,16 @@ egl::Error IOSurfaceSurfaceCGL::bindTexImage(const gl::Context *context,
gl::Texture *texture,
EGLint buffer)
{
StateManagerGL *stateManager = GetStateManagerGL(context);
const TextureGL *textureGL = GetImplAs<TextureGL>(texture);
GLuint textureID = textureGL->getTextureID();
mStateManager->bindTexture(gl::TextureType::Rectangle, textureID);
stateManager->bindTexture(gl::TextureType::Rectangle, textureID);
const auto &format = kIOSurfaceFormats[mFormatIndex];
auto error = CGLTexImageIOSurface2D(
mDisplay->getCGLContext(), GL_TEXTURE_RECTANGLE, format.nativeFormat, mWidth, mHeight,
format.nativeInternalFormat, format.nativeType, mIOSurface, mPlane);
auto error = CGLTexImageIOSurface2D(mCGLContext, GL_TEXTURE_RECTANGLE, format.nativeFormat,
mWidth, mHeight, format.nativeInternalFormat,
format.nativeType, mIOSurface, mPlane);
if (error != kCGLNoError)
{
......@@ -159,11 +158,8 @@ egl::Error IOSurfaceSurfaceCGL::bindTexImage(const gl::Context *context,
egl::Error IOSurfaceSurfaceCGL::releaseTexImage(const gl::Context *context, EGLint buffer)
{
gl::Error error = mRenderer->flush();
if (error.isError())
{
return egl::EglContextLost();
}
const FunctionsGL *functions = GetFunctionsGL(context);
functions->flush();
return egl::NoError();
}
......
......@@ -16,6 +16,7 @@ namespace rx
{
class FunctionsGL;
class RendererGL;
class StateManagerGL;
struct WorkaroundsGL;
......@@ -57,9 +58,10 @@ class PbufferSurfaceCGL : public SurfaceGL
unsigned mWidth;
unsigned mHeight;
// TODO(geofflang): Don't store these, they are potentially specific to a single GL context.
// http://anglebug.com/2464
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
RendererGL *mRenderer;
GLuint mFramebuffer;
GLuint mColorRenderbuffer;
......
......@@ -23,12 +23,11 @@ PbufferSurfaceCGL::PbufferSurfaceCGL(const egl::SurfaceState &state,
EGLint width,
EGLint height,
const FunctionsGL *functions)
: SurfaceGL(state, renderer),
: SurfaceGL(state),
mWidth(width),
mHeight(height),
mFunctions(functions),
mStateManager(renderer->getStateManager()),
mRenderer(renderer),
mFramebuffer(0),
mColorRenderbuffer(0),
mDSRenderbuffer(0)
......@@ -142,9 +141,7 @@ EGLint PbufferSurfaceCGL::getSwapBehavior() const
FramebufferImpl *PbufferSurfaceCGL::createDefaultFramebuffer(const gl::FramebufferState &state)
{
// TODO(cwallez) assert it happens only once?
return new FramebufferGL(mFramebuffer, state, mFunctions, mRenderer->getWorkarounds(),
mRenderer->getBlitter(), mRenderer->getMultiviewClearer(),
mStateManager);
return new FramebufferGL(state, mFramebuffer, true);
}
} // namespace rx
......@@ -25,6 +25,7 @@ namespace rx
class DisplayCGL;
class FramebufferGL;
class FunctionsGL;
class RendererGL;
class StateManagerGL;
struct WorkaroundsGL;
......@@ -94,8 +95,6 @@ class WindowSurfaceCGL : public SurfaceGL
CGLContextObj mContext;
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
RendererGL *mRenderer;
const WorkaroundsGL &mWorkarounds;
GLuint mFramebuffer;
GLuint mDSRenderbuffer;
......
......@@ -147,15 +147,13 @@
EGLNativeWindowType layer,
const FunctionsGL *functions,
CGLContextObj context)
: SurfaceGL(state, renderer),
: SurfaceGL(state),
mSwapLayer(nil),
mCurrentSwapId(0),
mLayer(reinterpret_cast<CALayer *>(layer)),
mContext(context),
mFunctions(functions),
mStateManager(renderer->getStateManager()),
mRenderer(renderer),
mWorkarounds(renderer->getWorkarounds()),
mFramebuffer(0),
mDSRenderbuffer(0)
{
......@@ -331,8 +329,7 @@ EGLint WindowSurfaceCGL::getSwapBehavior() const
FramebufferImpl *WindowSurfaceCGL::createDefaultFramebuffer(const gl::FramebufferState &state)
{
// TODO(cwallez) assert it happens only once?
return new FramebufferGL(mFramebuffer, state, mFunctions, mWorkarounds, mRenderer->getBlitter(),
mRenderer->getMultiviewClearer(), mStateManager);
return new FramebufferGL(state, mFramebuffer, true);
}
} // namespace rx
......@@ -16,9 +16,8 @@ namespace rx
PbufferSurfaceEGL::PbufferSurfaceEGL(const egl::SurfaceState &state,
const FunctionsEGL *egl,
EGLConfig config,
RendererGL *renderer)
: SurfaceEGL(state, egl, config, renderer)
EGLConfig config)
: SurfaceEGL(state, egl, config)
{
}
......
......@@ -20,10 +20,7 @@ namespace rx
class PbufferSurfaceEGL : public SurfaceEGL
{
public:
PbufferSurfaceEGL(const egl::SurfaceState &state,
const FunctionsEGL *egl,
EGLConfig config,
RendererGL *renderer);
PbufferSurfaceEGL(const egl::SurfaceState &state, const FunctionsEGL *egl, EGLConfig config);
~PbufferSurfaceEGL() override;
egl::Error initialize(const egl::Display *display) override;
......
......@@ -13,14 +13,8 @@
namespace rx
{
SurfaceEGL::SurfaceEGL(const egl::SurfaceState &state,
const FunctionsEGL *egl,
EGLConfig config,
RendererGL *renderer)
: SurfaceGL(state, renderer),
mEGL(egl),
mConfig(config),
mSurface(EGL_NO_SURFACE)
SurfaceEGL::SurfaceEGL(const egl::SurfaceState &state, const FunctionsEGL *egl, EGLConfig config)
: SurfaceGL(state), mEGL(egl), mConfig(config), mSurface(EGL_NO_SURFACE)
{
}
......
......@@ -20,10 +20,7 @@ namespace rx
class SurfaceEGL : public SurfaceGL
{
public:
SurfaceEGL(const egl::SurfaceState &state,
const FunctionsEGL *egl,
EGLConfig config,
RendererGL *renderer);
SurfaceEGL(const egl::SurfaceState &state, const FunctionsEGL *egl, EGLConfig config);
~SurfaceEGL() override;
egl::Error makeCurrent() override;
......
......@@ -17,9 +17,8 @@ namespace rx
WindowSurfaceEGL::WindowSurfaceEGL(const egl::SurfaceState &state,
const FunctionsEGL *egl,
EGLConfig config,
EGLNativeWindowType window,
RendererGL *renderer)
: SurfaceEGL(state, egl, config, renderer), mWindow(window)
EGLNativeWindowType window)
: SurfaceEGL(state, egl, config), mWindow(window)
{
}
......
......@@ -20,8 +20,7 @@ class WindowSurfaceEGL : public SurfaceEGL
WindowSurfaceEGL(const egl::SurfaceState &state,
const FunctionsEGL *egl,
EGLConfig config,
EGLNativeWindowType window,
RendererGL *renderer);
EGLNativeWindowType window);
~WindowSurfaceEGL() override;
egl::Error initialize(const egl::Display *display) override;
......
......@@ -201,7 +201,7 @@ SurfaceImpl *DisplayAndroid::createWindowSurface(const egl::SurfaceState &state,
success = mEGL->chooseConfig(configAttribList, &config, 1, &numConfig);
ASSERT(success && numConfig == 1);
return new WindowSurfaceEGL(state, mEGL, config, window, getRenderer());
return new WindowSurfaceEGL(state, mEGL, config, window);
}
SurfaceImpl *DisplayAndroid::createPbufferSurface(const egl::SurfaceState &state,
......@@ -215,7 +215,7 @@ SurfaceImpl *DisplayAndroid::createPbufferSurface(const egl::SurfaceState &state
success = mEGL->chooseConfig(configAttribList, &config, 1, &numConfig);
ASSERT(success && numConfig == 1);
return new PbufferSurfaceEGL(state, mEGL, config, getRenderer());
return new PbufferSurfaceEGL(state, mEGL, config);
}
SurfaceImpl *DisplayAndroid::createPbufferFromClientBuffer(const egl::SurfaceState &state,
......
......@@ -307,10 +307,7 @@ uint32_t DisplayOzone::Buffer::getDRMFB()
FramebufferGL *DisplayOzone::Buffer::framebufferGL(const gl::FramebufferState &state)
{
return new FramebufferGL(
mGLFB, state, mDisplay->mFunctionsGL, mDisplay->getRenderer()->getWorkarounds(),
mDisplay->getRenderer()->getBlitter(), mDisplay->getRenderer()->getMultiviewClearer(),
mDisplay->getRenderer()->getStateManager());
return new FramebufferGL(state, mGLFB, true);
}
void DisplayOzone::Buffer::present()
......@@ -861,7 +858,7 @@ SurfaceImpl *DisplayOzone::createWindowSurface(const egl::SurfaceState &state,
{
return nullptr;
}
return new SurfaceOzone(state, getRenderer(), buffer);
return new SurfaceOzone(state, buffer);
}
SurfaceImpl *DisplayOzone::createPbufferSurface(const egl::SurfaceState &state,
......@@ -875,7 +872,7 @@ SurfaceImpl *DisplayOzone::createPbufferSurface(const egl::SurfaceState &state,
{
return nullptr;
}
return new SurfaceOzone(state, getRenderer(), buffer);
return new SurfaceOzone(state, buffer);
}
SurfaceImpl *DisplayOzone::createPbufferFromClientBuffer(const egl::SurfaceState &state,
......
......@@ -14,10 +14,8 @@
namespace rx
{
SurfaceOzone::SurfaceOzone(const egl::SurfaceState &state,
RendererGL *renderer,
DisplayOzone::Buffer *buffer)
: SurfaceGL(state, renderer), mBuffer(buffer)
SurfaceOzone::SurfaceOzone(const egl::SurfaceState &state, DisplayOzone::Buffer *buffer)
: SurfaceGL(state), mBuffer(buffer)
{
}
......
......@@ -19,7 +19,6 @@ class SurfaceOzone : public SurfaceGL
{
public:
SurfaceOzone(const egl::SurfaceState &state,
RendererGL *renderer,
DisplayOzone::Buffer *buffer);
~SurfaceOzone() override;
......
......@@ -359,8 +359,7 @@ SurfaceImpl *DisplayGLX::createWindowSurface(const egl::SurfaceState &state,
ASSERT(configIdToGLXConfig.count(state.config->configID) > 0);
glx::FBConfig fbConfig = configIdToGLXConfig[state.config->configID];
return new WindowSurfaceGLX(state, mGLX, this, getRenderer(), window, mGLX.getDisplay(),
fbConfig);
return new WindowSurfaceGLX(state, mGLX, this, window, mGLX.getDisplay(), fbConfig);
}
SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::SurfaceState &state,
......@@ -373,7 +372,7 @@ SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::SurfaceState &state,
EGLint height = static_cast<EGLint>(attribs.get(EGL_HEIGHT, 0));
bool largest = (attribs.get(EGL_LARGEST_PBUFFER, EGL_FALSE) == EGL_TRUE);
return new PbufferSurfaceGLX(state, getRenderer(), width, height, largest, mGLX, fbConfig);
return new PbufferSurfaceGLX(state, width, height, largest, mGLX, fbConfig);
}
SurfaceImpl *DisplayGLX::createPbufferFromClientBuffer(const egl::SurfaceState &state,
......
......@@ -16,13 +16,12 @@ namespace rx
{
PbufferSurfaceGLX::PbufferSurfaceGLX(const egl::SurfaceState &state,
RendererGL *renderer,
EGLint width,
EGLint height,
bool largest,
const FunctionsGLX &glx,
glx::FBConfig fbConfig)
: SurfaceGLX(state, renderer),
: SurfaceGLX(state),
mWidth(width),
mHeight(height),
mLargest(largest),
......
......@@ -21,7 +21,6 @@ class PbufferSurfaceGLX : public SurfaceGLX
{
public:
PbufferSurfaceGLX(const egl::SurfaceState &state,
RendererGL *renderer,
EGLint width,
EGLint height,
bool largest,
......
......@@ -17,7 +17,7 @@ namespace rx
class SurfaceGLX : public SurfaceGL
{
public:
SurfaceGLX(const egl::SurfaceState &state, RendererGL *renderer) : SurfaceGL(state, renderer) {}
SurfaceGLX(const egl::SurfaceState &state) : SurfaceGL(state) {}
virtual egl::Error checkForResize() = 0;
virtual glx::Drawable getDrawable() const = 0;
......
......@@ -24,11 +24,10 @@ static int IgnoreX11Errors(Display *, XErrorEvent *)
WindowSurfaceGLX::WindowSurfaceGLX(const egl::SurfaceState &state,
const FunctionsGLX &glx,
DisplayGLX *glxDisplay,
RendererGL *renderer,
Window window,
Display *display,
glx::FBConfig fbConfig)
: SurfaceGLX(state, renderer),
: SurfaceGLX(state),
mParent(window),
mWindow(0),
mDisplay(display),
......
......@@ -25,7 +25,6 @@ class WindowSurfaceGLX : public SurfaceGLX
WindowSurfaceGLX(const egl::SurfaceState &state,
const FunctionsGLX &glx,
DisplayGLX *glxDisplay,
RendererGL *renderer,
Window window,
Display *display,
glx::FBConfig fbConfig);
......
......@@ -14,9 +14,11 @@
#include "common/mathutil.h"
#include "libANGLE/Buffer.h"
#include "libANGLE/Caps.h"
#include "libANGLE/Context.h"
#include "libANGLE/Workarounds.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/queryconversions.h"
#include "libANGLE/renderer/gl/ContextGL.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
#include "libANGLE/renderer/gl/QueryGL.h"
#include "libANGLE/renderer/gl/WorkaroundsGL.h"
......@@ -1251,6 +1253,31 @@ bool UseTexImage3D(gl::TextureType textureType)
}
}
const FunctionsGL *GetFunctionsGL(const gl::Context *context)
{
return GetImplAs<ContextGL>(context)->getFunctions();
}
StateManagerGL *GetStateManagerGL(const gl::Context *context)
{
return GetImplAs<ContextGL>(context)->getStateManager();
}
BlitGL *GetBlitGL(const gl::Context *context)
{
return GetImplAs<ContextGL>(context)->getBlitter();
}
ClearMultiviewGL *GetMultiviewClearer(const gl::Context *context)
{
return GetImplAs<ContextGL>(context)->getMultiviewClearer();
}
const WorkaroundsGL &GetWorkaroundsGL(const gl::Context *context)
{
return GetImplAs<ContextGL>(context)->getWorkaroundsGL();
}
bool CanMapBufferForRead(const FunctionsGL *functions)
{
return (functions->mapBufferRange != nullptr) ||
......
......@@ -30,7 +30,10 @@ struct Workarounds;
namespace rx
{
class BlitGL;
class ClearMultiviewGL;
class FunctionsGL;
class StateManagerGL;
struct WorkaroundsGL;
enum class MultiviewImplementationTypeGL
{
......@@ -41,6 +44,13 @@ enum class MultiviewImplementationTypeGL
VendorID GetVendorID(const FunctionsGL *functions);
std::string GetDriverVersion(const FunctionsGL *functions);
// Helpers for extracting the GL helper objects out of a context
const FunctionsGL *GetFunctionsGL(const gl::Context *context);
StateManagerGL *GetStateManagerGL(const gl::Context *context);
BlitGL *GetBlitGL(const gl::Context *context);
ClearMultiviewGL *GetMultiviewClearer(const gl::Context *context);
const WorkaroundsGL &GetWorkaroundsGL(const gl::Context *context);
namespace nativegl_gl
{
......
......@@ -230,7 +230,7 @@ egl::Error GetD3DTextureInfo(EGLenum buftype,
} // anonymous namespace
D3DTextureSurfaceWGL::D3DTextureSurfaceWGL(const egl::SurfaceState &state,
RendererGL *renderer,
StateManagerGL *stateManager,
EGLenum buftype,
EGLClientBuffer clientBuffer,
DisplayWGL *display,
......@@ -238,14 +238,12 @@ D3DTextureSurfaceWGL::D3DTextureSurfaceWGL(const egl::SurfaceState &state,
ID3D11Device *displayD3D11Device,
const FunctionsGL *functionsGL,
const FunctionsWGL *functionsWGL)
: SurfaceWGL(state, renderer),
: SurfaceWGL(state),
mBuftype(buftype),
mClientBuffer(clientBuffer),
mRenderer(renderer),
mDisplayD3D11Device(displayD3D11Device),
mDisplay(display),
mStateManager(renderer->getStateManager()),
mWorkarounds(renderer->getWorkarounds()),
mStateManager(stateManager),
mFunctionsGL(functionsGL),
mFunctionsWGL(functionsWGL),
mDeviceContext(deviceContext),
......@@ -500,9 +498,7 @@ EGLint D3DTextureSurfaceWGL::getSwapBehavior() const
FramebufferImpl *D3DTextureSurfaceWGL::createDefaultFramebuffer(const gl::FramebufferState &data)
{
return new FramebufferGL(mFramebufferID, data, mFunctionsGL, mWorkarounds,
mRenderer->getBlitter(), mRenderer->getMultiviewClearer(),
mStateManager);
return new FramebufferGL(data, mFramebufferID, true);
}
HDC D3DTextureSurfaceWGL::getDC() const
......
......@@ -26,7 +26,7 @@ class D3DTextureSurfaceWGL : public SurfaceWGL
{
public:
D3DTextureSurfaceWGL(const egl::SurfaceState &state,
RendererGL *renderer,
StateManagerGL *stateManager,
EGLenum buftype,
EGLClientBuffer clientBuffer,
DisplayWGL *display,
......@@ -73,13 +73,10 @@ class D3DTextureSurfaceWGL : public SurfaceWGL
EGLenum mBuftype;
EGLClientBuffer mClientBuffer;
RendererGL *mRenderer;
ID3D11Device *mDisplayD3D11Device;
DisplayWGL *mDisplay;
StateManagerGL *mStateManager;
const WorkaroundsGL &mWorkarounds;
const FunctionsGL *mFunctionsGL;
const FunctionsWGL *mFunctionsWGL;
......
......@@ -23,7 +23,7 @@ namespace rx
{
DXGISwapChainWindowSurfaceWGL::DXGISwapChainWindowSurfaceWGL(const egl::SurfaceState &state,
RendererGL *renderer,
StateManagerGL *stateManager,
EGLNativeWindowType window,
ID3D11Device *device,
HANDLE deviceHandle,
......@@ -31,11 +31,9 @@ DXGISwapChainWindowSurfaceWGL::DXGISwapChainWindowSurfaceWGL(const egl::SurfaceS
const FunctionsGL *functionsGL,
const FunctionsWGL *functionsWGL,
EGLint orientation)
: SurfaceWGL(state, renderer),
: SurfaceWGL(state),
mWindow(window),
mStateManager(renderer->getStateManager()),
mWorkarounds(renderer->getWorkarounds()),
mRenderer(renderer),
mStateManager(stateManager),
mFunctionsGL(functionsGL),
mFunctionsWGL(functionsWGL),
mDevice(device),
......@@ -272,9 +270,7 @@ EGLint DXGISwapChainWindowSurfaceWGL::getSwapBehavior() const
FramebufferImpl *DXGISwapChainWindowSurfaceWGL::createDefaultFramebuffer(
const gl::FramebufferState &data)
{
return new FramebufferGL(mFramebufferID, data, mFunctionsGL, mWorkarounds,
mRenderer->getBlitter(), mRenderer->getMultiviewClearer(),
mStateManager);
return new FramebufferGL(data, mFramebufferID, true);
}
HDC DXGISwapChainWindowSurfaceWGL::getDC() const
......
......@@ -27,7 +27,7 @@ class DXGISwapChainWindowSurfaceWGL : public SurfaceWGL
{
public:
DXGISwapChainWindowSurfaceWGL(const egl::SurfaceState &state,
RendererGL *renderer,
StateManagerGL *stateManager,
EGLNativeWindowType window,
ID3D11Device *device,
HANDLE deviceHandle,
......@@ -72,8 +72,6 @@ class DXGISwapChainWindowSurfaceWGL : public SurfaceWGL
EGLNativeWindowType mWindow;
StateManagerGL *mStateManager;
const WorkaroundsGL &mWorkarounds;
RendererGL *mRenderer;
const FunctionsGL *mFunctionsGL;
const FunctionsWGL *mFunctionsWGL;
......
......@@ -385,14 +385,13 @@ SurfaceImpl *DisplayWGL::createWindowSurface(const egl::SurfaceState &state,
return nullptr;
}
return new DXGISwapChainWindowSurfaceWGL(state, getRenderer(), window, mD3D11Device,
mD3D11DeviceHandle, mDeviceContext, mFunctionsGL,
mFunctionsWGL, orientation);
return new DXGISwapChainWindowSurfaceWGL(state, getRenderer()->getStateManager(), window,
mD3D11Device, mD3D11DeviceHandle, mDeviceContext,
mFunctionsGL, mFunctionsWGL, orientation);
}
else
{
return new WindowSurfaceWGL(state, getRenderer(), window, mPixelFormat, mFunctionsWGL,
orientation);
return new WindowSurfaceWGL(state, window, mPixelFormat, mFunctionsWGL, orientation);
}
}
......@@ -405,8 +404,8 @@ SurfaceImpl *DisplayWGL::createPbufferSurface(const egl::SurfaceState &state,
EGLenum textureFormat = static_cast<EGLenum>(attribs.get(EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE));
EGLenum textureTarget = static_cast<EGLenum>(attribs.get(EGL_TEXTURE_TARGET, EGL_NO_TEXTURE));
return new PbufferSurfaceWGL(state, getRenderer(), width, height, textureFormat, textureTarget,
largest, mPixelFormat, mDeviceContext, mFunctionsWGL);
return new PbufferSurfaceWGL(state, width, height, textureFormat, textureTarget, largest,
mPixelFormat, mDeviceContext, mFunctionsWGL);
}
SurfaceImpl *DisplayWGL::createPbufferFromClientBuffer(const egl::SurfaceState &state,
......@@ -420,8 +419,9 @@ SurfaceImpl *DisplayWGL::createPbufferFromClientBuffer(const egl::SurfaceState &
return nullptr;
}
return new D3DTextureSurfaceWGL(state, getRenderer(), buftype, clientBuffer, this,
mDeviceContext, mD3D11Device, mFunctionsGL, mFunctionsWGL);
return new D3DTextureSurfaceWGL(state, getRenderer()->getStateManager(), buftype, clientBuffer,
this, mDeviceContext, mD3D11Device, mFunctionsGL,
mFunctionsWGL);
}
SurfaceImpl *DisplayWGL::createPixmapSurface(const egl::SurfaceState &state,
......
......@@ -17,7 +17,6 @@ namespace rx
{
PbufferSurfaceWGL::PbufferSurfaceWGL(const egl::SurfaceState &state,
RendererGL *renderer,
EGLint width,
EGLint height,
EGLenum textureFormat,
......@@ -26,7 +25,7 @@ PbufferSurfaceWGL::PbufferSurfaceWGL(const egl::SurfaceState &state,
int pixelFormat,
HDC deviceContext,
const FunctionsWGL *functions)
: SurfaceWGL(state, renderer),
: SurfaceWGL(state),
mWidth(width),
mHeight(height),
mLargest(largest),
......
......@@ -22,7 +22,6 @@ class PbufferSurfaceWGL : public SurfaceWGL
{
public:
PbufferSurfaceWGL(const egl::SurfaceState &state,
RendererGL *renderer,
EGLint width,
EGLint height,
EGLenum textureFormat,
......
......@@ -16,7 +16,7 @@ namespace rx
class SurfaceWGL : public SurfaceGL
{
public:
SurfaceWGL(const egl::SurfaceState &state, RendererGL *renderer) : SurfaceGL(state, renderer) {}
SurfaceWGL(const egl::SurfaceState &state) : SurfaceGL(state) {}
~SurfaceWGL() override {}
......
......@@ -17,12 +17,11 @@ namespace rx
{
WindowSurfaceWGL::WindowSurfaceWGL(const egl::SurfaceState &state,
RendererGL *renderer,
EGLNativeWindowType window,
int pixelFormat,
const FunctionsWGL *functions,
EGLint orientation)
: SurfaceWGL(state, renderer),
: SurfaceWGL(state),
mPixelFormat(pixelFormat),
mWindow(window),
mDeviceContext(nullptr),
......
......@@ -22,7 +22,6 @@ class WindowSurfaceWGL : public SurfaceWGL
{
public:
WindowSurfaceWGL(const egl::SurfaceState &state,
RendererGL *renderer,
EGLNativeWindowType window,
int pixelFormat,
const FunctionsWGL *functions,
......
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