Skip to content

Commit

Permalink
Merge pull request #2149 from BOINC/Mac_OS10_3_Screensaver_Fix
Browse files Browse the repository at this point in the history
Mac os10 3 screensaver fix
  • Loading branch information
davidpanderson authored Oct 5, 2017
2 parents 8495e2f + 58360ef commit dd2be87
Show file tree
Hide file tree
Showing 12 changed files with 1,177 additions and 95 deletions.
19 changes: 19 additions & 0 deletions api/MultiGPUMig.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <mach/mach_types.defs>

subsystem MGSServer 29000;
userprefix _MGC; /* Routine prefixes for user access. */
serverprefix _MGS; /* Routine prefixes for internal server access. */

/* Client -> Server */
routine CheckinClient(
server_port : mach_port_t;
in client_port : mach_port_t;
out client_index : int32_t
);

/* Master -> Slave */
routine DisplayFrame(
server_port : mach_port_t;
frame_index : int32_t;
iosurface_port : mach_port_t
);
21 changes: 20 additions & 1 deletion api/graphics2.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2017 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
Expand Down Expand Up @@ -31,6 +31,9 @@
#include "shmem.h"
#include "boinc_api.h"
#include "graphics2.h"
#ifdef __APPLE__
#include "x_opengl.h"
#endif

double boinc_max_fps = 30.;
double boinc_max_gfx_cpu_frac = 0.2;
Expand Down Expand Up @@ -84,7 +87,23 @@ bool throttled_app_render(int x, int y, double t) {
if (boinc_max_gfx_cpu_frac) {
boinc_calling_thread_cpu_time(t0);
}

#ifdef __APPLE__
if (UseSharedOffscreenBuffer()) {
MacPrepareOffscreenBuffer();
}
#endif
app_graphics_render(x, y, t);

#ifdef __APPLE__
if (UseSharedOffscreenBuffer()) {
MacPassOffscreenBufferToScreenSaver();

//app_graphics_render(x, y, t); // For testing only
}

#endif

if (boinc_max_gfx_cpu_frac) {
boinc_calling_thread_cpu_time(t1);
total_render_time += t1 - t0;
Expand Down
52 changes: 51 additions & 1 deletion api/graphics2_unix.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2017 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
Expand Down Expand Up @@ -118,6 +118,11 @@ static void maybe_render() {


if (throttled_app_render(new_width, new_height, dtime())) {
#ifdef __APPLE__
if (UseSharedOffscreenBuffer()) {
return; // Don't try to send garbage to screen
}
#endif
glutSwapBuffers();
if (! fullscreen) {
// If user has changed window size, wait until it stops
Expand Down Expand Up @@ -244,3 +249,48 @@ void boinc_graphics_loop(int argc, char** argv, const char* title) {
#endif
glutMainLoop();
}

#ifdef __APPLE__

bool UseSharedOffscreenBuffer() {
static bool alreadyTested = false;
static bool needSharedGfxBuffer = false;

//return true; // FOR TESTING ONLY
if (alreadyTested) {
return needSharedGfxBuffer;
}
alreadyTested = true;
if (fullscreen) {
SInt32 major = -1;
SInt32 minor = -1;
char vers[100], *p1 = NULL;
FILE *f;
vers[0] = '\0';
f = popen("sw_vers -productVersion", "r");
if (f) {
fscanf(f, "%s", vers);
pclose(f);
}
if (vers[0] == '\0') {
fprintf(stderr, "popen(\"sw_vers -productVersion\" failed\n");
fflush(stderr);
return false;
}
// Extract the major system version number
major = atoi(vers);
if (major > 10) { // OS 11.0 or later
needSharedGfxBuffer = true;
return true;
}
// Extract the minor system version number
p1 = strchr(vers, '.');
minor = atoi(p1+1);
if (minor > 12) { // OS 10.13 or later
needSharedGfxBuffer = true;
return true;
}
}
return false;
}
#endif
Loading

0 comments on commit dd2be87

Please sign in to comment.