Commit a6426d67 by Yuly Novikov Committed by Commit Bot

Android GL backend and end2end tests

Just the bare minimum implementation for end2end tests to run. BUG=angleproject:1362 TEST=angle_end2end_tests on Nexus 5X Change-Id: I92293e0f8bdc2ffaa5d4661927750d7cb3d931e6 Reviewed-on: https://chromium-review.googlesource.com/349353Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
parent acccc6c9
...@@ -333,6 +333,16 @@ static_library("libANGLE") { ...@@ -333,6 +333,16 @@ static_library("libANGLE") {
"QuartzCore.framework", "QuartzCore.framework",
] ]
} }
if (is_android) {
sources += rebase_path(gles_gypi.libangle_gl_egl_sources, ".", "src")
sources += rebase_path(gles_gypi.libangle_gl_egl_dl_sources, ".", "src")
sources +=
rebase_path(gles_gypi.libangle_gl_egl_android_sources, ".", "src")
libs += [
"android",
"log",
]
}
} }
if (angle_enable_vulkan) { if (angle_enable_vulkan) {
...@@ -443,6 +453,17 @@ static_library("angle_util") { ...@@ -443,6 +453,17 @@ static_library("angle_util") {
sources += rebase_path(util_gypi.util_x11_sources, ".", "util") sources += rebase_path(util_gypi.util_x11_sources, ".", "util")
} }
if (is_android) {
# To prevent linux sources filtering on android
set_sources_assignment_filter([])
sources += rebase_path(util_gypi.util_linux_sources, ".", "util")
sources += rebase_path(util_gypi.util_android_sources, ".", "util")
libs = [
"android",
"log",
]
}
defines = [ defines = [
"GL_GLEXT_PROTOTYPES", "GL_GLEXT_PROTOTYPES",
"EGL_EGLEXT_PROTOTYPES", "EGL_EGLEXT_PROTOTYPES",
......
...@@ -20,6 +20,8 @@ if (is_win) { ...@@ -20,6 +20,8 @@ if (is_win) {
angle_enable_gl = true angle_enable_gl = true
} else if (is_mac) { } else if (is_mac) {
angle_enable_gl = true angle_enable_gl = true
} else if (is_android) {
angle_enable_gl = true
} }
# TODO(gyp): Probably also want to angle_enable_gl = true if (use_ozone) # TODO(gyp): Probably also want to angle_enable_gl = true if (use_ozone)
......
...@@ -40,6 +40,19 @@ bool AttributeMap::isEmpty() const ...@@ -40,6 +40,19 @@ bool AttributeMap::isEmpty() const
return mAttributes.empty(); return mAttributes.empty();
} }
std::vector<EGLint> AttributeMap::toIntVector() const
{
std::vector<EGLint> ret;
for (const auto &pair : mAttributes)
{
ret.push_back(pair.first);
ret.push_back(pair.second);
}
ret.push_back(EGL_NONE);
return ret;
}
AttributeMap::const_iterator AttributeMap::begin() const AttributeMap::const_iterator AttributeMap::begin() const
{ {
return mAttributes.begin(); return mAttributes.begin();
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <EGL/egl.h> #include <EGL/egl.h>
#include <map> #include <map>
#include <vector>
namespace egl namespace egl
{ {
...@@ -25,6 +26,7 @@ class AttributeMap final ...@@ -25,6 +26,7 @@ class AttributeMap final
EGLAttrib get(EGLAttrib key, EGLAttrib defaultValue) const; EGLAttrib get(EGLAttrib key, EGLAttrib defaultValue) const;
EGLint getAsInt(EGLAttrib key, EGLint defaultValue) const; EGLint getAsInt(EGLAttrib key, EGLint defaultValue) const;
bool isEmpty() const; bool isEmpty() const;
std::vector<EGLint> toIntVector() const;
typedef std::map<EGLAttrib, EGLAttrib>::const_iterator const_iterator; typedef std::map<EGLAttrib, EGLAttrib>::const_iterator const_iterator;
......
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
# include "libANGLE/renderer/gl/cgl/DisplayCGL.h" # include "libANGLE/renderer/gl/cgl/DisplayCGL.h"
# elif defined(ANGLE_USE_OZONE) # elif defined(ANGLE_USE_OZONE)
# include "libANGLE/renderer/gl/egl/ozone/DisplayOzone.h" # include "libANGLE/renderer/gl/egl/ozone/DisplayOzone.h"
# elif defined(ANGLE_PLATFORM_ANDROID)
# include "libANGLE/renderer/gl/egl/android/DisplayAndroid.h"
# else # else
# error Unsupported OpenGL platform. # error Unsupported OpenGL platform.
# endif # endif
...@@ -150,6 +152,8 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap) ...@@ -150,6 +152,8 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap)
impl = new rx::DisplayCGL(); impl = new rx::DisplayCGL();
#elif defined(ANGLE_USE_OZONE) #elif defined(ANGLE_USE_OZONE)
impl = new rx::DisplayOzone(); impl = new rx::DisplayOzone();
#elif defined(ANGLE_PLATFORM_ANDROID)
impl = new rx::DisplayAndroid();
#else #else
// No display available // No display available
UNREACHABLE(); UNREACHABLE();
...@@ -177,6 +181,9 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap) ...@@ -177,6 +181,9 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap)
#elif defined(ANGLE_USE_OZONE) #elif defined(ANGLE_USE_OZONE)
// This might work but has never been tried, so disallow for now. // This might work but has never been tried, so disallow for now.
impl = nullptr; impl = nullptr;
#elif defined(ANGLE_PLATFORM_ANDROID)
// No GL support on this platform, fail display creation.
impl = nullptr;
#else #else
#error Unsupported OpenGL platform. #error Unsupported OpenGL platform.
#endif #endif
...@@ -188,16 +195,18 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap) ...@@ -188,16 +195,18 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap)
#if defined(ANGLE_ENABLE_OPENGL) #if defined(ANGLE_ENABLE_OPENGL)
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE: case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
#if defined(ANGLE_PLATFORM_WINDOWS) #if defined(ANGLE_PLATFORM_WINDOWS)
impl = new rx::DisplayWGL(); impl = new rx::DisplayWGL();
#elif defined(ANGLE_USE_X11) #elif defined(ANGLE_USE_X11)
impl = new rx::DisplayGLX(); impl = new rx::DisplayGLX();
#elif defined(ANGLE_USE_OZONE) #elif defined(ANGLE_USE_OZONE)
impl = new rx::DisplayOzone(); impl = new rx::DisplayOzone();
#elif defined(ANGLE_PLATFORM_ANDROID)
impl = new rx::DisplayAndroid();
#else #else
// No GLES support on this platform, fail display creation. // No GLES support on this platform, fail display creation.
impl = nullptr; impl = nullptr;
#endif #endif
break; break;
#endif #endif
default: default:
......
...@@ -290,10 +290,13 @@ namespace rx ...@@ -290,10 +290,13 @@ namespace rx
{ {
enum VendorID : uint32_t enum VendorID : uint32_t
{ {
VENDOR_ID_UNKNOWN = 0x0, VENDOR_ID_UNKNOWN = 0x0,
VENDOR_ID_AMD = 0x1002, VENDOR_ID_AMD = 0x1002,
VENDOR_ID_INTEL = 0x8086, VENDOR_ID_INTEL = 0x8086,
VENDOR_ID_NVIDIA = 0x10DE, VENDOR_ID_NVIDIA = 0x10DE,
// This is Qualcomm PCI Vendor ID.
// Android doesn't have a PCI bus, but all we need is a unique id.
VENDOR_ID_QUALCOMM = 0x5143,
}; };
// A macro that determines whether an object has a given runtime type. // A macro that determines whether an object has a given runtime type.
......
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// DisplayEGL.cpp: Common across EGL parts of platform specific egl::Display implementations
#include "libANGLE/renderer/gl/egl/DisplayEGL.h"
namespace rx
{
#define EGL_NO_CONFIG ((EGLConfig)0)
DisplayEGL::DisplayEGL()
: DisplayGL(),
mEGL(nullptr),
mConfig(EGL_NO_CONFIG),
mContext(EGL_NO_CONTEXT),
mFunctionsGL(nullptr)
{
}
DisplayEGL::~DisplayEGL()
{
}
std::string DisplayEGL::getVendorString() const
{
const char *vendor = mEGL->queryString(EGL_VENDOR);
ASSERT(vendor);
return vendor;
}
egl::Error DisplayEGL::initializeContext(const egl::AttributeMap &eglAttributes)
{
gl::Version eglVersion(mEGL->majorVersion, mEGL->minorVersion);
EGLint requestedMajor =
eglAttributes.getAsInt(EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE);
EGLint requestedMinor =
eglAttributes.getAsInt(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, EGL_DONT_CARE);
bool initializeRequested = requestedMajor != EGL_DONT_CARE && requestedMinor != EGL_DONT_CARE;
static_assert(EGL_CONTEXT_MAJOR_VERSION == EGL_CONTEXT_MAJOR_VERSION_KHR,
"Major Version define should match");
static_assert(EGL_CONTEXT_MINOR_VERSION == EGL_CONTEXT_MINOR_VERSION_KHR,
"Minor Version define should match");
std::vector<std::vector<EGLint>> contextAttribLists;
if (eglVersion >= gl::Version(1, 5) || mEGL->hasExtension("EGL_KHR_create_context"))
{
if (initializeRequested)
{
contextAttribLists.push_back({EGL_CONTEXT_MAJOR_VERSION, requestedMajor,
EGL_CONTEXT_MINOR_VERSION, requestedMinor, EGL_NONE});
}
else
{
// clang-format off
const gl::Version esVersionsFrom2_0[] = {
gl::Version(3, 2),
gl::Version(3, 1),
gl::Version(3, 0),
gl::Version(2, 0),
};
// clang-format on
for (const auto &version : esVersionsFrom2_0)
{
contextAttribLists.push_back(
{EGL_CONTEXT_MAJOR_VERSION, static_cast<EGLint>(version.major),
EGL_CONTEXT_MINOR_VERSION, static_cast<EGLint>(version.minor), EGL_NONE});
}
}
}
else
{
if (initializeRequested && (requestedMajor != 2 || requestedMinor != 0))
{
return egl::Error(EGL_BAD_ATTRIBUTE, "Unsupported requested context version");
}
contextAttribLists.push_back({EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE});
}
for (auto &attribList : contextAttribLists)
{
mContext = mEGL->createContext(mConfig, EGL_NO_CONTEXT, attribList.data());
if (mContext != EGL_NO_CONTEXT)
{
return egl::Error(EGL_SUCCESS);
}
}
return egl::Error(mEGL->getError(), "eglCreateContext failed");
}
void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
{
outExtensions->createContextRobustness =
mEGL->hasExtension("EGL_EXT_create_context_robustness");
outExtensions->postSubBuffer = false; // Since SurfaceEGL::postSubBuffer is not implemented
}
void DisplayEGL::generateCaps(egl::Caps *outCaps) const
{
outCaps->textureNPOT = true; // Since we request GLES >= 2
}
const FunctionsGL *DisplayEGL::getFunctionsGL() const
{
return mFunctionsGL;
}
} // namespace rx
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// DisplayEGL.h: Common across EGL parts of platform specific egl::Display implementations
#ifndef LIBANGLE_RENDERER_GL_EGL_DISPLAYEGL_H_
#define LIBANGLE_RENDERER_GL_EGL_DISPLAYEGL_H_
#include "libANGLE/renderer/gl/DisplayGL.h"
#include "libANGLE/renderer/gl/egl/FunctionsEGL.h"
namespace rx
{
class DisplayEGL : public DisplayGL
{
public:
DisplayEGL();
~DisplayEGL() override;
std::string getVendorString() const override;
protected:
egl::Error initializeContext(const egl::AttributeMap &eglAttributes);
FunctionsEGL *mEGL;
EGLConfig mConfig;
EGLContext mContext;
FunctionsGL *mFunctionsGL;
private:
void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
void generateCaps(egl::Caps *outCaps) const override;
const FunctionsGL *getFunctionsGL() const override;
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_GL_EGL_DISPLAYEGL_H_ */
...@@ -38,15 +38,24 @@ struct FunctionsEGL::EGLDispatchTable ...@@ -38,15 +38,24 @@ struct FunctionsEGL::EGLDispatchTable
: bindAPIPtr(nullptr), : bindAPIPtr(nullptr),
chooseConfigPtr(nullptr), chooseConfigPtr(nullptr),
createContextPtr(nullptr), createContextPtr(nullptr),
createPbufferSurfacePtr(nullptr),
createWindowSurfacePtr(nullptr),
destroyContextPtr(nullptr), destroyContextPtr(nullptr),
destroySurfacePtr(nullptr),
getConfigAttribPtr(nullptr), getConfigAttribPtr(nullptr),
getDisplayPtr(nullptr), getDisplayPtr(nullptr),
getErrorPtr(nullptr), getErrorPtr(nullptr),
initializePtr(nullptr), initializePtr(nullptr),
makeCurrentPtr(nullptr), makeCurrentPtr(nullptr),
queryStringPtr(nullptr), queryStringPtr(nullptr),
querySurfacePtr(nullptr),
swapBuffersPtr(nullptr),
terminatePtr(nullptr), terminatePtr(nullptr),
bindTexImagePtr(nullptr),
releaseTexImagePtr(nullptr),
swapIntervalPtr(nullptr),
createImageKHRPtr(nullptr), createImageKHRPtr(nullptr),
destroyImageKHRPtr(nullptr), destroyImageKHRPtr(nullptr),
...@@ -57,18 +66,29 @@ struct FunctionsEGL::EGLDispatchTable ...@@ -57,18 +66,29 @@ struct FunctionsEGL::EGLDispatchTable
{ {
} }
// 1.0
PFNEGLBINDAPIPROC bindAPIPtr; PFNEGLBINDAPIPROC bindAPIPtr;
PFNEGLCHOOSECONFIGPROC chooseConfigPtr; PFNEGLCHOOSECONFIGPROC chooseConfigPtr;
PFNEGLCREATECONTEXTPROC createContextPtr; PFNEGLCREATECONTEXTPROC createContextPtr;
PFNEGLCREATEPBUFFERSURFACEPROC createPbufferSurfacePtr;
PFNEGLCREATEWINDOWSURFACEPROC createWindowSurfacePtr;
PFNEGLDESTROYCONTEXTPROC destroyContextPtr; PFNEGLDESTROYCONTEXTPROC destroyContextPtr;
PFNEGLDESTROYSURFACEPROC destroySurfacePtr;
PFNEGLGETCONFIGATTRIBPROC getConfigAttribPtr; PFNEGLGETCONFIGATTRIBPROC getConfigAttribPtr;
PFNEGLGETDISPLAYPROC getDisplayPtr; PFNEGLGETDISPLAYPROC getDisplayPtr;
PFNEGLGETERRORPROC getErrorPtr; PFNEGLGETERRORPROC getErrorPtr;
PFNEGLINITIALIZEPROC initializePtr; PFNEGLINITIALIZEPROC initializePtr;
PFNEGLMAKECURRENTPROC makeCurrentPtr; PFNEGLMAKECURRENTPROC makeCurrentPtr;
PFNEGLQUERYSTRINGPROC queryStringPtr; PFNEGLQUERYSTRINGPROC queryStringPtr;
PFNEGLQUERYSURFACEPROC querySurfacePtr;
PFNEGLSWAPBUFFERSPROC swapBuffersPtr;
PFNEGLTERMINATEPROC terminatePtr; PFNEGLTERMINATEPROC terminatePtr;
// 1.1
PFNEGLBINDTEXIMAGEPROC bindTexImagePtr;
PFNEGLRELEASETEXIMAGEPROC releaseTexImagePtr;
PFNEGLSWAPINTERVALPROC swapIntervalPtr;
// EGL_KHR_image // EGL_KHR_image
PFNEGLCREATEIMAGEKHRPROC createImageKHRPtr; PFNEGLCREATEIMAGEKHRPROC createImageKHRPtr;
PFNEGLDESTROYIMAGEKHRPROC destroyImageKHRPtr; PFNEGLDESTROYIMAGEKHRPROC destroyImageKHRPtr;
...@@ -101,19 +121,28 @@ egl::Error FunctionsEGL::initialize(EGLNativeDisplayType nativeDisplay) ...@@ -101,19 +121,28 @@ egl::Error FunctionsEGL::initialize(EGLNativeDisplayType nativeDisplay)
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->bindAPIPtr, eglBindAPI); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->bindAPIPtr, eglBindAPI);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->chooseConfigPtr, eglChooseConfig); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->chooseConfigPtr, eglChooseConfig);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->createContextPtr, eglCreateContext); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->createContextPtr, eglCreateContext);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->createPbufferSurfacePtr, eglCreatePbufferSurface);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->createWindowSurfacePtr, eglCreateWindowSurface);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->destroyContextPtr, eglDestroyContext); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->destroyContextPtr, eglDestroyContext);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->destroySurfacePtr, eglDestroySurface);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->getConfigAttribPtr, eglGetConfigAttrib); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->getConfigAttribPtr, eglGetConfigAttrib);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->getDisplayPtr, eglGetDisplay); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->getDisplayPtr, eglGetDisplay);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->getErrorPtr, eglGetError); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->getErrorPtr, eglGetError);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->initializePtr, eglInitialize); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->initializePtr, eglInitialize);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->makeCurrentPtr, eglMakeCurrent); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->makeCurrentPtr, eglMakeCurrent);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->queryStringPtr, eglQueryString); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->queryStringPtr, eglQueryString);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->querySurfacePtr, eglQuerySurface);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->swapBuffersPtr, eglSwapBuffers);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->terminatePtr, eglTerminate); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->terminatePtr, eglTerminate);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->bindTexImagePtr, eglBindTexImage);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->releaseTexImagePtr, eglReleaseTexImage);
ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->swapIntervalPtr, eglSwapInterval);
mEGLDisplay = mFnPtrs->getDisplayPtr(nativeDisplay); mEGLDisplay = mFnPtrs->getDisplayPtr(nativeDisplay);
if (mEGLDisplay == EGL_NO_DISPLAY) if (mEGLDisplay == EGL_NO_DISPLAY)
{ {
return egl::Error(mFnPtrs->getErrorPtr(), "Failed to get system egl display"); return egl::Error(EGL_NOT_INITIALIZED, "Failed to get system egl display");
} }
if (mFnPtrs->initializePtr(mEGLDisplay, &majorVersion, &minorVersion) != EGL_TRUE) if (mFnPtrs->initializePtr(mEGLDisplay, &majorVersion, &minorVersion) != EGL_TRUE)
{ {
...@@ -194,15 +223,20 @@ EGLDisplay FunctionsEGL::getDisplay() const ...@@ -194,15 +223,20 @@ EGLDisplay FunctionsEGL::getDisplay() const
return mEGLDisplay; return mEGLDisplay;
} }
EGLint FunctionsEGL::getError() const
{
return mFnPtrs->getErrorPtr();
}
EGLBoolean FunctionsEGL::chooseConfig(EGLint const *attribList, EGLBoolean FunctionsEGL::chooseConfig(EGLint const *attribList,
EGLConfig *configs, EGLConfig *configs,
EGLint configSize, EGLint configSize,
EGLint *numConfig) EGLint *numConfig) const
{ {
return mFnPtrs->chooseConfigPtr(mEGLDisplay, attribList, configs, configSize, numConfig); return mFnPtrs->chooseConfigPtr(mEGLDisplay, attribList, configs, configSize, numConfig);
} }
EGLBoolean FunctionsEGL::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value) EGLBoolean FunctionsEGL::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value) const
{ {
return mFnPtrs->getConfigAttribPtr(mEGLDisplay, config, attribute, value); return mFnPtrs->getConfigAttribPtr(mEGLDisplay, config, attribute, value);
} }
...@@ -214,11 +248,28 @@ EGLContext FunctionsEGL::createContext(EGLConfig config, ...@@ -214,11 +248,28 @@ EGLContext FunctionsEGL::createContext(EGLConfig config,
return mFnPtrs->createContextPtr(mEGLDisplay, config, share_context, attrib_list); return mFnPtrs->createContextPtr(mEGLDisplay, config, share_context, attrib_list);
} }
EGLSurface FunctionsEGL::createPbufferSurface(EGLConfig config, const EGLint *attrib_list) const
{
return mFnPtrs->createPbufferSurfacePtr(mEGLDisplay, config, attrib_list);
}
EGLSurface FunctionsEGL::createWindowSurface(EGLConfig config,
EGLNativeWindowType win,
const EGLint *attrib_list) const
{
return mFnPtrs->createWindowSurfacePtr(mEGLDisplay, config, win, attrib_list);
}
EGLBoolean FunctionsEGL::destroyContext(EGLContext context) const EGLBoolean FunctionsEGL::destroyContext(EGLContext context) const
{ {
return mFnPtrs->destroyContextPtr(mEGLDisplay, context); return mFnPtrs->destroyContextPtr(mEGLDisplay, context);
} }
EGLBoolean FunctionsEGL::destroySurface(EGLSurface surface) const
{
return mFnPtrs->destroySurfacePtr(mEGLDisplay, surface);
}
EGLBoolean FunctionsEGL::makeCurrent(EGLSurface surface, EGLContext context) const EGLBoolean FunctionsEGL::makeCurrent(EGLSurface surface, EGLContext context) const
{ {
return mFnPtrs->makeCurrentPtr(mEGLDisplay, surface, surface, context); return mFnPtrs->makeCurrentPtr(mEGLDisplay, surface, surface, context);
...@@ -229,6 +280,31 @@ char const *FunctionsEGL::queryString(EGLint name) const ...@@ -229,6 +280,31 @@ char const *FunctionsEGL::queryString(EGLint name) const
return mFnPtrs->queryStringPtr(mEGLDisplay, name); return mFnPtrs->queryStringPtr(mEGLDisplay, name);
} }
EGLBoolean FunctionsEGL::querySurface(EGLSurface surface, EGLint attribute, EGLint *value) const
{
return mFnPtrs->querySurfacePtr(mEGLDisplay, surface, attribute, value);
}
EGLBoolean FunctionsEGL::swapBuffers(EGLSurface surface) const
{
return mFnPtrs->swapBuffersPtr(mEGLDisplay, surface);
}
EGLBoolean FunctionsEGL::bindTexImage(EGLSurface surface, EGLint buffer) const
{
return mFnPtrs->bindTexImagePtr(mEGLDisplay, surface, buffer);
}
EGLBoolean FunctionsEGL::releaseTexImage(EGLSurface surface, EGLint buffer) const
{
return mFnPtrs->releaseTexImagePtr(mEGLDisplay, surface, buffer);
}
EGLBoolean FunctionsEGL::swapInterval(EGLint interval) const
{
return mFnPtrs->swapIntervalPtr(mEGLDisplay, interval);
}
EGLImageKHR FunctionsEGL::createImageKHR(EGLContext context, EGLImageKHR FunctionsEGL::createImageKHR(EGLContext context,
EGLenum target, EGLenum target,
EGLClientBuffer buffer, EGLClientBuffer buffer,
......
...@@ -31,26 +31,38 @@ class FunctionsEGL ...@@ -31,26 +31,38 @@ class FunctionsEGL
int majorVersion; int majorVersion;
int minorVersion; int minorVersion;
virtual egl::Error initialize(EGLNativeDisplayType nativeDisplay); egl::Error initialize(EGLNativeDisplayType nativeDisplay);
virtual egl::Error terminate(); egl::Error terminate();
virtual void *getProcAddress(const char *name) const = 0; virtual void *getProcAddress(const char *name) const = 0;
FunctionsGL *makeFunctionsGL() const; FunctionsGL *makeFunctionsGL() const;
bool hasExtension(const char *extension) const; bool hasExtension(const char *extension) const;
EGLDisplay getDisplay() const; EGLDisplay getDisplay() const;
EGLint getError() const;
EGLBoolean chooseConfig(EGLint const *attrib_list, EGLBoolean chooseConfig(EGLint const *attrib_list,
EGLConfig *configs, EGLConfig *configs,
EGLint config_size, EGLint config_size,
EGLint *num_config); EGLint *num_config) const;
EGLBoolean getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value); EGLBoolean getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value) const;
EGLContext createContext(EGLConfig config, EGLContext createContext(EGLConfig config,
EGLContext share_context, EGLContext share_context,
EGLint const *attrib_list) const; EGLint const *attrib_list) const;
EGLSurface createPbufferSurface(EGLConfig config, const EGLint *attrib_list) const;
EGLSurface createWindowSurface(EGLConfig config,
EGLNativeWindowType win,
const EGLint *attrib_list) const;
EGLBoolean destroyContext(EGLContext context) const; EGLBoolean destroyContext(EGLContext context) const;
EGLBoolean destroySurface(EGLSurface surface) const;
EGLBoolean makeCurrent(EGLSurface surface, EGLContext context) const; EGLBoolean makeCurrent(EGLSurface surface, EGLContext context) const;
const char *queryString(EGLint name) const; const char *queryString(EGLint name) const;
EGLBoolean querySurface(EGLSurface surface, EGLint attribute, EGLint *value) const;
EGLBoolean swapBuffers(EGLSurface surface) const;
EGLBoolean bindTexImage(EGLSurface surface, EGLint buffer) const;
EGLBoolean releaseTexImage(EGLSurface surface, EGLint buffer) const;
EGLBoolean swapInterval(EGLint interval) const;
EGLImageKHR createImageKHR(EGLContext context, EGLImageKHR createImageKHR(EGLContext context,
EGLenum target, EGLenum target,
......
...@@ -32,7 +32,7 @@ DynamicLib::~DynamicLib() ...@@ -32,7 +32,7 @@ DynamicLib::~DynamicLib()
// TODO(fjhenigman) File a bug and put a link here. // TODO(fjhenigman) File a bug and put a link here.
DynamicLib FunctionsEGLDL::sNativeLib; DynamicLib FunctionsEGLDL::sNativeLib;
FunctionsEGLDL::FunctionsEGLDL() FunctionsEGLDL::FunctionsEGLDL() : mGetProcAddressPtr(nullptr)
{ {
} }
......
...@@ -28,10 +28,10 @@ class FunctionsEGLDL : public FunctionsEGL ...@@ -28,10 +28,10 @@ class FunctionsEGLDL : public FunctionsEGL
{ {
public: public:
FunctionsEGLDL(); FunctionsEGLDL();
virtual ~FunctionsEGLDL(); ~FunctionsEGLDL() override;
egl::Error initialize(EGLNativeDisplayType nativeDisplay, const char *libName); egl::Error initialize(EGLNativeDisplayType nativeDisplay, const char *libName);
virtual void *getProcAddress(const char *name) const override; void *getProcAddress(const char *name) const override;
private: private:
PFNEGLGETPROCADDRESSPROC mGetProcAddressPtr; PFNEGLGETPROCADDRESSPROC mGetProcAddressPtr;
......
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// PbufferSurfaceEGL.h: EGL implementation of egl::Surface for pbuffers
#include "libANGLE/renderer/gl/egl/PbufferSurfaceEGL.h"
namespace rx
{
PbufferSurfaceEGL::PbufferSurfaceEGL(const egl::SurfaceState &state,
const FunctionsEGL *egl,
EGLConfig config,
const std::vector<EGLint> &attribList,
EGLContext context,
RendererGL *renderer)
: SurfaceEGL(state, egl, config, attribList, context, renderer)
{
}
PbufferSurfaceEGL::~PbufferSurfaceEGL()
{
}
egl::Error PbufferSurfaceEGL::initialize()
{
mSurface = mEGL->createPbufferSurface(mConfig, mAttribList.data());
if (mSurface == EGL_NO_SURFACE)
{
return egl::Error(mEGL->getError(), "eglCreatePbufferSurface failed");
}
return egl::Error(EGL_SUCCESS);
}
} // namespace rx
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// PbufferSurfaceEGL.h: EGL implementation of egl::Surface for pbuffers
#ifndef LIBANGLE_RENDERER_GL_EGL_PBUFFERSURFACEEGL_H_
#define LIBANGLE_RENDERER_GL_EGL_PBUFFERSURFACEEGL_H_
#include <vector>
#include <EGL/egl.h>
#include "libANGLE/renderer/gl/egl/SurfaceEGL.h"
namespace rx
{
class PbufferSurfaceEGL : public SurfaceEGL
{
public:
PbufferSurfaceEGL(const egl::SurfaceState &state,
const FunctionsEGL *egl,
EGLConfig config,
const std::vector<EGLint> &attribList,
EGLContext context,
RendererGL *renderer);
~PbufferSurfaceEGL() override;
egl::Error initialize() override;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_EGL_PBUFFERSURFACEEGL_H_
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// SurfaceEGL.cpp: EGL implementation of egl::Surface
#include "libANGLE/renderer/gl/egl/SurfaceEGL.h"
#include "common/debug.h"
namespace rx
{
SurfaceEGL::SurfaceEGL(const egl::SurfaceState &state,
const FunctionsEGL *egl,
EGLConfig config,
const std::vector<EGLint> &attribList,
EGLContext context,
RendererGL *renderer)
: SurfaceGL(state, renderer),
mEGL(egl),
mConfig(config),
mAttribList(attribList),
mSurface(EGL_NO_SURFACE),
mContext(context)
{
}
SurfaceEGL::~SurfaceEGL()
{
if (mSurface != EGL_NO_SURFACE)
{
EGLBoolean success = mEGL->destroySurface(mSurface);
UNUSED_ASSERTION_VARIABLE(success);
ASSERT(success == EGL_TRUE);
}
}
egl::Error SurfaceEGL::makeCurrent()
{
EGLBoolean success = mEGL->makeCurrent(mSurface, mContext);
if (success == EGL_FALSE)
{
return egl::Error(mEGL->getError(), "eglMakeCurrent failed");
}
return egl::Error(EGL_SUCCESS);
}
egl::Error SurfaceEGL::swap()
{
EGLBoolean success = mEGL->swapBuffers(mSurface);
if (success == EGL_FALSE)
{
return egl::Error(mEGL->getError(), "eglSwapBuffers failed");
}
return egl::Error(EGL_SUCCESS);
}
egl::Error SurfaceEGL::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height)
{
UNIMPLEMENTED();
return egl::Error(EGL_BAD_SURFACE);
}
egl::Error SurfaceEGL::querySurfacePointerANGLE(EGLint attribute, void **value)
{
UNIMPLEMENTED();
return egl::Error(EGL_BAD_SURFACE);
}
egl::Error SurfaceEGL::bindTexImage(gl::Texture *texture, EGLint buffer)
{
EGLBoolean success = mEGL->bindTexImage(mSurface, buffer);
if (success == EGL_FALSE)
{
return egl::Error(mEGL->getError(), "eglBindTexImage failed");
}
return egl::Error(EGL_SUCCESS);
}
egl::Error SurfaceEGL::releaseTexImage(EGLint buffer)
{
EGLBoolean success = mEGL->releaseTexImage(mSurface, buffer);
if (success == EGL_FALSE)
{
return egl::Error(mEGL->getError(), "eglReleaseTexImage failed");
}
return egl::Error(EGL_SUCCESS);
}
void SurfaceEGL::setSwapInterval(EGLint interval)
{
EGLBoolean success = mEGL->swapInterval(interval);
if (success == EGL_FALSE)
{
ERR("eglSwapInterval error 0x%04x", mEGL->getError());
ASSERT(false);
}
}
EGLint SurfaceEGL::getWidth() const
{
EGLint value;
EGLBoolean success = mEGL->querySurface(mSurface, EGL_WIDTH, &value);
UNUSED_ASSERTION_VARIABLE(success);
ASSERT(success == EGL_TRUE);
return value;
}
EGLint SurfaceEGL::getHeight() const
{
EGLint value;
EGLBoolean success = mEGL->querySurface(mSurface, EGL_HEIGHT, &value);
UNUSED_ASSERTION_VARIABLE(success);
ASSERT(success == EGL_TRUE);
return value;
}
EGLint SurfaceEGL::isPostSubBufferSupported() const
{
UNIMPLEMENTED();
return 0;
}
EGLint SurfaceEGL::getSwapBehavior() const
{
EGLint value;
EGLBoolean success = mEGL->querySurface(mSurface, EGL_SWAP_BEHAVIOR, &value);
UNUSED_ASSERTION_VARIABLE(success);
ASSERT(success == EGL_TRUE);
return value;
}
} // namespace rx
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// SurfaceEGL.h: common interface for EGL surfaces
#ifndef LIBANGLE_RENDERER_GL_EGL_SURFACEEGL_H_
#define LIBANGLE_RENDERER_GL_EGL_SURFACEEGL_H_
#include <EGL/egl.h>
#include "libANGLE/renderer/gl/SurfaceGL.h"
#include "libANGLE/renderer/gl/egl/FunctionsEGL.h"
namespace rx
{
class SurfaceEGL : public SurfaceGL
{
public:
SurfaceEGL(const egl::SurfaceState &state,
const FunctionsEGL *egl,
EGLConfig config,
const std::vector<EGLint> &attribList,
EGLContext context,
RendererGL *renderer);
~SurfaceEGL() override;
egl::Error makeCurrent() override;
egl::Error swap() override;
egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) override;
egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override;
egl::Error bindTexImage(gl::Texture *texture, EGLint buffer) override;
egl::Error releaseTexImage(EGLint buffer) override;
void setSwapInterval(EGLint interval) override;
EGLint getWidth() const override;
EGLint getHeight() const override;
EGLint isPostSubBufferSupported() const override;
EGLint getSwapBehavior() const override;
protected:
const FunctionsEGL *mEGL;
EGLConfig mConfig;
std::vector<EGLint> mAttribList;
EGLSurface mSurface;
private:
EGLContext mContext;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_EGL_SURFACEEGL_H_
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// WindowSurfaceEGL.h: EGL implementation of egl::Surface for windows
#include "libANGLE/renderer/gl/egl/WindowSurfaceEGL.h"
namespace rx
{
WindowSurfaceEGL::WindowSurfaceEGL(const egl::SurfaceState &state,
const FunctionsEGL *egl,
EGLConfig config,
EGLNativeWindowType window,
const std::vector<EGLint> &attribList,
EGLContext context,
RendererGL *renderer)
: SurfaceEGL(state, egl, config, attribList, context, renderer), mWindow(window)
{
}
WindowSurfaceEGL::~WindowSurfaceEGL()
{
}
egl::Error WindowSurfaceEGL::initialize()
{
mSurface = mEGL->createWindowSurface(mConfig, mWindow, mAttribList.data());
if (mSurface == EGL_NO_SURFACE)
{
return egl::Error(mEGL->getError(), "eglCreateWindowSurface failed");
}
return egl::Error(EGL_SUCCESS);
}
} // namespace rx
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// WindowSurfaceEGL.h: EGL implementation of egl::Surface for windows
#ifndef LIBANGLE_RENDERER_GL_EGL_WINDOWSURFACEEGL_H_
#define LIBANGLE_RENDERER_GL_EGL_WINDOWSURFACEEGL_H_
#include "libANGLE/renderer/gl/egl/SurfaceEGL.h"
namespace rx
{
class WindowSurfaceEGL : public SurfaceEGL
{
public:
WindowSurfaceEGL(const egl::SurfaceState &state,
const FunctionsEGL *egl,
EGLConfig config,
EGLNativeWindowType window,
const std::vector<EGLint> &attribList,
EGLContext context,
RendererGL *renderer);
~WindowSurfaceEGL() override;
egl::Error initialize() override;
private:
EGLNativeWindowType mWindow;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_EGL_WINDOWSURFACEEGL_H_
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// DisplayAndroid.h: Android implementation of egl::Display
#ifndef LIBANGLE_RENDERER_GL_EGL_ANDROID_DISPLAYANDROID_H_
#define LIBANGLE_RENDERER_GL_EGL_ANDROID_DISPLAYANDROID_H_
#include <map>
#include <string>
#include <vector>
#include "libANGLE/renderer/gl/egl/DisplayEGL.h"
namespace rx
{
class DisplayAndroid : public DisplayEGL
{
public:
DisplayAndroid();
~DisplayAndroid() override;
egl::Error initialize(egl::Display *display) override;
void terminate() override;
SurfaceImpl *createWindowSurface(const egl::SurfaceState &state,
const egl::Config *configuration,
EGLNativeWindowType window,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPbufferSurface(const egl::SurfaceState &state,
const egl::Config *configuration,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state,
const egl::Config *configuration,
EGLClientBuffer shareHandle,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state,
const egl::Config *configuration,
NativePixmapType nativePixmap,
const egl::AttributeMap &attribs) override;
ImageImpl *createImage(EGLenum target,
egl::ImageSibling *buffer,
const egl::AttributeMap &attribs) override;
egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override;
egl::Error restoreLostDevice() override;
bool isValidNativeWindow(EGLNativeWindowType window) const override;
egl::Error getDevice(DeviceImpl **device) override;
egl::Error waitClient() const override;
egl::Error waitNative(EGLint engine,
egl::Surface *drawSurface,
egl::Surface *readSurface) const override;
egl::Error getDriverVersion(std::string *version) const override;
private:
template <typename T>
void getConfigAttrib(EGLConfig config, EGLint attribute, T *value) const;
std::vector<EGLint> mConfigAttribList;
std::map<EGLint, EGLint> mConfigIds;
EGLSurface mDummyPbuffer;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_EGL_ANDROID_DISPLAYANDROID_H_
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "libANGLE/renderer/gl/FramebufferGL.h" #include "libANGLE/renderer/gl/FramebufferGL.h"
#include "libANGLE/renderer/gl/RendererGL.h" #include "libANGLE/renderer/gl/RendererGL.h"
#include "libANGLE/renderer/gl/StateManagerGL.h" #include "libANGLE/renderer/gl/StateManagerGL.h"
#include "libANGLE/renderer/gl/egl/FunctionsEGLDL.h"
#include "libANGLE/renderer/gl/egl/ozone/SurfaceOzone.h" #include "libANGLE/renderer/gl/egl/ozone/SurfaceOzone.h"
#include "platform/Platform.h" #include "platform/Platform.h"
...@@ -325,14 +326,11 @@ void DisplayOzone::Buffer::present() ...@@ -325,14 +326,11 @@ void DisplayOzone::Buffer::present()
} }
DisplayOzone::DisplayOzone() DisplayOzone::DisplayOzone()
: mContextConfig(nullptr), : DisplayEGL(),
mContext(nullptr),
mSwapControl(SwapControl::ABSENT), mSwapControl(SwapControl::ABSENT),
mMinSwapInterval(0), mMinSwapInterval(0),
mMaxSwapInterval(0), mMaxSwapInterval(0),
mCurrentSwapInterval(-1), mCurrentSwapInterval(-1),
mEGL(nullptr),
mFunctionsGL(nullptr),
mGBM(nullptr), mGBM(nullptr),
mConnector(nullptr), mConnector(nullptr),
mMode(nullptr), mMode(nullptr),
...@@ -446,12 +444,9 @@ egl::Error DisplayOzone::initialize(egl::Display *display) ...@@ -446,12 +444,9 @@ egl::Error DisplayOzone::initialize(egl::Display *display)
// couldn't use LD_LIBRARY_PATH which is often useful during development. Instead we take // couldn't use LD_LIBRARY_PATH which is often useful during development. Instead we take
// advantage of the fact that the system lib is available under multiple names (for example // advantage of the fact that the system lib is available under multiple names (for example
// with a .1 suffix) while Angle only installs libEGL.so. // with a .1 suffix) while Angle only installs libEGL.so.
mEGL = new FunctionsEGLDL(); FunctionsEGLDL *egl = new FunctionsEGLDL();
egl::Error result = mEGL->initialize(display->getNativeDisplayId(), "libEGL.so.1"); mEGL = egl;
if (result.isError()) ANGLE_TRY(egl->initialize(display->getNativeDisplayId(), "libEGL.so.1"));
{
return result;
}
const char *necessaryExtensions[] = { const char *necessaryExtensions[] = {
"EGL_KHR_image_base", "EGL_EXT_image_dma_buf_import", "EGL_KHR_surfaceless_context", "EGL_KHR_image_base", "EGL_EXT_image_dma_buf_import", "EGL_KHR_surfaceless_context",
...@@ -466,7 +461,7 @@ egl::Error DisplayOzone::initialize(egl::Display *display) ...@@ -466,7 +461,7 @@ egl::Error DisplayOzone::initialize(egl::Display *display)
if (mEGL->hasExtension("EGL_MESA_configless_context")) if (mEGL->hasExtension("EGL_MESA_configless_context"))
{ {
mContextConfig = EGL_NO_CONFIG_MESA; mConfig = EGL_NO_CONFIG_MESA;
} }
else else
{ {
...@@ -489,14 +484,10 @@ egl::Error DisplayOzone::initialize(egl::Display *display) ...@@ -489,14 +484,10 @@ egl::Error DisplayOzone::initialize(egl::Display *display)
{ {
return egl::Error(EGL_NOT_INITIALIZED, "Could not get EGL config."); return egl::Error(EGL_NOT_INITIALIZED, "Could not get EGL config.");
} }
mContextConfig = config[0]; mConfig = config[0];
} }
mContext = initializeContext(mContextConfig, display->getAttributeMap()); ANGLE_TRY(initializeContext(display->getAttributeMap()));
if (mContext == EGL_NO_CONTEXT)
{
return egl::Error(EGL_NOT_INITIALIZED, "Could not create GLES context.");
}
if (!mEGL->makeCurrent(EGL_NO_SURFACE, mContext)) if (!mEGL->makeCurrent(EGL_NO_SURFACE, mContext))
{ {
...@@ -883,46 +874,6 @@ egl::Error DisplayOzone::getDevice(DeviceImpl **device) ...@@ -883,46 +874,6 @@ egl::Error DisplayOzone::getDevice(DeviceImpl **device)
return egl::Error(EGL_BAD_DISPLAY); return egl::Error(EGL_BAD_DISPLAY);
} }
EGLContext DisplayOzone::initializeContext(EGLConfig config, const egl::AttributeMap &eglAttributes)
{
if (!(mEGL->majorVersion > 1 || mEGL->minorVersion > 4 ||
mEGL->hasExtension("EGL_KHR_create_context")))
{
const EGLint attrib[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
return mEGL->createContext(config, EGL_NO_CONTEXT, attrib);
}
std::vector<gl::Version> versions;
EGLint major = eglAttributes.get(EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE);
EGLint minor = eglAttributes.get(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, EGL_DONT_CARE);
if (major != EGL_DONT_CARE && minor != EGL_DONT_CARE)
{
// If specific version requested, only try that one.
versions.push_back(gl::Version(major, minor));
}
else
{
// Acceptable versions, from most to least preferred.
versions.push_back(gl::Version(3, 0));
versions.push_back(gl::Version(2, 0));
}
for (auto &version : versions)
{
const EGLint attrib[] = {EGL_CONTEXT_MAJOR_VERSION_KHR, UnsignedToSigned(version.major),
EGL_CONTEXT_MINOR_VERSION_KHR, UnsignedToSigned(version.minor),
EGL_NONE};
auto context = mEGL->createContext(config, EGL_NO_CONTEXT, attrib);
if (context != EGL_NO_CONTEXT)
{
return context;
}
}
return EGL_NO_CONTEXT;
}
egl::ConfigSet DisplayOzone::generateConfigs() egl::ConfigSet DisplayOzone::generateConfigs()
{ {
egl::ConfigSet configs; egl::ConfigSet configs;
...@@ -963,11 +914,6 @@ bool DisplayOzone::isValidNativeWindow(EGLNativeWindowType window) const ...@@ -963,11 +914,6 @@ bool DisplayOzone::isValidNativeWindow(EGLNativeWindowType window) const
return true; return true;
} }
std::string DisplayOzone::getVendorString() const
{
return "";
}
egl::Error DisplayOzone::getDriverVersion(std::string *version) const egl::Error DisplayOzone::getDriverVersion(std::string *version) const
{ {
*version = ""; *version = "";
...@@ -993,18 +939,4 @@ void DisplayOzone::setSwapInterval(EGLSurface drawable, SwapControlData *data) ...@@ -993,18 +939,4 @@ void DisplayOzone::setSwapInterval(EGLSurface drawable, SwapControlData *data)
ASSERT(data != nullptr); ASSERT(data != nullptr);
} }
const FunctionsGL *DisplayOzone::getFunctionsGL() const
{
return mFunctionsGL;
}
void DisplayOzone::generateExtensions(egl::DisplayExtensions *outExtensions) const
{
}
void DisplayOzone::generateCaps(egl::Caps *outCaps) const
{
outCaps->textureNPOT = true;
}
} // namespace rx } // namespace rx
...@@ -14,12 +14,16 @@ ...@@ -14,12 +14,16 @@
#include <string> #include <string>
#include "libANGLE/renderer/gl/DisplayGL.h" #include "libANGLE/renderer/gl/egl/DisplayEGL.h"
#include "libANGLE/renderer/gl/egl/FunctionsEGLDL.h"
struct gbm_device; struct gbm_device;
struct gbm_bo; struct gbm_bo;
namespace gl
{
class FramebufferState;
}
namespace rx namespace rx
{ {
...@@ -40,7 +44,7 @@ struct SwapControlData final ...@@ -40,7 +44,7 @@ struct SwapControlData final
int currentSwapInterval; int currentSwapInterval;
}; };
class DisplayOzone final : public DisplayGL class DisplayOzone final : public DisplayEGL
{ {
public: public:
struct NativeWindow struct NativeWindow
...@@ -135,8 +139,6 @@ class DisplayOzone final : public DisplayGL ...@@ -135,8 +139,6 @@ class DisplayOzone final : public DisplayGL
egl::Error getDevice(DeviceImpl **device) override; egl::Error getDevice(DeviceImpl **device) override;
std::string getVendorString() const override;
egl::Error waitClient() const override; egl::Error waitClient() const override;
egl::Error waitNative(EGLint engine, egl::Error waitNative(EGLint engine,
egl::Surface *drawSurface, egl::Surface *drawSurface,
...@@ -151,13 +153,6 @@ class DisplayOzone final : public DisplayGL ...@@ -151,13 +153,6 @@ class DisplayOzone final : public DisplayGL
egl::Error getDriverVersion(std::string *version) const override; egl::Error getDriverVersion(std::string *version) const override;
private: private:
const FunctionsGL *getFunctionsGL() const override;
EGLContext initializeContext(EGLConfig config, const egl::AttributeMap &eglAttributes);
void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
void generateCaps(egl::Caps *outCaps) const override;
GLuint makeShader(GLuint type, const char *src); GLuint makeShader(GLuint type, const char *src);
void drawBuffer(Buffer *buffer); void drawBuffer(Buffer *buffer);
void drawWithBlit(Buffer *buffer); void drawWithBlit(Buffer *buffer);
...@@ -171,9 +166,6 @@ class DisplayOzone final : public DisplayGL ...@@ -171,9 +166,6 @@ class DisplayOzone final : public DisplayGL
void *data); void *data);
void pageFlipHandler(unsigned int sequence, uint64_t tv); void pageFlipHandler(unsigned int sequence, uint64_t tv);
EGLConfig mContextConfig;
EGLContext mContext;
// TODO(fjhenigman) Implement swap control. The following stuff will be used for that. // TODO(fjhenigman) Implement swap control. The following stuff will be used for that.
enum class SwapControl enum class SwapControl
{ {
...@@ -187,9 +179,6 @@ class DisplayOzone final : public DisplayGL ...@@ -187,9 +179,6 @@ class DisplayOzone final : public DisplayGL
int mMaxSwapInterval; int mMaxSwapInterval;
int mCurrentSwapInterval; int mCurrentSwapInterval;
FunctionsEGLDL *mEGL;
FunctionsGL *mFunctionsGL;
gbm_device *mGBM; gbm_device *mGBM;
drmModeConnectorPtr mConnector; drmModeConnectorPtr mConnector;
drmModeModeInfoPtr mMode; drmModeModeInfoPtr mMode;
......
...@@ -38,6 +38,10 @@ VendorID GetVendorID(const FunctionsGL *functions) ...@@ -38,6 +38,10 @@ VendorID GetVendorID(const FunctionsGL *functions)
{ {
return VENDOR_ID_AMD; return VENDOR_ID_AMD;
} }
else if (nativeVendorString.find("Qualcomm") != std::string::npos)
{
return VENDOR_ID_QUALCOMM;
}
else else
{ {
return VENDOR_ID_UNKNOWN; return VENDOR_ID_UNKNOWN;
......
...@@ -513,9 +513,17 @@ ...@@ -513,9 +513,17 @@
], ],
'libangle_gl_egl_sources': 'libangle_gl_egl_sources':
[ [
'libANGLE/renderer/gl/egl/DisplayEGL.cpp',
'libANGLE/renderer/gl/egl/DisplayEGL.h',
'libANGLE/renderer/gl/egl/FunctionsEGL.cpp', 'libANGLE/renderer/gl/egl/FunctionsEGL.cpp',
'libANGLE/renderer/gl/egl/FunctionsEGL.h', 'libANGLE/renderer/gl/egl/FunctionsEGL.h',
'libANGLE/renderer/gl/egl/functionsegl_typedefs.h', 'libANGLE/renderer/gl/egl/functionsegl_typedefs.h',
'libANGLE/renderer/gl/egl/PbufferSurfaceEGL.cpp',
'libANGLE/renderer/gl/egl/PbufferSurfaceEGL.h',
'libANGLE/renderer/gl/egl/SurfaceEGL.cpp',
'libANGLE/renderer/gl/egl/SurfaceEGL.h',
'libANGLE/renderer/gl/egl/WindowSurfaceEGL.cpp',
'libANGLE/renderer/gl/egl/WindowSurfaceEGL.h',
], ],
'libangle_gl_egl_dl_sources': 'libangle_gl_egl_dl_sources':
[ [
...@@ -529,6 +537,11 @@ ...@@ -529,6 +537,11 @@
'libANGLE/renderer/gl/egl/ozone/SurfaceOzone.cpp', 'libANGLE/renderer/gl/egl/ozone/SurfaceOzone.cpp',
'libANGLE/renderer/gl/egl/ozone/SurfaceOzone.h', 'libANGLE/renderer/gl/egl/ozone/SurfaceOzone.h',
], ],
'libangle_gl_egl_android_sources':
[
'libANGLE/renderer/gl/egl/android/DisplayAndroid.cpp',
'libANGLE/renderer/gl/egl/android/DisplayAndroid.h',
],
'libangle_gl_cgl_sources': 'libangle_gl_cgl_sources':
[ [
'libANGLE/renderer/gl/cgl/DisplayCGL.mm', 'libANGLE/renderer/gl/cgl/DisplayCGL.mm',
......
...@@ -40,7 +40,7 @@ test("angle_unittests") { ...@@ -40,7 +40,7 @@ test("angle_unittests") {
] ]
} }
if (is_win || is_linux || is_mac) { if (is_win || is_linux || is_mac || is_android) {
end2end_gypi = exec_script("//build/gypi_to_gn.py", end2end_gypi = exec_script("//build/gypi_to_gn.py",
[ [
rebase_path("angle_end2end_tests.gypi"), rebase_path("angle_end2end_tests.gypi"),
...@@ -56,6 +56,10 @@ if (is_win || is_linux || is_mac) { ...@@ -56,6 +56,10 @@ if (is_win || is_linux || is_mac) {
"../../util", "../../util",
] ]
if (is_android) {
use_native_activity = true
}
sources = sources =
rebase_path(end2end_gypi.angle_end2end_tests_sources, ".", "../..") rebase_path(end2end_gypi.angle_end2end_tests_sources, ".", "../..")
......
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// AndroidWindow.cpp: Implementation of OSWindow for Android
#include "android/AndroidWindow.h"
#include <pthread.h>
#include "android/third_party/android_native_app_glue.h"
#include "common/debug.h"
namespace
{
struct android_app *sApp = nullptr;
pthread_mutex_t sInitWindowMutex;
pthread_cond_t sInitWindowCond;
bool sInitWindowDone = false;
} // namespace
AndroidWindow::AndroidWindow()
{
}
AndroidWindow::~AndroidWindow()
{
}
bool AndroidWindow::initialize(const std::string &name, size_t width, size_t height)
{
return resize(width, height);
}
void AndroidWindow::destroy()
{
}
EGLNativeWindowType AndroidWindow::getNativeWindow() const
{
// Return the entire Activity Surface for now
// sApp->window is valid only after sInitWindowDone, which is true after initialize()
return sApp->window;
}
EGLNativeDisplayType AndroidWindow::getNativeDisplay() const
{
return EGL_DEFAULT_DISPLAY;
}
void AndroidWindow::messageLoop()
{
// TODO: accumulate events in the real message loop of android_main,
// and process them here
}
void AndroidWindow::setMousePosition(int x, int y)
{
UNIMPLEMENTED();
}
bool AndroidWindow::setPosition(int x, int y)
{
UNIMPLEMENTED();
return false;
}
bool AndroidWindow::resize(int width, int height)
{
mWidth = width;
mHeight = height;
// sApp->window used below is valid only after Activity Surface is created
pthread_mutex_lock(&sInitWindowMutex);
while (!sInitWindowDone)
{
pthread_cond_wait(&sInitWindowCond, &sInitWindowMutex);
}
pthread_mutex_unlock(&sInitWindowMutex);
// TODO: figure out a way to set the format as well,
// which is available only after EGLWindow initialization
int32_t err = ANativeWindow_setBuffersGeometry(sApp->window, mWidth, mHeight, 0);
return err == 0;
}
void AndroidWindow::setVisible(bool isVisible)
{
}
void AndroidWindow::signalTestEvent()
{
UNIMPLEMENTED();
}
OSWindow *CreateOSWindow()
{
// There should be only one live instance of AndroidWindow at a time,
// as there is only one Activity Surface behind it.
// Creating a new AndroidWindow each time works for ANGLETest,
// as it destroys an old window before creating a new one.
// TODO: use GLSurfaceView to support multiple windows
return new AndroidWindow();
}
static void onAppCmd(struct android_app *app, int32_t cmd)
{
switch (cmd)
{
case APP_CMD_INIT_WINDOW:
pthread_mutex_lock(&sInitWindowMutex);
sInitWindowDone = true;
pthread_cond_broadcast(&sInitWindowCond);
pthread_mutex_unlock(&sInitWindowMutex);
break;
// TODO: process other commands and pass them to AndroidWindow for handling
// TODO: figure out how to handle APP_CMD_PAUSE,
// which should immediately halt all the rendering,
// since Activity Surface is no longer available.
// Currently tests crash when paused, for example, due to device changing orientation
}
}
static int32_t onInputEvent(struct android_app *app, AInputEvent *event)
{
// TODO: Handle input events
return 0; // 0 == not handled
}
void android_main(struct android_app *app)
{
int events;
struct android_poll_source *source;
sApp = app;
pthread_mutex_init(&sInitWindowMutex, nullptr);
pthread_cond_init(&sInitWindowCond, nullptr);
// Event handlers, invoked from source->process()
app->onAppCmd = onAppCmd;
app->onInputEvent = onInputEvent;
// Message loop, polling for events indefinitely (due to -1 timeout)
// Must be here in order to handle APP_CMD_INIT_WINDOW event,
// which occurs after AndroidWindow::initialize(), but before AndroidWindow::messageLoop
while (ALooper_pollAll(-1, nullptr, &events, reinterpret_cast<void **>(&source)) >= 0)
{
if (source != nullptr)
{
source->process(app, source);
}
}
}
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// AndroidWindow.h: Definition of the implementation of OSWindow for Android
#ifndef UTIL_ANDROID_WINDOW_H_
#define UTIL_ANDROID_WINDOW_H_
#include "OSWindow.h"
class AndroidWindow : public OSWindow
{
public:
AndroidWindow();
~AndroidWindow() override;
bool initialize(const std::string &name, size_t width, size_t height) override;
void destroy() override;
EGLNativeWindowType getNativeWindow() const override;
EGLNativeDisplayType getNativeDisplay() const override;
void messageLoop() override;
void setMousePosition(int x, int y) override;
bool setPosition(int x, int y) override;
bool resize(int width, int height) override;
void setVisible(bool isVisible) override;
void signalTestEvent() override;
};
#endif /* UTIL_ANDROID_WINDOW_H_ */
Name: android_native_app_glue
URL: https://android.googlesource.com/platform/ndk/+/65966d5033af36134135d1308bdc62b216a5a414/sources/android/native_app_glue
Version: 65966d5033af36134135d1308bdc62b216a5a414
License: Apache License, Version 2.0
License File: http://www.apache.org/licenses/LICENSE-2.0
Description:
Helper glue code for ANativeActivity implementations
\ No newline at end of file
...@@ -83,6 +83,13 @@ ...@@ -83,6 +83,13 @@
'osx/OSXWindow.h', 'osx/OSXWindow.h',
'posix/Posix_system_utils.cpp', 'posix/Posix_system_utils.cpp',
], ],
'util_android_sources':
[
'android/AndroidWindow.cpp',
'android/AndroidWindow.h',
'android/third_party/android_native_app_glue.c',
'android/third_party/android_native_app_glue.h',
],
}, },
'targets': 'targets':
[ [
......
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