[Bf-blender-cvs] [873223f38dd] soc-2019-openxr: Cleanup: Remove unused support for non-OpenGL Windows
Julian Eisel
noreply at git.blender.org
Fri Aug 9 16:12:51 CEST 2019
Commit: 873223f38ddc79ade3a5811ca72f029761d56fcd
Author: Julian Eisel
Date: Fri Aug 9 16:08:34 2019 +0200
Branches: soc-2019-openxr
https://developer.blender.org/rB873223f38ddc79ade3a5811ca72f029761d56fcd
Cleanup: Remove unused support for non-OpenGL Windows
This was very useful for testing, but there's no current need for it.
Neither for VR code, nor for anything else in master.
===================================================================
M source/blender/makesdna/DNA_windowmanager_types.h
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/intern/wm_draw.c
M source/blender/windowmanager/intern/wm_window.c
M source/blender/windowmanager/intern/wm_xr.c
M source/blender/windowmanager/wm_window.h
===================================================================
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index ca7ceb048ae..516fb7a7a38 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -205,8 +205,6 @@ typedef struct wmWindow {
/** Don't want to include ghost.h stuff. */
void *ghostwin;
- /** Ghost context for rendering the window offscreen (usually unused). */
- void *offscreen_context;
/** Don't want to include gpu stuff. */
void *gpuctx;
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 76ab06e0020..588defed389 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -112,7 +112,6 @@ int WM_window_pixels_x(const struct wmWindow *win);
int WM_window_pixels_y(const struct wmWindow *win);
void WM_window_rect_calc(const struct wmWindow *win, struct rcti *r_rect);
void WM_window_screen_rect_calc(const struct wmWindow *win, struct rcti *r_rect);
-bool WM_window_is_non_opengl(const wmWindow *win);
bool WM_window_is_fullscreen(struct wmWindow *win);
void WM_windows_scene_data_sync(const ListBase *win_lb, struct Scene *scene) ATTR_NONNULL();
@@ -173,7 +172,6 @@ enum {
struct wmWindow *WM_window_open(struct bContext *C, const struct rcti *rect);
struct wmWindow *WM_window_open_temp(
struct bContext *C, int x, int y, int sizex, int sizey, int type);
-struct wmWindow *WM_window_open_directx(struct bContext *C, const rcti *rect);
void WM_window_set_dpi(wmWindow *win);
bool WM_stereo3d_enabled(struct wmWindow *win, bool only_fullscreen_test);
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index b8e8c0af018..58a2b43d779 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -781,37 +781,6 @@ void wm_draw_upside_down(int sizex, int sizey, bool to_srgb)
immUnbindProgram();
}
-static void wm_draw_window_upside_down_onscreen(bContext *C, wmWindow *win)
-{
- const int width = WM_window_pixels_x(win);
- const int height = WM_window_pixels_y(win);
- GPUOffScreen *offscreen = GPU_offscreen_create(width, height, 0, false, false, NULL);
-
- /* Upside down rendering only implemented for non-stereo. Easy to add but makes code messy. */
- BLI_assert(
- !(WM_stereo3d_enabled(win, false) && GHOST_isUpsideDownWindow(win->offscreen_context)));
-
- if (offscreen) {
- GPUTexture *texture = GPU_offscreen_color_texture(offscreen);
- wm_draw_offscreen_texture_parameters(offscreen);
-
- /* Draw view into offscreen buffer. */
- GPU_offscreen_bind(offscreen, false);
- wm_draw_window_onscreen(C, win, -1);
- GPU_offscreen_unbind(offscreen, false);
-
- /* Draw offscreen buffer to screen. */
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(texture));
-
- wm_draw_upside_down(win->sizex, win->sizey, false);
-
- glBindTexture(GL_TEXTURE_2D, 0);
-
- GPU_offscreen_free(offscreen);
- }
-}
-
static void wm_draw_window(bContext *C, wmWindow *win)
{
bScreen *screen = WM_window_get_active_screen(win);
@@ -823,13 +792,8 @@ static void wm_draw_window(bContext *C, wmWindow *win)
/* Now we draw into the window framebuffer, in full window coordinates. */
if (!stereo) {
- if (GHOST_isUpsideDownWindow(win->ghostwin)) {
- wm_draw_window_upside_down_onscreen(C, win);
- }
- else {
- /* Regular mono drawing. */
- wm_draw_window_onscreen(C, win, -1);
- }
+ /* Regular mono drawing. */
+ wm_draw_window_onscreen(C, win, -1);
}
else if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP) {
/* For pageflip we simply draw to both back buffers. */
@@ -1023,7 +987,7 @@ void wm_draw_update(bContext *C)
wm_draw_window(C, win);
wm_draw_update_clear_window(win);
- wm_window_present(win);
+ wm_window_swap_buffers(win);
CTX_wm_window_set(C, NULL);
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 42c372855ca..b7720649a6d 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -95,12 +95,6 @@
# include "BLI_threads.h"
#endif
-/* We may want to open non-OpenGL windows in certain cases and do all drawing into an offscreen
- * OpenGL context then. This flag is useful for testing the blitting. It forces OpenGL windows
- * only, but still does the offscreen rendering and blitting (if supported by GHOST context).
- * See GHOST_BlitOpenGLOffscreenContext. */
-// #define USE_FORCE_OPENGL_FOR_NON_OPENGL_WIN
-
/* the global to talk to ghost */
static GHOST_SystemHandle g_system = NULL;
@@ -163,7 +157,7 @@ void wm_get_desktopsize(int *r_width, int *r_height)
/* keeps offset and size within monitor bounds */
/* XXX solve dual screen... */
-void wm_window_check_position(rcti *rect)
+static void wm_window_check_position(rcti *rect)
{
int width, height, d;
@@ -196,17 +190,6 @@ void wm_window_check_position(rcti *rect)
}
}
-static void wm_window_drawing_context_activate(wmWindow *win)
-{
- if (win->offscreen_context) {
- /* In rare cases we may want to draw to an offscreen context. */
- GHOST_ActivateOpenGLContext(win->offscreen_context);
- }
- else {
- GHOST_ActivateWindowDrawingContext(win->ghostwin);
- }
-}
-
static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win)
{
if (win->ghostwin) {
@@ -221,7 +204,7 @@ static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win)
}
/* We need this window's opengl context active to discard it. */
- wm_window_drawing_context_activate(win);
+ GHOST_ActivateWindowDrawingContext(win->ghostwin);
GPU_context_active_set(win->gpuctx);
/* Delete local gpu context. */
@@ -567,10 +550,7 @@ static void wm_window_ensure_eventstate(wmWindow *win)
}
/* belongs to below */
-static void wm_window_ghostwindow_add(wmWindowManager *wm,
- const char *title,
- wmWindow *win,
- GHOST_TDrawingContextType context_type)
+static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wmWindow *win)
{
GHOST_WindowHandle ghostwin;
GHOST_GLSettings glSettings = {0};
@@ -599,29 +579,14 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
win->sizex,
win->sizey,
(GHOST_TWindowState)win->windowstate,
-#ifdef USE_FORCE_OPENGL_FOR_NON_OPENGL_WIN
GHOST_kDrawingContextTypeOpenGL,
-#else
- context_type,
-#endif
glSettings);
if (ghostwin) {
GHOST_RectangleHandle bounds;
- GLuint default_fb;
- if (context_type == GHOST_kDrawingContextTypeOpenGL) {
- default_fb = GHOST_GetDefaultOpenGLFramebuffer(ghostwin);
- win->gpuctx = GPU_context_create(default_fb);
- }
- else {
- /* Drawing into a non-OpenGL window -> create an offscreen OpenGL context to draw into. */
- win->offscreen_context = WM_opengl_context_create();
- WM_opengl_context_activate(win->offscreen_context);
-
- default_fb = GHOST_GetContextDefaultOpenGLFramebuffer(win->offscreen_context);
- win->gpuctx = GPU_context_create(default_fb);
- }
+ GLuint default_fb = GHOST_GetDefaultOpenGLFramebuffer(ghostwin);
+ win->gpuctx = GPU_context_create(default_fb);
/* needed so we can detect the graphics card below */
GPU_init();
@@ -661,7 +626,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
/* needed here, because it's used before it reads userdef */
WM_window_set_dpi(win);
- wm_window_present(win);
+ wm_window_swap_buffers(win);
// GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified);
@@ -673,11 +638,23 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
}
}
-static void wm_window_ghostwindow_ensure(wmWindowManager *wm,
- wmWindow *win,
- GHOST_TDrawingContextType context_type)
+/**
+ * Initialize #wmWindow without ghostwin, open these and clear.
+ *
+ * window size is read from window, if 0 it uses prefsize
+ * called in #WM_check, also inits stuff after file read.
+ *
+ * \warning
+ * After running, 'win->ghostwin' can be NULL in rare cases
+ * (where OpenGL driver fails to create a context for eg).
+ * We could remove them with #wm_window_ghostwindows_remove_invalid
+ * but better not since caller may continue to use.
+ * Instead, caller needs to handle the error case and cleanup.
+ */
+void wm_window_ghostwindows_ensure(wmWindowManager *wm)
{
wmKeyMap *keymap;
+ wmWindow *win;
BLI_assert(G.background == false);
@@ -708,83 +685,63 @@ static void wm_window_ghostwindow_ensure(wmWindowManager *wm,
#endif
}
- if (win->ghostwin == NULL) {
- if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) {
- win->posx = wm_init_state.start_x;
- win->posy = wm_init_state.start_y;
- win->sizex = wm_init_state.size_x;
- win->sizey = wm_init_state.size_y;
-
- if (wm_init_state.override_flag & WIN_OVERRIDE_GEOM) {
- win->windowstate = GHOST_kWindowStateNormal;
- wm_init_state.override_flag &= ~WIN_OVERRIDE_GEOM;
+ for (win = wm->windows.first; win; win = win->next) {
+ if (win->ghostwin == NULL) {
+ if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) {
+ win->posx = wm_init_state.start_x;
+ win->posy = wm_init_state.start_y;
+ win->sizex = wm_init_state.size_x;
+ win->sizey = wm_init_state.size_y;
+
+ if (wm_init_state.override_flag & WIN_OVERRIDE_GEOM) {
+ win->windowstate = GHOST_kWindowStateNormal;
+ wm_init_state.override_flag &= ~WIN_OVERRIDE_GEOM;
+ }
+ else {
+ win->windowstate = GHOST_WINDOW_STATE_DEFAULT;
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list