80# include "BKE_subsurf.hh"
96 bool use_software_cursor_dummy =
false;
100 mode_dummy, wrap_axis_dummy,
bounds, use_software_cursor_dummy);
102 if (
bounds.getWidth() != 0 ||
bounds.getHeight() != 0) {
124 if (
wm->runtime->is_interface_locked) {
141 if (pc.poll ==
nullptr || pc.poll(
C)) {
215 bool use_software_cursor;
219 if (use_software_cursor) {
256 const int event_xy[2],
261 float gl_matrix[4][4];
267 gpu::TextureFormat::UNORM_8_8_8_8,
286 gl_matrix[3][0] = event_xy[0] - (bitmap->
hot_spot[0] *
scale);
337 const float unit =
max_ff(system_scale * cursor_scale, 1.0f);
343 const int ofs_line = (8 * unit);
344 const int ofs_size = (2 * unit);
346 event_xy[0] - ofs_line,
347 event_xy[1] - ofs_size,
348 event_xy[0] + ofs_line,
349 event_xy[1] + ofs_size);
351 event_xy[0] - ofs_size,
352 event_xy[1] - ofs_line,
353 event_xy[0] + ofs_size,
354 event_xy[1] + ofs_line);
358 const int ofs_line = (7 * unit);
359 const int ofs_size = (1 * unit);
361 event_xy[0] - ofs_line,
362 event_xy[1] - ofs_size,
363 event_xy[0] + ofs_line,
364 event_xy[1] + ofs_size);
366 event_xy[0] - ofs_size,
367 event_xy[1] - ofs_line,
368 event_xy[0] + ofs_size,
369 event_xy[1] + ofs_line);
521 for (
wmGizmo &gz : gzgroup.gizmos) {
533 Depsgraph *depsgraph,
564static void wm_region_test_xr_do_draw(
const wmWindowManager *wm,
569 if (ED_view3d_is_region_xr_mirror_active(
570 wm,
static_cast<const View3D *
>(area->spacedata.first_), region))
592#define SPACE_NAME(space) \
621 return "Unknown Space";
667 wdc.draw(win, wdc.customdata);
708 bool use_float =
false;
717 gpu::TextureFormat desired_format = (use_float) ? gpu::TextureFormat::SFLOAT_16_16_16_16 :
718 gpu::TextureFormat::UNORM_8_8_8_8;
719 return desired_format;
898 rect_tex.
xmin = halfx;
899 rect_tex.
ymin = halfy;
900 rect_tex.
xmax = 1.0f + halfx;
901 rect_tex.
ymax = 1.0f + halfy;
904 rect_tex.
xmax *= alpha;
907 rect_tex.
xmin += 1.0f - alpha;
910 rect_tex.
ymax *= alpha;
913 rect_tex.
ymin += 1.0f - alpha;
917 const float rectt[4] = {rect_tex.
xmin, rect_tex.
ymin, rect_tex.
xmax, rect_tex.
ymax};
918 const float rectg[4] = {
982 bool is_any_region_drawn =
false;
1000 if (!is_any_region_drawn) {
1004 is_any_region_drawn =
true;
1031 if (!is_any_region_drawn) {
1035 is_any_region_drawn =
true;
1047 for (
int view = 0; view < 2; view++) {
1174 for (
ARegion ®ion : area->regionbase) {
1179 if (region.
overlap ==
false) {
1188 for (
ARegion ®ion : area->regionbase) {
1192 const bool do_paint_cursor = (
wm->runtime->paintcursors.first() &&
1195 if (!(do_paint_cursor || do_draw_overlay)) {
1201 if (do_draw_overlay) {
1204 if (do_paint_cursor) {
1215 for (
ARegion ®ion : area->regionbase) {
1250 if (
wm->runtime->drags.first_) {
1278#ifdef WITH_GHOST_CSD
1335 for (
int view = 0; view < 2; view++) {
1363#ifdef WITH_GHOST_CSD
1415 bool setup_context =
wm->runtime->windrawable != win;
1417 if (setup_context) {
1423 const uint rect_len = win_size[0] * win_size[1];
1428 if (setup_context) {
1429 if (
wm->runtime->windrawable) {
1430 static_cast<GHOST_IWindow *
>(
wm->runtime->windrawable->runtime->ghostwin)
1431 ->activateDrawingContext();
1439 for (i = 0, cp += 3; i < rect_len; i++, cp += 4) {
1443 r_size[0] = win_size[0];
1444 r_size[1] = win_size[1];
1454 bool setup_context =
wm->runtime->windrawable != win;
1456 if (setup_context) {
1471 if (setup_context) {
1472 if (
wm->runtime->windrawable) {
1473 static_cast<GHOST_IWindow *
>(
wm->runtime->windrawable->runtime->ghostwin)
1474 ->activateDrawingContext();
1507 if (!offscreen) [[unlikely]] {
1511 const uint rect_len = win_size[0] * win_size[1];
1519 r_size[0] = win_size[0];
1520 r_size[1] = win_size[1];
1535 if (!(
uint(pos[0]) <
uint(win_size[0]) &&
uint(pos[1]) <
uint(win_size[1]))) {
1542 gpu::TextureFormat::UNORM_8_8_8_8,
1546 if (!offscreen) [[unlikely]] {
1550 float rect_pixel[4];
1612 bool do_draw =
false;
1625 for (
ARegion ®ion : area->regionbase) {
1628#ifdef WITH_XR_OPENXR
1629 wm_region_test_xr_do_draw(
wm, area, ®ion);
1674#ifndef WITH_XR_OPENXR
1688 for (
ARegion ®ion : area->regionbase) {
1721#ifdef WITH_METAL_BACKEND
1768 for (
wmWindow &win :
wm->windows.items_reversed()) {
#define BLI_SCOPED_DEFER(function_to_defer)
These structs are the foundation for all linked lists in the library system.
Object is a sort of wrapper for general info.
#define RGN_ALIGN_ENUM_FROM_MASK(align)
#define ED_screen_areas_iter(win, screen, area_name)
@ GHOST_kWindowStateMinimized
Read Blender memory allocation and freeing.
#define PRF_frame_mark_start(name)
#define PRF_scope(category)
#define PRF_frame_mark_end(name)
#define WM_CURSOR_DEFAULT_LOGICAL_SIZE
static GHOST_ISystem * getSystem()
virtual GHOST_TSuccess getPixelAtCursor(float r_color[3]) const =0
virtual GHOST_TSuccess getCursorBitmap(GHOST_CursorBitmapRef *bitmap)=0
virtual void getCursorGrabState(GHOST_TGrabCursorMode &mode, GHOST_TAxisFlag &axis_flag, GHOST_Rect &bounds, bool &use_software_cursor)=0
virtual bool getCursorVisibility() const =0
virtual GHOST_TWindowState getState() const =0
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
float3x3 scale(float3x3 mat, float2 scale)
void theme_set(int spacetype, int regionid)
void GPU_viewport_stereo_composite(GPUViewport *viewport, Stereo3dFormat *stereo_format)
bool ED_node_is_compositor(const SpaceNode *snode)
static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region)
static void wm_draw_region_blit(ARegion *region, int view)
uint8_t * WM_window_pixels_read_from_offscreen(bContext *C, wmWindow *win, int r_size[2])
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
gpu::Texture * GPU_viewport_color_texture(GPUViewport *viewport, int view)
int GPU_shader_get_sampler_binding(gpu::Shader *shader, const char *name)
void GPU_scissor_test(bool enable)
MINLINE int mod_i(int i, int n)
static bool wm_draw_region_stereo_set(Main *bmain, ScrArea *area, ARegion *region, eStereoViews sview)
ScrArea * CTX_wm_area(const bContext *C)
static void wm_software_cursor_motion_clear_with_window(const wmWindow *win)
void GPU_offscreen_free(GPUOffScreen *offscreen)
void ED_region_blend_rect(ARegion *region, rcti *r_rect)
void ED_screen_ensure_updated(bContext *C, wmWindowManager *wm, wmWindow *win)
void wmViewport(const rcti *winrct)
static void wm_draw_region_unbind(ARegion *region)
const ListBaseT< wmGizmoGroup > * WM_gizmomap_group_list(wmGizmoMap *gzmap)
void GPU_texture_update(gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
void wm_draw_region_test(bContext *C, ScrArea *area, ARegion *region)
bool IMB_colormanagement_display_is_hdr(const ColorManagedDisplaySettings *display_settings, const char *view_name)
void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *area)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void GPU_clear_color(float red, float green, float blue, float alpha)
WorkSpace * CTX_wm_workspace(const bContext *C)
MINLINE int round_fl_to_int(float a)
void wmWindowViewport(const wmWindow *win)
void ED_region_do_layout(bContext *C, ARegion *region)
int WM_window_native_pixel_y(const wmWindow *win)
void GPU_context_main_unlock()
static bool wm_software_cursor_needed_for_window(const wmWindow *win, GrabState *grab_state)
static bool wm_software_cursor_needed()
GPUVertFormat * immVertexFormat()
bool WM_region_use_viewport(ScrArea *area, ARegion *region)
bool IMB_colormanagement_display_is_wide_gamut(const ColorManagedDisplaySettings *display_settings, const char *view_name)
static void wm_region_test_render_do_draw(const Scene *scene, Depsgraph *depsgraph, ScrArea *area, ARegion *region)
void CTX_wm_window_set(bContext *C, wmWindow *win)
uint WM_cursor_preferred_logical_size(const bool hardware_cursor)
void GPU_context_end_frame(GPUContext *ctx)
void GPU_render_step(bool force_resource_release=false)
void immBegin(GPUPrimType, uint vertex_len)
float ED_region_blend_alpha(ARegion *region)
void WM_draw_region_free(ARegion *region)
static void wm_region_test_gizmo_do_draw(bContext *C, ScrArea *area, ARegion *region, bool tag_redraw)
static void wm_draw_window(bContext *C, wmWindow *win)
wmWindow * CTX_wm_window(const bContext *C)
bool WM_stereo3d_enabled(wmWindow *win, bool skip_stereo3d_check)
uint8_t * WM_window_pixels_read(bContext *C, wmWindow *win, int r_size[2])
void GPU_batch_set_shader(gpu::Batch *batch, gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_context_active_set(GPUContext *)
bool WM_window_pixels_read_sample_from_offscreen(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
int GPU_offscreen_width(const GPUOffScreen *offscreen)
void ED_region_tag_redraw_editor_overlays(ARegion *region)
ViewLayer * WM_window_get_active_view_layer(const wmWindow *win)
void wm_surface_clear_drawable()
void immAttr2f(uint attr_id, float x, float y)
void ED_region_do_draw(bContext *C, ARegion *region)
static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win)
ViewLayer * CTX_data_view_layer(const bContext *C)
void GPU_matrix_mul(const float m[4][4])
void GPU_context_begin_frame(GPUContext *ctx)
void WM_draw_region_viewport_bind(ARegion *region)
static void wm_draw_area_offscreen(bContext *C, wmWindow *win, ScrArea *area, bool stereo)
@ GPU_BLEND_ALPHA_PREMULT
void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win)
VecBase< float, 4 > float4
static void wm_draw_surface(bContext *C, wmSurface *surface)
void WM_draw_cb_exit(wmWindow *win, void *handle)
void GPU_offscreen_read_color_region(GPUOffScreen *offscreen, eGPUDataFormat data_format, int x, int y, int w, int h, void *r_data)
void GPU_viewport_unbind(GPUViewport *viewport)
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
static void wm_draw_region_buffer_create(Scene *scene, ARegion *region, bool stereo, bool use_viewport)
void GPU_texture_mipmap_mode(gpu::Texture *texture, bool use_mipmap, bool use_filter)
static void wm_region_draw_overlay(bContext *C, const ScrArea *area, ARegion *region)
static bool rna_disallow_writes
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void wm_draw_region_clear(wmWindow *win, ARegion *)
bool wm_cursor_position_get(wmWindow *win, int *r_x, int *r_y)
VecBase< int32_t, 2 > int2
Scene * WM_window_get_active_scene(const wmWindow *win)
int GPU_offscreen_height(const GPUOffScreen *offscreen)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void wm_stereo3d_draw_sidebyside(wmWindow *win, int view)
void GPU_offscreen_unbind(GPUOffScreen *offscreen, bool restore)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_GENERAL
static bool wm_window_pixels_read_use_frontbuffer()
static void wm_draw_update_clear_window(bContext *C, wmWindow *win)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
bool WM_window_pixels_read_sample(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
void wm_draw_region_blend(ARegion *region, int view, bool blend)
void wm_window_swap_buffer_acquire(wmWindow *win)
Push rendered buffer to the screen.
bool WM_desktop_cursor_sample_read(float r_col[3])
static void wm_software_cursor_draw_crosshair(const float system_scale, const int event_xy[2])
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_2D_IMAGE_RECT_COLOR
static struct blender::@037277116025112217063260326170341263035346017163 g_software_cursor
wmWindowManager * CTX_wm_manager(const bContext *C)
void GPU_shader_uniform_float_ex(gpu::Shader *shader, int location, int length, int array_size, const float *value)
void wm_drags_draw(bContext *C, wmWindow *win)
static void wm_draw_region_bind(ARegion *region, int view)
bool ED_view3d_calc_render_border(const Scene *scene, Depsgraph *depsgraph, View3D *v3d, ARegion *region, rcti *r_rect)
void GPU_texture_filter_mode(gpu::Texture *texture, bool use_filter)
void GPU_color_mask(bool r, bool g, bool b, bool a)
static void wm_software_cursor_draw(wmWindow *win, const GrabState *grab_state)
void GPU_offscreen_draw_to_screen(GPUOffScreen *offscreen, int x, int y)
bool GPU_frontbuffer_read_workaround()
static gpu::TextureFormat get_hdr_framebuffer_format(const Scene *scene)
void immUniformColor4f(float r, float g, float b, float a)
void wmWindowViewport_ex(const wmWindow *win, float offset)
void WM_redraw_windows(bContext *C)
static void wm_draw_offscreen_texture_parameters(GPUOffScreen *offscreen)
void GPU_backbuffer_bind(GPUBackBuffer back_buffer_type)
static void wm_draw_region_buffer_free(ARegion *region)
void GPU_batch_draw(gpu::Batch *batch)
static void wm_software_cursor_motion_clear()
void unit_m4(float m[4][4])
void WM_window_csd_draw_corner_mask(const wmWindow *win)
void wm_window_clear_drawable(wmWindowManager *wm)
void immBindTexture(const char *name, gpu::Texture *tex)
void WM_global_report(eReportType type, const char *message)
void GPU_shader_bind(gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
bool WM_window_csd_is_active()
void GPU_offscreen_bind(GPUOffScreen *offscreen, bool save)
void GPU_viewport_bind(GPUViewport *viewport, int view, const rcti *rect)
void WM_toolsystem_update_from_context(bContext *C, WorkSpace *workspace, const Scene *scene, ViewLayer *view_layer, ScrArea *area)
void CTX_wm_region_popup_set(bContext *C, ARegion *region_popup)
void WM_draw_region_viewport_ensure(Scene *scene, ARegion *region, short space_type)
void GPU_frontbuffer_read_color(int x, int y, int width, int height, int channels, eGPUDataFormat data_format, void *r_data)
MINLINE void zero_v3(float r[3])
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
void WM_window_csd_draw_titlebar(const wmWindow *win)
static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
void GPU_debug_group_end()
void CTX_rna_disallow_write_set_p(bContext *C, const bool *rna_disallow_writes)
int GPU_shader_get_uniform(gpu::Shader *shader, const char *name)
static const char * wm_area_name(const ScrArea *area)
@ WM_GIZMOGROUPTYPE_VR_REDRAWS
static bool wm_window_grab_warp_region_is_set(const wmWindow *win)
@ WM_CAPABILITY_CURSOR_RGBA
@ WM_CAPABILITY_GPU_FRONT_BUFFER_READ
@ WM_CAPABILITY_CURSOR_WARP
void wm_window_swap_buffer_release(wmWindow *win)
gpu::Shader * GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
void GPU_scissor(int x, int y, int width, int height)
bool WM_window_is_csd(const wmWindow *win)
void GPU_viewport_free(GPUViewport *viewport)
gpu::Batch * GPU_batch_preset_quad()
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Main * CTX_data_main(const bContext *C)
gpu::Texture * GPU_offscreen_color_texture(const GPUOffScreen *offscreen)
int2 WM_window_native_pixel_size(const wmWindow *win)
void GPU_texture_bind(gpu::Texture *texture, int unit)
eWM_CapabilitiesFlag WM_capabilities_flag()
MINLINE float max_ff(float a, float b)
void GPU_texture_free(gpu::Texture *texture)
Image * BKE_image_ensure_viewer(Main *bmain, int type, const char *name)
static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view)
gpu::TextureFormat GPU_offscreen_format(const GPUOffScreen *offscreen)
uint8_t * WM_window_pixels_read_from_frontbuffer(const wmWindowManager *wm, const wmWindow *win, int r_size[2])
void GPU_viewport_draw_to_screen(GPUViewport *viewport, int view, const rcti *rect)
void ED_screen_draw_edges(wmWindow *win)
bool WM_gizmo_group_type_poll(const bContext *C, const wmGizmoGroupType *gzgt)
void GPU_texture_unbind(gpu::Texture *texture)
RenderEngine * RE_view_engine_get(const ViewRender *view_render)
Scene * CTX_data_scene(const bContext *C)
void CTX_wm_region_set(bContext *C, ARegion *region)
Depsgraph * BKE_scene_ensure_depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer)
void wm_stereo3d_draw_topbottom(wmWindow *win, int view)
void immVertex3f(uint attr_id, float x, float y, float z)
void WM_window_pixels_read_sample_from_frontbuffer(const wmWindowManager *wm, const wmWindow *win, const int pos[2], float r_col[3])
GPUOffScreen * GPU_offscreen_create(int width, int height, bool with_depth_buffer, gpu::TextureFormat format, eGPUTextureUsage usage, bool clear, char err_out[256])
static void wm_draw_callbacks(wmWindow *win)
void GPU_blend(GPUBlend blend)
@ RGN_FLAG_SEARCH_FILTER_UPDATE
void wm_draw_update(bContext *C)
void * WM_draw_cb_activate(wmWindow *win, void(*draw)(const wmWindow *win, void *customdata), void *customdata)
float WM_window_dpi_get_scale(const wmWindow *win)
static bool wm_region_use_viewport_by_type(short space_type, short region_type)
GPUViewport * GPU_viewport_stereo_create()
int GPU_shader_get_builtin_uniform(gpu::Shader *shader, int builtin)
void GPU_context_main_lock()
void ED_region_tag_redraw_partial(ARegion *region, const rcti *rct, bool rebuild)
GPUViewport * WM_draw_region_get_viewport(ARegion *region)
bScreen * WM_window_get_active_screen(const wmWindow *win)
gpu::Texture * wm_draw_region_texture(ARegion *region, int view)
void WM_window_csd_clear_alpha(const wmWindow *win)
void wm_surfaces_iter(bContext *C, void(*cb)(bContext *C, wmSurface *))
GPUViewport * WM_draw_region_get_bound_viewport(ARegion *region)
void wm_gesture_draw(wmWindow *win)
void immRectf(uint pos, float x1, float y1, float x2, float y2)
ARegion * CTX_wm_region(const bContext *C)
void ED_region_tag_redraw_no_rebuild(ARegion *region)
static bool wm_software_cursor_motion_test(const wmWindow *win)
void WM_draw_region_viewport_unbind(ARegion *region)
void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion *)
static void wm_software_cursor_draw_bitmap(const float system_scale, const int event_xy[2], const GHOST_CursorBitmapRef *bitmap)
gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
bool GPU_viewport_do_update(GPUViewport *viewport)
GPUContext * GPU_context_active_get()
@ AREA_FLAG_ACTIVE_TOOL_UPDATE
void GPU_debug_group_begin(const char *name)
GPUViewport * GPU_viewport_create()
static void wm_software_cursor_motion_update(const wmWindow *win)
void CTX_wm_area_set(bContext *C, ScrArea *area)
void GPU_offscreen_read_color(GPUOffScreen *offscreen, eGPUDataFormat data_format, void *r_data)
void wm_surface_make_drawable(wmSurface *surface)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
void(*) draw_overlay(const bContext *C, ARegion *region)
void(*) layout(const bContext *C, ARegion *region)
bke::ARegionRuntime * runtime
eRegion_Alignment alignment
GHOST_TAxisFlag wrap_axis
GHOST_TGrabCursorMode mode
struct ViewRender * view_render
ColorManagedViewSettings view_settings
ColorManagedDisplaySettings display_settings
ListBaseT< ARegion > regionbase
ListBaseT< SpaceLink > spacedata
void(*) draw_pre(const bContext *C, ScrArea *area)
void(*) draw_post(const bContext *C, ScrArea *area)
void(*) draw(const wmWindow *win, void *customdata)
struct ARegion * active_region
ListBaseT< ARegion > regionbase
Vector< std::function< void(const bContext &C, ui::Block &Block)> > post_block_layout_fns
wmDrawBuffer * draw_buffer
short do_draw_paintcursor
struct ARegionType * type
ListBaseT< wmGesture > gesture
ListBaseT< WindowDrawCB > drawcalls
GPUContext * blender_gpu_context
bke::WindowRuntime * runtime
struct Stereo3dFormat * stereo3d_format
#define SPACE_NAME(space)