Skip to content

Commit e986338

Browse files
committed
This project now builds under GNU/Linux in my testing environment. Updated GNU-Linux_build_instructions.txt to reflect current build requirements. The Windows Clang/C2 builds now also build successfully once again. Guards added to require libpng 1.6.X or later and to provide non-R4 compliant functionality where the <filesystem> API is not available. (I never imagined I'd be adding guards because Visual C++ has functionality that other major vendors do not yet have; it's a very welcome development in terms of everyone's commitment to standards compliance). Various other changes to fix bugs exposed by building with Clang 4.0. This commit will be tagged R4. An R4 branch will be created to fix any bugs or issues with this. The main branch will reflect the development of R5 (the successor to R4).
1 parent d1526f4 commit e986338

22 files changed

+1472
-1166
lines changed

GNU-Linux_build_instructions.txt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
You will need a relatively recent build of GNU autotools. Any recent distro
22
should have a reasonably new version available which will fit the needs here.
3-
You will also need cairo, GTK+3, and related libraries; as long as you have
4-
autotools, if you should be able to generate a configure script and it will
5-
tell you if you are missing any other dependencies.
3+
4+
You will also need cairo version 1.12.14 or newer and libjpeg-turbo (note: on
5+
Ubuntu it's called libturbojpeg, maybe on other distros). To support PNG
6+
functionality, you need libpng 1.6.X or later.
7+
8+
This has been tested with Clang 4.0 and the version of libc++ that accompanies
9+
it. It will likely work with GCC 7 and the version of libstdc++ that
10+
accompanies it. The reason is that it requires std::variant, std::optional,
11+
and various other library features that are only in C++.
612

713
To build the project, from this directory run the command 'autoreconf -i'. It
814
should run for a bit then complete silently. If so, you should then run the
915
generated './configure' script with any necessary parameters. This should
1016
notify you if you are missing any pre-requisites or have an older version that
1117
won't work. If configure completes successfully, you should be able to run the
1218
'make' command and then execute the resulting executable by calling
13-
the './N3888_RefImpl/src/N3888_RefImpl' executable.
19+
the './N3888_RefImpl/src/N3888_RefImpl' executable. In sample_draw.cpp, the
20+
test_image_load_and_save function will only work if you run N3888_RefImpl from
21+
the N3888_RefImpl/src/ directory since it uses relative paths to load the
22+
images it uses.
1423

15-
The drawing portion is the same code as in the Windows version. The entry
16-
point uses GTK+3 and is primarily C code. It is patterned after Gnome project
17-
utilities. It has improved significantly and is now essentially on par with
18-
the Windows version.
24+
By default it will build using Xlib. You can use Xcb by passing the
25+
"--enable-xcb" option to configure.
1926

20-
Tested on OpenSUSE 13.2 with GCC 4.9.0 using the following configure command:
21-
'./configure CC=gcc-4.9 CXX=g++-4.9 CXXFLAGS="-g -std=c++1y"'. Also tested
22-
with Clang 3.5 using the configure settings found in the
23-
run-configure-with-clang-and-libstdc++.sh shell script.
27+
The "run-configure-with-*" shell scripts are provided as examples only. They
28+
are used for my personal testing. Like everything else, they are subject to
29+
the terms of LICENSE.md.

N3888_RefImpl/src/Makefile.am

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@ if USE_XLIB
2525
N3888_RefImpl_SOURCES += display_surface-xlib.cpp
2626
endif
2727

28-
N3888_RefImpl_LDADD = @GTKCAIRO_LIBS@
28+
N3888_RefImpl_LDADD = @LIBS@
29+
N3888_RefImpl_LDADD += @GTKCAIRO_LIBS@
2930
if USE_XCB
3031
N3888_RefImpl_LDADD += @xcb_LIBS@
3132
endif
3233

33-
N3888_RefImpl_CPPFLAGS = @GTKCAIRO_CFLAGS@
34+
N3888_RefImpl_CPPFLAGS = @CPPFLAGS@
35+
N3888_RefImpl_CXXFLAGS = @CXXFLAGS@
36+
N3888_RefImpl_CXXFLAGS += @GTKCAIRO_CFLAGS@
3437
if USE_XCB
35-
N3888_RefImpl_CPPFLAGS += @xcb_CFLAGS@ -DUSE_XCB
38+
N3888_RefImpl_CXXFLAGS += @xcb_CFLAGS@ -DUSE_XCB
3639
endif
3740
if USE_XLIB
38-
N3888_RefImpl_CPPFLAGS += -DUSE_XLIB
41+
N3888_RefImpl_CXXFLAGS += -DUSE_XLIB
3942
endif
4043
##if ! [ [ test "$CXX" = "g++" ] || [ test "$CXX" = "gcc" ] ]]
4144
##then

N3888_RefImpl/src/N3888_RefImpl.vcxproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,11 @@ copy "$(ProjectDir)alpha8.png" "$(OutputPath)"
184184
<Optimization>Disabled</Optimization>
185185
<PreprocessorDefinitions>WIN32;_WIN32_WINNT=0x0601;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
186186
<SDLCheck>true</SDLCheck>
187-
<AdditionalOptions>-Weverything -pedantic -Wno-c++98-compat -Wno-covered-switch-default -Wno-c++98-compat-pedantic -Wno-global-constructors -Wno-float-equal -Wno-documentation -Wno-documentation-unknown-command -Wno-padded -Wno-exit-time-destructors -Wno-reserved-id-macro -Wno-language-extension-token</AdditionalOptions>
187+
<AdditionalOptions>-Weverything -pedantic -Wno-c++98-compat -Wno-covered-switch-default -Wno-c++98-compat-pedantic -Wno-global-constructors -Wno-float-equal -Wno-documentation -Wno-documentation-unknown-command -Wno-padded -Wno-exit-time-destructors -Wno-reserved-id-macro -Wno-language-extension-token -std=c++1z</AdditionalOptions>
188188
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
189189
<ExceptionHandling>Enabled</ExceptionHandling>
190190
<RuntimeTypeInfo>true</RuntimeTypeInfo>
191191
<UndefinePreprocessorDefinitions>NDEBUG</UndefinePreprocessorDefinitions>
192-
<CppLanguageStandard>c++1y</CppLanguageStandard>
193192
</ClCompile>
194193
<Link>
195194
<SubSystem>Windows</SubSystem>

N3888_RefImpl/src/display_surface-xcb.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ display_surface::display_surface(int preferredWidth, int preferredHeight, experi
6565

6666
display_surface::display_surface(int preferredWidth, int preferredHeight, experimental::io2d::format preferredFormat, int preferredDisplayWidth, int preferredDisplayHeight, experimental::io2d::scaling scl, experimental::io2d::refresh_rate rr, double fps)
6767
: surface({ nullptr, nullptr }, preferredFormat)
68-
, _Default_brush(cairo_pattern_create_rgba(0.0, 0.0, 0.0, 1.0))
68+
, _Default_brush(bgra_color::transparent_black())
6969
, _Display_width(preferredDisplayWidth)
7070
, _Display_height(preferredDisplayHeight)
7171
, _Scaling(scl)
@@ -74,7 +74,7 @@ display_surface::display_surface(int preferredWidth, int preferredHeight, experi
7474
, _Draw_fn()
7575
, _Size_change_fn()
7676
, _User_scaling_fn()
77-
, _Letterbox_brush(cairo_pattern_create_rgba(0.0, 0.0, 0.0, 1.0))
77+
, _Letterbox_brush()
7878
, _Auto_clear(false)
7979
, _Screen(nullptr)
8080
, _Wndw()
@@ -240,7 +240,7 @@ int display_surface::show() {
240240
if (_Auto_clear) {
241241
clear();
242242
}
243-
_Draw_fn(*this);
243+
(*_Draw_fn)(*this);
244244
}
245245
else {
246246
throw system_error(make_error_code(errc::operation_would_block));
@@ -274,7 +274,7 @@ int display_surface::show() {
274274
if (resized) {
275275
cairo_xcb_surface_set_size(_Native_surface.get(), _Display_width, _Display_height);
276276
if (_Size_change_fn != nullptr) {
277-
_Size_change_fn(*this);
277+
(*_Size_change_fn)(*this);
278278
}
279279
}
280280
} break;
@@ -316,7 +316,7 @@ int display_surface::show() {
316316
if (_Auto_clear) {
317317
clear();
318318
}
319-
_Draw_fn(*this);
319+
(*_Draw_fn)(*this);
320320
}
321321
else {
322322
throw system_error(make_error_code(errc::operation_would_block));
@@ -420,7 +420,8 @@ int display_surface::show() {
420420
if (_Can_draw) {
421421
bool redraw = true;
422422
if (_Refresh_rate == experimental::io2d::refresh_rate::as_needed) {
423-
redraw = _Redraw_requested.exchange(false, std::memory_order_acquire);
423+
redraw = _Redraw_requested;
424+
_Redraw_requested = false;
424425
}
425426

426427
auto desiredElapsed = 1'000'000'000.0 / _Desired_frame_rate;
@@ -435,7 +436,7 @@ int display_surface::show() {
435436
if (_Auto_clear) {
436437
clear();
437438
}
438-
_Draw_fn(*this);
439+
(*_Draw_fn)(*this);
439440
}
440441
else {
441442
throw system_error(make_error_code(errc::operation_would_block));

N3888_RefImpl/src/display_surface-xlib.cpp

Lines changed: 9 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -136,64 +136,6 @@ display_surface::native_handle_type display_surface::native_handle() const {
136136
return{ { _Surface.get(), _Context.get() }, _Display.get(), _Wndw, _Display_mutex, _Display_ref_count };
137137
}
138138

139-
//display_surface::display_surface(display_surface&& other) noexcept
140-
// : surface(move(other))
141-
// , _Default_brush(move(other._Default_brush))
142-
// , _Display_width(move(other._Display_width))
143-
// , _Display_height(move(other._Display_height))
144-
// , _Scaling(move(other._Scaling))
145-
// , _Width(move(other._Width))
146-
// , _Height(move(other._Height))
147-
// , _Draw_fn(move(other._Draw_fn))
148-
// , _Size_change_fn(move(other._Size_change_fn))
149-
// , _User_scaling_fn(move(other._User_scaling_fn))
150-
// , _Letterbox_brush(move(other._Letterbox_brush))
151-
// , _Auto_clear(move(other._Auto_clear))
152-
// , _Wndw(move(other._Wndw))
153-
// , _Can_draw(move(other._Can_draw))
154-
// , _Refresh_rate(move(other._Refresh_rate))
155-
// , _Desired_frame_rate(move(other._Desired_frame_rate))
156-
// , _Redraw_requested(other._Redraw_requested.load())
157-
// , _Elapsed_draw_time(move(other._Elapsed_draw_time))
158-
// , _Native_surface(move(other._Native_surface))
159-
// , _Native_context(move(other._Native_context)) {
160-
// other._Draw_fn = nullptr;
161-
// other._Size_change_fn = nullptr;
162-
// other._Wndw = None;
163-
//}
164-
//
165-
//display_surface& display_surface::operator=(display_surface&& other) noexcept {
166-
// if (this != &other) {
167-
// surface::operator=(move(other));
168-
// _Default_brush = move(other._Default_brush);
169-
// _Display_width = move(other._Display_width);
170-
// _Display_height = move(other._Display_height);
171-
// _Scaling = move(other._Scaling);
172-
// _Width = move(other._Width);
173-
// _Height = move(other._Height);
174-
// _Draw_fn = move(other._Draw_fn);
175-
// _Size_change_fn = move(other._Size_change_fn);
176-
// _User_scaling_fn = move(other._User_scaling_fn);
177-
// _Letterbox_brush = move(other._Letterbox_brush);
178-
// _Auto_clear = move(other._Auto_clear);
179-
// _Wndw = move(other._Wndw);
180-
// _Can_draw = move(other._Can_draw);
181-
// _Refresh_rate = move(other._Refresh_rate);
182-
// _Desired_frame_rate = move(other._Desired_frame_rate);
183-
// _Redraw_requested = other._Redraw_requested.load();
184-
// _Elapsed_draw_time = move(other._Elapsed_draw_time);
185-
// _Native_surface = move(other._Native_surface);
186-
// _Native_context = move(other._Native_context);
187-
//
188-
// other._Wndw = None;
189-
// other._Draw_fn = nullptr;
190-
// other._Size_change_fn = nullptr;
191-
// other._Can_draw = false;
192-
// }
193-
//
194-
// return *this;
195-
//}
196-
//
197139
mutex display_surface::_Display_mutex;
198140
unique_ptr<Display, function<void(Display*)>> display_surface::_Display{ nullptr, [](Display*) { return; } };
199141
int display_surface::_Display_ref_count = 0;
@@ -236,7 +178,7 @@ display_surface::display_surface(int preferredWidth, int preferredHeight, experi
236178

237179
display_surface::display_surface(int preferredWidth, int preferredHeight, experimental::io2d::format preferredFormat, int preferredDisplayWidth, int preferredDisplayHeight, experimental::io2d::scaling scl, experimental::io2d::refresh_rate rr, double fps)
238180
: surface({ nullptr, nullptr }, preferredFormat)
239-
, _Default_brush(cairo_pattern_create_rgba(0.0, 0.0, 0.0, 1.0))
181+
, _Default_brush(bgra_color::transparent_black())
240182
, _Display_width(preferredDisplayWidth)
241183
, _Display_height(preferredDisplayHeight)
242184
, _Scaling(scl)
@@ -245,7 +187,7 @@ display_surface::display_surface(int preferredWidth, int preferredHeight, experi
245187
, _Draw_fn()
246188
, _Size_change_fn()
247189
, _User_scaling_fn()
248-
, _Letterbox_brush(cairo_pattern_create_rgba(0.0, 0.0, 0.0, 1.0))
190+
, _Letterbox_brush()
249191
, _Auto_clear(false)
250192
, _Wndw(None)
251193
, _Can_draw(false)
@@ -312,7 +254,7 @@ display_surface::~display_surface() {
312254
}
313255
}
314256

315-
int display_surface::show() {
257+
int display_surface::begin_show() {
316258
bool exit = false;
317259
XEvent event;
318260

@@ -337,7 +279,7 @@ int display_surface::show() {
337279
if (_Auto_clear) {
338280
clear();
339281
}
340-
_Draw_fn(*this);
282+
(*_Draw_fn)(*this);
341283
}
342284
else {
343285
throw system_error(make_error_code(errc::operation_would_block));
@@ -370,7 +312,7 @@ int display_surface::show() {
370312
if (resized) {
371313
cairo_xlib_surface_set_size(_Native_surface.get(), _Display_width, _Display_height);
372314
if (_Size_change_fn != nullptr) {
373-
_Size_change_fn(*this);
315+
(*_Size_change_fn)(*this);
374316
}
375317
}
376318
} break;
@@ -406,7 +348,7 @@ int display_surface::show() {
406348
if (_Auto_clear) {
407349
clear();
408350
}
409-
_Draw_fn(*this);
351+
(*_Draw_fn)(*this);
410352
}
411353
else {
412354
throw system_error(make_error_code(errc::operation_would_block));
@@ -498,7 +440,8 @@ int display_surface::show() {
498440
if (_Can_draw) {
499441
bool redraw = true;
500442
if (_Refresh_rate == experimental::io2d::refresh_rate::as_needed) {
501-
redraw = _Redraw_requested.exchange(false, std::memory_order_acquire);
443+
redraw = _Redraw_requested;
444+
_Redraw_requested = false;
502445
}
503446

504447
auto desiredElapsed = 1'000'000'000.0 / _Desired_frame_rate;
@@ -513,7 +456,7 @@ int display_surface::show() {
513456
if (_Auto_clear) {
514457
clear();
515458
}
516-
_Draw_fn(*this);
459+
(*_Draw_fn)(*this);
517460
}
518461
else {
519462
throw system_error(make_error_code(errc::operation_would_block));

0 commit comments

Comments
 (0)