aboutsummaryrefslogtreecommitdiffstats
path: root/support/hololens
diff options
context:
space:
mode:
authorbors-servo <servo-ops@mozilla.com>2020-04-18 21:03:25 -0400
committerGitHub <noreply@github.com>2020-04-18 21:03:25 -0400
commit306e8ac5f9b1f5b30c83f6861cfc3139273274bc (patch)
treeec9c27126d17f5e03f50ecbf5ea95a34ae3db919 /support/hololens
parent00ac44796667d93806b79f79e23dcd4dcee58652 (diff)
parent8bb1732258c44e6850618a8f2fbb2927bc01b090 (diff)
downloadservo-306e8ac5f9b1f5b30c83f6861cfc3139273274bc.tar.gz
servo-306e8ac5f9b1f5b30c83f6861cfc3139273274bc.zip
Auto merge of #25853 - asajeffrey:surfmanup, r=jdm
Replace glutin by winit + surfman 0.2 <!-- Please describe your changes on the following line: --> This PR updates surfman to 0.2, and replaces glutin with winit+surfman. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because this should all be invisible <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'support/hololens')
-rw-r--r--support/hololens/ServoApp/DefaultUrl.h2
-rw-r--r--support/hololens/ServoApp/ServoApp.vcxproj4
-rw-r--r--support/hololens/ServoApp/ServoControl/OpenGLES.cpp48
-rw-r--r--support/hololens/ServoApp/ServoControl/OpenGLES.h11
-rw-r--r--support/hololens/ServoApp/ServoControl/Servo.cpp11
-rw-r--r--support/hololens/ServoApp/ServoControl/Servo.h6
-rw-r--r--support/hololens/ServoApp/ServoControl/ServoControl.cpp49
-rw-r--r--support/hololens/ServoApp/ServoControl/ServoControl.h12
-rw-r--r--support/hololens/ServoApp/packages.config2
9 files changed, 39 insertions, 106 deletions
diff --git a/support/hololens/ServoApp/DefaultUrl.h b/support/hololens/ServoApp/DefaultUrl.h
index 35fbe247930..98a30fa39df 100644
--- a/support/hololens/ServoApp/DefaultUrl.h
+++ b/support/hololens/ServoApp/DefaultUrl.h
@@ -1,3 +1,3 @@
#pragma once
-#define DEFAULT_URL L"https://servo.org/hl-home/"
+#define DEFAULT_URL L"https://servo.org/hl-home/" \ No newline at end of file
diff --git a/support/hololens/ServoApp/ServoApp.vcxproj b/support/hololens/ServoApp/ServoApp.vcxproj
index a39b23f4737..1fcd54e529f 100644
--- a/support/hololens/ServoApp/ServoApp.vcxproj
+++ b/support/hololens/ServoApp/ServoApp.vcxproj
@@ -947,7 +947,7 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.190620.2\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.190620.2\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\packages\OpenXR.Loader.1.0.3\build\native\OpenXR.Loader.targets" Condition="Exists('..\packages\OpenXR.Loader.1.0.3\build\native\OpenXR.Loader.targets')" />
- <Import Project="..\packages\ANGLE.WindowsStore.Servo.2.1.16\build\native\ANGLE.WindowsStore.Servo.targets" Condition="Exists('..\packages\ANGLE.WindowsStore.Servo.2.1.16\build\native\ANGLE.WindowsStore.Servo.targets')" />
+ <Import Project="..\packages\ANGLE.WindowsStore.Servo.2.1.19\build\native\ANGLE.WindowsStore.Servo.targets" Condition="Exists('..\packages\ANGLE.WindowsStore.Servo.2.1.19\build\native\ANGLE.WindowsStore.Servo.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
@@ -957,6 +957,6 @@
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.190620.2\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.190620.2\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('..\packages\OpenXR.Loader.1.0.3\build\native\OpenXR.Loader.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\OpenXR.Loader.1.0.3\build\native\OpenXR.Loader.props'))" />
<Error Condition="!Exists('..\packages\OpenXR.Loader.1.0.3\build\native\OpenXR.Loader.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\OpenXR.Loader.1.0.3\build\native\OpenXR.Loader.targets'))" />
- <Error Condition="!Exists('..\packages\ANGLE.WindowsStore.Servo.2.1.16\build\native\ANGLE.WindowsStore.Servo.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\ANGLE.WindowsStore.Servo.2.1.16\build\native\ANGLE.WindowsStore.Servo.targets'))" />
+ <Error Condition="!Exists('..\packages\ANGLE.WindowsStore.Servo.2.1.19\build\native\ANGLE.WindowsStore.Servo.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\ANGLE.WindowsStore.Servo.2.1.19\build\native\ANGLE.WindowsStore.Servo.targets'))" />
</Target>
</Project>
diff --git a/support/hololens/ServoApp/ServoControl/OpenGLES.cpp b/support/hololens/ServoApp/ServoControl/OpenGLES.cpp
index 8889ee23d77..a89e5e373d4 100644
--- a/support/hololens/ServoApp/ServoControl/OpenGLES.cpp
+++ b/support/hololens/ServoApp/ServoControl/OpenGLES.cpp
@@ -187,51 +187,3 @@ void OpenGLES::Reset() {
Cleanup();
Initialize();
}
-
-EGLSurface OpenGLES::CreateSurface(SwapChainPanel const &panel, float dpi) {
- EGLSurface surface = EGL_NO_SURFACE;
-
- const EGLint surfaceAttributes[] = {EGL_NONE};
-
- PropertySet surfaceCreationProperties;
-
- surfaceCreationProperties.Insert(EGLNativeWindowTypeProperty, panel);
- // How to set size and or scale:
- // Insert(EGLRenderSurfaceSizeProperty),
- // PropertyValue::CreateSize(*renderSurfaceSize));
- surfaceCreationProperties.Insert(EGLRenderResolutionScaleProperty,
- PropertyValue::CreateSingle(dpi));
-
- EGLNativeWindowType win = static_cast<EGLNativeWindowType>(
- winrt::get_abi(surfaceCreationProperties));
- surface =
- eglCreateWindowSurface(mEglDisplay, mEglConfig, win, surfaceAttributes);
-
- if (surface == EGL_NO_SURFACE) {
- throw winrt::hresult_error(E_FAIL, L"Failed to create EGL surface");
- }
-
- return surface;
-}
-
-void OpenGLES::GetSurfaceDimensions(const EGLSurface surface, EGLint *width,
- EGLint *height) {
- eglQuerySurface(mEglDisplay, surface, EGL_WIDTH, width);
- eglQuerySurface(mEglDisplay, surface, EGL_HEIGHT, height);
-}
-
-void OpenGLES::DestroySurface(const EGLSurface surface) {
- if (mEglDisplay != EGL_NO_DISPLAY && surface != EGL_NO_SURFACE) {
- eglDestroySurface(mEglDisplay, surface);
- }
-}
-
-void OpenGLES::MakeCurrent(const EGLSurface surface) {
- if (eglMakeCurrent(mEglDisplay, surface, surface, mEglContext) == EGL_FALSE) {
- throw winrt::hresult_error(E_FAIL, L"Failed to make EGLSurface current");
- }
-}
-
-EGLBoolean OpenGLES::SwapBuffers(const EGLSurface surface) {
- return (eglSwapBuffers(mEglDisplay, surface));
-}
diff --git a/support/hololens/ServoApp/ServoControl/OpenGLES.h b/support/hololens/ServoApp/ServoControl/OpenGLES.h
index 96d96859194..ad952dd3439 100644
--- a/support/hololens/ServoApp/ServoControl/OpenGLES.h
+++ b/support/hololens/ServoApp/ServoControl/OpenGLES.h
@@ -9,15 +9,10 @@ public:
OpenGLES();
~OpenGLES();
- EGLSurface
- CreateSurface(winrt::Windows::UI::Xaml::Controls::SwapChainPanel const &,
- float dpi);
+ EGLNativeWindowType
+ GetNativeWindow(winrt::Windows::UI::Xaml::Controls::SwapChainPanel const &,
+ float dpi);
- void GetSurfaceDimensions(const EGLSurface surface, EGLint *width,
- EGLint *height);
- void DestroySurface(const EGLSurface surface);
- void MakeCurrent(const EGLSurface surface);
- EGLBoolean SwapBuffers(const EGLSurface surface);
void Reset();
private:
diff --git a/support/hololens/ServoApp/ServoControl/Servo.cpp b/support/hololens/ServoApp/ServoControl/Servo.cpp
index 17c86f17271..2502ddad06b 100644
--- a/support/hololens/ServoApp/ServoControl/Servo.cpp
+++ b/support/hololens/ServoApp/ServoControl/Servo.cpp
@@ -1,5 +1,6 @@
#include "pch.h"
#include "Servo.h"
+#include <EGL/egl.h>
namespace winrt::servo {
@@ -21,10 +22,6 @@ void on_url_changed(const char *url) {
sServo->Delegate().OnServoURLChanged(char2hstring(url));
}
-void flush() { sServo->Delegate().Flush(); }
-
-void make_current() { sServo->Delegate().MakeCurrent(); }
-
void wakeup() { sServo->Delegate().WakeUp(); }
bool on_allow_navigation(const char *url) {
@@ -128,7 +125,8 @@ const char *prompt_input(const char *message, const char *default,
}
Servo::Servo(hstring url, hstring args, GLsizei width, GLsizei height,
- float dpi, ServoDelegate &aDelegate)
+ EGLNativeWindowType eglNativeWindow, float dpi,
+ ServoDelegate &aDelegate)
: mWindowHeight(height), mWindowWidth(width), mDelegate(aDelegate) {
SetEnvironmentVariableA("PreviewRuntimeEnabled", "1");
@@ -140,6 +138,7 @@ Servo::Servo(hstring url, hstring args, GLsizei width, GLsizei height,
o.height = mWindowHeight;
o.density = dpi;
o.enable_subpixel_text_antialiasing = false;
+ o.native_widget = eglNativeWindow;
// Note about logs:
// By default: all modules are enabled. Only warn level-logs are displayed.
@@ -179,8 +178,6 @@ Servo::Servo(hstring url, hstring args, GLsizei width, GLsizei height,
#endif
capi::CHostCallbacks c;
- c.flush = &flush;
- c.make_current = &make_current;
c.on_load_started = &on_load_started;
c.on_load_ended = &on_load_ended;
c.on_title_changed = &on_title_changed;
diff --git a/support/hololens/ServoApp/ServoControl/Servo.h b/support/hololens/ServoApp/ServoControl/Servo.h
index ccc8c1efa06..a61adf81f49 100644
--- a/support/hololens/ServoApp/ServoControl/Servo.h
+++ b/support/hololens/ServoApp/ServoControl/Servo.h
@@ -5,6 +5,7 @@
#pragma once
#include "pch.h"
+#include <EGL/egl.h>
#include "logs.h"
#include <stdlib.h>
@@ -23,7 +24,8 @@ class ServoDelegate;
class Servo {
public:
- Servo(hstring, hstring, GLsizei, GLsizei, float, ServoDelegate &);
+ Servo(hstring, hstring, GLsizei, GLsizei, EGLNativeWindowType, float,
+ ServoDelegate &);
~Servo();
ServoDelegate &Delegate() { return mDelegate; }
@@ -100,8 +102,6 @@ public:
virtual void OnServoAnimatingChanged(bool) = 0;
virtual void OnServoIMEStateChanged(bool) = 0;
virtual void OnServoDevtoolsStarted(bool, const unsigned int) = 0;
- virtual void Flush() = 0;
- virtual void MakeCurrent() = 0;
virtual void OnServoMediaSessionMetadata(hstring, hstring, hstring) = 0;
virtual void OnServoMediaSessionPlaybackStateChange(int) = 0;
virtual void OnServoPromptAlert(hstring, bool) = 0;
diff --git a/support/hololens/ServoApp/ServoControl/ServoControl.cpp b/support/hololens/ServoApp/ServoControl/ServoControl.cpp
index 4d1349ee370..9c5869d44e9 100644
--- a/support/hololens/ServoApp/ServoControl/ServoControl.cpp
+++ b/support/hololens/ServoApp/ServoControl/ServoControl.cpp
@@ -72,7 +72,7 @@ void ServoControl::OnLoaded(IInspectable const &, RoutedEventArgs const &) {
InitializeCriticalSection(&mGLLock);
InitializeConditionVariable(&mDialogCondVar);
InitializeCriticalSection(&mDialogLock);
- CreateRenderSurface();
+ CreateNativeWindow();
StartRenderLoop();
}
@@ -80,22 +80,26 @@ Controls::SwapChainPanel ServoControl::Panel() {
return GetTemplateChild(L"swapChainPanel").as<Controls::SwapChainPanel>();
}
-void ServoControl::CreateRenderSurface() {
- if (mRenderSurface == EGL_NO_SURFACE) {
- mRenderSurface = mOpenGLES.CreateSurface(Panel(), mDPI);
- }
+void ServoControl::CreateNativeWindow() {
+ mPanelWidth = Panel().ActualWidth() * mDPI;
+ mPanelHeight = Panel().ActualHeight() * mDPI;
+ mNativeWindowProperties.Insert(EGLNativeWindowTypeProperty, Panel());
+ // How to set size and or scale:
+ // Insert(EGLRenderSurfaceSizeProperty),
+ // PropertyValue::CreateSize(*renderSurfaceSize));
+ mNativeWindowProperties.Insert(EGLRenderResolutionScaleProperty,
+ PropertyValue::CreateSingle(mDPI));
}
-void ServoControl::DestroyRenderSurface() {
- mOpenGLES.DestroySurface(mRenderSurface);
- mRenderSurface = EGL_NO_SURFACE;
+EGLNativeWindowType ServoControl::GetNativeWindow() {
+ EGLNativeWindowType win =
+ static_cast<EGLNativeWindowType>(winrt::get_abi(mNativeWindowProperties));
+
+ return win;
}
void ServoControl::RecoverFromLostDevice() {
StopRenderLoop();
- DestroyRenderSurface();
- mOpenGLES.Reset();
- CreateRenderSurface();
StartRenderLoop();
}
@@ -311,18 +315,12 @@ void ServoControl::RunOnGLThread(std::function<void()> task) {
void ServoControl::Loop() {
log("BrowserPage::Loop(). GL thread: %i", GetCurrentThreadId());
- mOpenGLES.MakeCurrent(mRenderSurface);
-
- EGLint panelWidth = 0;
- EGLint panelHeight = 0;
- mOpenGLES.GetSurfaceDimensions(mRenderSurface, &panelWidth, &panelHeight);
- glViewport(0, 0, panelWidth, panelHeight);
-
if (mServo == nullptr) {
log("Entering loop");
ServoDelegate *sd = static_cast<ServoDelegate *>(this);
- mServo = std::make_unique<Servo>(mInitialURL, mArgs, panelWidth,
- panelHeight, mDPI, *sd);
+ EGLNativeWindowType win = GetNativeWindow();
+ mServo = std::make_unique<Servo>(mInitialURL, mArgs, mPanelWidth,
+ mPanelHeight, win, mDPI, *sd);
} else {
// FIXME: this will fail since create_task didn't pick the thread
// where Servo was running initially.
@@ -406,17 +404,6 @@ void ServoControl::OnServoURLChanged(hstring url) {
});
}
-void ServoControl::Flush() {
- if (mOpenGLES.SwapBuffers(mRenderSurface) != GL_TRUE) {
- // The call to eglSwapBuffers might not be successful (i.e. due to Device
- // Lost) If the call fails, then we must reinitialize EGL and the GL
- // resources.
- RunOnUIThread([=] { RecoverFromLostDevice(); });
- }
-}
-
-void ServoControl::MakeCurrent() { mOpenGLES.MakeCurrent(mRenderSurface); }
-
void ServoControl::WakeUp() {
RunOnGLThread([=] {});
}
diff --git a/support/hololens/ServoApp/ServoControl/ServoControl.h b/support/hololens/ServoApp/ServoControl/ServoControl.h
index 6eaf4459f4b..dbc9e91ca92 100644
--- a/support/hololens/ServoApp/ServoControl/ServoControl.h
+++ b/support/hololens/ServoApp/ServoControl/ServoControl.h
@@ -4,6 +4,8 @@
#include "Servo.h"
#include "DefaultUrl.h"
+using namespace winrt::Windows::Foundation::Collections;
+
namespace winrt::ServoApp::implementation {
struct ServoControl : ServoControlT<ServoControl>, public servo::ServoDelegate {
@@ -108,8 +110,6 @@ struct ServoControl : ServoControlT<ServoControl>, public servo::ServoDelegate {
virtual void OnServoShutdownComplete();
virtual void OnServoTitleChanged(winrt::hstring);
virtual void OnServoURLChanged(winrt::hstring);
- virtual void Flush();
- virtual void MakeCurrent();
virtual bool OnServoAllowNavigation(winrt::hstring);
virtual void OnServoAnimatingChanged(bool);
virtual void OnServoIMEStateChanged(bool);
@@ -150,14 +150,16 @@ private:
std::optional<hstring> secondaryButton,
std::optional<hstring> input);
+ int mPanelHeight = 0;
+ int mPanelWidth = 0;
float mDPI = 1;
hstring mInitialURL = DEFAULT_URL;
hstring mCurrentUrl = L"";
bool mTransient = false;
Windows::UI::Xaml::Controls::SwapChainPanel ServoControl::Panel();
- void CreateRenderSurface();
- void DestroyRenderSurface();
+ void CreateNativeWindow();
+ EGLNativeWindowType GetNativeWindow();
void RecoverFromLostDevice();
void StartRenderLoop();
@@ -204,7 +206,7 @@ private:
void TryLoadUri(hstring);
std::unique_ptr<servo::Servo> mServo;
- EGLSurface mRenderSurface{EGL_NO_SURFACE};
+ PropertySet mNativeWindowProperties;
OpenGLES mOpenGLES;
bool mAnimating = false;
bool mLooping = false;
diff --git a/support/hololens/ServoApp/packages.config b/support/hololens/ServoApp/packages.config
index fa1a5cf1668..149f1735c5d 100644
--- a/support/hololens/ServoApp/packages.config
+++ b/support/hololens/ServoApp/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="ANGLE.WindowsStore.Servo" version="2.1.16" targetFramework="native" />
+ <package id="ANGLE.WindowsStore.Servo" version="2.1.19" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.190620.2" targetFramework="native" />
<package id="OpenXR.Loader" version="1.0.3" targetFramework="native" />
</packages> \ No newline at end of file