diff options
author | David Robillard <d@drobilla.net> | 2021-05-24 14:12:17 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-05-24 15:14:41 -0400 |
commit | f535b6eaeed44093bed7d90b4be76363c2e2e4f4 (patch) | |
tree | 035478b033d349e06e8339d0217cf93aa607b268 /src/win_stub.c | |
parent | 830862ed8345a9620d2ff75293666e46972e2692 (diff) | |
download | pugl-f535b6eaeed44093bed7d90b4be76363c2e2e4f4.tar.gz pugl-f535b6eaeed44093bed7d90b4be76363c2e2e4f4.tar.bz2 pugl-f535b6eaeed44093bed7d90b4be76363c2e2e4f4.zip |
Separate stub backends from other backends
Stub backends were a dependency of other backends to allow some code reuse.
However, that can cause conflicting symbols if multiple backends are linked
into the same binary, which should be possible.
To avoid this, move the shared code into the platform implementation, and
export those symbols so that backends can use them. This adds some semi-public
platform-specific API that can only be used by backends included with pugl.
They are undocumented, subject to change at any time without a corresponding
version change, and may not be used by third parties (for example by custom
backends in an application).
Diffstat (limited to 'src/win_stub.c')
-rw-r--r-- | src/win_stub.c | 42 |
1 files changed, 7 insertions, 35 deletions
diff --git a/src/win_stub.c b/src/win_stub.c index cf86390..6b0cb23 100644 --- a/src/win_stub.c +++ b/src/win_stub.c @@ -1,5 +1,5 @@ /* - Copyright 2012-2020 David Robillard <d@drobilla.net> + Copyright 2012-2021 David Robillard <d@drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -20,50 +20,22 @@ #include "pugl/stub.h" -PuglStatus +static PuglStatus puglWinStubConfigure(PuglView* view) { - PuglInternals* const impl = view->impl; - PuglStatus st = PUGL_SUCCESS; - - if ((st = puglWinCreateWindow(view, "Pugl", &impl->hwnd, &impl->hdc))) { - return st; - } - - impl->pfd = puglWinGetPixelFormatDescriptor(view->hints); - impl->pfId = ChoosePixelFormat(impl->hdc, &impl->pfd); - - if (!SetPixelFormat(impl->hdc, impl->pfId, &impl->pfd)) { - ReleaseDC(impl->hwnd, impl->hdc); - DestroyWindow(impl->hwnd); - impl->hwnd = NULL; - impl->hdc = NULL; - return PUGL_SET_FORMAT_FAILED; - } - - return PUGL_SUCCESS; + return puglWinConfigure(view); } -PuglStatus +static PuglStatus puglWinStubEnter(PuglView* view, const PuglEventExpose* expose) { - if (expose) { - PAINTSTRUCT ps; - BeginPaint(view->impl->hwnd, &ps); - } - - return PUGL_SUCCESS; + return puglWinEnter(view, expose); } -PuglStatus +static PuglStatus puglWinStubLeave(PuglView* view, const PuglEventExpose* expose) { - if (expose) { - PAINTSTRUCT ps; - EndPaint(view->impl->hwnd, &ps); - } - - return PUGL_SUCCESS; + return puglWinLeave(view, expose); } const PuglBackend* |