-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3056 from MirServer/feature/virtual_output_support
Virtual output display platform and tests
- Loading branch information
Showing
22 changed files
with
1,194 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
usr/lib/*/mir/server-platform/server-virtual.so.20 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Copyright © Canonical Ltd. | ||
* | ||
* This program is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License version 2 or 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "options_parsing_helpers.h" | ||
#include <stdexcept> | ||
#include <boost/throw_exception.hpp> | ||
|
||
namespace mgc = mir::graphics::common; | ||
namespace geom = mir::geometry; | ||
|
||
namespace | ||
{ | ||
auto parse_scale(std::string const& str) -> float | ||
{ | ||
try | ||
{ | ||
size_t num_end = 0; | ||
float const value = std::stof(str, &num_end); | ||
if (num_end != str.size()) | ||
BOOST_THROW_EXCEPTION(std::runtime_error("Scale \"" + str + "\" is not a valid float")); | ||
if (value <= 0.000001) | ||
BOOST_THROW_EXCEPTION(std::runtime_error("Scale must be greater than zero")); | ||
return value; | ||
} | ||
catch (std::invalid_argument const &) | ||
{ | ||
BOOST_THROW_EXCEPTION(std::runtime_error("Scale \"" + str + "\" is not a valid float")); | ||
} | ||
catch (std::out_of_range const &) | ||
{ | ||
BOOST_THROW_EXCEPTION(std::runtime_error("Scale \"" + str + "\" is out of range")); | ||
} | ||
} | ||
|
||
auto parse_size_dimension(std::string const& str) -> int | ||
{ | ||
try | ||
{ | ||
size_t num_end = 0; | ||
int const value = std::stoi(str, &num_end); | ||
if (num_end != str.size()) | ||
BOOST_THROW_EXCEPTION(std::runtime_error("Output dimension \"" + str + "\" is not a valid number")); | ||
if (value <= 0) | ||
BOOST_THROW_EXCEPTION(std::runtime_error("Output dimensions must be greater than zero")); | ||
return value; | ||
} | ||
catch (std::invalid_argument const &) | ||
{ | ||
BOOST_THROW_EXCEPTION(std::runtime_error("Output dimension \"" + str + "\" is not a valid number")); | ||
} | ||
catch (std::out_of_range const &) | ||
{ | ||
BOOST_THROW_EXCEPTION(std::runtime_error("Output dimension \"" + str + "\" is out of range")); | ||
} | ||
} | ||
} | ||
|
||
|
||
auto mgc::parse_size(std::string const& str) -> geom::Size | ||
{ | ||
auto const x = str.find('x'); // "x" between width and height | ||
if (x == std::string::npos || x <= 0 || x >= str.size() - 1) | ||
BOOST_THROW_EXCEPTION(std::runtime_error("Output size \"" + str + "\" does not have two dimensions")); | ||
return geom::Size{ | ||
parse_size_dimension(str.substr(0, x)), | ||
parse_size_dimension(str.substr(x + 1))}; | ||
} | ||
|
||
auto mgc::parse_size_with_scale(std::string const& str) -> std::tuple<mir::geometry::Size, float> | ||
{ | ||
auto const x = str.find('x'); // "x" between width and height | ||
if (x == std::string::npos || x <= 0 || x >= str.size() - 1) | ||
BOOST_THROW_EXCEPTION(std::runtime_error("Output size \"" + str + "\" does not have two dimensions")); | ||
auto const scale_start = str.find('^'); // start of output scale | ||
float scale = 1.0f; | ||
if (scale_start != std::string::npos) | ||
{ | ||
if (scale_start >= str.size() - 1) | ||
BOOST_THROW_EXCEPTION(std::runtime_error("In \"" + str + "\", '^' is not followed by a scale")); | ||
scale = parse_scale(str.substr(scale_start + 1, std::string::npos)); | ||
} | ||
return {geom::Size{ | ||
parse_size_dimension(str.substr(0, x)), | ||
parse_size_dimension(str.substr(x + 1, scale_start - x - 1))}, | ||
scale}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright © Canonical Ltd. | ||
* | ||
* This program is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License version 2 or 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef MIR_PLATFORM_OPTIONS_PARSING_HELPERS_H | ||
#define MIR_PLATFORM_OPTIONS_PARSING_HELPERS_H | ||
|
||
#include <string> | ||
#include <tuple> | ||
#include <mir/geometry/size.h> | ||
|
||
namespace mir | ||
{ | ||
namespace graphics | ||
{ | ||
namespace common | ||
{ | ||
|
||
auto parse_size(std::string const& str) -> mir::geometry::Size; | ||
auto parse_size_with_scale(std::string const& str) -> std::tuple<mir::geometry::Size, float>; | ||
|
||
} | ||
} | ||
} | ||
|
||
#endif //MIR_PLATFORM_OPTIONS_PARSING_HELPERS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
include_directories( | ||
${server_common_include_dirs} | ||
) | ||
|
||
configure_file( | ||
${CMAKE_CURRENT_SOURCE_DIR}/symbols.map.in | ||
${CMAKE_CURRENT_BINARY_DIR}/symbols.map | ||
) | ||
set(symbol_map ${CMAKE_CURRENT_BINARY_DIR}/symbols.map) | ||
|
||
add_compile_definitions(MIR_LOG_COMPONENT="mir:virtual") | ||
|
||
add_library(mirplatformgraphicsvirtualobjects OBJECT | ||
graphics.cpp | ||
platform.cpp | ||
platform.h | ||
display.h | ||
display.cpp | ||
display_configuration.h | ||
display_configuration.cpp | ||
) | ||
|
||
target_link_libraries(mirplatformgraphicsvirtualobjects | ||
PUBLIC | ||
mirplatform | ||
mircommon | ||
mircore | ||
) | ||
|
||
add_library(mirplatformvirtual MODULE | ||
$<TARGET_OBJECTS:mirplatformgraphicsvirtualobjects> | ||
) | ||
|
||
target_link_libraries( | ||
mirplatformvirtual | ||
|
||
PRIVATE | ||
mirplatform | ||
server_platform_common | ||
) | ||
|
||
set_target_properties( | ||
mirplatformvirtual PROPERTIES | ||
OUTPUT_NAME server-virtual | ||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/server-modules | ||
PREFIX "" | ||
SUFFIX ".so.${MIR_SERVER_GRAPHICS_PLATFORM_ABI}" | ||
LINK_FLAGS "-Wl,--exclude-libs=ALL -Wl,--version-script,${symbol_map}" | ||
LINK_DEPENDS ${symbol_map} | ||
) | ||
|
||
install(TARGETS mirplatformvirtual LIBRARY DESTINATION ${MIR_SERVER_PLATFORM_PATH}) |
Oops, something went wrong.