Commit aba65a8e by Maksim Sisov

X11 and Ozone: Try to check for display type when creating framebuf

We're making a new config in the Chromium project for Linux builds - USE_X11 && USE_OZONE. The idea of that is to ease migration from non-Ozone/X11 to Ozone. It will be possible to choose between Ozone and non-Ozone path on runtime by supplying the --enable-features=UseOzonePlatform flag. However, SwiftShader doesn't support such a build and always uses FrameBufferOzone. This is not correct when the browser is run without the Ozone feature enabled aka using old non-Ozone/X11 path. Basically, it results in crashes during swap buffers call. The very naive solution is to try to test the display. If we can cast it to XDisplay and its valid, use X11 framebuffer. Otherwise, use Ozone. Though, I'm not 100% sure about the safiness of this check. Thus, we must be careful about that. This is one of the last patches that blocks enabling both use_x11 && use_ozone in Chromium. Bug: chromium:1119303 Change-Id: I969798abd4d0bbacaffb7704161eac38e77d9311 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/47868Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarMaksim Sisov <msisov@igalia.com>
parent 66d1f73e
......@@ -48,14 +48,10 @@ swiftshader_source_set("swiftshader_main") {
]
if (use_ozone && !is_win) {
sources += [ "FrameBufferOzone.cpp" ]
} else if (is_linux) {
if (use_x11) {
sources += [
"FrameBufferX11.cpp",
"libX11.cpp",
]
}
sources += [
"FrameBufferOzone.cpp",
"FrameBufferFactoryOzone.cpp",
]
} else if (is_mac) {
sources += [ "FrameBufferOSX.mm" ]
} else if (is_win) {
......@@ -66,6 +62,13 @@ swiftshader_source_set("swiftshader_main") {
]
}
if (use_x11) {
sources += [
"FrameBufferX11.cpp",
"libX11.cpp",
]
}
if (is_win) {
libs = [ "dxguid.lib" ] # For FrameBufferDD
}
......
// Copyright 2020 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "Main/FrameBuffer.hpp"
#include "Main/FrameBufferOzone.hpp"
#if defined(USE_X11)
#include "libX11.hpp"
#include "Main/FrameBufferX11.hpp"
#endif
NO_SANITIZE_FUNCTION sw::FrameBuffer *createFrameBuffer(void *display, intptr_t window, int width, int height)
{
#if defined(USE_X11)
if(reinterpret_cast<::Display *>(display))
{
return new sw::FrameBufferX11((::Display *)display, window, width, height);
}
#endif
return new sw::FrameBufferOzone((intptr_t)display, window, width, height);
}
......@@ -47,8 +47,3 @@ namespace sw
copy(source);
}
}
NO_SANITIZE_FUNCTION sw::FrameBuffer *createFrameBuffer(void* display, intptr_t window, int width, int height)
{
return new sw::FrameBufferOzone((intptr_t)display, window, width, height);
}
......@@ -186,7 +186,11 @@ namespace sw
}
}
// Chromium can be built with USE_X11 && USE_OZONE. In case of pure USE_X11 builds, we can use this path.
// In another case, the decision what framebuffer to create will be done by the FrameBufferFactoryOzone.
#if !defined(USE_OZONE)
NO_SANITIZE_FUNCTION sw::FrameBuffer *createFrameBuffer(void *display, Window window, int width, int height)
{
return new sw::FrameBufferX11((::Display*)display, window, width, height);
}
#endif
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