72# include "BKE_subsurf.hh"
88 bool use_software_cursor_dummy =
false;
93 &use_software_cursor_dummy);
116 if (wm->
runtime->is_interface_locked) {
133 if (pc->poll ==
nullptr || pc->poll(
C)) {
205 bool use_software_cursor;
210 &use_software_cursor);
211 if (use_software_cursor) {
248 const int event_xy[2],
253 float gl_matrix[4][4];
260 blender::gpu::TextureFormat::UNORM_8_8_8_8,
279 gl_matrix[3][0] = event_xy[0] - (bitmap->
hot_spot[0] * scale);
280 gl_matrix[3][1] = event_xy[1] - ((bitmap->
data_size[1] - bitmap->
hot_spot[1]) * scale);
282 gl_matrix[0][0] = bitmap->
data_size[0] * scale;
283 gl_matrix[1][1] = bitmap->
data_size[1] * scale;
289 imm_format,
"pos", blender::gpu::VertAttrType::SFLOAT_32_32_32);
291 imm_format,
"texCoord", blender::gpu::VertAttrType::SFLOAT_32_32);
332 const float unit =
max_ff(system_scale * cursor_scale, 1.0f);
339 const int ofs_line = (8 * unit);
340 const int ofs_size = (2 * unit);
342 event_xy[0] - ofs_line,
343 event_xy[1] - ofs_size,
344 event_xy[0] + ofs_line,
345 event_xy[1] + ofs_size);
347 event_xy[0] - ofs_size,
348 event_xy[1] - ofs_line,
349 event_xy[0] + ofs_size,
350 event_xy[1] + ofs_line);
354 const int ofs_line = (7 * unit);
355 const int ofs_size = (1 * unit);
357 event_xy[0] - ofs_line,
358 event_xy[1] - ofs_size,
359 event_xy[0] + ofs_line,
360 event_xy[1] + ofs_size);
362 event_xy[0] - ofs_size,
363 event_xy[1] - ofs_line,
364 event_xy[0] + ofs_size,
365 event_xy[1] + ofs_line);
383 const int min = height - grab_state->
bounds[1];
384 const int max = height - grab_state->
bounds[3];
415 region->
runtime->type->draw_overlay(
C, region);
496 if (region->
runtime->gizmo_map ==
nullptr) {
566 if (ED_view3d_is_region_xr_mirror_active(
589#define SPACE_NAME(space) \
617 return "Unknown Space";
636 void (*draw)(
const wmWindow *win,
void *customdata),
663 wdc->
draw(win, wdc->customdata);
680 if (region->
runtime->draw_buffer) {
681 if (region->
runtime->draw_buffer->viewport) {
684 if (region->
runtime->draw_buffer->offscreen) {
689 region->
runtime->draw_buffer =
nullptr;
704 bool use_float =
false;
714 (use_float) ? blender::gpu::TextureFormat::SFLOAT_16_16_16_16 :
715 blender::gpu::TextureFormat::UNORM_8_8_8_8;
716 return desired_format;
728 if (region->
runtime->draw_buffer) {
729 if (region->
runtime->draw_buffer->stereo != stereo) {
745 if (!region->
runtime->draw_buffer) {
771 region->
runtime->draw_buffer->offscreen = offscreen;
774 region->
runtime->draw_buffer->bound_view = -1;
775 region->
runtime->draw_buffer->stereo = stereo;
781 if (!region->
runtime->draw_buffer) {
785 if (region->
runtime->draw_buffer->viewport) {
802 if (!region->
runtime->draw_buffer) {
806 region->
runtime->draw_buffer->bound_view = -1;
808 if (region->
runtime->draw_buffer->viewport) {
819 if (!region->
runtime->draw_buffer) {
828 if (region->
runtime->draw_buffer->viewport ==
nullptr) {
834 if (region->
runtime->draw_buffer->viewport) {
845 if (!region->
runtime->draw_buffer) {
858 if (!region->
runtime->draw_buffer) {
881 rect_tex.
xmin = halfx;
882 rect_tex.
ymin = halfy;
883 rect_tex.
xmax = 1.0f + halfx;
884 rect_tex.
ymax = 1.0f + halfy;
886 float alpha_easing = 1.0f - alpha;
887 alpha_easing = 1.0f - alpha_easing * alpha_easing;
892 rect_geo.
xmin += ofs_x;
893 rect_tex.
xmax *= alpha_easing;
897 rect_geo.
xmax -= ofs_x;
898 rect_tex.
xmin += 1.0f - alpha_easing;
903 const float rectt[4] = {rect_tex.
xmin, rect_tex.
ymin, rect_tex.
xmax, rect_tex.
ymax};
904 const float rectg[4] = {
942 if (!region->
runtime->draw_buffer) {
952 if (!region->
runtime->draw_buffer || region->
runtime->draw_buffer->bound_view == -1) {
980 if ((region->
runtime->visible || ignore_visibility) && region->
runtime->do_draw &&
1073 if (!region->
runtime->visible) {
1084 region->
runtime->type->layout(
C, region);
1121 if (!region->
runtime->visible) {
1125 if (region->
overlap ==
false) {
1135 if (!region->
runtime->visible) {
1138 const bool do_paint_cursor = (wm->
runtime->paintcursors.first &&
1140 const bool do_draw_overlay = (region->
runtime->type && region->
runtime->type->draw_overlay);
1141 if (!(do_paint_cursor || do_draw_overlay)) {
1147 if (do_draw_overlay) {
1150 if (do_paint_cursor) {
1162 if (!region->
runtime->visible) {
1183 if (!region->
runtime->visible) {
1196 if (wm->
runtime->drags.first) {
1338 bool setup_context = wm->
runtime->windrawable != win;
1340 if (setup_context) {
1346 const uint rect_len = win_size[0] * win_size[1];
1351 if (setup_context) {
1352 if (wm->
runtime->windrawable) {
1354 static_cast<GHOST_WindowHandle
>(wm->
runtime->windrawable->ghostwin));
1362 for (
i = 0, cp += 3;
i < rect_len;
i++, cp += 4) {
1366 r_size[0] = win_size[0];
1367 r_size[1] = win_size[1];
1377 bool setup_context = wm->
runtime->windrawable != win;
1379 if (setup_context) {
1394 if (setup_context) {
1395 if (wm->
runtime->windrawable) {
1397 static_cast<GHOST_WindowHandle
>(wm->
runtime->windrawable->ghostwin));
1435 const uint rect_len = win_size[0] * win_size[1];
1443 r_size[0] = win_size[0];
1444 r_size[1] = win_size[1];
1466 blender::gpu::TextureFormat::UNORM_8_8_8_8,
1474 float rect_pixel[4];
1520 bool do_draw =
false;
1523 if (region->
runtime->do_draw_paintcursor) {
1525 region->
runtime->do_draw_paintcursor =
false;
1536#ifdef WITH_XR_OPENXR
1537 wm_region_test_xr_do_draw(wm, area, region);
1582#ifndef WITH_XR_OPENXR
1626#ifdef WITH_METAL_BACKEND
1636 static_cast<GHOST_WindowHandle
>(win->
ghostwin));
WorkSpace * CTX_wm_workspace(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
void CTX_wm_window_set(bContext *C, wmWindow *win)
Main * CTX_data_main(const bContext *C)
void CTX_wm_area_set(bContext *C, ScrArea *area)
void CTX_wm_region_set(bContext *C, ARegion *region)
ARegion * CTX_wm_region(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
void CTX_wm_region_popup_set(bContext *C, ARegion *region_popup)
ViewLayer * CTX_data_view_layer(const bContext *C)
Image * BKE_image_ensure_viewer(Main *bmain, int type, const char *name)
void BKE_image_free_unused_gpu_textures()
Depsgraph * BKE_scene_ensure_depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer)
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE int round_fl_to_int(float a)
MINLINE float max_ff(float a, float b)
MINLINE int mod_i(int i, int n)
void unit_m4(float m[4][4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
These structs are the foundation for all linked lists in the library system.
Object is a sort of wrapper for general info.
@ AREA_FLAG_ACTIVE_TOOL_UPDATE
#define RGN_ALIGN_ENUM_FROM_MASK(align)
bool ED_node_is_compositor(const SpaceNode *snode)
float ED_region_blend_alpha(ARegion *region)
void ED_screen_ensure_updated(bContext *C, wmWindowManager *wm, wmWindow *win)
#define ED_screen_areas_iter(win, screen, area_name)
void ED_region_tag_redraw_no_rebuild(ARegion *region)
void ED_region_tag_redraw_partial(ARegion *region, const rcti *rct, bool rebuild)
void ED_screen_draw_edges(wmWindow *win)
void ED_region_do_layout(bContext *C, ARegion *region)
void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *area)
void ED_region_tag_redraw_editor_overlays(ARegion *region)
void ED_region_do_draw(bContext *C, ARegion *region)
bool ED_view3d_calc_render_border(const Scene *scene, Depsgraph *depsgraph, View3D *v3d, ARegion *region, rcti *r_rect)
GHOST C-API function and type declarations.
GHOST_TWindowState GHOST_GetWindowState(GHOST_WindowHandle windowhandle)
GHOST_TSuccess GHOST_GetPixelAtCursor(float r_color[3])
void GHOST_GetCursorGrabState(GHOST_WindowHandle windowhandle, GHOST_TGrabCursorMode *r_mode, GHOST_TAxisFlag *r_axis_flag, int r_bounds[4], bool *r_use_software_cursor)
GHOST_TSuccess GHOST_GetCursorBitmap(GHOST_WindowHandle windowhandle, GHOST_CursorBitmapRef *bitmap)
bool GHOST_GetCursorVisibility(GHOST_WindowHandle windowhandle)
GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
@ GHOST_kWindowStateMinimized
void GPU_batch_draw(blender::gpu::Batch *batch)
void GPU_batch_set_shader(blender::gpu::Batch *batch, blender::gpu::Shader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
blender::gpu::Batch * GPU_batch_preset_quad()
void GPU_render_step(bool force_resource_release=false)
void GPU_context_main_lock()
void GPU_context_begin_frame(GPUContext *ctx)
void GPU_context_main_unlock()
void GPU_context_end_frame(GPUContext *ctx)
void GPU_context_active_set(GPUContext *)
void GPU_debug_group_end()
void GPU_debug_group_begin(const char *name)
blender::gpu::Texture * GPU_offscreen_color_texture(const GPUOffScreen *offscreen)
void GPU_offscreen_draw_to_screen(GPUOffScreen *offscreen, int x, int y)
int GPU_offscreen_width(const GPUOffScreen *offscreen)
void GPU_offscreen_bind(GPUOffScreen *offscreen, bool save)
void GPU_backbuffer_bind(GPUBackBuffer back_buffer_type)
blender::gpu::TextureFormat GPU_offscreen_format(const GPUOffScreen *offscreen)
void GPU_frontbuffer_read_color(int x, int y, int width, int height, int channels, eGPUDataFormat data_format, void *r_data)
int GPU_offscreen_height(const GPUOffScreen *offscreen)
GPUOffScreen * GPU_offscreen_create(int width, int height, bool with_depth_buffer, blender::gpu::TextureFormat format, eGPUTextureUsage usage, bool clear, char err_out[256])
void GPU_clear_color(float red, float green, float blue, float alpha)
void GPU_offscreen_read_color_region(GPUOffScreen *offscreen, eGPUDataFormat data_format, int x, int y, int w, int h, void *r_data)
void GPU_offscreen_free(GPUOffScreen *offscreen)
void GPU_offscreen_read_color(GPUOffScreen *offscreen, eGPUDataFormat data_format, void *r_data)
void GPU_offscreen_unbind(GPUOffScreen *offscreen, bool restore)
#define GPU_matrix_mul(x)
int GPU_shader_get_sampler_binding(blender::gpu::Shader *shader, const char *name)
void GPU_shader_bind(blender::gpu::Shader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
int GPU_shader_get_uniform(blender::gpu::Shader *shader, const char *name)
int GPU_shader_get_builtin_uniform(blender::gpu::Shader *shader, int builtin)
void GPU_shader_uniform_float_ex(blender::gpu::Shader *shader, int location, int length, int array_size, const float *value)
blender::gpu::Shader * GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_2D_IMAGE_RECT_COLOR
void GPU_scissor_test(bool enable)
@ GPU_BLEND_ALPHA_PREMULT
void GPU_blend(GPUBlend blend)
void GPU_scissor(int x, int y, int width, int height)
void GPU_texture_unbind(blender::gpu::Texture *texture)
void GPU_texture_mipmap_mode(blender::gpu::Texture *texture, bool use_mipmap, bool use_filter)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_GENERAL
blender::gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, blender::gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_filter_mode(blender::gpu::Texture *texture, bool use_filter)
void GPU_texture_bind(blender::gpu::Texture *texture, int unit)
void GPU_texture_free(blender::gpu::Texture *texture)
void GPU_texture_update(blender::gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
void GPU_viewport_bind(GPUViewport *viewport, int view, const rcti *rect)
void GPU_viewport_draw_to_screen(GPUViewport *viewport, int view, const rcti *rect)
GPUViewport * GPU_viewport_create()
GPUViewport * GPU_viewport_stereo_create()
bool GPU_viewport_do_update(GPUViewport *viewport)
void GPU_viewport_free(GPUViewport *viewport)
void GPU_viewport_stereo_composite(GPUViewport *viewport, Stereo3dFormat *stereo_format)
blender::gpu::Texture * GPU_viewport_color_texture(GPUViewport *viewport, int view)
void GPU_viewport_unbind(GPUViewport *viewport)
bool IMB_colormanagement_display_is_hdr(const ColorManagedDisplaySettings *display_settings, const char *view_name)
bool IMB_colormanagement_display_is_wide_gamut(const ColorManagedDisplaySettings *display_settings, const char *view_name)
Read Guarded memory(de)allocation.
void UI_SetTheme(int spacetype, int regionid)
#define WM_CURSOR_DEFAULT_LOGICAL_SIZE
@ WM_CAPABILITY_CURSOR_WARP
@ WM_CAPABILITY_CURSOR_RGBA
@ WM_CAPABILITY_GPU_FRONT_BUFFER_READ
@ WM_GIZMOGROUPTYPE_VR_REDRAWS
BPy_StructRNA * depsgraph
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
blender::gpu::Batch * quad
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
RenderEngine * RE_view_engine_get(const ViewRender *view_render)
void * MEM_callocN(size_t len, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
ARegionRuntimeHandle * runtime
struct ListBase bg_images
GHOST_TAxisFlag wrap_axis
GHOST_TGrabCursorMode mode
struct ViewRender * view_render
ColorManagedViewSettings view_settings
ColorManagedDisplaySettings display_settings
void(* draw)(const wmWindow *win, void *customdata)
struct ARegion * active_region
VecBase< T, 3 > xyz() const
GPUContext * blender_gpu_context
WindowManagerRuntimeHandle * runtime
struct wmEvent * eventstate
struct Stereo3dFormat * stereo3d_format
static int blend(const Tex *tex, const float texvec[3], TexResult *texres)
void wm_drags_draw(bContext *C, wmWindow *win)
static void wm_draw_callbacks(wmWindow *win)
void WM_draw_region_viewport_unbind(ARegion *region)
static void wm_draw_offscreen_texture_parameters(GPUOffScreen *offscreen)
uint8_t * WM_window_pixels_read_from_frontbuffer(const wmWindowManager *wm, const wmWindow *win, int r_size[2])
static void wm_draw_region_unbind(ARegion *region)
static void wm_draw_region_bind(ARegion *region, int view)
static void wm_software_cursor_draw_bitmap(const float system_scale, const int event_xy[2], const GHOST_CursorBitmapRef *bitmap)
static bool wm_software_cursor_needed_for_window(const wmWindow *win, GrabState *grab_state)
uint8_t * WM_window_pixels_read(bContext *C, wmWindow *win, int r_size[2])
blender::gpu::Texture * wm_draw_region_texture(ARegion *region, int view)
static bool wm_region_use_viewport_by_type(short space_type, short region_type)
static void wm_draw_surface(bContext *C, wmSurface *surface)
void WM_window_pixels_read_sample_from_frontbuffer(const wmWindowManager *wm, const wmWindow *win, const int pos[2], float r_col[3])
static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
void WM_draw_region_viewport_ensure(Scene *scene, ARegion *region, short space_type)
static void wm_draw_area_offscreen(bContext *C, wmWindow *win, ScrArea *area, bool stereo)
void WM_redraw_windows(bContext *C)
static void wm_draw_region_buffer_free(ARegion *region)
static void wm_draw_region_buffer_create(Scene *scene, ARegion *region, bool stereo, bool use_viewport)
GPUViewport * WM_draw_region_get_viewport(ARegion *region)
void * WM_draw_cb_activate(wmWindow *win, void(*draw)(const wmWindow *win, void *customdata), void *customdata)
static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region)
void wm_draw_region_blend(ARegion *region, int view, bool blend)
static void wm_draw_update_clear_window(bContext *C, wmWindow *win)
static bool wm_software_cursor_needed()
bool WM_region_use_viewport(ScrArea *area, ARegion *region)
#define SPACE_NAME(space)
static void wm_region_test_render_do_draw(const Scene *scene, Depsgraph *depsgraph, ScrArea *area, ARegion *region)
static bool wm_draw_region_stereo_set(Main *bmain, ScrArea *area, ARegion *region, eStereoViews sview)
bool WM_window_pixels_read_sample_from_offscreen(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
void WM_draw_cb_exit(wmWindow *win, void *handle)
void wm_draw_region_clear(wmWindow *win, ARegion *)
static const char * wm_area_name(const ScrArea *area)
static void wm_region_test_gizmo_do_draw(bContext *C, ScrArea *area, ARegion *region, bool tag_redraw)
void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion *)
static blender::gpu::TextureFormat get_hdr_framebuffer_format(const Scene *scene)
static struct @131002343213154054037057266272263130272302153112 g_software_cursor
static void wm_software_cursor_draw(wmWindow *win, const GrabState *grab_state)
static bool wm_software_cursor_motion_test(const wmWindow *win)
static void wm_software_cursor_motion_clear_with_window(const wmWindow *win)
void WM_draw_region_viewport_bind(ARegion *region)
GPUViewport * WM_draw_region_get_bound_viewport(ARegion *region)
void wm_draw_region_test(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])
void WM_draw_region_free(ARegion *region)
static void wm_software_cursor_motion_update(const wmWindow *win)
static void wm_region_draw_overlay(bContext *C, const ScrArea *area, ARegion *region)
static void wm_draw_window(bContext *C, wmWindow *win)
static bool wm_window_grab_warp_region_is_set(const wmWindow *win)
bool WM_desktop_cursor_sample_read(float r_col[3])
void wm_draw_update(bContext *C)
static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win)
static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view)
static void wm_software_cursor_motion_clear()
static void wm_software_cursor_draw_crosshair(const float system_scale, const int event_xy[2])
bool WM_window_pixels_read_sample(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
void WM_global_report(eReportType type, const char *message)
void wm_gesture_draw(wmWindow *win)
bool WM_gizmo_group_type_poll(const bContext *C, const wmGizmoGroupType *gzgt)
const ListBase * WM_gizmomap_group_list(wmGizmoMap *gzmap)
void wm_stereo3d_draw_sidebyside(wmWindow *win, int view)
bool WM_stereo3d_enabled(wmWindow *win, bool skip_stereo3d_check)
void wm_stereo3d_draw_topbottom(wmWindow *win, int view)
void wmViewport(const rcti *winrct)
void wmWindowViewport(const wmWindow *win)
void wmWindowViewport_ex(const wmWindow *win, float offset)
void wm_surface_make_drawable(wmSurface *surface)
void wm_surface_clear_drawable()
void wm_surfaces_iter(bContext *C, void(*cb)(bContext *C, wmSurface *))
blender::int2 WM_window_native_pixel_size(const wmWindow *win)
void wm_window_swap_buffer_release(wmWindow *win)
void wm_window_swap_buffer_acquire(wmWindow *win)
Push rendered buffer to the screen.
bool wm_cursor_position_get(wmWindow *win, int *r_x, int *r_y)
int WM_window_native_pixel_y(const wmWindow *win)
void wm_window_clear_drawable(wmWindowManager *wm)
float WM_window_dpi_get_scale(const wmWindow *win)
void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win)
eWM_CapabilitiesFlag WM_capabilities_flag()
uint WM_cursor_preferred_logical_size()
ViewLayer * WM_window_get_active_view_layer(const wmWindow *win)
Scene * WM_window_get_active_scene(const wmWindow *win)
bScreen * WM_window_get_active_screen(const wmWindow *win)