Blender  V2.93
Classes | Macros
wm_draw.c File Reference
#include <stdlib.h>
#include <string.h>
#include "DNA_camera_types.h"
#include "DNA_listBase.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_userdef_types.h"
#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "GHOST_C-api.h"
#include "ED_node.h"
#include "ED_screen.h"
#include "ED_view3d.h"
#include "GPU_batch_presets.h"
#include "GPU_context.h"
#include "GPU_debug.h"
#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_state.h"
#include "GPU_texture.h"
#include "GPU_viewport.h"
#include "RE_engine.h"
#include "WM_api.h"
#include "WM_toolsystem.h"
#include "WM_types.h"
#include "wm.h"
#include "wm_draw.h"
#include "wm_event_system.h"
#include "wm_surface.h"
#include "wm_window.h"
#include "UI_resources.h"

Go to the source code of this file.

Classes

struct  WindowDrawCB
 

Macros

#define SPACE_NAME(space)
 

Functions

Draw Paint Cursor
static void wm_paintcursor_draw (bContext *C, ScrArea *area, ARegion *region)
 
Post Draw Region on display handlers
static void wm_region_draw_overlay (bContext *C, ScrArea *area, ARegion *region)
 
Internal Utilities
static bool wm_draw_region_stereo_set (Main *bmain, ScrArea *area, ARegion *region, eStereoViews sview)
 
static void wm_region_test_gizmo_do_draw (bContext *C, ScrArea *area, ARegion *region, bool tag_redraw)
 
static void wm_region_test_render_do_draw (const Scene *scene, struct Depsgraph *depsgraph, ScrArea *area, ARegion *region)
 
static bool wm_region_use_viewport_by_type (short space_type, short region_type)
 
bool WM_region_use_viewport (ScrArea *area, ARegion *region)
 
static const char * wm_area_name (ScrArea *area)
 
Region Drawing

Each region draws into its own frame-buffer, which is then blit on the window draw buffer. This helps with fast redrawing if only some regions change. It also means we can share a single context for multiple windows, so that for example VAOs can be shared between windows.

static void wm_draw_region_buffer_free (ARegion *region)
 
static void wm_draw_offscreen_texture_parameters (GPUOffScreen *offscreen)
 
static void wm_draw_region_buffer_create (ARegion *region, bool stereo, bool use_viewport)
 
static void wm_draw_region_bind (ARegion *region, int view)
 
static void wm_draw_region_unbind (ARegion *region)
 
static void wm_draw_region_blit (ARegion *region, int view)
 
GPUTexturewm_draw_region_texture (ARegion *region, int view)
 
void wm_draw_region_blend (ARegion *region, int view, bool blend)
 
GPUViewportWM_draw_region_get_viewport (ARegion *region)
 
GPUViewportWM_draw_region_get_bound_viewport (ARegion *region)
 
static void wm_draw_window_offscreen (bContext *C, wmWindow *win, bool stereo)
 
static void wm_draw_window_onscreen (bContext *C, wmWindow *win, int view)
 
static void wm_draw_window (bContext *C, wmWindow *win)
 
static void wm_draw_surface (bContext *C, wmSurface *surface)
 
Main Update Call
static bool wm_draw_update_test_window (Main *bmain, bContext *C, wmWindow *win)
 
static void wm_draw_update_clear_window (bContext *C, wmWindow *win)
 
void WM_paint_cursor_tag_redraw (wmWindow *win, ARegion *UNUSED(region))
 
void wm_draw_update (bContext *C)
 
void wm_draw_region_clear (wmWindow *win, ARegion *UNUSED(region))
 
void WM_draw_region_free (ARegion *region, bool hide)
 
void wm_draw_region_test (bContext *C, ScrArea *area, ARegion *region)
 
void WM_redraw_windows (bContext *C)
 
Region Viewport Drawing

This is needed for viewport drawing for operator use (where the viewport may not have drawn yet).

Otherwise avoid using these sine they're exposing low level logic externally.

void WM_draw_region_viewport_ensure (ARegion *region, short space_type)
 
void WM_draw_region_viewport_bind (ARegion *region)
 
void WM_draw_region_viewport_unbind (ARegion *region)
 

Window Drawing (Draw All)

Reference method, draw all each time.

typedef struct WindowDrawCB WindowDrawCB
 
void * WM_draw_cb_activate (wmWindow *win, void(*draw)(const struct wmWindow *, void *), void *customdata)
 
void WM_draw_cb_exit (wmWindow *win, void *handle)
 
static void wm_draw_callbacks (wmWindow *win)
 

Detailed Description

Handle OpenGL buffers for windowing, also paint cursor.

Definition in file wm_draw.c.

Macro Definition Documentation

◆ SPACE_NAME

#define SPACE_NAME (   space)
Value:
case space: \
return #space;

Typedef Documentation

◆ WindowDrawCB

typedef struct WindowDrawCB WindowDrawCB

Function Documentation

◆ wm_area_name()

static const char* wm_area_name ( ScrArea area)
static

◆ wm_draw_callbacks()

static void wm_draw_callbacks ( wmWindow win)
static

Definition at line 386 of file wm_draw.c.

References wmWindow::drawcalls, and LISTBASE_FOREACH.

Referenced by wm_draw_window_onscreen().

◆ WM_draw_cb_activate()

void* WM_draw_cb_activate ( wmWindow win,
void(*)(const struct wmWindow *, void *)  draw,
void *  customdata 
)

◆ WM_draw_cb_exit()

void WM_draw_cb_exit ( wmWindow win,
void *  handle 
)

◆ wm_draw_offscreen_texture_parameters()

static void wm_draw_offscreen_texture_parameters ( GPUOffScreen offscreen)
static

◆ wm_draw_region_bind()

static void wm_draw_region_bind ( ARegion region,
int  view 
)
static

◆ wm_draw_region_blend()

void wm_draw_region_blend ( ARegion region,
int  view,
bool  blend 
)

◆ wm_draw_region_blit()

static void wm_draw_region_blit ( ARegion region,
int  view 
)
static

◆ wm_draw_region_buffer_create()

static void wm_draw_region_buffer_create ( ARegion region,
bool  stereo,
bool  use_viewport 
)
static

◆ wm_draw_region_buffer_free()

static void wm_draw_region_buffer_free ( ARegion region)
static

◆ wm_draw_region_clear()

void wm_draw_region_clear ( wmWindow win,
ARegion UNUSEDregion 
)

Definition at line 1080 of file wm_draw.c.

References bScreen::do_draw, and WM_window_get_active_screen().

Referenced by ui_region_temp_remove().

◆ WM_draw_region_free()

void WM_draw_region_free ( ARegion region,
bool  hide 
)

Definition at line 1086 of file wm_draw.c.

References ARegion::visible, and wm_draw_region_buffer_free().

Referenced by ED_region_exit(), and ED_view3d_stop_render_preview().

◆ WM_draw_region_get_bound_viewport()

GPUViewport* WM_draw_region_get_bound_viewport ( ARegion region)

◆ WM_draw_region_get_viewport()

GPUViewport* WM_draw_region_get_viewport ( ARegion region)

◆ wm_draw_region_stereo_set()

static bool wm_draw_region_stereo_set ( Main bmain,
ScrArea area,
ARegion region,
eStereoViews  sview 
)
static

◆ wm_draw_region_test()

void wm_draw_region_test ( bContext C,
ScrArea area,
ARegion region 
)

◆ wm_draw_region_texture()

GPUTexture* wm_draw_region_texture ( ARegion region,
int  view 
)

◆ wm_draw_region_unbind()

static void wm_draw_region_unbind ( ARegion region)
static

◆ WM_draw_region_viewport_bind()

void WM_draw_region_viewport_bind ( ARegion region)

Definition at line 1136 of file wm_draw.c.

References wm_draw_region_bind().

Referenced by ED_view3d_depth_override().

◆ WM_draw_region_viewport_ensure()

void WM_draw_region_viewport_ensure ( ARegion region,
short  space_type 
)

◆ WM_draw_region_viewport_unbind()

void WM_draw_region_viewport_unbind ( ARegion region)

Definition at line 1141 of file wm_draw.c.

References wm_draw_region_unbind().

Referenced by ED_view3d_depth_override().

◆ wm_draw_surface()

static void wm_draw_surface ( bContext C,
wmSurface surface 
)
static

Draw offscreen contexts not bound to a specific window.

Definition at line 930 of file wm_draw.c.

References C, CTX_wm_manager(), surface, wm_surface_clear_drawable(), wm_surface_make_drawable(), and wm_window_clear_drawable().

Referenced by wm_draw_update().

◆ wm_draw_update()

void wm_draw_update ( bContext C)

◆ wm_draw_update_clear_window()

static void wm_draw_update_clear_window ( bContext C,
wmWindow win 
)
static

◆ wm_draw_update_test_window()

static bool wm_draw_update_test_window ( Main bmain,
bContext C,
wmWindow win 
)
static

◆ wm_draw_window()

static void wm_draw_window ( bContext C,
wmWindow win 
)
static

◆ wm_draw_window_offscreen()

static void wm_draw_window_offscreen ( bContext C,
wmWindow win,
bool  stereo 
)
static

◆ wm_draw_window_onscreen()

static void wm_draw_window_onscreen ( bContext C,
wmWindow win,
int  view 
)
static

◆ WM_paint_cursor_tag_redraw()

void WM_paint_cursor_tag_redraw ( wmWindow win,
ARegion UNUSEDregion 
)

◆ wm_paintcursor_draw()

static void wm_paintcursor_draw ( bContext C,
ScrArea area,
ARegion region 
)
static

◆ WM_redraw_windows()

void WM_redraw_windows ( bContext C)

◆ wm_region_draw_overlay()

static void wm_region_draw_overlay ( bContext C,
ScrArea area,
ARegion region 
)
static

◆ wm_region_test_gizmo_do_draw()

static void wm_region_test_gizmo_do_draw ( bContext C,
ScrArea area,
ARegion region,
bool  tag_redraw 
)
static

◆ wm_region_test_render_do_draw()

static void wm_region_test_render_do_draw ( const Scene scene,
struct Depsgraph depsgraph,
ScrArea area,
ARegion region 
)
static

◆ WM_region_use_viewport()

bool WM_region_use_viewport ( ScrArea area,
ARegion region 
)

◆ wm_region_use_viewport_by_type()

static bool wm_region_use_viewport_by_type ( short  space_type,
short  region_type 
)
static