Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a19db1a

Browse filesBrowse files
committed
removed traces of unfinished Emscripten support
This removes a few methods that were added to io2d's public interface to help with Emscripten support. If and when Emscripten support is added back in, these methods, or ones like them, may need to be re-added.
1 parent b9285f3 commit a19db1a
Copy full SHA for a19db1a

File tree

Expand file treeCollapse file tree

2 files changed

+32
-77
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+32
-77
lines changed

‎P0267_RefImpl/P0267_RefImpl/cairo/sdl2/cairo_renderer_sdl2.cpp

Copy file name to clipboardExpand all lines: P0267_RefImpl/P0267_RefImpl/cairo/sdl2/cairo_renderer_sdl2.cpp
+32-75Lines changed: 32 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
#include "xio2d_cairo_sdl2_main.h"
44
#include "xgraphicsmathfloat.h"
55

6-
#if __EMSCRIPTEN__
7-
#include <emscripten/emscripten.h>
8-
#endif
9-
106
#if ! SDL_VERSION_ATLEAST(2, 0, 0)
117
#error "io2d's SDL module must be compiled with SDL 2.x or higher, but SDL 1.x was detected"
128
#endif
@@ -228,59 +224,6 @@ namespace std::experimental::io2d {
228224
return true;
229225
}
230226

231-
template <>
232-
void _Cairo_graphics_surfaces<std::experimental::io2d::v1::_Graphics_math_float_impl>::surfaces::_Tick_show(_Output_surface_datadata& osd, _Output_surface* instance, _Output_surface& sfc)
233-
{
234-
_Display_surface_data_type &data = osd->data;
235-
236-
auto currentTime = ::std::chrono::steady_clock::now();
237-
auto elapsedTimeIncrement = static_cast<float>(::std::chrono::duration_cast<::std::chrono::nanoseconds>(currentTime - data.previous_time).count());
238-
data.elapsed_draw_time += elapsedTimeIncrement;
239-
data.previous_time = currentTime;
240-
241-
SDL_Event ev;
242-
while (SDL_PollEvent(&ev)) {}
243-
244-
bool redraw = true;
245-
if (data.rr == io2d::refresh_style::as_needed) {
246-
redraw = data.redraw_required;
247-
data.redraw_required = false;
248-
}
249-
250-
const auto desiredElapsed = 1'000'000'000.0F / data.refresh_fps;
251-
if (data.rr == io2d::refresh_style::fixed) {
252-
#if __EMSCRIPTEN__
253-
// TODO(dludwig@pobox.com): consider redeclaring the above 'if __EMSCRIPTEN__' to 'if use_external_runloop'
254-
redraw = true;
255-
#else
256-
redraw = data.elapsed_draw_time >= desiredElapsed;
257-
#endif
258-
}
259-
if (redraw) {
260-
if (osd->draw_callback) {
261-
osd->draw_callback(sfc);
262-
}
263-
_Render_to_native_surface(osd, sfc);
264-
if (data.rr == experimental::io2d::refresh_style::fixed) {
265-
while (data.elapsed_draw_time >= desiredElapsed) {
266-
data.elapsed_draw_time -= desiredElapsed;
267-
}
268-
}
269-
else {
270-
data.elapsed_draw_time = 0.0F;
271-
}
272-
}
273-
}
274-
275-
template <>
276-
void _Cairo_graphics_surfaces<std::experimental::io2d::v1::_Graphics_math_float_impl>::surfaces::_Tick_emscripten(void * userdata)
277-
{
278-
_Output_surface * instance = (_Output_surface *) userdata;
279-
_Output_surface & sfc = *instance;
280-
_Output_surface_datadata & osd = instance->data();
281-
_Tick_show(osd, instance, sfc);
282-
}
283-
284227
template <>
285228
int _Cairo_graphics_surfaces<std::experimental::io2d::v1::_Graphics_math_float_impl>::surfaces::begin_show(_Output_surface_datadata& osd, _Output_surface* instance, _Output_surface& sfc)
286229
{
@@ -340,30 +283,44 @@ namespace std::experimental::io2d {
340283

341284
data.redraw_required = true;
342285

343-
#ifdef __EMSCRIPTEN__
344-
int fps_for_emscripten = 0;
345-
switch (data.rr) {
346-
case io2d::refresh_style::as_needed:
347-
// TODO(dludwig@pobox.com): if refresh rate == as_needed', then pass what to emscripten_set_main_loop* ?
348-
fps_for_emscripten = 0;
349-
break;
350-
case io2d::refresh_style::as_fast_as_possible:
351-
fps_for_emscripten = 0;
352-
break;
353-
case io2d::refresh_style::fixed:
354-
fps_for_emscripten = data.refresh_fps;
355-
break;
356-
}
357-
emscripten_set_main_loop_arg(&_Tick_emscripten, instance, fps_for_emscripten, 1);
358-
#else
359286
while (_Is_active<std::experimental::io2d::v1::_Graphics_math_float_impl>(data)) {
360-
_Tick_show(osd, instance, sfc);
287+
auto currentTime = ::std::chrono::steady_clock::now();
288+
auto elapsedTimeIncrement = static_cast<float>(::std::chrono::duration_cast<::std::chrono::nanoseconds>(currentTime - data.previous_time).count());
289+
data.elapsed_draw_time += elapsedTimeIncrement;
290+
data.previous_time = currentTime;
291+
292+
SDL_Event ev;
293+
while (SDL_PollEvent(&ev)) {}
294+
295+
bool redraw = true;
296+
if (data.rr == io2d::refresh_style::as_needed) {
297+
redraw = data.redraw_required;
298+
data.redraw_required = false;
299+
}
300+
301+
const auto desiredElapsed = 1'000'000'000.0F / data.refresh_fps;
302+
if (data.rr == io2d::refresh_style::fixed) {
303+
redraw = data.elapsed_draw_time >= desiredElapsed;
304+
}
305+
if (redraw) {
306+
if (osd->draw_callback) {
307+
osd->draw_callback(sfc);
308+
}
309+
_Render_to_native_surface(osd, sfc);
310+
if (data.rr == experimental::io2d::refresh_style::fixed) {
311+
while (data.elapsed_draw_time >= desiredElapsed) {
312+
data.elapsed_draw_time -= desiredElapsed;
313+
}
314+
}
315+
else {
316+
data.elapsed_draw_time = 0.0F;
317+
}
318+
}
361319

362320
// Try to delay by a negligible amount of time. On some platforms, this can help with responsiveness.
363321
SDL_Delay(0);
364322
}
365323
data.elapsed_draw_time = 0.0F;
366-
#endif
367324
return 0;
368325
}
369326

‎P0267_RefImpl/P0267_RefImpl/cairo/xcairo.h

Copy file name to clipboardExpand all lines: P0267_RefImpl/P0267_RefImpl/cairo/xcairo.h
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,6 @@ namespace std {
515515
static void destroy(output_surface_data_type& data) noexcept;
516516

517517
static int begin_show(output_surface_data_type& data, basic_output_surface<_Graphics_surfaces_type>* instance, basic_output_surface<_Graphics_surfaces_type>& sfc);
518-
static void _Tick_show(output_surface_data_type& data, basic_output_surface<_Graphics_surfaces_type>* instance, basic_output_surface<_Graphics_surfaces_type>& sfc);
519-
static void _Tick_emscripten(void *);
520518
static void end_show(output_surface_data_type &data);
521519
static void refresh_style(output_surface_data_type& data, io2d::refresh_style val);
522520
static void desired_frame_rate(output_surface_data_type& data, float val);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.