mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Update surfman to 0.2 and remove glutin
This commit is contained in:
parent
9dbc6554f0
commit
8bb1732258
94 changed files with 2265 additions and 1513 deletions
|
@ -1,3 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
#define DEFAULT_URL L"https://servo.org/hl-home/"
|
||||
#define DEFAULT_URL L"https://servo.org/hl-home/"
|
|
@ -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>
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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) {
|
||||
|
@ -107,7 +104,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");
|
||||
|
||||
|
@ -119,6 +117,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.
|
||||
|
@ -142,8 +141,6 @@ Servo::Servo(hstring url, hstring args, GLsizei width, GLsizei height,
|
|||
sServo = this; // FIXME;
|
||||
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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([=] {});
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue