Commit 31c07a30 by Nicolas Capens

Make the EGL surface class abstract.

gl::Surface is now the pure abstract interface for egl::Surface, which can be used by libGLESv2 without requiring typeinfo. Bug chromium:732667 Bug swiftshader:31 Change-Id: I7d8a5892c5b6186541f84c3cf39e72ac1d6c613d Reviewed-on: https://swiftshader-review.googlesource.com/10129Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 88f5ec6b
......@@ -12,10 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// Surface.cpp: Implements the egl::Surface class, representing a drawing surface
// such as the client area of a window, including any back buffers.
// Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3.
#include "FrameBufferX11.hpp"
#include "libX11.hpp"
......
......@@ -12,10 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// Surface.cpp: Implements the egl::Surface class, representing a drawing surface
// such as the client area of a window, including any back buffers.
// Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3.
#ifndef sw_FrameBufferX11_hpp
#define sw_FrameBufferX11_hpp
......
// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Surface.hpp: Defines the gl::Surface class, which is the abstract interface
// for an EGL surface as viewed by the GL implementation.
#ifndef INCLUDE_SURFACE_H_
#define INCLUDE_SURFACE_H_
#include "Renderer/Surface.hpp"
#include <EGL/egl.h>
namespace egl
{
class Texture;
class Image;
}
namespace gl
{
class [[clang::lto_visibility_public]] Surface
{
protected:
Surface();
virtual ~Surface() = 0;
public:
virtual egl::Image *getRenderTarget() = 0;
virtual egl::Image *getDepthStencil() = 0;
virtual sw::Format getInternalFormat() const = 0;
virtual EGLint getWidth() const = 0;
virtual EGLint getHeight() const = 0;
virtual void setBoundTexture(egl::Texture *texture) = 0;
};
}
#endif // INCLUDE_SURFACE_H_
......@@ -19,7 +19,7 @@ endif
COMMON_SRC_FILES := \
Config.cpp \
Display.cpp \
EGLSurface.cpp \
Surface.cpp \
libEGL.cpp \
main.cpp
......
......@@ -56,7 +56,7 @@ shared_library("swiftshader_libEGL") {
"../common/Object.cpp",
"Config.cpp",
"Display.cpp",
"EGLSurface.cpp",
"Surface.cpp",
"libEGL.cpp",
"libEGL.def",
"libEGL.rc",
......
......@@ -20,19 +20,18 @@
#include <EGL/egl.h>
#include <GLES/gl.h>
namespace gl { class Surface; }
namespace egl
{
class Display;
class Surface;
class Image;
class [[clang::lto_visibility_public]] Context : public gl::Object
{
public:
Context(egl::Display *display) : display(display) {}
virtual void makeCurrent(Surface *surface) = 0;
virtual void bindTexImage(Surface *surface) = 0;
virtual void makeCurrent(gl::Surface *surface) = 0;
virtual void bindTexImage(gl::Surface *surface) = 0;
virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel) = 0;
virtual Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel) = 0;
virtual EGLint getClientVersion() const = 0;
......@@ -40,6 +39,7 @@ public:
virtual void finish() = 0;
protected:
Context(egl::Display *display) : display(display) {}
virtual ~Context() {};
egl::Display *const display;
......
......@@ -19,7 +19,7 @@
#include "Display.h"
#include "main.h"
#include "libEGL/EGLSurface.h"
#include "libEGL/Surface.hpp"
#include "libEGL/Context.hpp"
#include "common/Image.hpp"
#include "common/debug.h"
......
......@@ -16,7 +16,7 @@
// such as the client area of a window, including any back buffers.
// Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3.
#include "EGLSurface.h"
#include "Surface.hpp"
#include "main.h"
#include "Display.h"
......@@ -36,9 +36,19 @@
#include <algorithm>
namespace egl
namespace gl
{
Surface::Surface()
{
}
Surface::~Surface()
{
}
}
namespace egl
{
Surface::Surface(const Display *display, const Config *config) : display(display), config(config)
{
backBuffer = nullptr;
......
......@@ -12,15 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// Surface.h: Defines the egl::Surface class, representing a drawing surface
// Surface.hpp: Defines the egl::Surface class, representing a rendering surface
// such as the client area of a window, including any back buffers.
// Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3.
#ifndef INCLUDE_SURFACE_H_
#define INCLUDE_SURFACE_H_
#ifndef INCLUDE_EGL_SURFACE_H_
#define INCLUDE_EGL_SURFACE_H_
#include "Main/FrameBuffer.hpp"
#include "common/Object.hpp"
#include "common/Surface.hpp"
#include "Main/FrameBuffer.hpp"
#include <EGL/egl.h>
......@@ -28,27 +30,25 @@ namespace egl
{
class Display;
class Config;
class Texture;
class Image;
class [[clang::lto_visibility_public]] Surface : public gl::Object
class Surface : public gl::Surface, public gl::Object
{
public:
virtual bool initialize();
virtual void swap() = 0;
virtual egl::Image *getRenderTarget();
virtual egl::Image *getDepthStencil();
egl::Image *getRenderTarget() override;
egl::Image *getDepthStencil() override;
void setSwapBehavior(EGLenum swapBehavior);
void setSwapInterval(EGLint interval);
virtual EGLint getConfigID() const;
virtual EGLenum getSurfaceType() const;
virtual sw::Format getInternalFormat() const;
sw::Format getInternalFormat() const override;
virtual EGLint getWidth() const;
virtual EGLint getHeight() const;
EGLint getWidth() const override;
EGLint getHeight() const override;
virtual EGLint getPixelAspectRatio() const;
virtual EGLenum getRenderBuffer() const;
virtual EGLenum getSwapBehavior() const;
......@@ -57,7 +57,7 @@ public:
virtual EGLBoolean getLargestPBuffer() const;
virtual EGLNativeWindowType getWindowHandle() const = 0;
virtual void setBoundTexture(egl::Texture *texture);
void setBoundTexture(egl::Texture *texture) override;
virtual egl::Texture *getBoundTexture() const;
virtual bool isWindowSurface() const { return false; }
......@@ -66,7 +66,7 @@ public:
protected:
Surface(const Display *display, const Config *config);
virtual ~Surface();
~Surface() override;
virtual void deleteResources();
......@@ -134,4 +134,4 @@ private:
};
}
#endif // INCLUDE_SURFACE_H_
#endif // INCLUDE_EGL_SURFACE_H_
......@@ -16,7 +16,7 @@
#include "main.h"
#include "Display.h"
#include "EGLSurface.h"
#include "Surface.hpp"
#include "Texture.hpp"
#include "Context.hpp"
#include "common/Image.hpp"
......
......@@ -319,13 +319,14 @@ copy "$(OutDir)libEGL.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\trans
<ClCompile Include="Display.cpp" />
<ClCompile Include="libEGL.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="EGLSurface.cpp" />
<ClCompile Include="Surface.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\debug.h" />
<ClInclude Include="..\common\Image.hpp" />
<ClInclude Include="..\common\NameSpace.hpp" />
<ClInclude Include="..\common\Object.hpp" />
<ClInclude Include="..\common\Surface.hpp" />
<ClInclude Include="..\include\EGL\egl.h" />
<ClInclude Include="..\include\EGL\eglext.h" />
<ClInclude Include="..\include\EGL\eglplatform.h" />
......@@ -335,7 +336,7 @@ copy "$(OutDir)libEGL.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\trans
<ClInclude Include="libEGL.hpp" />
<ClInclude Include="main.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="EGLSurface.h" />
<ClInclude Include="Surface.hpp" />
<ClInclude Include="Sync.hpp" />
<ClInclude Include="Texture.hpp" />
</ItemGroup>
......
......@@ -29,7 +29,7 @@
<ClCompile Include="..\common\Object.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="EGLSurface.cpp">
<ClCompile Include="Surface.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
......@@ -79,7 +79,10 @@
<ClInclude Include="..\common\NameSpace.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="EGLSurface.h">
<ClInclude Include="..\common\Surface.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Surface.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
......
......@@ -18,7 +18,7 @@
#include "libEGL.hpp"
#include "Context.hpp"
#include "EGLSurface.h"
#include "Surface.hpp"
#include "resource.h"
#include "Common/Thread.hpp"
......
......@@ -28,6 +28,8 @@ namespace egl
class Display;
class Context;
class Surface;
class Config;
class Image;
struct Current
{
......@@ -76,12 +78,6 @@ namespace egl
return returnValue;
}
class Config;
class Surface;
class Display;
class Context;
class Image;
}
extern LibGLES_CM libGLES_CM;
......
......@@ -28,7 +28,7 @@
#include "VertexDataManager.h"
#include "IndexDataManager.h"
#include "libEGL/Display.h"
#include "libEGL/EGLSurface.h"
#include "common/Surface.hpp"
#include "Common/Half.hpp"
#include <EGL/eglext.h>
......@@ -281,7 +281,7 @@ Context::~Context()
delete device;
}
void Context::makeCurrent(egl::Surface *surface)
void Context::makeCurrent(gl::Surface *surface)
{
if(!mHasBeenCurrent)
{
......@@ -3095,7 +3095,7 @@ void Context::setVertexAttrib(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLf
mVertexDataManager->dirtyCurrentValue(index);
}
void Context::bindTexImage(egl::Surface *surface)
void Context::bindTexImage(gl::Surface *surface)
{
es1::Texture2D *textureObject = getTexture2D();
......
......@@ -33,10 +33,11 @@
#include <map>
#include <string>
namespace gl { class Surface; }
namespace egl
{
class Display;
class Surface;
class Config;
}
......@@ -296,7 +297,7 @@ class [[clang::lto_visibility_public]] Context : public egl::Context
public:
Context(egl::Display *display, const Context *shareContext, const egl::Config *config);
void makeCurrent(egl::Surface *surface) override;
void makeCurrent(gl::Surface *surface) override;
EGLint getClientVersion() const override;
EGLint getConfigID() const override;
......@@ -508,9 +509,9 @@ public:
static int getSupportedMultisampleCount(int requested);
virtual void bindTexImage(egl::Surface *surface);
virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel);
virtual egl::Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel);
void bindTexImage(gl::Surface *surface) override;
EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel) override;
egl::Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel) override;
egl::Image *getSharedImage(GLeglImageOES image);
Device *getDevice();
......@@ -579,7 +580,7 @@ public:
void setPointFadeThresholdSize(float threshold);
private:
virtual ~Context();
~Context() override;
bool applyRenderTarget();
void applyState(GLenum drawMode);
......
......@@ -23,7 +23,7 @@
#include "Framebuffer.h"
#include "Device.hpp"
#include "libEGL/Display.h"
#include "libEGL/EGLSurface.h"
#include "common/Surface.hpp"
#include "common/debug.h"
#include <algorithm>
......@@ -474,7 +474,7 @@ void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum form
Texture::setImage(format, type, unpackAlignment, pixels, image[level]);
}
void Texture2D::bindTexImage(egl::Surface *surface)
void Texture2D::bindTexImage(gl::Surface *surface)
{
GLenum format;
......
......@@ -29,11 +29,8 @@
#include <vector>
namespace egl
{
class Surface;
class Config;
}
namespace gl { class Surface; }
namespace egl { class Config; }
namespace es1
{
......@@ -155,7 +152,7 @@ public:
virtual bool isSamplerComplete() const;
virtual bool isCompressed(GLenum target, GLint level) const;
virtual bool isDepth(GLenum target, GLint level) const;
virtual void bindTexImage(egl::Surface *surface);
virtual void bindTexImage(gl::Surface *surface);
virtual void releaseTexImage();
virtual void generateMipmaps();
......@@ -174,7 +171,7 @@ protected:
egl::Image *image[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
egl::Surface *mSurface;
gl::Surface *mSurface;
// A specific internal reference count is kept for colorbuffer proxy references,
// because, as the renderbuffer acting as proxy will maintain a binding pointer
......
......@@ -18,7 +18,7 @@
#include "libGLES_CM.hpp"
#include "Framebuffer.h"
#include "libEGL/EGLSurface.h"
#include "common/Surface.hpp"
#include "Common/Thread.hpp"
#include "Common/SharedLibrary.hpp"
#include "common/debug.h"
......
......@@ -35,7 +35,7 @@
#include "VertexDataManager.h"
#include "IndexDataManager.h"
#include "libEGL/Display.h"
#include "libEGL/EGLSurface.h"
#include "common/Surface.hpp"
#include "Common/Half.hpp"
#include <EGL/eglext.h>
......@@ -265,7 +265,7 @@ Context::~Context()
delete device;
}
void Context::makeCurrent(egl::Surface *surface)
void Context::makeCurrent(gl::Surface *surface)
{
if(!mHasBeenCurrent)
{
......@@ -4138,7 +4138,7 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1
}
}
void Context::bindTexImage(egl::Surface *surface)
void Context::bindTexImage(gl::Surface *surface)
{
es2::Texture2D *textureObject = getTexture2D();
......
......@@ -37,7 +37,6 @@
namespace egl
{
class Display;
class Surface;
class Config;
}
......@@ -431,7 +430,7 @@ class [[clang::lto_visibility_public]] Context : public egl::Context
public:
Context(egl::Display *display, const Context *shareContext, EGLint clientVersion, const egl::Config *config);
void makeCurrent(egl::Surface *surface) override;
void makeCurrent(gl::Surface *surface) override;
EGLint getClientVersion() const override;
EGLint getConfigID() const override;
......@@ -691,7 +690,7 @@ public:
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, bool filter, bool allowPartialDepthStencilBlit);
void bindTexImage(egl::Surface *surface) override;
void bindTexImage(gl::Surface *surface) override;
EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel) override;
egl::Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel) override;
egl::Image *getSharedImage(GLeglImageOES image);
......@@ -701,7 +700,7 @@ public:
const GLubyte *getExtensions(GLuint index, GLuint *numExt = nullptr) const;
private:
virtual ~Context();
~Context() override;
void applyScissor(int width, int height);
bool applyRenderTarget();
......
......@@ -23,7 +23,7 @@
#include "Framebuffer.h"
#include "Device.hpp"
#include "libEGL/Display.h"
#include "libEGL/EGLSurface.h"
#include "common/Surface.hpp"
#include "common/debug.h"
#include <algorithm>
......@@ -650,7 +650,7 @@ void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum form
Texture::setImage(format, type, unpackInfo, pixels, image[level]);
}
void Texture2D::bindTexImage(egl::Surface *surface)
void Texture2D::bindTexImage(gl::Surface *surface)
{
GLenum format;
......@@ -1611,7 +1611,7 @@ void Texture3D::setImage(GLint level, GLsizei width, GLsizei height, GLsizei dep
Texture::setImage(format, type, unpackInfo, pixels, image[level]);
}
void Texture3D::bindTexImage(egl::Surface *surface)
void Texture3D::bindTexImage(gl::Surface *surface)
{
GLenum format;
......
......@@ -29,11 +29,8 @@
#include <vector>
namespace egl
{
class Surface;
class Config;
}
namespace gl { class Surface; }
namespace egl { class Config; }
namespace es2
{
......@@ -180,7 +177,7 @@ public:
virtual bool isSamplerComplete() const;
virtual bool isCompressed(GLenum target, GLint level) const;
virtual bool isDepth(GLenum target, GLint level) const;
virtual void bindTexImage(egl::Surface *surface);
virtual void bindTexImage(gl::Surface *surface);
virtual void releaseTexImage();
virtual void generateMipmaps();
......@@ -198,7 +195,7 @@ protected:
egl::Image *image[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
egl::Surface *mSurface;
gl::Surface *mSurface;
// A specific internal reference count is kept for colorbuffer proxy references,
// because, as the renderbuffer acting as proxy will maintain a binding pointer
......@@ -300,7 +297,7 @@ public:
virtual bool isSamplerComplete() const;
virtual bool isCompressed(GLenum target, GLint level) const;
virtual bool isDepth(GLenum target, GLint level) const;
virtual void bindTexImage(egl::Surface *surface);
virtual void bindTexImage(gl::Surface *surface);
virtual void releaseTexImage();
virtual void generateMipmaps();
......@@ -318,7 +315,7 @@ protected:
egl::Image *image[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
egl::Surface *mSurface;
gl::Surface *mSurface;
// A specific internal reference count is kept for colorbuffer proxy references,
// because, as the renderbuffer acting as proxy will maintain a binding pointer
......
......@@ -365,6 +365,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr
<ClInclude Include="..\common\Image.hpp" />
<ClInclude Include="..\common\NameSpace.hpp" />
<ClInclude Include="..\common\Object.hpp" />
<ClInclude Include="..\common\Surface.hpp" />
<ClInclude Include="..\include\GLES2\gl2.h" />
<ClInclude Include="..\include\GLES2\gl2ext.h" />
<ClInclude Include="..\include\GLES2\gl2platform.h" />
......
......@@ -163,6 +163,9 @@
<ClInclude Include="..\common\Image.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\common\Surface.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="libGLESv2.rc" />
......
......@@ -19,7 +19,7 @@
#include "libGLESv2.hpp"
#include "Framebuffer.h"
#include "libEGL/main.h"
#include "libEGL/EGLSurface.h"
#include "common/Surface.hpp"
#include "Common/Thread.hpp"
#include "Common/SharedLibrary.hpp"
#include "common/debug.h"
......
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