Commit 87bef77c by Corentin Wallez

Compile end2end tests on MacOS

This includes an implementation of OSX timer and path_utils. BUG=angleproject:891 Change-Id: Id5440a8321bcfd4a61f3fe35b4a3fc0c651f564f Reviewed-on: https://chromium-review.googlesource.com/278211Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 34d719b5
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include "Matrix.h"
#include "random_utils.h" #include "random_utils.h"
#include "shader_utils.h" #include "shader_utils.h"
#include "Matrix.h"
class MultiWindowSample : public SampleApplication class MultiWindowSample : public SampleApplication
{ {
......
...@@ -12,12 +12,6 @@ ...@@ -12,12 +12,6 @@
#include "OSWindow.h" #include "OSWindow.h"
#include "common/debug.h" #include "common/debug.h"
#ifdef _WIN32
#elif __linux__
#else
#error unsupported OS.
#endif
EGLPlatformParameters::EGLPlatformParameters() EGLPlatformParameters::EGLPlatformParameters()
: renderer(EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE), : renderer(EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE),
majorVersion(EGL_DONT_CARE), majorVersion(EGL_DONT_CARE),
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <array>
namespace angle namespace angle
{ {
......
//
// Copyright (c) 2015 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.
//
// OSXTimer.cpp: Implementation of a high precision timer class on OSX
#include "osx/OSXTimer.h"
#include <CoreServices/CoreServices.h>
#include <mach/mach.h>
#include <mach/mach_time.h>
#include <iostream>
OSXTimer::OSXTimer()
: mRunning(false)
{
}
void OSXTimer::start()
{
mStartTime = mach_absolute_time();
mRunning = true;
}
void OSXTimer::stop()
{
mStopTime = mach_absolute_time();
mRunning = false;
}
double OSXTimer::getElapsedTime() const
{
// If this is the first time we've run, get the timebase.
// We can use denom == 0 to indicate that sTimebaseInfo is
// uninitialised because it makes no sense to have a zero
// denominator is a fraction.
static mach_timebase_info_data_t timebaseInfo;
if ( timebaseInfo.denom == 0 )
{
mach_timebase_info(&timebaseInfo);
}
double secondCoeff = timebaseInfo.numer * (1.0 / 1000000000) / timebaseInfo.denom;
if (mRunning)
{
return secondCoeff * (mach_absolute_time() - mStartTime);
}
else
{
return secondCoeff * (mStopTime - mStartTime);
}
}
Timer *CreateTimer()
{
return new OSXTimer();
}
//
// Copyright (c) 2015 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.
//
// OSXTimer.h: Definition of a high precision timer class on OSX
#ifndef UTIL_OSX_TIMER_H_
#define UTIL_OSX_TIMER_H_
#include <time.h>
#include <cstdint>
#include "Timer.h"
class OSXTimer : public Timer
{
public:
OSXTimer();
void start() override;
void stop() override;
double getElapsedTime() const override;
private:
bool mRunning;
uint64_t mStartTime;
uint64_t mStopTime;
};
#endif // UTIL_OSX_TIMER_H_
//
// Copyright (c) 2015 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.
//
// OSXWindow.cpp: Implementation of OSWindow for OSX
#include "osx/OSXWindow.h"
// TODO(cwallez): implement OSXWindow.
OSWindow *CreateOSWindow()
{
return nullptr;
}
//
// Copyright (c) 2015 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.
//
// OSXWindow.h: Definition of the implementation of OSWindow for OSX`
#ifndef UTIL_OSX_WINDOW_H_
#define UTIL_OSX_WINDOW_H_
#include "OSWindow.h"
// TODO(cwallez): implement OSXWindow.
#endif // UTIL_OSX_WINDOW_H_
//
// Copyright (c) 2015 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.
//
// OSX_system_utils.cpp: Implementation of OS-specific functions for OSX
#include "system_utils.h"
#include <cstdlib>
#include <mach-o/dyld.h>
#include <vector>
namespace angle
{
std::string GetExecutablePath()
{
std::string result;
uint32_t size = 0;
_NSGetExecutablePath(nullptr, &size);
std::vector<char> buffer;
buffer.resize(size + 1);
_NSGetExecutablePath(buffer.data(), &size);
buffer[size] = '\0';
if (!strrchr(buffer.data(), '/'))
{
return "";
}
return buffer.data();
}
std::string GetExecutableDirectory()
{
std::string executablePath = GetExecutablePath();
size_t lastPathSepLoc = executablePath.find_last_of("/");
return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : "";
}
} // namespace angle
...@@ -47,6 +47,15 @@ ...@@ -47,6 +47,15 @@
'x11/X11Window.cpp', 'x11/X11Window.cpp',
'x11/X11Window.h', 'x11/X11Window.h',
], ],
'util_osx_sources':
[
'osx/OSX_system_utils.cpp',
'osx/OSXTimer.cpp',
'osx/OSXTimer.h',
'osx/OSXWindow.cpp',
'osx/OSXWindow.h',
'posix/Posix_system_utils.cpp',
],
}, },
'targets': 'targets':
[ [
...@@ -116,6 +125,13 @@ ...@@ -116,6 +125,13 @@
], ],
}, },
}], }],
['OS=="mac"',
{
'sources':
[
'<@(util_osx_sources)',
],
}],
], ],
}, },
], ],
......
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