Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-08-07 14:04:31 +0300
committerJulian Eisel <julian@blender.org>2020-08-07 14:04:31 +0300
commit0d2d4a6d4a75ac38c41f872c88255eab70e88ab7 (patch)
treeb7a7518af86dddba48e05a98b3c2be55e8804721 /source/blender/windowmanager
parent9b416c66fb714bdfd15a481489dbf650d0f389ea (diff)
parentcfc6f9eb18e701f5be601b95c45004e8cf7fbc81 (diff)
Merge branch 'master' into temp-ui-button-type-refactortemp-ui-button-type-refactor
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_api.h14
-rw-r--r--source/blender/windowmanager/WM_keymap.h5
-rw-r--r--source/blender/windowmanager/WM_message.h5
-rw-r--r--source/blender/windowmanager/WM_toolsystem.h5
-rw-r--r--source/blender/windowmanager/WM_types.h6
-rw-r--r--source/blender/windowmanager/gizmo/WM_gizmo_api.h11
-rw-r--r--source/blender/windowmanager/gizmo/WM_gizmo_types.h11
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo.c5
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c23
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h5
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c25
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c12
-rw-r--r--source/blender/windowmanager/gizmo/wm_gizmo_fn.h11
-rw-r--r--source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h11
-rw-r--r--source/blender/windowmanager/intern/wm.c12
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c6
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c10
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c124
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c323
-rw-r--r--source/blender/windowmanager/intern/wm_files.c35
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c210
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c35
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c20
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c8
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c16
-rw-r--r--source/blender/windowmanager/intern/wm_operator_type.c8
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c370
-rw-r--r--source/blender/windowmanager/intern/wm_platform_support.h5
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c26
-rw-r--r--source/blender/windowmanager/intern/wm_stereo.c25
-rw-r--r--source/blender/windowmanager/intern/wm_subwindow.c13
-rw-r--r--source/blender/windowmanager/intern/wm_window.c52
-rw-r--r--source/blender/windowmanager/intern/wm_window_private.h5
-rw-r--r--source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h5
-rw-r--r--source/blender/windowmanager/message_bus/wm_message_bus.h11
-rw-r--r--source/blender/windowmanager/wm.h9
-rw-r--r--source/blender/windowmanager/wm_cursors.h11
-rw-r--r--source/blender/windowmanager/wm_draw.h13
-rw-r--r--source/blender/windowmanager/wm_event_system.h11
-rw-r--r--source/blender/windowmanager/wm_event_types.h11
-rw-r--r--source/blender/windowmanager/wm_files.h11
-rw-r--r--source/blender/windowmanager/wm_surface.h11
-rw-r--r--source/blender/windowmanager/wm_window.h11
-rw-r--r--source/blender/windowmanager/xr/intern/wm_xr_intern.h5
-rw-r--r--source/blender/windowmanager/xr/intern/wm_xr_session.c92
-rw-r--r--source/blender/windowmanager/xr/wm_xr.h5
46 files changed, 822 insertions, 836 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 482589e2ccb..07746af4b60 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*/
-#ifndef __WM_API_H__
-#define __WM_API_H__
+#pragma once
/** \file
* \ingroup wm
@@ -99,7 +98,7 @@ void WM_main(struct bContext *C) ATTR_NORETURN;
void WM_init_splash(struct bContext *C);
-void WM_init_opengl(struct Main *bmain);
+void WM_init_opengl(void);
void WM_check(struct bContext *C);
void WM_reinit_gizmomap_all(struct Main *bmain);
@@ -744,8 +743,13 @@ void *WM_jobs_customdata_get(struct wmJob *);
void WM_jobs_customdata_set(struct wmJob *, void *customdata, void (*free)(void *));
void WM_jobs_timer(struct wmJob *, double timestep, unsigned int note, unsigned int endnote);
void WM_jobs_delay_start(struct wmJob *, double delay_time);
+
+typedef void (*wm_jobs_start_callback)(void *custom_data,
+ short *stop,
+ short *do_update,
+ float *progress);
void WM_jobs_callbacks(struct wmJob *,
- void (*startjob)(void *, short *, short *, float *),
+ wm_jobs_start_callback startjob,
void (*initjob)(void *),
void (*update)(void *),
void (*endjob)(void *));
@@ -899,5 +903,3 @@ bool WM_xr_session_state_viewer_pose_matrix_info_get(const wmXrData *xr,
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_API_H__ */
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index 53a3fd5ebda..15be21bdbc4 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __WM_KEYMAP_H__
-#define __WM_KEYMAP_H__
+#pragma once
/** \file
* \ingroup wm
@@ -194,5 +193,3 @@ const char *WM_bool_as_string(bool test);
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_KEYMAP_H__ */
diff --git a/source/blender/windowmanager/WM_message.h b/source/blender/windowmanager/WM_message.h
index 1527d514e9b..25d5bae392b 100644
--- a/source/blender/windowmanager/WM_message.h
+++ b/source/blender/windowmanager/WM_message.h
@@ -18,9 +18,6 @@
* \ingroup wm
*/
-#ifndef __WM_MESSAGE_H__
-#define __WM_MESSAGE_H__
+#pragma once
#include "message_bus/wm_message_bus.h"
-
-#endif /* __WM_MESSAGE_H__ */
diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h
index 163f37be974..13d1666dc95 100644
--- a/source/blender/windowmanager/WM_toolsystem.h
+++ b/source/blender/windowmanager/WM_toolsystem.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __WM_TOOLSYSTEM_H__
-#define __WM_TOOLSYSTEM_H__
+#pragma once
/** \file
* \ingroup wm
@@ -140,5 +139,3 @@ void WM_toolsystem_refresh_screen_all(struct Main *bmain);
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_TOOLSYSTEM_API_H__ */
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 4acce793707..efe600a846a 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -106,8 +106,7 @@
* \endcode
*/
-#ifndef __WM_TYPES_H__
-#define __WM_TYPES_H__
+#pragma once
struct ID;
struct ImBuf;
@@ -361,6 +360,7 @@ typedef struct wmNotifier {
#define ND_LOD (30 << 16)
#define ND_DRAW_RENDER_VIEWPORT \
(31 << 16) /* for camera & sequencer viewport update, also /w NC_SCENE */
+#define ND_SHADERFX (32 << 16)
/* NC_MATERIAL Material */
#define ND_SHADING (30 << 16)
@@ -927,5 +927,3 @@ extern struct CLG_LogRef *WM_LOG_MSGBUS_SUB;
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_TYPES_H__ */
diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h
index 07a3f0445bb..a4412ecce5c 100644
--- a/source/blender/windowmanager/gizmo/WM_gizmo_api.h
+++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h
@@ -26,8 +26,7 @@
* Only included in WM_api.h
*/
-#ifndef __WM_GIZMO_API_H__
-#define __WM_GIZMO_API_H__
+#pragma once
struct ARegion;
struct GHashIterator;
@@ -52,6 +51,10 @@ struct wmWindowManager;
#include "wm_gizmo_fn.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* -------------------------------------------------------------------- */
/* wmGizmo */
@@ -396,4 +399,6 @@ void WM_gizmo_group_tag_remove(struct wmGizmoGroup *gzgroup);
bool WM_gizmo_group_type_poll(const struct bContext *C, const struct wmGizmoGroupType *gzgt);
void WM_gizmo_group_refresh(const struct bContext *C, struct wmGizmoGroup *gzgroup);
-#endif /* __WM_GIZMO_API_H__ */
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h
index 3863e3bd797..bddf54b846f 100644
--- a/source/blender/windowmanager/gizmo/WM_gizmo_types.h
+++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h
@@ -26,8 +26,7 @@
* Only included in WM_types.h and lower level files.
*/
-#ifndef __WM_GIZMO_TYPES_H__
-#define __WM_GIZMO_TYPES_H__
+#pragma once
#include "BLI_compiler_attrs.h"
@@ -40,6 +39,10 @@ struct wmKeyConfig;
#include "DNA_listBase.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* -------------------------------------------------------------------- */
/* Enum Typedef's */
@@ -506,4 +509,6 @@ typedef enum eWM_GizmoFlagMapDrawStep {
} eWM_GizmoFlagMapDrawStep;
#define WM_GIZMOMAP_DRAWSTEP_MAX 2
-#endif /* __WM_GIZMO_TYPES_H__ */
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
index e687af15982..87cb4d5f584 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
@@ -29,7 +29,6 @@
#include "BKE_context.h"
#include "GPU_batch.h"
-#include "GPU_glew.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -453,9 +452,7 @@ bool wm_gizmo_select_and_highlight(bContext *C, wmGizmoMap *gzmap, wmGizmo *gz)
wm_gizmomap_highlight_set(gzmap, C, gz, gz->highlight_part);
return true;
}
- else {
- return false;
- }
+ return false;
}
/**
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
index 67f30f0d7ee..b64d544962d 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
@@ -166,12 +166,10 @@ int WM_gizmo_cmp_temp_fl(const void *gz_a_ptr, const void *gz_b_ptr)
if (gz_a->temp.f < gz_b->temp.f) {
return -1;
}
- else if (gz_a->temp.f > gz_b->temp.f) {
+ if (gz_a->temp.f > gz_b->temp.f) {
return 1;
}
- else {
- return 0;
- }
+ return 0;
}
int WM_gizmo_cmp_temp_fl_reverse(const void *gz_a_ptr, const void *gz_b_ptr)
@@ -181,12 +179,10 @@ int WM_gizmo_cmp_temp_fl_reverse(const void *gz_a_ptr, const void *gz_b_ptr)
if (gz_a->temp.f < gz_b->temp.f) {
return 1;
}
- else if (gz_a->temp.f > gz_b->temp.f) {
+ if (gz_a->temp.f > gz_b->temp.f) {
return -1;
}
- else {
- return 0;
- }
+ return 0;
}
static bool wm_gizmo_keymap_uses_event_modifier(wmWindowManager *wm,
@@ -396,10 +392,9 @@ static int gizmo_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
return OPERATOR_FINISHED;
}
- else {
- BLI_assert(0);
- return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
- }
+
+ BLI_assert(0);
+ return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
}
void GIZMOGROUP_OT_gizmo_select(wmOperatorType *ot)
@@ -476,9 +471,7 @@ static bool gizmo_tweak_start_and_finish(
}
return true;
}
- else {
- return false;
- }
+ return false;
}
static void gizmo_tweak_finish(bContext *C, wmOperator *op, const bool cancel, bool clear_modal)
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h
index 00df6edef22..953722f28e9 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h
@@ -18,8 +18,7 @@
* \ingroup wm
*/
-#ifndef __WM_GIZMO_INTERN_H__
-#define __WM_GIZMO_INTERN_H__
+#pragma once
struct BLI_Buffer;
struct wmGizmoMap;
@@ -142,5 +141,3 @@ bool wm_gizmomap_deselect_all(struct wmGizmoMap *gzmap);
void wm_gizmomap_select_array_shrink(struct wmGizmoMap *gzmap, int len_subtract);
void wm_gizmomap_select_array_push_back(struct wmGizmoMap *gzmap, wmGizmo *gz);
void wm_gizmomap_select_array_remove(struct wmGizmoMap *gzmap, wmGizmo *gz);
-
-#endif
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index 6ed6c485e89..cecd324ff28 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -38,7 +38,6 @@
#include "ED_select_utils.h"
#include "ED_view3d.h"
-#include "GPU_glew.h"
#include "GPU_matrix.h"
#include "GPU_select.h"
#include "GPU_state.h"
@@ -264,11 +263,10 @@ bool WM_gizmomap_minmax(const wmGizmoMap *gzmap,
}
return i != 0;
}
- else {
- bool ok = false;
- BLI_assert(!"TODO");
- return ok;
- }
+
+ bool ok = false;
+ BLI_assert(!"TODO");
+ return ok;
}
/**
@@ -548,7 +546,7 @@ static void gizmo_draw_select_3d_loop(const bContext *C,
/* pass */
}
else {
- glDepthMask(!is_depth_skip);
+ GPU_depth_mask(!is_depth_skip);
is_depth_skip_prev = is_depth_skip;
}
@@ -565,7 +563,7 @@ static void gizmo_draw_select_3d_loop(const bContext *C,
GPU_depth_test(false);
}
if (is_depth_skip_prev) {
- glDepthMask(true);
+ GPU_depth_mask(true);
}
}
@@ -582,7 +580,7 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos,
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
rcti rect;
/* Almost certainly overkill, but allow for many custom gizmos. */
- GLuint buffer[MAXPICKBUF];
+ uint buffer[MAXPICKBUF];
short hits;
BLI_rcti_init_pt_radius(&rect, co, hotspot);
@@ -625,7 +623,7 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos,
GPU_matrix_unproject_with_precalc(&unproj_precalc, co_screen, co_3d_origin);
- GLuint *buf_iter = buffer;
+ uint *buf_iter = buffer;
int hit_found = -1;
float dot_best = FLT_MAX;
@@ -648,10 +646,9 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos,
}
return hit_found;
}
- else {
- const GLuint *hit_near = GPU_select_buffer_near(buffer, hits);
- return hit_near ? hit_near[3] : -1;
- }
+
+ const uint *hit_near = GPU_select_buffer_near(buffer, hits);
+ return hit_near ? hit_near[3] : -1;
}
/**
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c
index 2dc03d1419c..b056ed40943 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c
@@ -70,9 +70,7 @@ wmGizmoProperty *WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
if (index != -1) {
return WM_gizmo_target_property_at_index(gz, index);
}
- else {
- return NULL;
- }
+ return NULL;
}
void WM_gizmo_target_property_def_rna_ptr(wmGizmo *gz,
@@ -195,9 +193,7 @@ float WM_gizmo_target_property_float_get(const wmGizmo *gz, wmGizmoProperty *gz_
if (gz_prop->index == -1) {
return RNA_property_float_get(&gz_prop->ptr, gz_prop->prop);
}
- else {
- return RNA_property_float_get_index(&gz_prop->ptr, gz_prop->prop, gz_prop->index);
- }
+ return RNA_property_float_get_index(&gz_prop->ptr, gz_prop->prop, gz_prop->index);
}
void WM_gizmo_target_property_float_set(bContext *C,
@@ -255,9 +251,7 @@ bool WM_gizmo_target_property_float_range_get(const wmGizmo *gz,
gz_prop->custom_func.range_get_fn(gz, gz_prop, range);
return true;
}
- else {
- return false;
- }
+ return false;
}
float step, precision;
diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_fn.h b/source/blender/windowmanager/gizmo/wm_gizmo_fn.h
index 58b58fa01d0..418e848e35b 100644
--- a/source/blender/windowmanager/gizmo/wm_gizmo_fn.h
+++ b/source/blender/windowmanager/gizmo/wm_gizmo_fn.h
@@ -20,13 +20,16 @@
* Callback function definitions, needed for both Types & API headers.
*/
-#ifndef __WM_GIZMO_FN_H__
-#define __WM_GIZMO_FN_H__
+#pragma once
#include "BLI_compiler_attrs.h"
struct wmMsgBus;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* wmGizmoGroup */
typedef bool (*wmGizmoGroupFnPoll)(const struct bContext *,
struct wmGizmoGroupType *) ATTR_WARN_UNUSED_RESULT;
@@ -85,4 +88,6 @@ typedef struct wmGizmoPropertyFnParams {
void *user_data;
} wmGizmoPropertyFnParams;
-#endif /* __WM_GIZMO_FN_H__ */
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h
index cc9ccc5f4bb..18b3f40aba6 100644
--- a/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h
+++ b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h
@@ -28,14 +28,17 @@
* Only included in wm.h and lower level files.
*/
-#ifndef __WM_GIZMO_WMAPI_H__
-#define __WM_GIZMO_WMAPI_H__
+#pragma once
struct wmEventHandler_Gizmo;
struct wmEventHandler_Op;
struct wmGizmoMap;
struct wmOperatorType;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* -------------------------------------------------------------------- */
/* wmGizmo */
@@ -92,4 +95,6 @@ struct ListBase *wm_gizmomap_groups_get(wmGizmoMap *gzmap);
void wm_gizmomaptypes_free(void);
-#endif /* __WM_GIZMO_WMAPI_H__ */
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 2112477e62a..43c08a2b980 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -293,7 +293,7 @@ void WM_keyconfig_init(bContext *C)
/* initialize only after python init is done, for keymaps that
* use python operators */
- if (CTX_py_init_get(C) && (wm->initialized & WM_KEYCONFIG_IS_INITIALIZED) == 0) {
+ if (CTX_py_init_get(C) && (wm->initialized & WM_KEYCONFIG_IS_INIT) == 0) {
/* create default key config, only initialize once,
* it's persistent across sessions */
if (!(wm->defaultconf->flag & KEYCONF_INIT_DEFAULT)) {
@@ -308,7 +308,7 @@ void WM_keyconfig_init(bContext *C)
WM_keyconfig_update_tag(NULL, NULL);
WM_keyconfig_update(wm);
- wm->initialized |= WM_KEYCONFIG_IS_INITIALIZED;
+ wm->initialized |= WM_KEYCONFIG_IS_INIT;
}
}
@@ -334,7 +334,7 @@ void WM_check(bContext *C)
if (!G.background) {
/* case: fileread */
- if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) {
+ if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) {
WM_keyconfig_init(C);
WM_autosave_init(wm);
}
@@ -345,9 +345,9 @@ void WM_check(bContext *C)
/* case: fileread */
/* note: this runs in bg mode to set the screen context cb */
- if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) {
- ED_screens_initialize(bmain, wm);
- wm->initialized |= WM_WINDOW_IS_INITIALIZED;
+ if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) {
+ ED_screens_init(bmain, wm);
+ wm->initialized |= WM_WINDOW_IS_INIT;
}
}
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index 2af68956923..08d6df340d0 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -319,15 +319,15 @@ bool wm_cursor_arrow_move(wmWindow *win, const wmEvent *event)
wm_cursor_warp_relative(win, 0, fac);
return 1;
}
- else if (event->type == EVT_DOWNARROWKEY) {
+ if (event->type == EVT_DOWNARROWKEY) {
wm_cursor_warp_relative(win, 0, -fac);
return 1;
}
- else if (event->type == EVT_LEFTARROWKEY) {
+ if (event->type == EVT_LEFTARROWKEY) {
wm_cursor_warp_relative(win, -fac, 0);
return 1;
}
- else if (event->type == EVT_RIGHTARROWKEY) {
+ if (event->type == EVT_RIGHTARROWKEY) {
wm_cursor_warp_relative(win, fac, 0);
return 1;
}
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c
index ad3fc7a1302..ec18a401fa4 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -39,7 +39,6 @@
#include "BKE_context.h"
#include "BKE_idtype.h"
-#include "GPU_glew.h"
#include "GPU_shader.h"
#include "GPU_state.h"
#include "GPU_viewport.h"
@@ -297,7 +296,7 @@ void WM_drag_add_ID(wmDrag *drag, ID *id, ID *from_parent)
}
return;
}
- else if (GS(drag_id->id->name) != GS(id->name)) {
+ if (GS(drag_id->id->name) != GS(id->name)) {
BLI_assert(!"All dragged IDs must have the same type");
return;
}
@@ -356,7 +355,7 @@ static const char *wm_drag_name(wmDrag *drag)
if (single) {
return id->name + 2;
}
- else if (id) {
+ if (id) {
return BKE_idtype_idcode_to_name_plural(GS(id->name));
}
break;
@@ -424,9 +423,8 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
y,
drag->imb->x,
drag->imb->y,
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- GL_NEAREST,
+ GPU_RGBA8,
+ false,
drag->imb->rect,
drag->scale,
drag->scale,
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index 2b679dfefde..fe4c98394a3 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -51,7 +51,7 @@
#include "ED_screen.h"
#include "ED_view3d.h"
-#include "GPU_draw.h"
+#include "GPU_context.h"
#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_state.h"
@@ -106,11 +106,11 @@ static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region)
if (pc->poll == NULL || pc->poll(C)) {
/* Prevent drawing outside region. */
- glEnable(GL_SCISSOR_TEST);
- glScissor(region->winrct.xmin,
- region->winrct.ymin,
- BLI_rcti_size_x(&region->winrct) + 1,
- BLI_rcti_size_y(&region->winrct) + 1);
+ GPU_scissor_test(true);
+ GPU_scissor(region->winrct.xmin,
+ region->winrct.ymin,
+ BLI_rcti_size_x(&region->winrct) + 1,
+ BLI_rcti_size_y(&region->winrct) + 1);
if (ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)) {
int x = 0, y = 0;
@@ -121,7 +121,7 @@ static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region)
pc->draw(C, win->eventstate->x, win->eventstate->y, pc->customdata);
}
- glDisable(GL_SCISSOR_TEST);
+ GPU_scissor_test(false);
}
}
}
@@ -135,15 +135,8 @@ static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region)
static void wm_region_draw_overlay(bContext *C, ScrArea *area, ARegion *region)
{
- wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
- /* Don't draw overlay with locked interface. Drawing could access scene data that another thread
- * may be modifying. */
- if (wm->is_interface_locked) {
- return;
- }
-
wmViewport(&region->winrct);
UI_SetTheme(area->spacetype, region->regiontype);
region->type->draw_overlay(C, region);
@@ -214,7 +207,7 @@ static bool wm_draw_region_stereo_set(Main *bmain,
if (region->regiontype == RGN_TYPE_PREVIEW) {
return true;
}
- else if (region->regiontype == RGN_TYPE_WINDOW) {
+ if (region->regiontype == RGN_TYPE_WINDOW) {
return (sseq->draw_flag & SEQ_DRAW_BACKDROP) != 0;
}
}
@@ -403,14 +396,8 @@ static void wm_draw_offscreen_texture_parameters(GPUOffScreen *offscreen)
/* We don't support multisample textures here. */
BLI_assert(GPU_texture_target(texture) == GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(texture));
-
/* No mipmaps or filtering. */
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
- /* GL_TEXTURE_BASE_LEVEL = 0 by default */
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glBindTexture(GL_TEXTURE_2D, 0);
+ GPU_texture_mipmap_mode(texture, false, false);
}
static void wm_draw_region_buffer_create(ARegion *region, bool stereo, bool use_viewport)
@@ -473,8 +460,8 @@ static void wm_draw_region_bind(ARegion *region, int view)
/* For now scissor is expected by region drawing, we could disable it
* and do the enable/disable in the specific cases that setup scissor. */
- glEnable(GL_SCISSOR_TEST);
- glScissor(0, 0, region->winx, region->winy);
+ GPU_scissor_test(true);
+ GPU_scissor(0, 0, region->winx, region->winy);
}
region->draw_buffer->bound_view = view;
@@ -492,7 +479,7 @@ static void wm_draw_region_unbind(ARegion *region)
GPU_viewport_unbind(region->draw_buffer->viewport);
}
else {
- glDisable(GL_SCISSOR_TEST);
+ GPU_scissor_test(false);
GPU_offscreen_unbind(region->draw_buffer->offscreen, false);
}
}
@@ -533,9 +520,7 @@ GPUTexture *wm_draw_region_texture(ARegion *region, int view)
if (viewport) {
return GPU_viewport_color_texture(viewport, view);
}
- else {
- return GPU_offscreen_color_texture(region->draw_buffer->offscreen);
- }
+ return GPU_offscreen_color_texture(region->draw_buffer->offscreen);
}
void wm_draw_region_blend(ARegion *region, int view, bool blend)
@@ -554,24 +539,10 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend)
alpha = 1.0f;
}
- /* setup actual texture */
- GPUTexture *texture = wm_draw_region_texture(region, view);
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(texture));
-
/* wmOrtho for the screen has this same offset */
const float halfx = GLA_PIXEL_OFS / (BLI_rcti_size_x(&region->winrct) + 1);
const float halfy = GLA_PIXEL_OFS / (BLI_rcti_size_y(&region->winrct) + 1);
- if (blend) {
- /* GL_ONE because regions drawn offscreen have premultiplied alpha. */
- GPU_blend(true);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- }
-
- GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR);
- GPU_shader_bind(shader);
-
rcti rect_geo = region->winrct;
rect_geo.xmax += 1;
rect_geo.ymax += 1;
@@ -598,26 +569,39 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend)
alpha = 1.0f;
}
- glUniform1i(GPU_shader_get_uniform(shader, "image"), 0);
- glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"),
- rect_tex.xmin,
- rect_tex.ymin,
- rect_tex.xmax,
- rect_tex.ymax);
- glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"),
- rect_geo.xmin,
- rect_geo.ymin,
- rect_geo.xmax,
- rect_geo.ymax);
- glUniform4f(
- GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha);
+ /* Not the same layout as rectf/recti. */
+ float rectt[4] = {rect_tex.xmin, rect_tex.ymin, rect_tex.xmax, rect_tex.ymax};
+ float rectg[4] = {rect_geo.xmin, rect_geo.ymin, rect_geo.xmax, rect_geo.ymax};
+
+ if (blend) {
+ /* GL_ONE because regions drawn offscreen have premultiplied alpha. */
+ GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+ GPU_blend(true);
+ }
+
+ /* setup actual texture */
+ GPUTexture *texture = wm_draw_region_texture(region, view);
+
+ GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR);
+ GPU_shader_bind(shader);
+
+ int color_loc = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR);
+ int rect_tex_loc = GPU_shader_get_uniform(shader, "rect_icon");
+ int rect_geo_loc = GPU_shader_get_uniform(shader, "rect_geom");
+ int texture_bind_loc = GPU_shader_get_texture_binding(shader, "image");
+
+ GPU_texture_bind(texture, texture_bind_loc);
+
+ GPU_shader_uniform_vector(shader, rect_tex_loc, 4, 1, rectt);
+ GPU_shader_uniform_vector(shader, rect_geo_loc, 4, 1, rectg);
+ GPU_shader_uniform_vector(shader, color_loc, 4, 1, (const float[4]){1, 1, 1, 1});
GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4);
- glBindTexture(GL_TEXTURE_2D, 0);
+ GPU_texture_unbind(texture);
if (blend) {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ GPU_blend_set_func(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA);
GPU_blend(false);
}
}
@@ -736,8 +720,8 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
wm_draw_region_buffer_create(region, false, false);
wm_draw_region_bind(region, 0);
- glClearColor(0, 0, 0, 0);
- glClear(GL_COLOR_BUFFER_BIT);
+ GPU_clear_color(0, 0, 0, 0);
+ GPU_clear(GPU_COLOR_BIT);
ED_region_do_draw(C, region);
wm_draw_region_unbind(region);
@@ -759,8 +743,8 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view)
* Actually this is only a problem when resizing the window.
* If it becomes a problem we should clear only when window size changes. */
#if 0
- glClearColor(0, 0, 0, 0);
- glClear(GL_COLOR_BUFFER_BIT);
+ GPU_clear_color(0, 0, 0, 0);
+ GPU_clear(GPU_COLOR_BIT);
#endif
/* Blit non-overlapping area regions. */
@@ -844,11 +828,13 @@ static void wm_draw_window(bContext *C, wmWindow *win)
}
else if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP) {
/* For pageflip we simply draw to both back buffers. */
- glDrawBuffer(GL_BACK_LEFT);
+ GPU_backbuffer_bind(GPU_BACKBUFFER_LEFT);
wm_draw_window_onscreen(C, win, 0);
- glDrawBuffer(GL_BACK_RIGHT);
+
+ GPU_backbuffer_bind(GPU_BACKBUFFER_RIGHT);
wm_draw_window_onscreen(C, win, 1);
- glDrawBuffer(GL_BACK);
+
+ GPU_backbuffer_bind(GPU_BACKBUFFER);
}
else if (ELEM(win->stereo3d_format->display_mode, S3D_DISPLAY_ANAGLYPH, S3D_DISPLAY_INTERLACE)) {
/* For anaglyph and interlace, we draw individual regions with
@@ -874,8 +860,7 @@ static void wm_draw_window(bContext *C, wmWindow *win)
GPU_offscreen_unbind(offscreen, false);
/* Draw offscreen buffer to screen. */
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(texture));
+ GPU_texture_bind(texture, 0);
wmWindowViewport(win);
if (win->stereo3d_format->display_mode == S3D_DISPLAY_SIDEBYSIDE) {
@@ -885,7 +870,7 @@ static void wm_draw_window(bContext *C, wmWindow *win)
wm_stereo3d_draw_topbottom(win, view);
}
- glBindTexture(GL_TEXTURE_2D, 0);
+ GPU_texture_unbind(texture);
}
GPU_offscreen_free(offscreen);
@@ -1012,7 +997,8 @@ void wm_draw_update(bContext *C)
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win;
- GPU_free_unused_buffers();
+ GPU_context_main_lock();
+ BKE_image_free_unused_gpu_textures();
for (win = wm->windows.first; win; win = win->next) {
#ifdef WIN32
@@ -1049,6 +1035,8 @@ void wm_draw_update(bContext *C)
/* Draw non-windows (surfaces) */
wm_surfaces_iter(C, wm_draw_surface);
+
+ GPU_context_main_unlock();
}
void wm_draw_region_clear(wmWindow *win, ARegion *UNUSED(region))
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 53d6df915d6..0941dd49d23 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -591,13 +591,13 @@ static int wm_handler_ui_call(bContext *C,
return WM_HANDLER_CONTINUE;
}
- /* UI is quite aggressive with swallowing events, like scrollwheel */
+ /* UI is quite aggressive with swallowing events, like scroll-wheel. */
/* I realize this is not extremely nice code... when UI gets keymaps it can be maybe smarter */
if (do_wheel_ui == false) {
if (is_wheel) {
return WM_HANDLER_CONTINUE;
}
- else if (wm_event_always_pass(event) == 0) {
+ if (wm_event_always_pass(event) == 0) {
do_wheel_ui = true;
}
}
@@ -608,7 +608,7 @@ static int wm_handler_ui_call(bContext *C,
return WM_UI_HANDLER_CONTINUE;
}
- /* we set context to where ui handler came from */
+ /* We set context to where UI handler came from. */
if (handler->context.area) {
CTX_wm_area_set(C, handler->context.area);
}
@@ -783,7 +783,7 @@ bool WM_operator_poll(bContext *C, wmOperatorType *ot)
if (ot->pyop_poll) {
return ot->pyop_poll(C, ot);
}
- else if (ot->poll) {
+ if (ot->poll) {
return ot->poll(C);
}
@@ -810,7 +810,7 @@ bool WM_operator_check_ui_empty(wmOperatorType *ot)
return true;
}
- /* Assume a ui callback will draw something. */
+ /* Assume a UI callback will draw something. */
if (ot->ui) {
return false;
}
@@ -1095,7 +1095,7 @@ bool WM_operator_repeat_check(const bContext *UNUSED(C), wmOperator *op)
if (op->type->exec != NULL) {
return true;
}
- else if (op->opm) {
+ if (op->opm) {
/* for macros, check all have exec() we can call */
wmOperatorTypeMacro *otmacro;
for (otmacro = op->opm->type->macro.first; otmacro; otmacro = otmacro->next) {
@@ -1816,10 +1816,10 @@ static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi)
/* tablet events can occur on hover + keypress */
return false;
}
- else if ((kmitype == TABLET_STYLUS) && (wmtab->active != EVT_TABLET_STYLUS)) {
+ if ((kmitype == TABLET_STYLUS) && (wmtab->active != EVT_TABLET_STYLUS)) {
return false;
}
- else if ((kmitype == TABLET_ERASER) && (wmtab->active != EVT_TABLET_ERASER)) {
+ if ((kmitype == TABLET_ERASER) && (wmtab->active != EVT_TABLET_ERASER)) {
return false;
}
}
@@ -2434,13 +2434,11 @@ static int wm_handlers_do_keymap_with_keymap_handler(
}
break;
}
+ if (action & WM_HANDLER_HANDLED) {
+ CLOG_INFO(WM_LOG_HANDLERS, 2, "handled - and pass on! '%s'", kmi->idname);
+ }
else {
- if (action & WM_HANDLER_HANDLED) {
- CLOG_INFO(WM_LOG_HANDLERS, 2, "handled - and pass on! '%s'", kmi->idname);
- }
- else {
- CLOG_INFO(WM_LOG_HANDLERS, 2, "un-handled '%s'", kmi->idname);
- }
+ CLOG_INFO(WM_LOG_HANDLERS, 2, "un-handled '%s'", kmi->idname);
}
}
}
@@ -2492,16 +2490,14 @@ static int wm_handlers_do_keymap_with_gizmo_handler(
}
break;
}
- else {
- if (action & WM_HANDLER_HANDLED) {
- if (G.debug & (G_DEBUG_EVENTS | G_DEBUG_HANDLERS)) {
- printf("%s: handled - and pass on! '%s'\n", __func__, kmi->idname);
- }
- }
- else {
- PRINT("%s: un-handled '%s'\n", __func__, kmi->idname);
+ if (action & WM_HANDLER_HANDLED) {
+ if (G.debug & (G_DEBUG_EVENTS | G_DEBUG_HANDLERS)) {
+ printf("%s: handled - and pass on! '%s'\n", __func__, kmi->idname);
}
}
+ else {
+ PRINT("%s: un-handled '%s'\n", __func__, kmi->idname);
+ }
}
}
}
@@ -2707,7 +2703,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
handler_base = handler_base_next) {
handler_base_next = handler_base->next;
- /* during this loop, ui handlers for nested menus can tag multiple handlers free */
+ /* During this loop, UI handlers for nested menus can tag multiple handlers free. */
if (handler_base->flag & WM_HANDLER_DO_FREE) {
/* pass */
}
@@ -2829,7 +2825,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
/* XXX code this for all modal ops, and ensure free only happens here */
- /* modal ui handler can be tagged to be freed */
+ /* Modal UI handler can be tagged to be freed. */
if (BLI_findindex(handlers, handler_base) !=
-1) { /* could be freed already by regular modal ops */
if (handler_base->flag & WM_HANDLER_DO_FREE) {
@@ -3126,13 +3122,9 @@ static bool wm_event_pie_filter(wmWindow *win, const wmEvent *event)
win->lock_pie_event = EVENT_NONE;
return false;
}
- else {
- return true;
- }
- }
- else {
- return false;
+ return true;
}
+ return false;
}
/**
@@ -3692,10 +3684,8 @@ wmKeyMap *WM_event_get_keymap_from_toolsystem_fallback(wmWindowManager *wm,
handler->keymap_tool = area->runtime.tool;
return km;
}
- else {
- printf(
- "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, area->runtime.tool->idname);
- }
+ printf(
+ "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, area->runtime.tool->idname);
}
}
return NULL;
@@ -3716,10 +3706,8 @@ wmKeyMap *WM_event_get_keymap_from_toolsystem(wmWindowManager *wm, wmEventHandle
handler->keymap_tool = area->runtime.tool;
return km;
}
- else {
- printf(
- "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, area->runtime.tool->idname);
- }
+ printf(
+ "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, area->runtime.tool->idname);
}
}
return NULL;
@@ -3775,12 +3763,10 @@ static bool event_or_prev_in_rect(const wmEvent *event, const rcti *rect)
if (BLI_rcti_isect_pt(rect, event->x, event->y)) {
return true;
}
- else if (event->type == MOUSEMOVE && BLI_rcti_isect_pt(rect, event->prevx, event->prevy)) {
+ if (event->type == MOUSEMOVE && BLI_rcti_isect_pt(rect, event->prevx, event->prevy)) {
return true;
}
- else {
- return false;
- }
+ return false;
}
static bool handler_region_v2d_mask_test(const ARegion *region, const wmEvent *event)
@@ -3966,138 +3952,137 @@ static int convert_key(GHOST_TKey key)
if (key >= GHOST_kKeyA && key <= GHOST_kKeyZ) {
return (EVT_AKEY + ((int)key - GHOST_kKeyA));
}
- else if (key >= GHOST_kKey0 && key <= GHOST_kKey9) {
+ if (key >= GHOST_kKey0 && key <= GHOST_kKey9) {
return (EVT_ZEROKEY + ((int)key - GHOST_kKey0));
}
- else if (key >= GHOST_kKeyNumpad0 && key <= GHOST_kKeyNumpad9) {
+ if (key >= GHOST_kKeyNumpad0 && key <= GHOST_kKeyNumpad9) {
return (EVT_PAD0 + ((int)key - GHOST_kKeyNumpad0));
}
- else if (key >= GHOST_kKeyF1 && key <= GHOST_kKeyF24) {
+ if (key >= GHOST_kKeyF1 && key <= GHOST_kKeyF24) {
return (EVT_F1KEY + ((int)key - GHOST_kKeyF1));
}
- else {
- switch (key) {
- case GHOST_kKeyBackSpace:
- return EVT_BACKSPACEKEY;
- case GHOST_kKeyTab:
- return EVT_TABKEY;
- case GHOST_kKeyLinefeed:
- return EVT_LINEFEEDKEY;
- case GHOST_kKeyClear:
- return 0;
- case GHOST_kKeyEnter:
- return EVT_RETKEY;
-
- case GHOST_kKeyEsc:
- return EVT_ESCKEY;
- case GHOST_kKeySpace:
- return EVT_SPACEKEY;
- case GHOST_kKeyQuote:
- return EVT_QUOTEKEY;
- case GHOST_kKeyComma:
- return EVT_COMMAKEY;
- case GHOST_kKeyMinus:
- return EVT_MINUSKEY;
- case GHOST_kKeyPlus:
- return EVT_PLUSKEY;
- case GHOST_kKeyPeriod:
- return EVT_PERIODKEY;
- case GHOST_kKeySlash:
- return EVT_SLASHKEY;
-
- case GHOST_kKeySemicolon:
- return EVT_SEMICOLONKEY;
- case GHOST_kKeyEqual:
- return EVT_EQUALKEY;
-
- case GHOST_kKeyLeftBracket:
- return EVT_LEFTBRACKETKEY;
- case GHOST_kKeyRightBracket:
- return EVT_RIGHTBRACKETKEY;
- case GHOST_kKeyBackslash:
- return EVT_BACKSLASHKEY;
- case GHOST_kKeyAccentGrave:
- return EVT_ACCENTGRAVEKEY;
-
- case GHOST_kKeyLeftShift:
- return EVT_LEFTSHIFTKEY;
- case GHOST_kKeyRightShift:
- return EVT_RIGHTSHIFTKEY;
- case GHOST_kKeyLeftControl:
- return EVT_LEFTCTRLKEY;
- case GHOST_kKeyRightControl:
- return EVT_RIGHTCTRLKEY;
- case GHOST_kKeyOS:
- return EVT_OSKEY;
- case GHOST_kKeyLeftAlt:
- return EVT_LEFTALTKEY;
- case GHOST_kKeyRightAlt:
- return EVT_RIGHTALTKEY;
- case GHOST_kKeyApp:
- return EVT_APPKEY;
-
- case GHOST_kKeyCapsLock:
- return EVT_CAPSLOCKKEY;
- case GHOST_kKeyNumLock:
- return 0;
- case GHOST_kKeyScrollLock:
- return 0;
-
- case GHOST_kKeyLeftArrow:
- return EVT_LEFTARROWKEY;
- case GHOST_kKeyRightArrow:
- return EVT_RIGHTARROWKEY;
- case GHOST_kKeyUpArrow:
- return EVT_UPARROWKEY;
- case GHOST_kKeyDownArrow:
- return EVT_DOWNARROWKEY;
-
- case GHOST_kKeyPrintScreen:
- return 0;
- case GHOST_kKeyPause:
- return EVT_PAUSEKEY;
-
- case GHOST_kKeyInsert:
- return EVT_INSERTKEY;
- case GHOST_kKeyDelete:
- return EVT_DELKEY;
- case GHOST_kKeyHome:
- return EVT_HOMEKEY;
- case GHOST_kKeyEnd:
- return EVT_ENDKEY;
- case GHOST_kKeyUpPage:
- return EVT_PAGEUPKEY;
- case GHOST_kKeyDownPage:
- return EVT_PAGEDOWNKEY;
-
- case GHOST_kKeyNumpadPeriod:
- return EVT_PADPERIOD;
- case GHOST_kKeyNumpadEnter:
- return EVT_PADENTER;
- case GHOST_kKeyNumpadPlus:
- return EVT_PADPLUSKEY;
- case GHOST_kKeyNumpadMinus:
- return EVT_PADMINUS;
- case GHOST_kKeyNumpadAsterisk:
- return EVT_PADASTERKEY;
- case GHOST_kKeyNumpadSlash:
- return EVT_PADSLASHKEY;
-
- case GHOST_kKeyGrLess:
- return EVT_GRLESSKEY;
-
- case GHOST_kKeyMediaPlay:
- return EVT_MEDIAPLAY;
- case GHOST_kKeyMediaStop:
- return EVT_MEDIASTOP;
- case GHOST_kKeyMediaFirst:
- return EVT_MEDIAFIRST;
- case GHOST_kKeyMediaLast:
- return EVT_MEDIALAST;
-
- default:
- return EVT_UNKNOWNKEY; /* GHOST_kKeyUnknown */
- }
+
+ switch (key) {
+ case GHOST_kKeyBackSpace:
+ return EVT_BACKSPACEKEY;
+ case GHOST_kKeyTab:
+ return EVT_TABKEY;
+ case GHOST_kKeyLinefeed:
+ return EVT_LINEFEEDKEY;
+ case GHOST_kKeyClear:
+ return 0;
+ case GHOST_kKeyEnter:
+ return EVT_RETKEY;
+
+ case GHOST_kKeyEsc:
+ return EVT_ESCKEY;
+ case GHOST_kKeySpace:
+ return EVT_SPACEKEY;
+ case GHOST_kKeyQuote:
+ return EVT_QUOTEKEY;
+ case GHOST_kKeyComma:
+ return EVT_COMMAKEY;
+ case GHOST_kKeyMinus:
+ return EVT_MINUSKEY;
+ case GHOST_kKeyPlus:
+ return EVT_PLUSKEY;
+ case GHOST_kKeyPeriod:
+ return EVT_PERIODKEY;
+ case GHOST_kKeySlash:
+ return EVT_SLASHKEY;
+
+ case GHOST_kKeySemicolon:
+ return EVT_SEMICOLONKEY;
+ case GHOST_kKeyEqual:
+ return EVT_EQUALKEY;
+
+ case GHOST_kKeyLeftBracket:
+ return EVT_LEFTBRACKETKEY;
+ case GHOST_kKeyRightBracket:
+ return EVT_RIGHTBRACKETKEY;
+ case GHOST_kKeyBackslash:
+ return EVT_BACKSLASHKEY;
+ case GHOST_kKeyAccentGrave:
+ return EVT_ACCENTGRAVEKEY;
+
+ case GHOST_kKeyLeftShift:
+ return EVT_LEFTSHIFTKEY;
+ case GHOST_kKeyRightShift:
+ return EVT_RIGHTSHIFTKEY;
+ case GHOST_kKeyLeftControl:
+ return EVT_LEFTCTRLKEY;
+ case GHOST_kKeyRightControl:
+ return EVT_RIGHTCTRLKEY;
+ case GHOST_kKeyOS:
+ return EVT_OSKEY;
+ case GHOST_kKeyLeftAlt:
+ return EVT_LEFTALTKEY;
+ case GHOST_kKeyRightAlt:
+ return EVT_RIGHTALTKEY;
+ case GHOST_kKeyApp:
+ return EVT_APPKEY;
+
+ case GHOST_kKeyCapsLock:
+ return EVT_CAPSLOCKKEY;
+ case GHOST_kKeyNumLock:
+ return 0;
+ case GHOST_kKeyScrollLock:
+ return 0;
+
+ case GHOST_kKeyLeftArrow:
+ return EVT_LEFTARROWKEY;
+ case GHOST_kKeyRightArrow:
+ return EVT_RIGHTARROWKEY;
+ case GHOST_kKeyUpArrow:
+ return EVT_UPARROWKEY;
+ case GHOST_kKeyDownArrow:
+ return EVT_DOWNARROWKEY;
+
+ case GHOST_kKeyPrintScreen:
+ return 0;
+ case GHOST_kKeyPause:
+ return EVT_PAUSEKEY;
+
+ case GHOST_kKeyInsert:
+ return EVT_INSERTKEY;
+ case GHOST_kKeyDelete:
+ return EVT_DELKEY;
+ case GHOST_kKeyHome:
+ return EVT_HOMEKEY;
+ case GHOST_kKeyEnd:
+ return EVT_ENDKEY;
+ case GHOST_kKeyUpPage:
+ return EVT_PAGEUPKEY;
+ case GHOST_kKeyDownPage:
+ return EVT_PAGEDOWNKEY;
+
+ case GHOST_kKeyNumpadPeriod:
+ return EVT_PADPERIOD;
+ case GHOST_kKeyNumpadEnter:
+ return EVT_PADENTER;
+ case GHOST_kKeyNumpadPlus:
+ return EVT_PADPLUSKEY;
+ case GHOST_kKeyNumpadMinus:
+ return EVT_PADMINUS;
+ case GHOST_kKeyNumpadAsterisk:
+ return EVT_PADASTERKEY;
+ case GHOST_kKeyNumpadSlash:
+ return EVT_PADSLASHKEY;
+
+ case GHOST_kKeyGrLess:
+ return EVT_GRLESSKEY;
+
+ case GHOST_kKeyMediaPlay:
+ return EVT_MEDIAPLAY;
+ case GHOST_kKeyMediaStop:
+ return EVT_MEDIASTOP;
+ case GHOST_kKeyMediaFirst:
+ return EVT_MEDIAFIRST;
+ case GHOST_kKeyMediaLast:
+ return EVT_MEDIALAST;
+
+ default:
+ return EVT_UNKNOWNKEY; /* GHOST_kKeyUnknown */
}
}
@@ -4834,7 +4819,7 @@ wmKeyMapItem *WM_event_match_keymap_item_from_handlers(bContext *C,
const wmEvent *event)
{
LISTBASE_FOREACH (wmEventHandler *, handler_base, handlers) {
- /* during this loop, ui handlers for nested menus can tag multiple handlers free */
+ /* During this loop, UI handlers for nested menus can tag multiple handlers free. */
if (handler_base->flag & WM_HANDLER_DO_FREE) {
/* pass */
}
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index d5a240a358e..ef4f2b4a62a 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -258,7 +258,7 @@ static void wm_window_match_keep_current_wm(const bContext *C,
bScreen *screen = NULL;
/* match oldwm to new dbase, only old files */
- wm->initialized &= ~WM_WINDOW_IS_INITIALIZED;
+ wm->initialized &= ~WM_WINDOW_IS_INIT;
/* when loading without UI, no matching needed */
if (load_ui && (screen = CTX_wm_screen(C))) {
@@ -1027,13 +1027,6 @@ void wm_homefile_read(bContext *C,
},
NULL);
}
- if (BLI_listbase_is_empty(&U.themes)) {
- if (G.debug & G_DEBUG) {
- printf("\nNote: No (valid) '%s' found, fall back to built-in default.\n\n",
- filepath_startup);
- }
- success = false;
- }
if (success) {
if (update_defaults) {
if (use_data) {
@@ -1411,10 +1404,8 @@ bool write_crash_blend(void)
printf("written: %s\n", path);
return 1;
}
- else {
- printf("failed: %s\n", path);
- return 0;
- }
+ printf("failed: %s\n", path);
+ return 0;
}
/**
@@ -2098,9 +2089,7 @@ static int wm_homefile_read_invoke(bContext *C, wmOperator *op, const wmEvent *U
wm_close_file_dialog(C, callback);
return OPERATOR_INTERFACE;
}
- else {
- return wm_homefile_read_exec(C, op);
- }
+ return wm_homefile_read_exec(C, op);
}
static void read_homefile_props(wmOperatorType *ot)
@@ -2262,9 +2251,7 @@ static int wm_open_mainfile__discard_changes(bContext *C, wmOperator *op)
wm_close_file_dialog(C, callback);
return OPERATOR_INTERFACE;
}
- else {
- return wm_open_mainfile_dispatch(C, op);
- }
+ return wm_open_mainfile_dispatch(C, op);
}
static int wm_open_mainfile__select_file_path(bContext *C, wmOperator *op)
@@ -2335,9 +2322,7 @@ static int wm_open_mainfile__open(bContext *C, wmOperator *op)
ED_view3d_local_collections_reset(C, (G.fileflags & G_FILE_NO_UI) != 0);
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
static OperatorDispatchTarget wm_open_mainfile_dispatch_targets[] = {
@@ -2482,9 +2467,7 @@ static int wm_revert_mainfile_exec(bContext *C, wmOperator *op)
if (success) {
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
static bool wm_revert_mainfile_poll(bContext *UNUSED(C))
@@ -2579,9 +2562,7 @@ static int wm_recover_auto_save_exec(bContext *C, wmOperator *op)
if (success) {
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
static int wm_recover_auto_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index c8574a5a7fb..6ccc5d79962 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -34,6 +34,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_ID.h"
+#include "DNA_key_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_windowmanager_types.h"
@@ -50,8 +51,10 @@
#include "BKE_context.h"
#include "BKE_global.h"
+#include "BKE_key.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
+#include "BKE_lib_override.h"
#include "BKE_lib_remap.h"
#include "BKE_main.h"
#include "BKE_report.h"
@@ -354,11 +357,11 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
BKE_reportf(op->reports, RPT_ERROR, "'%s': not a library", path);
return OPERATOR_CANCELLED;
}
- else if (!group) {
+ if (!group) {
BKE_reportf(op->reports, RPT_ERROR, "'%s': nothing indicated", path);
return OPERATOR_CANCELLED;
}
- else if (BLI_path_cmp(BKE_main_blendfile_path(bmain), libname) == 0) {
+ if (BLI_path_cmp(BKE_main_blendfile_path(bmain), libname) == 0) {
BKE_reportf(op->reports, RPT_ERROR, "'%s': cannot use current file as library", path);
return OPERATOR_CANCELLED;
}
@@ -694,6 +697,92 @@ static int wm_lib_relocate_invoke(bContext *C, wmOperator *op, const wmEvent *UN
return OPERATOR_CANCELLED;
}
+static void lib_relocate_do_remap(Main *bmain,
+ ID *old_id,
+ ID *new_id,
+ ReportList *reports,
+ const bool do_reload,
+ const short remap_flags)
+{
+ BLI_assert(old_id);
+ if (do_reload) {
+ /* Since we asked for placeholders in case of missing IDs,
+ * we expect to always get a valid one. */
+ BLI_assert(new_id);
+ }
+ if (new_id) {
+#ifdef PRINT_DEBUG
+ printf("before remap of %s, old_id users: %d, new_id users: %d\n",
+ old_id->name,
+ old_id->us,
+ new_id->us);
+#endif
+ BKE_libblock_remap_locked(bmain, old_id, new_id, remap_flags);
+
+ if (old_id->flag & LIB_FAKEUSER) {
+ id_fake_user_clear(old_id);
+ id_fake_user_set(new_id);
+ }
+
+#ifdef PRINT_DEBUG
+ printf("after remap of %s, old_id users: %d, new_id users: %d\n",
+ old_id->name,
+ old_id->us,
+ new_id->us);
+#endif
+
+ /* In some cases, new_id might become direct link, remove parent of library in this case. */
+ if (new_id->lib->parent && (new_id->tag & LIB_TAG_INDIRECT) == 0) {
+ if (do_reload) {
+ BLI_assert(0); /* Should not happen in 'pure' reload case... */
+ }
+ new_id->lib->parent = NULL;
+ }
+ }
+
+ if (old_id->us > 0 && new_id && old_id->lib == new_id->lib) {
+ /* Note that this *should* not happen - but better be safe than sorry in this area,
+ * at least until we are 100% sure this cannot ever happen.
+ * Also, we can safely assume names were unique so far,
+ * so just replacing '.' by '~' should work,
+ * but this does not totally rules out the possibility of name collision. */
+ size_t len = strlen(old_id->name);
+ size_t dot_pos;
+ bool has_num = false;
+
+ for (dot_pos = len; dot_pos--;) {
+ char c = old_id->name[dot_pos];
+ if (c == '.') {
+ break;
+ }
+ if (c < '0' || c > '9') {
+ has_num = false;
+ break;
+ }
+ has_num = true;
+ }
+
+ if (has_num) {
+ old_id->name[dot_pos] = '~';
+ }
+ else {
+ len = MIN2(len, MAX_ID_NAME - 7);
+ BLI_strncpy(&old_id->name[len], "~000", 7);
+ }
+
+ id_sort_by_name(which_libbase(bmain, GS(old_id->name)), old_id, NULL);
+
+ BKE_reportf(
+ reports,
+ RPT_WARNING,
+ "Lib Reload: Replacing all references to old data-block '%s' by reloaded one failed, "
+ "old one (%d remaining users) had to be kept and was renamed to '%s'",
+ new_id->name,
+ old_id->us,
+ old_id->name);
+ }
+}
+
static void lib_relocate_do(Main *bmain,
Library *library,
WMLinkAppendData *lapp_data,
@@ -725,6 +814,12 @@ static void lib_relocate_do(Main *bmain,
/* We remove it from current Main, and add it to items to link... */
/* Note that non-linkable IDs (like e.g. shapekeys) are also explicitly linked here... */
BLI_remlink(lbarray[lba_idx], id);
+ /* Usual special code for ShapeKeys snowflakes... */
+ Key *old_key = BKE_key_from_id(id);
+ if (old_key != NULL) {
+ BLI_remlink(which_libbase(bmain, GS(old_key->id.name)), &old_key->id);
+ }
+
item = wm_link_append_data_item_add(lapp_data, id->name + 2, idcode, id);
BLI_bitmap_set_all(item->libraries, true, lapp_data->num_libraries);
@@ -757,6 +852,12 @@ static void lib_relocate_do(Main *bmain,
BLI_assert(old_id);
BLI_addtail(which_libbase(bmain, GS(old_id->name)), old_id);
+
+ /* Usual special code for ShapeKeys snowflakes... */
+ Key *old_key = BKE_key_from_id(old_id);
+ if (old_key != NULL) {
+ BLI_addtail(which_libbase(bmain, GS(old_key->id.name)), &old_key->id);
+ }
}
/* Since our (old) reloaded IDs were removed from main, the user count done for them in linking
@@ -773,82 +874,20 @@ static void lib_relocate_do(Main *bmain,
ID *old_id = item->customdata;
ID *new_id = item->new_id;
- BLI_assert(old_id);
- if (do_reload) {
- /* Since we asked for placeholders in case of missing IDs,
- * we expect to always get a valid one. */
- BLI_assert(new_id);
- }
- if (new_id) {
-#ifdef PRINT_DEBUG
- printf("before remap of %s, old_id users: %d, new_id users: %d\n",
- old_id->name,
- old_id->us,
- new_id->us);
-#endif
- BKE_libblock_remap_locked(bmain, old_id, new_id, remap_flags);
-
- if (old_id->flag & LIB_FAKEUSER) {
- id_fake_user_clear(old_id);
- id_fake_user_set(new_id);
- }
-
-#ifdef PRINT_DEBUG
- printf("after remap of %s, old_id users: %d, new_id users: %d\n",
- old_id->name,
- old_id->us,
- new_id->us);
-#endif
-
- /* In some cases, new_id might become direct link, remove parent of library in this case. */
- if (new_id->lib->parent && (new_id->tag & LIB_TAG_INDIRECT) == 0) {
- if (do_reload) {
- BLI_assert(0); /* Should not happen in 'pure' reload case... */
- }
- new_id->lib->parent = NULL;
- }
+ lib_relocate_do_remap(bmain, old_id, new_id, reports, do_reload, remap_flags);
+ /* Usual special code for ShapeKeys snowflakes... */
+ Key **old_key_p = BKE_key_from_id_p(old_id);
+ if (old_key_p == NULL) {
+ continue;
}
-
- if (old_id->us > 0 && new_id && old_id->lib == new_id->lib) {
- /* Note that this *should* not happen - but better be safe than sorry in this area,
- * at least until we are 100% sure this cannot ever happen.
- * Also, we can safely assume names were unique so far,
- * so just replacing '.' by '~' should work,
- * but this does not totally rules out the possibility of name collision. */
- size_t len = strlen(old_id->name);
- size_t dot_pos;
- bool has_num = false;
-
- for (dot_pos = len; dot_pos--;) {
- char c = old_id->name[dot_pos];
- if (c == '.') {
- break;
- }
- else if (c < '0' || c > '9') {
- has_num = false;
- break;
- }
- has_num = true;
- }
-
- if (has_num) {
- old_id->name[dot_pos] = '~';
- }
- else {
- len = MIN2(len, MAX_ID_NAME - 7);
- BLI_strncpy(&old_id->name[len], "~000", 7);
- }
-
- id_sort_by_name(which_libbase(bmain, GS(old_id->name)), old_id, NULL);
-
- BKE_reportf(
- reports,
- RPT_WARNING,
- "Lib Reload: Replacing all references to old data-block '%s' by reloaded one failed, "
- "old one (%d remaining users) had to be kept and was renamed to '%s'",
- new_id->name,
- old_id->us,
- old_id->name);
+ Key *old_key = *old_key_p;
+ Key *new_key = BKE_key_from_id(new_id);
+ if (old_key != NULL) {
+ *old_key_p = NULL;
+ id_us_min(&old_key->id);
+ lib_relocate_do_remap(bmain, &old_key->id, &new_key->id, reports, do_reload, remap_flags);
+ *old_key_p = old_key;
+ id_us_plus_no_lib(&old_key->id);
}
}
@@ -900,6 +939,23 @@ static void lib_relocate_do(Main *bmain,
}
}
+ /* Update overrides of reloaded linked data-blocks.
+ * Note that this will not necessarily fully update the override, it might need to be manually
+ * 're-generated' depending on changes in linked data. */
+ ID *id;
+ FOREACH_MAIN_ID_BEGIN (bmain, id) {
+ if (ID_IS_LINKED(id) || !ID_IS_OVERRIDE_LIBRARY_REAL(id) ||
+ (id->tag & LIB_TAG_PRE_EXISTING) == 0) {
+ continue;
+ }
+ if (id->override_library->reference->lib == library) {
+ BKE_lib_override_library_update(bmain, id);
+ }
+ }
+ FOREACH_MAIN_ID_END;
+
+ BKE_main_collection_sync(bmain);
+
BKE_main_lib_objects_recalc_all(bmain);
IMB_colormanagement_check_file_config(bmain);
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 6b2a74138c9..5a66cbd10eb 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -209,7 +209,7 @@ static void wm_gesture_draw_line(wmGesture *gt)
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
- glGetFloatv(GL_VIEWPORT, viewport_size);
+ GPU_viewport_size_get_f(viewport_size);
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
immUniform1i("colors_len", 2); /* "advanced" mode */
@@ -252,7 +252,7 @@ static void wm_gesture_draw_rect(wmGesture *gt)
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
- glGetFloatv(GL_VIEWPORT, viewport_size);
+ GPU_viewport_size_get_f(viewport_size);
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
immUniform1i("colors_len", 2); /* "advanced" mode */
@@ -291,7 +291,7 @@ static void wm_gesture_draw_circle(wmGesture *gt)
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
- glGetFloatv(GL_VIEWPORT, viewport_size);
+ GPU_viewport_size_get_f(viewport_size);
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
immUniform1i("colors_len", 2); /* "advanced" mode */
@@ -355,39 +355,22 @@ static void draw_filled_lasso(wmGesture *gt)
/* Additive Blending */
GPU_blend(true);
- glBlendFunc(GL_ONE, GL_ONE);
-
- GLint unpack_alignment;
- glGetIntegerv(GL_UNPACK_ALIGNMENT, &unpack_alignment);
-
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ GPU_blend_set_func(GPU_ONE, GPU_ONE);
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
GPU_shader_bind(state.shader);
GPU_shader_uniform_vector(
state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red);
- immDrawPixelsTex(&state,
- rect.xmin,
- rect.ymin,
- w,
- h,
- GL_RED,
- GL_UNSIGNED_BYTE,
- GL_NEAREST,
- pixel_buf,
- 1.0f,
- 1.0f,
- NULL);
+ immDrawPixelsTex(
+ &state, rect.xmin, rect.ymin, w, h, GL_R8, false, pixel_buf, 1.0f, 1.0f, NULL);
GPU_shader_unbind();
- glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment);
-
MEM_freeN(pixel_buf);
GPU_blend(false);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ GPU_blend_set_func(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA);
}
MEM_freeN(mcoords);
@@ -415,7 +398,7 @@ static void wm_gesture_draw_lasso(wmGesture *gt, bool filled)
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
- glGetFloatv(GL_VIEWPORT, viewport_size);
+ GPU_viewport_size_get_f(viewport_size);
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
immUniform1i("colors_len", 2); /* "advanced" mode */
@@ -449,7 +432,7 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
- glGetFloatv(GL_VIEWPORT, viewport_size);
+ GPU_viewport_size_get_f(viewport_size);
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
immUniform1i("colors_len", 2); /* "advanced" mode */
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index cb5a039765a..85694dec9c8 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -59,6 +59,7 @@
#include "BKE_font.h"
#include "BKE_global.h"
#include "BKE_icons.h"
+#include "BKE_image.h"
#include "BKE_keyconfig.h"
#include "BKE_lib_remap.h"
#include "BKE_main.h"
@@ -120,7 +121,6 @@
#include "UI_interface.h"
#include "UI_resources.h"
-#include "GPU_draw.h"
#include "GPU_init_exit.h"
#include "GPU_material.h"
@@ -171,7 +171,7 @@ void WM_init_state_start_with_console_set(bool value)
*/
static bool opengl_is_init = false;
-void WM_init_opengl(Main *bmain)
+void WM_init_opengl(void)
{
/* must be called only once */
BLI_assert(opengl_is_init == false);
@@ -185,9 +185,6 @@ void WM_init_opengl(Main *bmain)
DRW_opengl_context_create();
GPU_init();
- GPU_set_mipmap(bmain, true);
- GPU_set_linear_mipmap(true);
- GPU_set_anisotropic(U.anisotropic_filter);
GPU_pass_cache_init();
@@ -315,7 +312,7 @@ void WM_init(bContext *C, int argc, const char **argv)
/* sets 3D mouse deadzone */
WM_ndof_deadzone_set(U.ndof_deadzone);
#endif
- WM_init_opengl(G_MAIN);
+ WM_init_opengl();
if (!WM_platform_support_perform_checks()) {
exit(-1);
@@ -351,7 +348,7 @@ void WM_init(bContext *C, int argc, const char **argv)
BKE_material_copybuf_clear();
ED_render_clear_mtex_copybuf();
- // glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ // GPU_blend_set_func(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
wm_history_file_read();
@@ -578,7 +575,7 @@ void WM_exit_ex(bContext *C, const bool do_python)
BKE_subdiv_exit();
if (opengl_is_init) {
- GPU_free_unused_buffers();
+ BKE_image_free_unused_gpu_textures();
}
BKE_blender_free(); /* blender.c, does entire library and spacetypes */
@@ -656,13 +653,6 @@ void WM_exit_ex(bContext *C, const bool do_python)
BKE_blender_atexit();
- if (MEM_get_memory_blocks_in_use() != 0) {
- size_t mem_in_use = MEM_get_memory_in_use() + MEM_get_memory_in_use();
- printf("Error: Not freed memory blocks: %u, total unfreed memory %f MB\n",
- MEM_get_memory_blocks_in_use(),
- (double)mem_in_use / 1024 / 1024);
- MEM_printmemlist();
- }
wm_autosave_delete();
BKE_tempdir_session_purge();
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index c10f03f3dab..c9b125901e7 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -86,7 +86,7 @@ struct wmJob {
* This performs the actual parallel work.
* Executed in worker thread(s).
*/
- void (*startjob)(void *, short *stop, short *do_update, float *progress);
+ wm_jobs_start_callback startjob;
/**
* Called if thread defines so (see `do_update` flag), and max once per timer step.
* Executed in main thread.
@@ -344,9 +344,7 @@ void *WM_jobs_customdata_get(wmJob *wm_job)
if (!wm_job->customdata) {
return wm_job->run_customdata;
}
- else {
- return wm_job->customdata;
- }
+ return wm_job->customdata;
}
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void (*free)(void *))
@@ -378,7 +376,7 @@ void WM_jobs_delay_start(wmJob *wm_job, double delay_time)
}
void WM_jobs_callbacks(wmJob *wm_job,
- void (*startjob)(void *, short *, short *, float *),
+ wm_jobs_start_callback startjob,
void (*initjob)(void *),
void (*update)(void *),
void (*endjob)(void *))
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index d7102a1e8af..d7ff2689a86 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -321,9 +321,7 @@ bool WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
return true;
}
- else {
- return false;
- }
+ return false;
}
void WM_keyconfig_clear(wmKeyConfig *keyconf)
@@ -363,7 +361,7 @@ void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname)
WM_keyconfig_update(wm);
BLI_strncpy(U.keyconfigstr, idname, sizeof(U.keyconfigstr));
- if (wm->initialized & WM_KEYCONFIG_IS_INITIALIZED) {
+ if (wm->initialized & WM_KEYCONFIG_IS_INIT) {
U.runtime.is_dirty = true;
}
@@ -448,9 +446,7 @@ bool WM_keymap_remove(wmKeyConfig *keyconf, wmKeyMap *keymap)
return true;
}
- else {
- return false;
- }
+ return false;
}
bool WM_keymap_poll(bContext *C, wmKeyMap *keymap)
@@ -551,9 +547,7 @@ bool WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
WM_keyconfig_update_tag(keymap, NULL);
return true;
}
- else {
- return false;
- }
+ return false;
}
/** \} */
@@ -1122,7 +1116,7 @@ const char *WM_key_event_string(const short type, const bool compact)
if (platform == MACOS) {
return key_event_glyph_or_text(font_id, IFACE_("Cmd"), "\xe2\x8c\x98");
}
- else if (platform == MSWIN) {
+ if (platform == MSWIN) {
return key_event_glyph_or_text(font_id, IFACE_("Win"), "\xe2\x9d\x96");
}
return IFACE_("OS");
diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c
index 650d5bbe015..457cd0f16be 100644
--- a/source/blender/windowmanager/intern/wm_operator_type.c
+++ b/source/blender/windowmanager/intern/wm_operator_type.c
@@ -606,9 +606,7 @@ char *WM_operatortype_description(struct bContext *C,
if (description[0]) {
return description;
}
- else {
- MEM_freeN(description);
- }
+ MEM_freeN(description);
}
}
@@ -621,9 +619,7 @@ char *WM_operatortype_description(struct bContext *C,
if (info && info[0]) {
return BLI_strdup(info);
}
- else {
- return NULL;
- }
+ return NULL;
}
/** \} */
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 525f96329b7..6a3f4f6a364 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -864,19 +864,17 @@ int WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
return ret_value | OPERATOR_PASS_THROUGH;
}
- else {
- /* If we are in init phase, and cannot validate init of modal operations,
- * just fall back to basic exec.
- */
- RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, false);
+ /* If we are in init phase, and cannot validate init of modal operations,
+ * just fall back to basic exec.
+ */
+ RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, false);
- ret_value = op->type->exec(C, op);
- OPERATOR_RETVAL_CHECK(ret_value);
+ ret_value = op->type->exec(C, op);
+ OPERATOR_RETVAL_CHECK(ret_value);
- return ret_value | OPERATOR_PASS_THROUGH;
- }
+ return ret_value | OPERATOR_PASS_THROUGH;
}
- else if (event->type == init_event_type && event->val == KM_RELEASE) {
+ if (event->type == init_event_type && event->val == KM_RELEASE) {
RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, false);
ret_value = op->type->exec(C, op);
@@ -884,7 +882,7 @@ int WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
return ret_value | OPERATOR_PASS_THROUGH;
}
- else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
+ if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
const int drag_delta[2] = {
mval[0] - event->mval[0],
mval[1] - event->mval[1],
@@ -895,11 +893,9 @@ int WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (WM_event_drag_test_with_delta(event, drag_delta)) {
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
}
- else {
- /* Important not to return anything other than PASS_THROUGH here,
- * otherwise it prevents underlying tweak detection code to work properly. */
- return OPERATOR_PASS_THROUGH;
- }
+ /* Important not to return anything other than PASS_THROUGH here,
+ * otherwise it prevents underlying tweak detection code to work properly. */
+ return OPERATOR_PASS_THROUGH;
}
return OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH;
@@ -1151,9 +1147,7 @@ int WM_operator_confirm_or_exec(bContext *C, wmOperator *op, const wmEvent *UNUS
if (confirm) {
return WM_operator_confirm_message(C, op, NULL);
}
- else {
- return op->type->exec(C, op);
- }
+ return op->type->exec(C, op);
}
/* op->invoke, opens fileselect if path property not set, otherwise executes */
@@ -1162,10 +1156,8 @@ int WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *UNUSED(event
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return WM_operator_call_notest(C, op); /* call exec direct */
}
- else {
- WM_event_add_fileselect(C, op);
- return OPERATOR_RUNNING_MODAL;
- }
+ WM_event_add_fileselect(C, op);
+ return OPERATOR_RUNNING_MODAL;
}
bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const struct ImageFormatData *im_format)
@@ -2120,7 +2112,7 @@ typedef struct {
int slow_mouse[2];
bool slow_mode;
Dial *dial;
- unsigned int gltex;
+ GPUTexture *texture;
ListBase orig_paintcursors;
bool use_secondary_tex;
void *cursor;
@@ -2224,11 +2216,15 @@ static void radial_control_set_tex(RadialControl *rc)
rc->image_id_ptr.data,
rc->use_secondary_tex,
!ELEM(rc->subtype, PROP_NONE, PROP_PIXEL, PROP_DISTANCE)))) {
- glGenTextures(1, &rc->gltex);
- glBindTexture(GL_TEXTURE_2D, rc->gltex);
- glTexImage2D(
- GL_TEXTURE_2D, 0, GL_R8, ibuf->x, ibuf->y, 0, GL_RED, GL_FLOAT, ibuf->rect_float);
- glBindTexture(GL_TEXTURE_2D, 0);
+
+ rc->texture = GPU_texture_create_nD(
+ ibuf->x, ibuf->y, 0, 2, ibuf->rect_float, GPU_R8, GPU_DATA_FLOAT, 0, false, NULL);
+ GPU_texture_filter_mode(rc->texture, true);
+
+ GPU_texture_bind(rc->texture, 0);
+ GPU_texture_swizzle_set(rc->texture, "111r");
+ GPU_texture_unbind(rc->texture);
+
MEM_freeN(ibuf->rect_float);
MEM_freeN(ibuf);
}
@@ -2264,19 +2260,9 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- if (rc->gltex) {
-
+ if (rc->texture) {
uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, rc->gltex);
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- GLint swizzleMask[] = {GL_ZERO, GL_ZERO, GL_ZERO, GL_RED};
- glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
-
/* set up rotation if available */
if (rc->rot_prop) {
rot = RNA_property_float_get(&rc->rot_ptr, rc->rot_prop);
@@ -2284,10 +2270,10 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
GPU_matrix_rotate_2d(RAD2DEGF(rot));
}
- immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_MASK_UNIFORM_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
immUniformColor3fvAlpha(col, alpha);
- immUniform1i("image", 0);
+ immBindTexture("image", rc->texture);
/* draw textured quad */
immBegin(GPU_PRIM_TRI_FAN, 4);
@@ -2306,6 +2292,8 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
immEnd();
+ GPU_texture_unbind(rc->texture);
+
/* undo rotation */
if (rc->rot_prop) {
GPU_matrix_pop();
@@ -2326,7 +2314,7 @@ static void radial_control_paint_curve(uint pos, Brush *br, float radius, int li
GPU_line_width(2.0f);
immUniformColor4f(0.8f, 0.8f, 0.8f, 0.85f);
float step = (radius * 2.0f) / (float)line_segments;
- BKE_curvemapping_initialize(br->curve);
+ BKE_curvemapping_init(br->curve);
immBegin(GPU_PRIM_LINES, line_segments * 2);
for (int i = 0; i < line_segments; i++) {
float h1 = BKE_brush_curve_strength_clamped(br, fabsf((i * step) - radius), radius);
@@ -2540,10 +2528,8 @@ static int radial_control_get_path(PointerRNA *ctx_ptr,
if (flags & RC_PROP_ALLOW_MISSING) {
return 1;
}
- else {
- BKE_reportf(op->reports, RPT_ERROR, "Could not resolve path '%s'", name);
- return 0;
- }
+ BKE_reportf(op->reports, RPT_ERROR, "Could not resolve path '%s'", name);
+ return 0;
}
/* check property type */
@@ -2595,13 +2581,12 @@ static int radial_control_get_properties(bContext *C, wmOperator *op)
(RC_PROP_ALLOW_MISSING | RC_PROP_REQUIRE_BOOL))) {
return 0;
}
+
+ if (use_secondary_prop && RNA_property_boolean_get(&use_secondary_ptr, use_secondary_prop)) {
+ data_path = "data_path_secondary";
+ }
else {
- if (use_secondary_prop && RNA_property_boolean_get(&use_secondary_ptr, use_secondary_prop)) {
- data_path = "data_path_secondary";
- }
- else {
- data_path = "data_path_primary";
- }
+ data_path = "data_path_primary";
}
if (!radial_control_get_path(&ctx_ptr, op, data_path, &rc->ptr, &rc->prop, 0, 0)) {
@@ -2668,7 +2653,7 @@ static int radial_control_get_properties(bContext *C, wmOperator *op)
if (!radial_control_get_path(&ctx_ptr, op, "image_id", &rc->image_id_ptr, NULL, 0, 0)) {
return 0;
}
- else if (rc->image_id_ptr.data) {
+ if (rc->image_id_ptr.data) {
/* extra check, pointer must be to an ID */
if (!RNA_struct_is_ID(rc->image_id_ptr.type)) {
BKE_report(op->reports, RPT_ERROR, "Pointer from path image_id is not an ID");
@@ -2803,7 +2788,9 @@ static void radial_control_cancel(bContext *C, wmOperator *op)
* new value is displayed in sliders/numfields */
WM_event_add_notifier(C, NC_WINDOW, NULL);
- glDeleteTextures(1, &rc->gltex);
+ if (rc->texture != NULL) {
+ GPU_texture_free(rc->texture);
+ }
MEM_freeN(rc);
}
@@ -2843,171 +2830,169 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even
radial_control_update_header(op, C);
return OPERATOR_RUNNING_MODAL;
}
- else {
- handled = false;
- switch (event->type) {
- case EVT_ESCKEY:
- case RIGHTMOUSE:
- /* canceled; restore original value */
- radial_control_set_value(rc, rc->initial_value);
- ret = OPERATOR_CANCELLED;
- break;
-
- case LEFTMOUSE:
- case EVT_PADENTER:
- case EVT_RETKEY:
- /* done; value already set */
- RNA_property_update(C, &rc->ptr, rc->prop);
- ret = OPERATOR_FINISHED;
- break;
-
- case MOUSEMOVE:
- if (!has_numInput) {
- if (rc->slow_mode) {
- if (rc->subtype == PROP_ANGLE) {
- float position[2] = {event->x, event->y};
-
- /* calculate the initial angle here first */
- delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0];
- delta[1] = rc->initial_mouse[1] - rc->slow_mouse[1];
-
- /* precision angle gets calculated from dial and gets added later */
- angle_precision = -0.1f * BLI_dial_angle(rc->dial, position);
- }
- else {
- delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0];
- delta[1] = 0.0f;
- if (rc->zoom_prop) {
- RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom);
- delta[0] /= zoom[0];
- }
+ handled = false;
+ switch (event->type) {
+ case EVT_ESCKEY:
+ case RIGHTMOUSE:
+ /* canceled; restore original value */
+ radial_control_set_value(rc, rc->initial_value);
+ ret = OPERATOR_CANCELLED;
+ break;
- dist = len_v2(delta);
+ case LEFTMOUSE:
+ case EVT_PADENTER:
+ case EVT_RETKEY:
+ /* done; value already set */
+ RNA_property_update(C, &rc->ptr, rc->prop);
+ ret = OPERATOR_FINISHED;
+ break;
- delta[0] = event->x - rc->slow_mouse[0];
+ case MOUSEMOVE:
+ if (!has_numInput) {
+ if (rc->slow_mode) {
+ if (rc->subtype == PROP_ANGLE) {
+ float position[2] = {event->x, event->y};
- if (rc->zoom_prop) {
- delta[0] /= zoom[0];
- }
+ /* calculate the initial angle here first */
+ delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0];
+ delta[1] = rc->initial_mouse[1] - rc->slow_mouse[1];
- dist = dist + 0.1f * (delta[0]);
- }
+ /* precision angle gets calculated from dial and gets added later */
+ angle_precision = -0.1f * BLI_dial_angle(rc->dial, position);
}
else {
- delta[0] = rc->initial_mouse[0] - event->x;
- delta[1] = rc->initial_mouse[1] - event->y;
+ delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0];
+ delta[1] = 0.0f;
+
if (rc->zoom_prop) {
RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom);
delta[0] /= zoom[0];
- delta[1] /= zoom[1];
}
- if (rc->subtype == PROP_ANGLE) {
- dist = len_v2(delta);
- }
- else {
- dist = clamp_f(-delta[0], 0.0f, FLT_MAX);
+
+ dist = len_v2(delta);
+
+ delta[0] = event->x - rc->slow_mouse[0];
+
+ if (rc->zoom_prop) {
+ delta[0] /= zoom[0];
}
- }
- /* calculate new value and apply snapping */
- switch (rc->subtype) {
- case PROP_NONE:
- case PROP_DISTANCE:
- case PROP_PIXEL:
- new_value = dist;
- if (snap) {
- new_value = ((int)new_value + 5) / 10 * 10;
- }
- break;
- case PROP_PERCENTAGE:
- new_value = ((dist - WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE) /
- WM_RADIAL_CONTROL_DISPLAY_WIDTH) *
- 100.0f;
- if (snap) {
- new_value = ((int)(new_value + 2.5f)) / 5 * 5;
- }
- break;
- case PROP_FACTOR:
- new_value = (WM_RADIAL_CONTROL_DISPLAY_SIZE - dist) /
- WM_RADIAL_CONTROL_DISPLAY_WIDTH;
- if (snap) {
- new_value = ((int)ceil(new_value * 10.f) * 10.0f) / 100.f;
- }
- /* Invert new value to increase the factor moving the mouse to the right */
- new_value = 1 - new_value;
- break;
- case PROP_ANGLE:
- new_value = atan2f(delta[1], delta[0]) + (float)M_PI + angle_precision;
- new_value = fmod(new_value, 2.0f * (float)M_PI);
- if (new_value < 0.0f) {
- new_value += 2.0f * (float)M_PI;
- }
- if (snap) {
- new_value = DEG2RADF(((int)RAD2DEGF(new_value) + 5) / 10 * 10);
- }
- break;
- default:
- new_value = dist; /* dummy value, should this ever happen? - campbell */
- break;
+ dist = dist + 0.1f * (delta[0]);
}
-
- /* clamp and update */
- CLAMP(new_value, rc->min_value, rc->max_value);
- radial_control_set_value(rc, new_value);
- rc->current_value = new_value;
- handled = true;
- break;
}
- break;
-
- case EVT_LEFTSHIFTKEY:
- case EVT_RIGHTSHIFTKEY: {
- if (event->val == KM_PRESS) {
- rc->slow_mouse[0] = event->x;
- rc->slow_mouse[1] = event->y;
- rc->slow_mode = true;
+ else {
+ delta[0] = rc->initial_mouse[0] - event->x;
+ delta[1] = rc->initial_mouse[1] - event->y;
+ if (rc->zoom_prop) {
+ RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom);
+ delta[0] /= zoom[0];
+ delta[1] /= zoom[1];
+ }
if (rc->subtype == PROP_ANGLE) {
- float initial_position[2] = {UNPACK2(rc->initial_mouse)};
- float current_position[2] = {UNPACK2(rc->slow_mouse)};
- rc->dial = BLI_dial_initialize(initial_position, 0.0f);
- /* immediately set the position to get a an initial direction */
- BLI_dial_angle(rc->dial, current_position);
+ dist = len_v2(delta);
}
- handled = true;
- }
- if (event->val == KM_RELEASE) {
- rc->slow_mode = false;
- handled = true;
- if (rc->dial) {
- MEM_freeN(rc->dial);
- rc->dial = NULL;
+ else {
+ dist = clamp_f(-delta[0], 0.0f, FLT_MAX);
}
}
+
+ /* calculate new value and apply snapping */
+ switch (rc->subtype) {
+ case PROP_NONE:
+ case PROP_DISTANCE:
+ case PROP_PIXEL:
+ new_value = dist;
+ if (snap) {
+ new_value = ((int)new_value + 5) / 10 * 10;
+ }
+ break;
+ case PROP_PERCENTAGE:
+ new_value = ((dist - WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE) /
+ WM_RADIAL_CONTROL_DISPLAY_WIDTH) *
+ 100.0f;
+ if (snap) {
+ new_value = ((int)(new_value + 2.5f)) / 5 * 5;
+ }
+ break;
+ case PROP_FACTOR:
+ new_value = (WM_RADIAL_CONTROL_DISPLAY_SIZE - dist) / WM_RADIAL_CONTROL_DISPLAY_WIDTH;
+ if (snap) {
+ new_value = ((int)ceil(new_value * 10.f) * 10.0f) / 100.f;
+ }
+ /* Invert new value to increase the factor moving the mouse to the right */
+ new_value = 1 - new_value;
+ break;
+ case PROP_ANGLE:
+ new_value = atan2f(delta[1], delta[0]) + (float)M_PI + angle_precision;
+ new_value = fmod(new_value, 2.0f * (float)M_PI);
+ if (new_value < 0.0f) {
+ new_value += 2.0f * (float)M_PI;
+ }
+ if (snap) {
+ new_value = DEG2RADF(((int)RAD2DEGF(new_value) + 5) / 10 * 10);
+ }
+ break;
+ default:
+ new_value = dist; /* dummy value, should this ever happen? - campbell */
+ break;
+ }
+
+ /* clamp and update */
+ CLAMP(new_value, rc->min_value, rc->max_value);
+ radial_control_set_value(rc, new_value);
+ rc->current_value = new_value;
+ handled = true;
break;
}
+ break;
+
+ case EVT_LEFTSHIFTKEY:
+ case EVT_RIGHTSHIFTKEY: {
+ if (event->val == KM_PRESS) {
+ rc->slow_mouse[0] = event->x;
+ rc->slow_mouse[1] = event->y;
+ rc->slow_mode = true;
+ if (rc->subtype == PROP_ANGLE) {
+ float initial_position[2] = {UNPACK2(rc->initial_mouse)};
+ float current_position[2] = {UNPACK2(rc->slow_mouse)};
+ rc->dial = BLI_dial_init(initial_position, 0.0f);
+ /* immediately set the position to get a an initial direction */
+ BLI_dial_angle(rc->dial, current_position);
+ }
+ handled = true;
+ }
+ if (event->val == KM_RELEASE) {
+ rc->slow_mode = false;
+ handled = true;
+ if (rc->dial) {
+ MEM_freeN(rc->dial);
+ rc->dial = NULL;
+ }
+ }
+ break;
}
+ }
- /* Modal numinput inactive, try to handle numeric inputs last... */
- if (!handled && event->val == KM_PRESS && handleNumInput(C, &rc->num_input, event)) {
- applyNumInput(&rc->num_input, &numValue);
+ /* Modal numinput inactive, try to handle numeric inputs last... */
+ if (!handled && event->val == KM_PRESS && handleNumInput(C, &rc->num_input, event)) {
+ applyNumInput(&rc->num_input, &numValue);
- if (rc->subtype == PROP_ANGLE) {
- numValue = fmod(numValue, 2.0f * (float)M_PI);
- if (numValue < 0.0f) {
- numValue += 2.0f * (float)M_PI;
- }
+ if (rc->subtype == PROP_ANGLE) {
+ numValue = fmod(numValue, 2.0f * (float)M_PI);
+ if (numValue < 0.0f) {
+ numValue += 2.0f * (float)M_PI;
}
+ }
- CLAMP(numValue, rc->min_value, rc->max_value);
- new_value = numValue;
+ CLAMP(numValue, rc->min_value, rc->max_value);
+ new_value = numValue;
- radial_control_set_value(rc, new_value);
+ radial_control_set_value(rc, new_value);
- rc->current_value = new_value;
- radial_control_update_header(op, C);
- return OPERATOR_RUNNING_MODAL;
- }
+ rc->current_value = new_value;
+ radial_control_update_header(op, C);
+ return OPERATOR_RUNNING_MODAL;
}
ED_region_tag_redraw(CTX_wm_region(C));
@@ -3919,6 +3904,7 @@ static void gesture_box_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_assign(keymap, "CLIP_OT_select_box");
WM_modalkeymap_assign(keymap, "CLIP_OT_graph_select_box");
WM_modalkeymap_assign(keymap, "MASK_OT_select_box");
+ WM_modalkeymap_assign(keymap, "PAINT_OT_mask_box_gesture");
WM_modalkeymap_assign(keymap, "VIEW2D_OT_zoom_border");
WM_modalkeymap_assign(keymap, "VIEW3D_OT_clip_border");
WM_modalkeymap_assign(keymap, "VIEW3D_OT_render_border");
diff --git a/source/blender/windowmanager/intern/wm_platform_support.h b/source/blender/windowmanager/intern/wm_platform_support.h
index a8e20f6bcdf..6346f517343 100644
--- a/source/blender/windowmanager/intern/wm_platform_support.h
+++ b/source/blender/windowmanager/intern/wm_platform_support.h
@@ -20,11 +20,8 @@
/** \file
* \ingroup wm
*/
-#ifndef __WM_PLATFORM_SUPPORT_H__
-#define __WM_PLATFORM_SUPPORT_H__
+#pragma once
#include "BLI_sys_types.h"
bool WM_platform_support_perform_checks(void);
-
-#endif
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 948e8d9fb74..d0a70596957 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -58,6 +58,7 @@
#include "BIF_glutil.h"
#include "GPU_context.h"
+#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_init_exit.h"
@@ -309,13 +310,14 @@ static void playanim_toscreen(
CLAMP(offs_x, 0.0f, 1.0f);
CLAMP(offs_y, 0.0f, 1.0f);
- glClearColor(0.1, 0.1, 0.1, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ GPU_clear_color(0.1, 0.1, 0.1, 0.0);
+ GPU_clear(GPU_COLOR_BIT);
/* checkerboard for case alpha */
if (ibuf->planes == 32) {
GPU_blend(true);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ GPU_blend_set_func_separate(
+ GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
imm_draw_box_checker_2d_ex(offs_x,
offs_y,
@@ -333,9 +335,8 @@ static void playanim_toscreen(
offs_y + (ps->draw_flip[1] ? span_y : 0.0f),
ibuf->x,
ibuf->y,
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- GL_NEAREST,
+ GPU_RGBA8,
+ false,
ibuf->rect,
((ps->draw_flip[0] ? -1.0f : 1.0f)) * (ps->zoom / (float)ps->win_x),
((ps->draw_flip[1] ? -1.0f : 1.0f)) * (ps->zoom / (float)ps->win_y),
@@ -542,7 +543,6 @@ static void build_pict_list_ex(
totframes--;
}
}
- return;
}
static void build_pict_list(PlayState *ps, const char *first, int totframes, int fstep, int fontid)
@@ -1059,8 +1059,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
/* zoom always show entire image */
ps->zoom = MIN2(zoomx, zoomy);
- glViewport(0, 0, ps->win_x, ps->win_y);
- glScissor(0, 0, ps->win_x, ps->win_y);
+ GPU_viewport(0, 0, ps->win_x, ps->win_y);
+ GPU_scissor(0, 0, ps->win_x, ps->win_y);
playanim_gl_matrix();
@@ -1316,13 +1316,13 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
maxwiny = ibuf->y * (1 + (maxwiny / ibuf->y));
}
- glClearColor(0.1, 0.1, 0.1, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ GPU_clear_color(0.1, 0.1, 0.1, 0.0);
+ GPU_clear(GPU_COLOR_BIT);
int win_x, win_y;
playanim_window_get_size(&win_x, &win_y);
- glViewport(0, 0, win_x, win_y);
- glScissor(0, 0, win_x, win_y);
+ GPU_viewport(0, 0, win_x, win_y);
+ GPU_scissor(0, 0, win_x, win_y);
playanim_gl_matrix();
GHOST_SwapWindowBuffers(g_WS.ghost_window);
diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c
index 8ae343d5eb5..9667ed5b631 100644
--- a/source/blender/windowmanager/intern/wm_stereo.c
+++ b/source/blender/windowmanager/intern/wm_stereo.c
@@ -40,6 +40,7 @@
#include "ED_screen.h"
+#include "GPU_extensions.h"
#include "GPU_immediate.h"
#include "GPU_texture.h"
#include "GPU_viewport.h"
@@ -147,13 +148,6 @@ void wm_stereo3d_draw_topbottom(wmWindow *win, int view)
immUnbindProgram();
}
-static bool wm_stereo3d_quadbuffer_supported(void)
-{
- GLboolean stereo = GL_FALSE;
- glGetBooleanv(GL_STEREO, &stereo);
- return stereo == GL_TRUE;
-}
-
static bool wm_stereo3d_is_fullscreen_required(eStereoDisplayMode stereo_display)
{
return ELEM(stereo_display, S3D_DISPLAY_SIDEBYSIDE, S3D_DISPLAY_TOPBOTTOM);
@@ -325,7 +319,7 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
}
/* pageflip requires a new window to be created with the proper OS flags */
else if ((win_dst = wm_window_copy_test(C, win_src, false, false))) {
- if (wm_stereo3d_quadbuffer_supported()) {
+ if (GPU_stereo_quadbuffer_support()) {
BKE_report(op->reports, RPT_INFO, "Quad-buffer window successfully created");
}
else {
@@ -359,12 +353,11 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_WINDOW, NULL);
return OPERATOR_FINISHED;
}
- else {
- /* without this, the popup won't be freed freed properly T44688 */
- CTX_wm_window_set(C, win_src);
- win_src->stereo3d_format->display_mode = prev_display_mode;
- return OPERATOR_CANCELLED;
- }
+
+ /* without this, the popup won't be freed freed properly T44688 */
+ CTX_wm_window_set(C, win_src);
+ win_src->stereo3d_format->display_mode = prev_display_mode;
+ return OPERATOR_CANCELLED;
}
int wm_stereo3d_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
@@ -374,9 +367,7 @@ int wm_stereo3d_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
if (wm_stereo3d_set_properties(C, op)) {
return wm_stereo3d_set_exec(C, op);
}
- else {
- return WM_operator_props_dialog_popup(C, op, 250);
- }
+ return WM_operator_props_dialog_popup(C, op, 250);
}
void wm_stereo3d_set_draw(bContext *UNUSED(C), wmOperator *op)
diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c
index 5483d79c075..0cb76404258 100644
--- a/source/blender/windowmanager/intern/wm_subwindow.c
+++ b/source/blender/windowmanager/intern/wm_subwindow.c
@@ -29,7 +29,6 @@
#include "DNA_screen_types.h"
#include "DNA_windowmanager_types.h"
-#include "GPU_glew.h"
#include "GPU_matrix.h"
#include "GPU_viewport.h"
@@ -40,8 +39,8 @@ void wmViewport(const rcti *winrct)
int width = BLI_rcti_size_x(winrct) + 1;
int height = BLI_rcti_size_y(winrct) + 1;
- glViewport(winrct->xmin, winrct->ymin, width, height);
- glScissor(winrct->xmin, winrct->ymin, width, height);
+ GPU_viewport(winrct->xmin, winrct->ymin, width, height);
+ GPU_scissor(winrct->xmin, winrct->ymin, width, height);
wmOrtho2_pixelspace(width, height);
GPU_matrix_identity_set();
@@ -79,8 +78,8 @@ void wmPartialViewport(rcti *drawrct, const rcti *winrct, const rcti *partialrct
scissor_height += 1;
}
- glViewport(0, 0, width, height);
- glScissor(x, y, scissor_width, scissor_height);
+ GPU_viewport(0, 0, width, height);
+ GPU_scissor(x, y, scissor_width, scissor_height);
wmOrtho2_pixelspace(width, height);
GPU_matrix_identity_set();
@@ -91,8 +90,8 @@ void wmWindowViewport(wmWindow *win)
int width = WM_window_pixels_x(win);
int height = WM_window_pixels_y(win);
- glViewport(0, 0, width, height);
- glScissor(0, 0, width, height);
+ GPU_viewport(0, 0, width, height);
+ GPU_scissor(0, 0, width, height);
wmOrtho2_pixelspace(width, height);
GPU_matrix_identity_set();
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index e1b2285313c..e0dcd746aea 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -89,6 +89,7 @@
#include "GPU_init_exit.h"
#include "GPU_platform.h"
#include "GPU_state.h"
+#include "GPU_texture.h"
#include "UI_resources.h"
@@ -354,10 +355,8 @@ wmWindow *wm_window_copy_test(bContext *C,
WM_event_add_notifier_ex(wm, CTX_wm_window(C), NC_WINDOW | NA_ADDED, NULL);
return win_dst;
}
- else {
- wm_window_close(C, wm, win_dst);
- return NULL;
- }
+ wm_window_close(C, wm, win_dst);
+ return NULL;
}
/** \} */
@@ -648,10 +647,10 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
}
#endif
/* until screens get drawn, make it nice gray */
- glClearColor(0.55, 0.55, 0.55, 0.0);
+ GPU_clear_color(0.55, 0.55, 0.55, 1.0f);
/* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */
if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) {
- glClear(GL_COLOR_BUFFER_BIT);
+ GPU_clear(GPU_COLOR_BIT);
}
/* needed here, because it's used before it reads userdef */
@@ -812,9 +811,7 @@ static bool wm_window_update_size_position(wmWindow *win)
win->posy = posy;
return true;
}
- else {
- return false;
- }
+ return false;
}
/**
@@ -839,11 +836,10 @@ wmWindow *WM_window_open(bContext *C, const rcti *rect)
if (win->ghostwin) {
return win;
}
- else {
- wm_window_close(C, wm, win);
- CTX_wm_window_set(C, win_prev);
- return NULL;
- }
+
+ wm_window_close(C, wm, win);
+ CTX_wm_window_set(C, win_prev);
+ return NULL;
}
/**
@@ -968,13 +964,12 @@ wmWindow *WM_window_open_temp(bContext *C,
GHOST_SetTitle(win->ghostwin, title);
return win;
}
- else {
- /* very unlikely! but opening a new window can fail */
- wm_window_close(C, wm, win);
- CTX_wm_window_set(C, win_prev);
- return NULL;
- }
+ /* very unlikely! but opening a new window can fail */
+ wm_window_close(C, wm, win);
+ CTX_wm_window_set(C, win_prev);
+
+ return NULL;
}
/* ****************** Operators ****************** */
@@ -1205,7 +1200,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
/* Ghost now can call this function for life resizes,
* but it should return if WM didn't initialize yet.
* Can happen on file read (especially full size window). */
- if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) {
+ if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) {
return 1;
}
if (!ghostwin) {
@@ -1214,15 +1209,13 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
puts("<!> event has no window");
return 1;
}
- else if (!GHOST_ValidWindow(g_system, ghostwin)) {
+ if (!GHOST_ValidWindow(g_system, ghostwin)) {
/* XXX - should be checked, why are we getting an event here, and */
/* what is it? */
puts("<!> event has invalid window");
return 1;
}
- else {
- win = GHOST_GetWindowUserData(ghostwin);
- }
+ win = GHOST_GetWindowUserData(ghostwin);
switch (type) {
case GHOST_kEventWindowDeactivate:
@@ -2054,9 +2047,7 @@ void WM_window_pixel_sample_read(const wmWindowManager *wm,
GPU_context_active_set(win->gpuctx);
}
- glReadBuffer(GL_FRONT);
- glReadPixels(pos[0], pos[1], 1, 1, GL_RGB, GL_FLOAT, r_col);
- glReadBuffer(GL_BACK);
+ GPU_frontbuffer_read_pixels(pos[0], pos[1], 1, 1, 3, GPU_DATA_FLOAT, r_col);
if (setup_context) {
if (wm->windrawable) {
@@ -2089,10 +2080,7 @@ uint *WM_window_pixels_read(wmWindowManager *wm, wmWindow *win, int r_size[2])
const uint rect_len = r_size[0] * r_size[1];
uint *rect = MEM_mallocN(sizeof(*rect) * rect_len, __func__);
- glReadBuffer(GL_FRONT);
- glReadPixels(0, 0, r_size[0], r_size[1], GL_RGBA, GL_UNSIGNED_BYTE, rect);
- glFinish();
- glReadBuffer(GL_BACK);
+ GPU_frontbuffer_read_pixels(0, 0, r_size[0], r_size[1], 4, GPU_DATA_UNSIGNED_BYTE, rect);
if (setup_context) {
if (wm->windrawable) {
diff --git a/source/blender/windowmanager/intern/wm_window_private.h b/source/blender/windowmanager/intern/wm_window_private.h
index 115539861d7..c208d07ee37 100644
--- a/source/blender/windowmanager/intern/wm_window_private.h
+++ b/source/blender/windowmanager/intern/wm_window_private.h
@@ -20,8 +20,7 @@
/** \file
* \ingroup wm
*/
-#ifndef __WM_WINDOW_PRIVATE_H__
-#define __WM_WINDOW_PRIVATE_H__
+#pragma once
#include "BLI_sys_types.h"
#include "GHOST_Types.h"
@@ -38,5 +37,3 @@ void WM_ghost_show_message_box(const char *title,
const char *continue_label,
const char *link,
GHOST_DialogOptions dialog_options);
-
-#endif
diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h b/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h
index ccf7034e3e0..24c0192fe14 100644
--- a/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h
+++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h
@@ -18,8 +18,7 @@
* \ingroup wm
*/
-#ifndef __WM_MESSAGE_BUS_INTERN_H__
-#define __WM_MESSAGE_BUS_INTERN_H__
+#pragma once
#include "../wm_message_bus.h"
@@ -47,5 +46,3 @@ BLI_INLINE wmMsg *wm_msg_subscribe_value_msg_cast_mut(wmMsgSubscribeKey *key)
{
return &((wmMsgSubscribeKey_Generic *)key)->msg;
}
-
-#endif /* __WM_MESSAGE_BUS_INTERN_H__ */
diff --git a/source/blender/windowmanager/message_bus/wm_message_bus.h b/source/blender/windowmanager/message_bus/wm_message_bus.h
index 8020be3017a..23a53eace52 100644
--- a/source/blender/windowmanager/message_bus/wm_message_bus.h
+++ b/source/blender/windowmanager/message_bus/wm_message_bus.h
@@ -18,8 +18,7 @@
* \ingroup wm
*/
-#ifndef __WM_MESSAGE_BUS_H__
-#define __WM_MESSAGE_BUS_H__
+#pragma once
#include "RNA_types.h"
#include <stdio.h>
@@ -34,6 +33,10 @@ struct wmMsgSubscribeKey;
struct wmMsgSubscribeValue;
struct wmMsgSubscribeValueLink;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef void (*wmMsgNotifyFn)(struct bContext *C,
struct wmMsgSubscribeKey *msg_key,
struct wmMsgSubscribeValue *msg_val);
@@ -287,4 +290,6 @@ void WM_msg_publish_ID(struct wmMsgBus *mbus, struct ID *id);
} \
((void)0)
-#endif /* __WM_MESSAGE_BUS_H__ */
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h
index 16aa5cb44db..baa47098bd3 100644
--- a/source/blender/windowmanager/wm.h
+++ b/source/blender/windowmanager/wm.h
@@ -21,8 +21,7 @@
* \ingroup wm
*/
-#ifndef __WM_H__
-#define __WM_H__
+#pragma once
struct ARegion;
struct ReportList;
@@ -30,6 +29,10 @@ struct wmWindow;
#include "gizmo/wm_gizmo_wmapi.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct wmPaintCursor {
struct wmPaintCursor *next, *prev;
@@ -97,4 +100,6 @@ void wm_stereo3d_set_cancel(bContext *C, wmOperator *op);
void wm_open_init_load_ui(wmOperator *op, bool use_prefs);
void wm_open_init_use_scripts(wmOperator *op, bool use_prefs);
+#ifdef __cplusplus
+}
#endif
diff --git a/source/blender/windowmanager/wm_cursors.h b/source/blender/windowmanager/wm_cursors.h
index 7a28aeb3c70..b85616deda5 100644
--- a/source/blender/windowmanager/wm_cursors.h
+++ b/source/blender/windowmanager/wm_cursors.h
@@ -21,12 +21,15 @@
* \ingroup wm
*/
-#ifndef __WM_CURSORS_H__
-#define __WM_CURSORS_H__
+#pragma once
struct wmEvent;
struct wmWindow;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef enum WMCursorType {
WM_CURSOR_DEFAULT = 1,
WM_CURSOR_TEXT_EDIT,
@@ -77,4 +80,6 @@ typedef enum WMCursorType {
void wm_init_cursor_data(void);
bool wm_cursor_arrow_move(struct wmWindow *win, const struct wmEvent *event);
-#endif /* __WM_CURSORS_H__ */
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/windowmanager/wm_draw.h b/source/blender/windowmanager/wm_draw.h
index ff2fc25333a..4997361b485 100644
--- a/source/blender/windowmanager/wm_draw.h
+++ b/source/blender/windowmanager/wm_draw.h
@@ -21,15 +21,16 @@
* \ingroup wm
*/
-#ifndef __WM_DRAW_H__
-#define __WM_DRAW_H__
-
-#include "GPU_glew.h"
+#pragma once
struct GPUOffScreen;
struct GPUTexture;
struct GPUViewport;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct wmDrawBuffer {
struct GPUOffScreen *offscreen;
struct GPUViewport *viewport;
@@ -50,4 +51,6 @@ void wm_draw_region_test(struct bContext *C, struct ScrArea *area, struct ARegio
struct GPUTexture *wm_draw_region_texture(struct ARegion *region, int view);
-#endif /* __WM_DRAW_H__ */
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
index efcf40d03eb..787c840de8a 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -21,8 +21,7 @@
* \ingroup wm
*/
-#ifndef __WM_EVENT_SYSTEM_H__
-#define __WM_EVENT_SYSTEM_H__
+#pragma once
/* return value of handler-operator call */
#define WM_HANDLER_CONTINUE 0
@@ -34,6 +33,10 @@ struct ARegion;
struct GHOST_TabletData;
struct ScrArea;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* wmKeyMap is in DNA_windowmanager.h, it's saveable */
/** Custom types for handlers, for signaling, freeing */
@@ -165,4 +168,6 @@ void wm_dropbox_free(void);
void wm_drags_check_ops(bContext *C, const wmEvent *event);
void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect);
-#endif /* __WM_EVENT_SYSTEM_H__ */
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index ffed86abfe7..ed8f39fea48 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -23,8 +23,11 @@
* Blender copied the conventions quite some, and expanded it with internal new defines (ton)
*/
-#ifndef __WM_EVENT_TYPES_H__
-#define __WM_EVENT_TYPES_H__
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
/* customdata type */
enum {
@@ -489,4 +492,6 @@ enum {
GESTURE_MODAL_CIRCLE_SIZE = 11,
};
-#endif /* __WM_EVENT_TYPES_H__ */
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h
index 42eab35cdb9..d54090a6025 100644
--- a/source/blender/windowmanager/wm_files.h
+++ b/source/blender/windowmanager/wm_files.h
@@ -21,13 +21,16 @@
* \ingroup wm
*/
-#ifndef __WM_FILES_H__
-#define __WM_FILES_H__
+#pragma once
struct Main;
struct wmGenericCallback;
struct wmOperatorType;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* wm_files.c */
void wm_history_file_read(void);
void wm_homefile_read(struct bContext *C,
@@ -68,4 +71,6 @@ void WM_OT_append(struct wmOperatorType *ot);
void WM_OT_lib_relocate(struct wmOperatorType *ot);
void WM_OT_lib_reload(struct wmOperatorType *ot);
-#endif /* __WM_FILES_H__ */
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/windowmanager/wm_surface.h b/source/blender/windowmanager/wm_surface.h
index bc1cc825e4b..06c29231361 100644
--- a/source/blender/windowmanager/wm_surface.h
+++ b/source/blender/windowmanager/wm_surface.h
@@ -22,11 +22,14 @@
* Container to manage painting in an offscreen context.
*/
-#ifndef __WM_SURFACE_H__
-#define __WM_SURFACE_H__
+#pragma once
struct bContext;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct wmSurface {
struct wmSurface *next, *prev;
@@ -59,4 +62,6 @@ void wm_surface_clear_drawable(void);
void wm_surface_set_drawable(wmSurface *surface, bool activate);
void wm_surface_reset_drawable(void);
-#endif /* __WM_SURFACE_H__ */
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h
index 5ca5711b4f2..336db7edb50 100644
--- a/source/blender/windowmanager/wm_window.h
+++ b/source/blender/windowmanager/wm_window.h
@@ -21,11 +21,14 @@
* \ingroup wm
*/
-#ifndef __WM_WINDOW_H__
-#define __WM_WINDOW_H__
+#pragma once
struct wmOperator;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* *************** internal api ************** */
void wm_ghost_init(bContext *C);
void wm_ghost_exit(void);
@@ -85,4 +88,6 @@ int wm_window_new_main_exec(bContext *C, struct wmOperator *op);
void wm_test_autorun_warning(bContext *C);
-#endif /* __WM_WINDOW_H__ */
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_intern.h b/source/blender/windowmanager/xr/intern/wm_xr_intern.h
index 9b7e9a15948..9b7b81f769a 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_intern.h
+++ b/source/blender/windowmanager/xr/intern/wm_xr_intern.h
@@ -18,8 +18,7 @@
* \ingroup wm
*/
-#ifndef __WM_XR_INTERN_H__
-#define __WM_XR_INTERN_H__
+#pragma once
#include "CLG_log.h"
@@ -92,5 +91,3 @@ void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle context);
void wm_xr_pose_to_viewmat(const GHOST_XrPose *pose, float r_viewmat[4][4]);
void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata);
-
-#endif
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c b/source/blender/windowmanager/xr/intern/wm_xr_session.c
index 1baac10dbd8..b44f006cde8 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_session.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c
@@ -41,8 +41,8 @@
#include "wm_window.h"
#include "wm_xr_intern.h"
-wmSurface *g_xr_surface = NULL;
-CLG_LogRef LOG = {"wm.xr"};
+static wmSurface *g_xr_surface = NULL;
+static CLG_LogRef LOG = {"wm.xr"};
/* -------------------------------------------------------------------- */
@@ -159,6 +159,13 @@ static void wm_xr_session_draw_data_populate(wmXrData *xr_data,
wm_xr_session_base_pose_calc(r_draw_data->scene, settings, &r_draw_data->base_pose);
}
+typedef enum wmXrSessionStateEvent {
+ SESSION_STATE_EVENT_NONE = 0,
+ SESSION_STATE_EVENT_START,
+ SESSION_STATE_EVENT_RESET_TO_BASE_POSE,
+ SESSION_STATE_EVENT_POSITON_TRACKING_TOGGLE,
+} wmXrSessionStateEvent;
+
static bool wm_xr_session_draw_data_needs_reset_to_base_pose(const wmXrSessionState *state,
const XrSessionSettings *settings)
{
@@ -170,36 +177,63 @@ static bool wm_xr_session_draw_data_needs_reset_to_base_pose(const wmXrSessionSt
(state->prev_base_pose_object != settings->base_pose_object));
}
+static wmXrSessionStateEvent wm_xr_session_state_to_event(const wmXrSessionState *state,
+ const XrSessionSettings *settings)
+{
+ if (!state->is_view_data_set) {
+ return SESSION_STATE_EVENT_START;
+ }
+ if (wm_xr_session_draw_data_needs_reset_to_base_pose(state, settings)) {
+ return SESSION_STATE_EVENT_RESET_TO_BASE_POSE;
+ }
+
+ const bool position_tracking_toggled = ((state->prev_settings_flag &
+ XR_SESSION_USE_POSITION_TRACKING) !=
+ (settings->flag & XR_SESSION_USE_POSITION_TRACKING));
+ if (position_tracking_toggled) {
+ return SESSION_STATE_EVENT_POSITON_TRACKING_TOGGLE;
+ }
+
+ return SESSION_STATE_EVENT_NONE;
+}
+
void wm_xr_session_draw_data_update(const wmXrSessionState *state,
const XrSessionSettings *settings,
const GHOST_XrDrawViewInfo *draw_view,
wmXrDrawData *draw_data)
{
- const bool position_tracking_toggled = ((state->prev_settings_flag &
- XR_SESSION_USE_POSITION_TRACKING) !=
- (settings->flag & XR_SESSION_USE_POSITION_TRACKING));
- const bool use_position_tracking = settings->flag & XR_SESSION_USE_POSITION_TRACKING;
+ const wmXrSessionStateEvent event = wm_xr_session_state_to_event(state, settings);
+ const bool use_position_tracking = (settings->flag & XR_SESSION_USE_POSITION_TRACKING);
- /* Set the eye position offset, it's used to offset the base pose when changing positional
- * tracking. */
- if (!state->is_view_data_set ||
- wm_xr_session_draw_data_needs_reset_to_base_pose(state, settings)) {
- /* Always use the exact base pose with no offset when starting the session. */
- copy_v3_fl(draw_data->eye_position_ofs, 0.0f);
- }
- else if (position_tracking_toggled) {
- if (use_position_tracking) {
+ switch (event) {
+ case SESSION_STATE_EVENT_START:
+ /* Always use the exact base pose with no offset when starting the session. */
copy_v3_fl(draw_data->eye_position_ofs, 0.0f);
- }
- else {
- /* Store the current local offset (local pose) so that we can apply that to the eyes. This
- * way the eyes stay exactly where they are when disabling positional tracking. */
- copy_v3_v3(draw_data->eye_position_ofs, draw_view->local_pose.position);
- }
- }
- else if (!use_position_tracking) {
- /* Keep previous offset when positional tracking is disabled. */
- copy_v3_v3(draw_data->eye_position_ofs, state->prev_eye_position_ofs);
+ break;
+ /* This should be triggered by the VR add-on if a landmark changes. */
+ case SESSION_STATE_EVENT_RESET_TO_BASE_POSE:
+ if (use_position_tracking) {
+ /* Switch exactly to base pose, so use eye offset to cancel out current position delta. */
+ copy_v3_v3(draw_data->eye_position_ofs, draw_view->local_pose.position);
+ }
+ else {
+ copy_v3_fl(draw_data->eye_position_ofs, 0.0f);
+ }
+ break;
+ case SESSION_STATE_EVENT_POSITON_TRACKING_TOGGLE:
+ if (use_position_tracking) {
+ /* Keep the current position, and let the user move from there. */
+ copy_v3_v3(draw_data->eye_position_ofs, state->prev_eye_position_ofs);
+ }
+ else {
+ /* Back to the exact base-pose position. */
+ copy_v3_fl(draw_data->eye_position_ofs, 0.0f);
+ }
+ break;
+ case SESSION_STATE_EVENT_NONE:
+ /* Keep previous offset when positional tracking is disabled. */
+ copy_v3_v3(draw_data->eye_position_ofs, state->prev_eye_position_ofs);
+ break;
}
}
@@ -243,6 +277,8 @@ void wm_xr_session_state_update(const XrSessionSettings *settings,
state->prev_base_pose_type = settings->base_pose_type;
state->prev_base_pose_object = settings->base_pose_object;
state->is_view_data_set = true;
+ /* Assume this was already done through wm_xr_session_draw_data_update(). */
+ state->force_reset_to_base_pose = false;
}
wmXrSessionState *WM_xr_session_state_handle_get(const wmXrData *xr)
@@ -299,9 +335,9 @@ bool WM_xr_session_state_viewer_pose_matrix_info_get(const wmXrData *xr,
/**
* \brief Call Ghost-XR to draw a frame
*
- * Draw callback for the XR-session surface. It's expected to be called on each main loop iteration
- * and tells Ghost-XR to submit a new frame by drawing its views. Note that for drawing each view,
- * #wm_xr_draw_view() will be called through Ghost-XR (see GHOST_XrDrawViewFunc()).
+ * Draw callback for the XR-session surface. It's expected to be called on each main loop
+ * iteration and tells Ghost-XR to submit a new frame by drawing its views. Note that for drawing
+ * each view, #wm_xr_draw_view() will be called through Ghost-XR (see GHOST_XrDrawViewFunc()).
*/
static void wm_xr_session_surface_draw(bContext *C)
{
diff --git a/source/blender/windowmanager/xr/wm_xr.h b/source/blender/windowmanager/xr/wm_xr.h
index 33f79bc75b2..886f1315e8c 100644
--- a/source/blender/windowmanager/xr/wm_xr.h
+++ b/source/blender/windowmanager/xr/wm_xr.h
@@ -18,8 +18,7 @@
* \ingroup wm
*/
-#ifndef __WM_XR_H__
-#define __WM_XR_H__
+#pragma once
struct wmWindowManager;
struct wmXrData;
@@ -31,5 +30,3 @@ bool wm_xr_init(wmWindowManager *wm);
void wm_xr_exit(wmWindowManager *wm);
void wm_xr_session_toggle(wmWindowManager *wm, wmXrSessionExitFn session_exit_fn);
bool wm_xr_events_handle(wmWindowManager *wm);
-
-#endif