Commit 9b1a9084 by Jamie Madill Committed by Commit Bot

dEQP: Format display factory and clean up style.

This fixes a bunch of minor style issues. Bug: angleproject:2552 Change-Id: If0e8130cf85deb176a5dcbca568cca477d2c1068 Reviewed-on: https://chromium-review.googlesource.com/1062789Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 78b7f3a8
......@@ -14,9 +14,9 @@
#include <gtest/gtest.h>
#include "angle_deqp_libtester.h"
#include "common/Optional.h"
#include "common/angleutils.h"
#include "common/debug.h"
#include "common/Optional.h"
#include "common/platform.h"
#include "common/string_utils.h"
#include "gpu_test_expectations_parser.h"
......@@ -119,8 +119,7 @@ void Die()
exit(EXIT_FAILURE);
}
Optional<std::string> FindTestExpectationsPath(const std::string &exeDir,
size_t testModuleIndex)
Optional<std::string> FindTestExpectationsPath(const std::string &exeDir, size_t testModuleIndex)
{
for (const char *testPath : gTestExpectationsSearchPaths)
{
......@@ -146,12 +145,8 @@ class dEQPCaseList
struct CaseInfo
{
CaseInfo(const std::string &dEQPName,
const std::string &gTestName,
int expectation)
: mDEQPName(dEQPName),
mGTestName(gTestName),
mExpectation(expectation)
CaseInfo(const std::string &dEQPName, const std::string &gTestName, int expectation)
: mDEQPName(dEQPName), mGTestName(gTestName), mExpectation(expectation)
{
}
......@@ -184,8 +179,7 @@ class dEQPCaseList
};
dEQPCaseList::dEQPCaseList(size_t testModuleIndex)
: mTestModuleIndex(testModuleIndex),
mInitialized(false)
: mTestModuleIndex(testModuleIndex), mInitialized(false)
{
}
......@@ -322,9 +316,9 @@ class dEQPTest : public testing::TestWithParam<size_t>
};
template <size_t TestModuleIndex>
unsigned int dEQPTest<TestModuleIndex>::sPasses = 0;
unsigned int dEQPTest<TestModuleIndex>::sPasses = 0;
template <size_t TestModuleIndex>
unsigned int dEQPTest<TestModuleIndex>::sFails = 0;
unsigned int dEQPTest<TestModuleIndex>::sFails = 0;
template <size_t TestModuleIndex>
unsigned int dEQPTest<TestModuleIndex>::sUnexpectedPasses = 0;
......@@ -467,7 +461,7 @@ void DeleteArg(int *argc, int argIndex, char **argv)
}
}
} // anonymous namespace
} // anonymous namespace
// Called from main() to process command-line arguments.
namespace angle
......
......@@ -23,13 +23,12 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "OSPixmap.h"
#include "OSWindow.h"
#include "deClock.h"
#include "deMemory.h"
#include "deThread.h"
#include "egluDefs.hpp"
#include "eglwLibrary.hpp"
#include "OSPixmap.h"
#include "OSWindow.h"
#include "tcuTexture.hpp"
// clang-format off
......@@ -51,26 +50,28 @@ namespace
enum
{
DEFAULT_SURFACE_WIDTH = 400,
DEFAULT_SURFACE_HEIGHT = 300,
WAIT_WINDOW_VISIBLE_MS = 500 //!< Time to wait before issuing screenshot after changing window visibility (hack for DWM)
DEFAULT_SURFACE_WIDTH = 400,
DEFAULT_SURFACE_HEIGHT = 300,
};
static const eglu::NativeDisplay::Capability DISPLAY_CAPABILITIES = eglu::NativeDisplay::CAPABILITY_GET_DISPLAY_PLATFORM;
static const eglu::NativePixmap::Capability BITMAP_CAPABILITIES = eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY;
static const eglu::NativeWindow::Capability WINDOW_CAPABILITIES = (eglu::NativeWindow::Capability)
(eglu::NativeWindow::CAPABILITY_CREATE_SURFACE_LEGACY |
eglu::NativeWindow::CAPABILITY_GET_SURFACE_SIZE |
eglu::NativeWindow::CAPABILITY_GET_SCREEN_SIZE |
eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS |
eglu::NativeWindow::CAPABILITY_SET_SURFACE_SIZE |
eglu::NativeWindow::CAPABILITY_CHANGE_VISIBILITY);
constexpr eglu::NativeDisplay::Capability kDisplayCapabilities =
eglu::NativeDisplay::CAPABILITY_GET_DISPLAY_PLATFORM;
constexpr eglu::NativePixmap::Capability kBitmapCapabilities =
eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY;
constexpr eglu::NativeWindow::Capability kWindowCapabilities =
static_cast<eglu::NativeWindow::Capability>(
eglu::NativeWindow::CAPABILITY_CREATE_SURFACE_LEGACY |
eglu::NativeWindow::CAPABILITY_GET_SURFACE_SIZE |
eglu::NativeWindow::CAPABILITY_GET_SCREEN_SIZE |
eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS |
eglu::NativeWindow::CAPABILITY_SET_SURFACE_SIZE |
eglu::NativeWindow::CAPABILITY_CHANGE_VISIBILITY);
class ANGLENativeDisplay : public eglu::NativeDisplay
{
public:
ANGLENativeDisplay(const std::vector<eglw::EGLAttrib> &attribs);
virtual ~ANGLENativeDisplay() {}
explicit ANGLENativeDisplay(std::vector<eglw::EGLAttrib> attribs);
~ANGLENativeDisplay() override = default;
void *getPlatformNative() override
{
......@@ -80,10 +81,13 @@ class ANGLENativeDisplay : public eglu::NativeDisplay
memcpy(&result, &mDeviceContext, sizeof(mDeviceContext));
return result;
}
const eglw::EGLAttrib *getPlatformAttributes() const override { return &mPlatformAttributes[0]; }
const eglw::EGLAttrib *getPlatformAttributes() const override
{
return &mPlatformAttributes[0];
}
const eglw::Library &getLibrary() const override { return mLibrary; }
EGLNativeDisplayType getDeviceContext() { return mDeviceContext; }
EGLNativeDisplayType getDeviceContext() const { return mDeviceContext; }
private:
EGLNativeDisplayType mDeviceContext;
......@@ -95,10 +99,17 @@ class NativePixmapFactory : public eglu::NativePixmapFactory
{
public:
NativePixmapFactory();
~NativePixmapFactory() {}
eglu::NativePixmap *createPixmap(eglu::NativeDisplay *nativeDisplay, int width, int height) const override;
eglu::NativePixmap *createPixmap(eglu::NativeDisplay *nativeDisplay, eglw::EGLDisplay display, eglw::EGLConfig config, const eglw::EGLAttrib* attribList, int width, int height) const override;
~NativePixmapFactory() override = default;
eglu::NativePixmap *createPixmap(eglu::NativeDisplay *nativeDisplay,
int width,
int height) const override;
eglu::NativePixmap *createPixmap(eglu::NativeDisplay *nativeDisplay,
eglw::EGLDisplay display,
eglw::EGLConfig config,
const eglw::EGLAttrib *attribList,
int width,
int height) const override;
};
class NativePixmap : public eglu::NativePixmap
......@@ -116,10 +127,11 @@ class NativePixmap : public eglu::NativePixmap
class NativeWindowFactory : public eglu::NativeWindowFactory
{
public:
NativeWindowFactory(EventState *eventState);
~NativeWindowFactory() override {}
explicit NativeWindowFactory(EventState *eventState);
~NativeWindowFactory() override = default;
eglu::NativeWindow *createWindow(eglu::NativeDisplay *nativeDisplay, const eglu::WindowParams &params) const override;
eglu::NativeWindow *createWindow(eglu::NativeDisplay *nativeDisplay,
const eglu::WindowParams &params) const override;
private:
EventState *mEvents;
......@@ -128,7 +140,9 @@ class NativeWindowFactory : public eglu::NativeWindowFactory
class NativeWindow : public eglu::NativeWindow
{
public:
NativeWindow(ANGLENativeDisplay *nativeDisplay, const eglu::WindowParams &params, EventState *eventState);
NativeWindow(ANGLENativeDisplay *nativeDisplay,
const eglu::WindowParams &params,
EventState *eventState);
~NativeWindow() override;
eglw::EGLNativeWindowType getLegacyNative() override;
......@@ -137,7 +151,7 @@ class NativeWindow : public eglu::NativeWindow
void processEvents() override;
void setSurfaceSize(IVec2 size) override;
void setVisibility(eglu::WindowParams::Visibility visibility) override;
void readScreenPixels(tcu::TextureLevel* dst) const override;
void readScreenPixels(tcu::TextureLevel *dst) const override;
private:
OSWindow *mWindow;
......@@ -146,19 +160,18 @@ class NativeWindow : public eglu::NativeWindow
// ANGLE NativeDisplay
ANGLENativeDisplay::ANGLENativeDisplay(const std::vector<EGLAttrib> &attribs)
: eglu::NativeDisplay(DISPLAY_CAPABILITIES, EGL_PLATFORM_ANGLE_ANGLE, "EGL_EXT_platform_base"),
ANGLENativeDisplay::ANGLENativeDisplay(std::vector<EGLAttrib> attribs)
: eglu::NativeDisplay(kDisplayCapabilities, EGL_PLATFORM_ANGLE_ANGLE, "EGL_EXT_platform_base"),
mDeviceContext(EGL_DEFAULT_DISPLAY),
mLibrary(ANGLE_EGL_LIBRARY_FULL_NAME),
mPlatformAttributes(attribs)
mPlatformAttributes(std::move(attribs))
{
}
// NativePixmap
NativePixmap::NativePixmap(EGLNativeDisplayType display, int width, int height, int bitDepth)
: eglu::NativePixmap(BITMAP_CAPABILITIES),
mPixmap(CreateOSPixmap())
: eglu::NativePixmap(kBitmapCapabilities), mPixmap(CreateOSPixmap())
{
if (!mPixmap)
{
......@@ -184,83 +197,93 @@ eglw::EGLNativePixmapType NativePixmap::getLegacyNative()
// NativePixmapFactory
NativePixmapFactory::NativePixmapFactory()
: eglu::NativePixmapFactory("bitmap", "ANGLE Bitmap", BITMAP_CAPABILITIES)
: eglu::NativePixmapFactory("bitmap", "ANGLE Bitmap", kBitmapCapabilities)
{
}
eglu::NativePixmap *NativePixmapFactory::createPixmap (eglu::NativeDisplay* nativeDisplay, eglw::EGLDisplay display, eglw::EGLConfig config, const eglw::EGLAttrib* attribList, int width, int height) const
eglu::NativePixmap *NativePixmapFactory::createPixmap(eglu::NativeDisplay *nativeDisplay,
eglw::EGLDisplay display,
eglw::EGLConfig config,
const eglw::EGLAttrib *attribList,
int width,
int height) const
{
const eglw::Library& egl = nativeDisplay->getLibrary();
int redBits = 0;
int greenBits = 0;
int blueBits = 0;
int alphaBits = 0;
int bitSum = 0;
const eglw::Library &egl = nativeDisplay->getLibrary();
int redBits = 0;
int greenBits = 0;
int blueBits = 0;
int alphaBits = 0;
int bitSum = 0;
DE_ASSERT(display != EGL_NO_DISPLAY);
egl.getConfigAttrib(display, config, EGL_RED_SIZE, &redBits);
egl.getConfigAttrib(display, config, EGL_GREEN_SIZE, &greenBits);
egl.getConfigAttrib(display, config, EGL_BLUE_SIZE, &blueBits);
egl.getConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaBits);
egl.getConfigAttrib(display, config, EGL_RED_SIZE, &redBits);
egl.getConfigAttrib(display, config, EGL_GREEN_SIZE, &greenBits);
egl.getConfigAttrib(display, config, EGL_BLUE_SIZE, &blueBits);
egl.getConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaBits);
EGLU_CHECK_MSG(egl, "eglGetConfigAttrib()");
bitSum = redBits+greenBits+blueBits+alphaBits;
bitSum = redBits + greenBits + blueBits + alphaBits;
return new NativePixmap(dynamic_cast<ANGLENativeDisplay*>(nativeDisplay)->getDeviceContext(), width, height, bitSum);
return new NativePixmap(dynamic_cast<ANGLENativeDisplay *>(nativeDisplay)->getDeviceContext(),
width, height, bitSum);
}
eglu::NativePixmap *NativePixmapFactory::createPixmap(eglu::NativeDisplay* nativeDisplay, int width, int height) const
eglu::NativePixmap *NativePixmapFactory::createPixmap(eglu::NativeDisplay *nativeDisplay,
int width,
int height) const
{
const int defaultDepth = 32;
return new NativePixmap(dynamic_cast<ANGLENativeDisplay*>(nativeDisplay)->getDeviceContext(), width, height, defaultDepth);
return new NativePixmap(dynamic_cast<ANGLENativeDisplay *>(nativeDisplay)->getDeviceContext(),
width, height, defaultDepth);
}
// NativeWindowFactory
NativeWindowFactory::NativeWindowFactory(EventState *eventState)
: eglu::NativeWindowFactory("window", "ANGLE Window", WINDOW_CAPABILITIES),
mEvents(eventState)
: eglu::NativeWindowFactory("window", "ANGLE Window", kWindowCapabilities), mEvents(eventState)
{
}
eglu::NativeWindow *NativeWindowFactory::createWindow(eglu::NativeDisplay* nativeDisplay, const eglu::WindowParams& params) const
eglu::NativeWindow *NativeWindowFactory::createWindow(eglu::NativeDisplay *nativeDisplay,
const eglu::WindowParams &params) const
{
return new NativeWindow(dynamic_cast<ANGLENativeDisplay*>(nativeDisplay), params, mEvents);
return new NativeWindow(dynamic_cast<ANGLENativeDisplay *>(nativeDisplay), params, mEvents);
}
// NativeWindow
NativeWindow::NativeWindow(ANGLENativeDisplay *nativeDisplay, const eglu::WindowParams& params, EventState *eventState)
: eglu::NativeWindow(WINDOW_CAPABILITIES),
mWindow(CreateOSWindow()),
mEvents(eventState)
NativeWindow::NativeWindow(ANGLENativeDisplay *nativeDisplay,
const eglu::WindowParams &params,
EventState *eventState)
: eglu::NativeWindow(kWindowCapabilities), mWindow(CreateOSWindow()), mEvents(eventState)
{
bool initialized = mWindow->initialize("dEQP ANGLE Tests",
params.width == eglu::WindowParams::SIZE_DONT_CARE ? DEFAULT_SURFACE_WIDTH : params.width,
params.height == eglu::WindowParams::SIZE_DONT_CARE ? DEFAULT_SURFACE_HEIGHT : params.height);
bool initialized = mWindow->initialize(
"dEQP ANGLE Tests",
params.width == eglu::WindowParams::SIZE_DONT_CARE ? DEFAULT_SURFACE_WIDTH : params.width,
params.height == eglu::WindowParams::SIZE_DONT_CARE ? DEFAULT_SURFACE_HEIGHT
: params.height);
TCU_CHECK(initialized);
if (params.visibility != eglu::WindowParams::VISIBILITY_DONT_CARE)
setVisibility(params.visibility);
NativeWindow::setVisibility(params.visibility);
}
void NativeWindow::setVisibility(eglu::WindowParams::Visibility visibility)
{
switch (visibility)
{
case eglu::WindowParams::VISIBILITY_HIDDEN:
mWindow->setVisible(false);
break;
case eglu::WindowParams::VISIBILITY_VISIBLE:
case eglu::WindowParams::VISIBILITY_FULLSCREEN:
// \todo [2014-03-12 pyry] Implement FULLSCREEN, or at least SW_MAXIMIZE.
mWindow->setVisible(true);
break;
default:
DE_ASSERT(DE_FALSE);
case eglu::WindowParams::VISIBILITY_HIDDEN:
mWindow->setVisible(false);
break;
case eglu::WindowParams::VISIBILITY_VISIBLE:
case eglu::WindowParams::VISIBILITY_FULLSCREEN:
mWindow->setVisible(true);
break;
default:
DE_ASSERT(DE_FALSE);
}
}
......@@ -284,7 +307,7 @@ void NativeWindow::processEvents()
mWindow->messageLoop();
// Look for a quit event to forward to the EventState
Event event;
Event event = {};
while (mWindow->popEvent(&event))
{
if (event.Type == Event::EVENT_CLOSED)
......@@ -301,34 +324,39 @@ void NativeWindow::setSurfaceSize(IVec2 size)
void NativeWindow::readScreenPixels(tcu::TextureLevel *dst) const
{
dst->setStorage(TextureFormat(TextureFormat::BGRA, TextureFormat::UNORM_INT8), mWindow->getWidth(), mWindow->getHeight());
dst->setStorage(TextureFormat(TextureFormat::BGRA, TextureFormat::UNORM_INT8),
mWindow->getWidth(), mWindow->getHeight());
if (!mWindow->takeScreenshot(reinterpret_cast<uint8_t *>(dst->getAccess().getDataPtr())))
{
throw InternalError("Failed to read screen pixels", DE_NULL, __FILE__, __LINE__);
}
}
} // anonymous
ANGLENativeDisplayFactory::ANGLENativeDisplayFactory(const std::string &name,
const std::string &description,
const std::vector<eglw::EGLAttrib> &platformAttributes,
EventState *eventState)
: eglu::NativeDisplayFactory(name, description, DISPLAY_CAPABILITIES, EGL_PLATFORM_ANGLE_ANGLE, "EGL_EXT_platform_base"),
mPlatformAttributes(platformAttributes)
} // anonymous
ANGLENativeDisplayFactory::ANGLENativeDisplayFactory(
const std::string &name,
const std::string &description,
std::vector<eglw::EGLAttrib> platformAttributes,
EventState *eventState)
: eglu::NativeDisplayFactory(name,
description,
kDisplayCapabilities,
EGL_PLATFORM_ANGLE_ANGLE,
"EGL_EXT_platform_base"),
mPlatformAttributes(std::move(platformAttributes))
{
m_nativeWindowRegistry.registerFactory(new NativeWindowFactory(eventState));
m_nativePixmapRegistry.registerFactory(new NativePixmapFactory());
}
ANGLENativeDisplayFactory::~ANGLENativeDisplayFactory()
{
}
ANGLENativeDisplayFactory::~ANGLENativeDisplayFactory() = default;
eglu::NativeDisplay *ANGLENativeDisplayFactory::createDisplay(const eglw::EGLAttrib *attribList) const
eglu::NativeDisplay *ANGLENativeDisplayFactory::createDisplay(
const eglw::EGLAttrib *attribList) const
{
DE_UNREF(attribList);
return new ANGLENativeDisplay(mPlatformAttributes);
}
} // tcu
} // tcu
......@@ -21,9 +21,9 @@
#ifndef TCU_ANGLE_WIN32_NATIVE_DISPLAY_FACTORY_H_
#define TCU_ANGLE_WIN32_NATIVE_DISPLAY_FACTORY_H_
#include "tcuDefs.hpp"
#include "egluNativeDisplay.hpp"
#include "eglwDefs.hpp"
#include "tcuDefs.hpp"
namespace tcu
{
......@@ -31,10 +31,7 @@ namespace tcu
class EventState
{
public:
EventState()
: mQuit(false)
{
}
EventState() : mQuit(false) {}
bool quitSignaled() const { return mQuit; };
void signalQuitEvent() { mQuit = true; };
......@@ -47,16 +44,16 @@ class ANGLENativeDisplayFactory : public eglu::NativeDisplayFactory
public:
ANGLENativeDisplayFactory(const std::string &name,
const std::string &description,
const std::vector<eglw::EGLAttrib> &platformAttributes,
std::vector<eglw::EGLAttrib> platformAttributes,
EventState *eventState);
~ANGLENativeDisplayFactory() override;
eglu::NativeDisplay *createDisplay(const eglw::EGLAttrib* attribList) const override;
eglu::NativeDisplay *createDisplay(const eglw::EGLAttrib *attribList) const override;
private:
std::vector<eglw::EGLAttrib> mPlatformAttributes;
};
} // tcu
} // tcu
#endif // TCU_ANGLE_WIN32_NATIVE_DISPLAY_FACTORY_H_
#endif // TCU_ANGLE_WIN32_NATIVE_DISPLAY_FACTORY_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