Blender  V2.93
wm_draw.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2007 Blender Foundation.
17  * All rights reserved.
18  */
19 
26 #include <stdlib.h>
27 #include <string.h>
28 
29 #include "DNA_camera_types.h"
30 #include "DNA_listBase.h"
31 #include "DNA_object_types.h"
32 #include "DNA_screen_types.h"
33 #include "DNA_userdef_types.h"
34 #include "DNA_view3d_types.h"
36 
37 #include "MEM_guardedalloc.h"
38 
39 #include "BLI_blenlib.h"
40 #include "BLI_utildefines.h"
41 
42 #include "BKE_context.h"
43 #include "BKE_image.h"
44 #include "BKE_main.h"
45 #include "BKE_scene.h"
46 #include "BKE_screen.h"
47 
48 #include "GHOST_C-api.h"
49 
50 #include "ED_node.h"
51 #include "ED_screen.h"
52 #include "ED_view3d.h"
53 
54 #include "GPU_batch_presets.h"
55 #include "GPU_context.h"
56 #include "GPU_debug.h"
57 #include "GPU_framebuffer.h"
58 #include "GPU_immediate.h"
59 #include "GPU_state.h"
60 #include "GPU_texture.h"
61 #include "GPU_viewport.h"
62 
63 #include "RE_engine.h"
64 
65 #include "WM_api.h"
66 #include "WM_toolsystem.h"
67 #include "WM_types.h"
68 #include "wm.h"
69 #include "wm_draw.h"
70 #include "wm_event_system.h"
71 #include "wm_surface.h"
72 #include "wm_window.h"
73 
74 #include "UI_resources.h"
75 
76 #ifdef WITH_OPENSUBDIV
77 # include "BKE_subsurf.h"
78 #endif
79 
80 /* -------------------------------------------------------------------- */
85 {
87  wmWindow *win = CTX_wm_window(C);
88  bScreen *screen = WM_window_get_active_screen(win);
89 
90  /* Don't draw paint cursors with locked interface. Painting is not possible
91  * then, and cursor drawing can use scene data that another thread may be
92  * modifying. */
93  if (wm->is_interface_locked) {
94  return;
95  }
96 
97  if (!region->visible || region != screen->active_region) {
98  return;
99  }
100 
102  if ((pc->space_type != SPACE_TYPE_ANY) && (area->spacetype != pc->space_type)) {
103  continue;
104  }
105 
106  if (!ELEM(pc->region_type, RGN_TYPE_ANY, region->regiontype)) {
107  continue;
108  }
109 
110  if (pc->poll == NULL || pc->poll(C)) {
111  /* Prevent drawing outside region. */
112  GPU_scissor_test(true);
113  GPU_scissor(region->winrct.xmin,
114  region->winrct.ymin,
115  BLI_rcti_size_x(&region->winrct) + 1,
116  BLI_rcti_size_y(&region->winrct) + 1);
117 
119  int x = 0, y = 0;
120  wm_cursor_position_get(win, &x, &y);
121  pc->draw(C, x, y, pc->customdata);
122  }
123  else {
124  pc->draw(C, win->eventstate->x, win->eventstate->y, pc->customdata);
125  }
126 
127  GPU_scissor_test(false);
128  }
129  }
130 }
131 
134 /* -------------------------------------------------------------------- */
139 {
140  wmWindow *win = CTX_wm_window(C);
141 
142  wmViewport(&region->winrct);
143  UI_SetTheme(area->spacetype, region->regiontype);
144  region->type->draw_overlay(C, region);
145  wmWindowViewport(win);
146 }
147 
149 /* -------------------------------------------------------------------- */
153 static bool wm_draw_region_stereo_set(Main *bmain,
154  ScrArea *area,
155  ARegion *region,
156  eStereoViews sview)
157 {
158  /* We could detect better when stereo is actually needed, by inspecting the
159  * image in the image editor and sequencer. */
161  return false;
162  }
163 
164  switch (area->spacetype) {
165  case SPACE_IMAGE: {
166  if (region->regiontype == RGN_TYPE_WINDOW) {
167  SpaceImage *sima = area->spacedata.first;
168  sima->iuser.multiview_eye = sview;
169  return true;
170  }
171  break;
172  }
173  case SPACE_VIEW3D: {
174  if (region->regiontype == RGN_TYPE_WINDOW) {
175  View3D *v3d = area->spacedata.first;
176  if (v3d->camera && v3d->camera->type == OB_CAMERA) {
177  RegionView3D *rv3d = region->regiondata;
178  RenderEngine *engine = rv3d->render_engine;
179  if (engine && !(engine->type->flag & RE_USE_STEREO_VIEWPORT)) {
180  return false;
181  }
182 
183  Camera *cam = v3d->camera->data;
184  CameraBGImage *bgpic = cam->bg_images.first;
185  v3d->multiview_eye = sview;
186  if (bgpic) {
187  bgpic->iuser.multiview_eye = sview;
188  }
189  return true;
190  }
191  }
192  break;
193  }
194  case SPACE_NODE: {
195  if (region->regiontype == RGN_TYPE_WINDOW) {
196  SpaceNode *snode = area->spacedata.first;
197  if ((snode->flag & SNODE_BACKDRAW) && ED_node_is_compositor(snode)) {
198  Image *ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
199  ima->eye = sview;
200  return true;
201  }
202  }
203  break;
204  }
205  case SPACE_SEQ: {
206  SpaceSeq *sseq = area->spacedata.first;
207  sseq->multiview_eye = sview;
208 
209  if (region->regiontype == RGN_TYPE_PREVIEW) {
210  return true;
211  }
212  if (region->regiontype == RGN_TYPE_WINDOW) {
213  return (sseq->draw_flag & SEQ_DRAW_BACKDROP) != 0;
214  }
215  }
216  }
217 
218  return false;
219 }
220 
222  ScrArea *area,
223  ARegion *region,
224  bool tag_redraw)
225 {
226  if (region->gizmo_map == NULL) {
227  return;
228  }
229 
230  wmGizmoMap *gzmap = region->gizmo_map;
232  if (tag_redraw && (gzgroup->type->flag & WM_GIZMOGROUPTYPE_VR_REDRAWS)) {
233  ScrArea *ctx_area = CTX_wm_area(C);
234  ARegion *ctx_region = CTX_wm_region(C);
235 
237  CTX_wm_region_set(C, region);
238 
239  if (WM_gizmo_group_type_poll(C, gzgroup->type)) {
241  }
242 
243  /* Reset. */
244  CTX_wm_area_set(C, ctx_area);
245  CTX_wm_region_set(C, ctx_region);
246  }
247 
248  LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) {
249  if (gz->do_draw) {
250  if (tag_redraw) {
252  }
253  gz->do_draw = false;
254  }
255  }
256  }
257 }
258 
260  struct Depsgraph *depsgraph,
261  ScrArea *area,
262  ARegion *region)
263 {
264  /* tag region for redraw from render engine preview running inside of it */
265  if (area->spacetype == SPACE_VIEW3D && region->regiontype == RGN_TYPE_WINDOW) {
266  RegionView3D *rv3d = region->regiondata;
267  RenderEngine *engine = rv3d->render_engine;
268  GPUViewport *viewport = WM_draw_region_get_viewport(region);
269 
270  if (engine && (engine->flag & RE_ENGINE_DO_DRAW)) {
271  View3D *v3d = area->spacedata.first;
272  rcti border_rect;
273 
274  /* do partial redraw when possible */
275  if (ED_view3d_calc_render_border(scene, depsgraph, v3d, region, &border_rect)) {
276  ED_region_tag_redraw_partial(region, &border_rect, false);
277  }
278  else {
280  }
281 
282  engine->flag &= ~RE_ENGINE_DO_DRAW;
283  }
284  else if (viewport && GPU_viewport_do_update(viewport)) {
286  }
287  }
288 }
289 
290 #ifdef WITH_XR_OPENXR
291 static void wm_region_test_xr_do_draw(const wmWindowManager *wm,
292  const ScrArea *area,
293  ARegion *region)
294 {
295  if ((area->spacetype == SPACE_VIEW3D) && (region->regiontype == RGN_TYPE_WINDOW)) {
296  if (ED_view3d_is_region_xr_mirror_active(wm, area->spacedata.first, region)) {
298  }
299  }
300 }
301 #endif
302 
303 static bool wm_region_use_viewport_by_type(short space_type, short region_type)
304 {
305  return (ELEM(space_type, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE) &&
306  region_type == RGN_TYPE_WINDOW) ||
307  ((space_type == SPACE_SEQ) && ELEM(region_type, RGN_TYPE_PREVIEW, RGN_TYPE_WINDOW));
308 }
309 
311 {
312  return wm_region_use_viewport_by_type(area->spacetype, region->regiontype);
313 }
314 
315 static const char *wm_area_name(ScrArea *area)
316 {
317 #define SPACE_NAME(space) \
318  case space: \
319  return #space;
320 
321  switch (area->spacetype) {
341  default:
342  return "Unknown Space";
343  }
344 }
345 
348 /* -------------------------------------------------------------------- */
354 typedef struct WindowDrawCB {
355  struct WindowDrawCB *next, *prev;
356 
357  void (*draw)(const struct wmWindow *, void *);
358  void *customdata;
359 
361 
363  void (*draw)(const struct wmWindow *, void *),
364  void *customdata)
365 {
366  WindowDrawCB *wdc = MEM_callocN(sizeof(*wdc), "WindowDrawCB");
367 
368  BLI_addtail(&win->drawcalls, wdc);
369  wdc->draw = draw;
370  wdc->customdata = customdata;
371 
372  return wdc;
373 }
374 
375 void WM_draw_cb_exit(wmWindow *win, void *handle)
376 {
377  LISTBASE_FOREACH (WindowDrawCB *, wdc, &win->drawcalls) {
378  if (wdc == (WindowDrawCB *)handle) {
379  BLI_remlink(&win->drawcalls, wdc);
380  MEM_freeN(wdc);
381  return;
382  }
383  }
384 }
385 
386 static void wm_draw_callbacks(wmWindow *win)
387 {
388  LISTBASE_FOREACH (WindowDrawCB *, wdc, &win->drawcalls) {
389  wdc->draw(win, wdc->customdata);
390  }
391 }
392 
395 /* -------------------------------------------------------------------- */
405 {
406  if (region->draw_buffer) {
407  if (region->draw_buffer->viewport) {
409  }
410  if (region->draw_buffer->offscreen) {
412  }
413 
414  MEM_freeN(region->draw_buffer);
415  region->draw_buffer = NULL;
416  }
417 }
418 
420 {
421  /* Setup offscreen color texture for drawing. */
423 
424  /* No mipmaps or filtering. */
425  GPU_texture_mipmap_mode(texture, false, false);
426 }
427 
428 static void wm_draw_region_buffer_create(ARegion *region, bool stereo, bool use_viewport)
429 {
430  if (region->draw_buffer) {
431  if (region->draw_buffer->stereo != stereo) {
432  /* Free draw buffer on stereo changes. */
434  }
435  else {
436  /* Free offscreen buffer on size changes. Viewport auto resizes. */
437  GPUOffScreen *offscreen = region->draw_buffer->offscreen;
438  if (offscreen && (GPU_offscreen_width(offscreen) != region->winx ||
439  GPU_offscreen_height(offscreen) != region->winy)) {
441  }
442  }
443  }
444 
445  if (!region->draw_buffer) {
446  if (use_viewport) {
447  /* Allocate viewport which includes an offscreen buffer with depth
448  * multisample, etc. */
449  region->draw_buffer = MEM_callocN(sizeof(wmDrawBuffer), "wmDrawBuffer");
450  region->draw_buffer->viewport = stereo ? GPU_viewport_stereo_create() :
452  }
453  else {
454  /* Allocate offscreen buffer if it does not exist. This one has no
455  * depth or multisample buffers. 3D view creates own buffers with
456  * the data it needs. */
457  GPUOffScreen *offscreen = GPU_offscreen_create(
458  region->winx, region->winy, false, false, NULL);
459  if (!offscreen) {
460  return;
461  }
462 
464 
465  region->draw_buffer = MEM_callocN(sizeof(wmDrawBuffer), "wmDrawBuffer");
466  region->draw_buffer->offscreen = offscreen;
467  }
468 
469  region->draw_buffer->bound_view = -1;
470  region->draw_buffer->stereo = stereo;
471  }
472 }
473 
474 static void wm_draw_region_bind(ARegion *region, int view)
475 {
476  if (!region->draw_buffer) {
477  return;
478  }
479 
480  if (region->draw_buffer->viewport) {
481  GPU_viewport_bind(region->draw_buffer->viewport, view, &region->winrct);
482  }
483  else {
484  GPU_offscreen_bind(region->draw_buffer->offscreen, false);
485 
486  /* For now scissor is expected by region drawing, we could disable it
487  * and do the enable/disable in the specific cases that setup scissor. */
488  GPU_scissor_test(true);
489  GPU_scissor(0, 0, region->winx, region->winy);
490  }
491 
492  region->draw_buffer->bound_view = view;
493 }
494 
495 static void wm_draw_region_unbind(ARegion *region)
496 {
497  if (!region->draw_buffer) {
498  return;
499  }
500 
501  region->draw_buffer->bound_view = -1;
502 
503  if (region->draw_buffer->viewport) {
505  }
506  else {
507  GPU_scissor_test(false);
508  GPU_offscreen_unbind(region->draw_buffer->offscreen, false);
509  }
510 }
511 
512 static void wm_draw_region_blit(ARegion *region, int view)
513 {
514  if (!region->draw_buffer) {
515  return;
516  }
517 
518  if (view == -1) {
519  /* Non-stereo drawing. */
520  view = 0;
521  }
522  else if (view > 0) {
523  if (region->draw_buffer->viewport == NULL) {
524  /* Region does not need stereo or failed to allocate stereo buffers. */
525  view = 0;
526  }
527  }
528 
529  if (region->draw_buffer->viewport) {
531  }
532  else {
534  region->draw_buffer->offscreen, region->winrct.xmin, region->winrct.ymin);
535  }
536 }
537 
539 {
540  if (!region->draw_buffer) {
541  return NULL;
542  }
543 
544  GPUViewport *viewport = region->draw_buffer->viewport;
545  if (viewport) {
546  return GPU_viewport_color_texture(viewport, view);
547  }
549 }
550 
551 void wm_draw_region_blend(ARegion *region, int view, bool blend)
552 {
553  if (!region->draw_buffer) {
554  return;
555  }
556 
557  /* Alpha is always 1, except when blend timer is running. */
558  float alpha = ED_region_blend_alpha(region);
559  if (alpha <= 0.0f) {
560  return;
561  }
562 
563  if (!blend) {
564  alpha = 1.0f;
565  }
566 
567  /* wmOrtho for the screen has this same offset */
568  const float halfx = GLA_PIXEL_OFS / (BLI_rcti_size_x(&region->winrct) + 1);
569  const float halfy = GLA_PIXEL_OFS / (BLI_rcti_size_y(&region->winrct) + 1);
570 
571  rcti rect_geo = region->winrct;
572  rect_geo.xmax += 1;
573  rect_geo.ymax += 1;
574 
575  rctf rect_tex;
576  rect_tex.xmin = halfx;
577  rect_tex.ymin = halfy;
578  rect_tex.xmax = 1.0f + halfx;
579  rect_tex.ymax = 1.0f + halfy;
580 
581  float alpha_easing = 1.0f - alpha;
582  alpha_easing = 1.0f - alpha_easing * alpha_easing;
583 
584  /* Slide vertical panels */
585  float ofs_x = BLI_rcti_size_x(&region->winrct) * (1.0f - alpha_easing);
587  rect_geo.xmin += ofs_x;
588  rect_tex.xmax *= alpha_easing;
589  alpha = 1.0f;
590  }
591  else if (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_LEFT) {
592  rect_geo.xmax -= ofs_x;
593  rect_tex.xmin += 1.0f - alpha_easing;
594  alpha = 1.0f;
595  }
596 
597  /* Not the same layout as rectf/recti. */
598  const float rectt[4] = {rect_tex.xmin, rect_tex.ymin, rect_tex.xmax, rect_tex.ymax};
599  const float rectg[4] = {rect_geo.xmin, rect_geo.ymin, rect_geo.xmax, rect_geo.ymax};
600 
601  if (blend) {
602  /* Regions drawn offscreen have premultiplied alpha. */
604  }
605 
606  /* setup actual texture */
608 
611 
613  int rect_tex_loc = GPU_shader_get_uniform(shader, "rect_icon");
614  int rect_geo_loc = GPU_shader_get_uniform(shader, "rect_geom");
615  int texture_bind_loc = GPU_shader_get_texture_binding(shader, "image");
616 
617  GPU_texture_bind(texture, texture_bind_loc);
618 
619  GPU_shader_uniform_vector(shader, rect_tex_loc, 4, 1, rectt);
620  GPU_shader_uniform_vector(shader, rect_geo_loc, 4, 1, rectg);
621  GPU_shader_uniform_vector(shader, color_loc, 4, 1, (const float[4]){1, 1, 1, 1});
622 
626 
628 
629  if (blend) {
631  }
632 }
633 
635 {
636  if (!region->draw_buffer) {
637  return NULL;
638  }
639 
640  GPUViewport *viewport = region->draw_buffer->viewport;
641  return viewport;
642 }
643 
645 {
646  if (!region->draw_buffer || region->draw_buffer->bound_view == -1) {
647  return NULL;
648  }
649 
650  GPUViewport *viewport = region->draw_buffer->viewport;
651  return viewport;
652 }
653 
654 static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
655 {
656  Main *bmain = CTX_data_main(C);
658  bScreen *screen = WM_window_get_active_screen(win);
659 
660  /* Draw screen areas into own frame buffer. */
661  ED_screen_areas_iter (win, screen, area) {
664 
665  /* Compute UI layouts for dynamically size regions. */
666  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
667  /* Dynamic region may have been flagged as too small because their size on init is 0.
668  * ARegion.visible is false then, as expected. The layout should still be created then, so
669  * the region size can be updated (it may turn out to be not too small then). */
670  const bool ignore_visibility = (region->flag & RGN_FLAG_DYNAMIC_SIZE) &&
671  (region->flag & RGN_FLAG_TOO_SMALL) &&
672  !(region->flag & RGN_FLAG_HIDDEN);
673 
674  if ((region->visible || ignore_visibility) && region->do_draw && region->type &&
675  region->type->layout) {
676  CTX_wm_region_set(C, region);
677  ED_region_do_layout(C, region);
679  }
680  }
681 
683 
684  if (area->flag & AREA_FLAG_ACTIVE_TOOL_UPDATE) {
685  if ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) {
687  }
689  }
690 
691  /* Then do actual drawing of regions. */
692  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
693  if (region->visible && region->do_draw) {
694  CTX_wm_region_set(C, region);
695  bool use_viewport = WM_region_use_viewport(area, region);
696 
697  GPU_debug_group_begin(use_viewport ? "Viewport" : "ARegion");
698 
699  if (stereo && wm_draw_region_stereo_set(bmain, area, region, STEREO_LEFT_ID)) {
700  wm_draw_region_buffer_create(region, true, use_viewport);
701 
702  for (int view = 0; view < 2; view++) {
703  eStereoViews sview;
704  if (view == 0) {
705  sview = STEREO_LEFT_ID;
706  }
707  else {
708  sview = STEREO_RIGHT_ID;
709  wm_draw_region_stereo_set(bmain, area, region, sview);
710  }
711 
712  wm_draw_region_bind(region, view);
713  ED_region_do_draw(C, region);
714  wm_draw_region_unbind(region);
715  }
716  if (use_viewport) {
717  GPUViewport *viewport = region->draw_buffer->viewport;
719  }
720  }
721  else {
722  wm_draw_region_buffer_create(region, false, use_viewport);
723  wm_draw_region_bind(region, 0);
724  ED_region_do_draw(C, region);
725  wm_draw_region_unbind(region);
726  }
727 
729 
730  region->do_draw = false;
732  }
733  }
734 
736 
738  }
739 
740  /* Draw menus into their own framebuffer. */
741  LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
742  if (region->visible) {
743  CTX_wm_menu_set(C, region);
744 
745  GPU_debug_group_begin("Menu");
746 
747  if (region->type && region->type->layout) {
748  /* UI code reads the OpenGL state, but we have to refresh
749  * the UI layout beforehand in case the menu size changes. */
750  wmViewport(&region->winrct);
751  region->type->layout(C, region);
752  }
753 
754  wm_draw_region_buffer_create(region, false, false);
755  wm_draw_region_bind(region, 0);
756  GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f);
757  ED_region_do_draw(C, region);
758  wm_draw_region_unbind(region);
759 
761 
762  region->do_draw = false;
764  }
765  }
766 }
767 
769 {
771  bScreen *screen = WM_window_get_active_screen(win);
772 
773  GPU_debug_group_begin("Window Redraw");
774 
775  /* Draw into the window framebuffer, in full window coordinates. */
776  wmWindowViewport(win);
777 
778  /* We draw on all pixels of the windows so we don't need to clear them before.
779  * Actually this is only a problem when resizing the window.
780  * If it becomes a problem we should clear only when window size changes. */
781 #if 0
782  GPU_clear_color(0, 0, 0, 0);
783 #endif
784 
785  /* Blit non-overlapping area regions. */
786  ED_screen_areas_iter (win, screen, area) {
787  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
788  if (region->visible && region->overlap == false) {
789  /* Blit from offscreen buffer. */
790  wm_draw_region_blit(region, view);
791  }
792  }
793  }
794 
795  /* Draw overlays and paint cursors. */
796  ED_screen_areas_iter (win, screen, area) {
797  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
798  if (region->visible) {
799  const bool do_paint_cursor = (wm->paintcursors.first && region == screen->active_region);
800  const bool do_draw_overlay = (region->type && region->type->draw_overlay);
801  if (!(do_paint_cursor || do_draw_overlay)) {
802  continue;
803  }
804 
806  CTX_wm_region_set(C, region);
807  if (do_draw_overlay) {
808  wm_region_draw_overlay(C, area, region);
809  }
810  if (do_paint_cursor) {
811  wm_paintcursor_draw(C, area, region);
812  }
815  }
816  }
817  }
818  wmWindowViewport(win);
819 
820  /* Blend in overlapping area regions */
821  ED_screen_areas_iter (win, screen, area) {
822  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
823  if (region->visible && region->overlap) {
824  wm_draw_region_blend(region, 0, true);
825  }
826  }
827  }
828 
829  /* After area regions so we can do area 'overlay' drawing. */
831  wm_draw_callbacks(win);
832  wmWindowViewport(win);
833 
834  /* Blend in floating regions (menus). */
835  LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
836  if (region->visible) {
837  wm_draw_region_blend(region, 0, true);
838  }
839  }
840 
841  /* always draw, not only when screen tagged */
842  if (win->gesture.first) {
843  wm_gesture_draw(win);
844  }
845 
846  /* needs pixel coords in screen */
847  if (wm->drags.first) {
848  wm_drags_draw(C, win, NULL);
849  }
850 
852 }
853 
854 static void wm_draw_window(bContext *C, wmWindow *win)
855 {
856  bScreen *screen = WM_window_get_active_screen(win);
857  bool stereo = WM_stereo3d_enabled(win, false);
858 
859  /* Avoid any BGL call issued before this to alter the window drawin. */
860  GPU_bgl_end();
861 
862  /* Draw area regions into their own framebuffer. This way we can redraw
863  * the areas that need it, and blit the rest from existing framebuffers. */
864  wm_draw_window_offscreen(C, win, stereo);
865 
866  /* Now we draw into the window framebuffer, in full window coordinates. */
867  if (!stereo) {
868  /* Regular mono drawing. */
869  wm_draw_window_onscreen(C, win, -1);
870  }
872  /* For pageflip we simply draw to both back buffers. */
874  wm_draw_window_onscreen(C, win, 1);
875 
877  wm_draw_window_onscreen(C, win, 0);
878  }
880  /* For anaglyph and interlace, we draw individual regions with
881  * stereo framebuffers using different shaders. */
882  wm_draw_window_onscreen(C, win, -1);
883  }
884  else {
885  /* For side-by-side and top-bottom, we need to render each view to an
886  * an offscreen texture and then draw it. This used to happen for all
887  * stereo methods, but it's less efficient than drawing directly. */
888  const int width = WM_window_pixels_x(win);
889  const int height = WM_window_pixels_y(win);
890  GPUOffScreen *offscreen = GPU_offscreen_create(width, height, false, false, NULL);
891 
892  if (offscreen) {
895 
896  for (int view = 0; view < 2; view++) {
897  /* Draw view into offscreen buffer. */
898  GPU_offscreen_bind(offscreen, false);
900  GPU_offscreen_unbind(offscreen, false);
901 
902  /* Draw offscreen buffer to screen. */
904 
905  wmWindowViewport(win);
908  }
909  else {
911  }
912 
914  }
915 
916  GPU_offscreen_free(offscreen);
917  }
918  else {
919  /* Still draw something in case of allocation failure. */
920  wm_draw_window_onscreen(C, win, 0);
921  }
922  }
923 
924  screen->do_draw = false;
925 }
926 
931 {
934 
935  surface->draw(C);
936 
937  /* Avoid interference with window drawable */
939 }
940 
943 /* -------------------------------------------------------------------- */
947 /* quick test to prevent changing window drawable */
948 static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win)
949 {
950  const wmWindowManager *wm = CTX_wm_manager(C);
952  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
953  struct Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer);
954  bScreen *screen = WM_window_get_active_screen(win);
955  bool do_draw = false;
956 
957  LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
958  if (region->do_draw_paintcursor) {
959  screen->do_draw_paintcursor = true;
960  region->do_draw_paintcursor = false;
961  }
962  if (region->visible && region->do_draw) {
963  do_draw = true;
964  }
965  }
966 
967  ED_screen_areas_iter (win, screen, area) {
968  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
969  wm_region_test_gizmo_do_draw(C, area, region, true);
971 #ifdef WITH_XR_OPENXR
972  wm_region_test_xr_do_draw(wm, area, region);
973 #endif
974 
975  if (region->visible && region->do_draw) {
976  do_draw = true;
977  }
978  }
979  }
980 
981  if (do_draw) {
982  return true;
983  }
984 
985  if (screen->do_refresh) {
986  return true;
987  }
988  if (screen->do_draw) {
989  return true;
990  }
991  if (screen->do_draw_gesture) {
992  return true;
993  }
994  if (screen->do_draw_paintcursor) {
995  return true;
996  }
997  if (screen->do_draw_drag) {
998  return true;
999  }
1000 
1001 #ifndef WITH_XR_OPENXR
1002  UNUSED_VARS(wm);
1003 #endif
1004 
1005  return false;
1006 }
1007 
1008 /* Clear drawing flags, after drawing is complete so any draw flags set during
1009  * drawing don't cause any additional redraws. */
1011 {
1012  bScreen *screen = WM_window_get_active_screen(win);
1013 
1014  ED_screen_areas_iter (win, screen, area) {
1015  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
1016  wm_region_test_gizmo_do_draw(C, area, region, false);
1017  }
1018  }
1019 
1020  screen->do_draw_gesture = false;
1021  screen->do_draw_paintcursor = false;
1022  screen->do_draw_drag = false;
1023 }
1024 
1026 {
1027  if (win) {
1028  bScreen *screen = WM_window_get_active_screen(win);
1029  screen->do_draw_paintcursor = true;
1030  }
1031 }
1032 
1034 {
1035  Main *bmain = CTX_data_main(C);
1037 
1040 
1041  LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
1042 #ifdef WIN32
1044 
1046  /* do not update minimized windows, gives issues on Intel (see T33223)
1047  * and AMD (see T50856). it seems logical to skip update for invisible
1048  * window anyway.
1049  */
1050  continue;
1051  }
1052 #endif
1053 
1054  CTX_wm_window_set(C, win);
1055 
1056  if (wm_draw_update_test_window(bmain, C, win)) {
1057  bScreen *screen = WM_window_get_active_screen(win);
1058 
1059  /* sets context window+screen */
1060  wm_window_make_drawable(wm, win);
1061 
1062  /* notifiers for screen redraw */
1063  ED_screen_ensure_updated(wm, win, screen);
1064 
1065  wm_draw_window(C, win);
1067 
1069  }
1070  }
1071 
1073 
1074  /* Draw non-windows (surfaces) */
1076 
1078 }
1079 
1081 {
1082  bScreen *screen = WM_window_get_active_screen(win);
1083  screen->do_draw = true;
1084 }
1085 
1086 void WM_draw_region_free(ARegion *region, bool hide)
1087 {
1089  if (hide) {
1090  region->visible = 0;
1091  }
1092 }
1093 
1095 {
1096  /* Function for redraw timer benchmark. */
1097  bool use_viewport = WM_region_use_viewport(area, region);
1098  wm_draw_region_buffer_create(region, false, use_viewport);
1099  wm_draw_region_bind(region, 0);
1100  ED_region_do_draw(C, region);
1101  wm_draw_region_unbind(region);
1102  region->do_draw = false;
1103 }
1104 
1106 {
1107  wmWindow *win_prev = CTX_wm_window(C);
1108  ScrArea *area_prev = CTX_wm_area(C);
1109  ARegion *region_prev = CTX_wm_region(C);
1110 
1111  wm_draw_update(C);
1112 
1113  CTX_wm_window_set(C, win_prev);
1114  CTX_wm_area_set(C, area_prev);
1115  CTX_wm_region_set(C, region_prev);
1116 }
1117 
1120 /* -------------------------------------------------------------------- */
1130 void WM_draw_region_viewport_ensure(ARegion *region, short space_type)
1131 {
1132  bool use_viewport = wm_region_use_viewport_by_type(space_type, region->regiontype);
1133  wm_draw_region_buffer_create(region, false, use_viewport);
1134 }
1135 
1137 {
1138  wm_draw_region_bind(region, 0);
1139 }
1140 
1142 {
1143  wm_draw_region_unbind(region);
1144 }
1145 
struct WorkSpace * CTX_wm_workspace(const bContext *C)
Definition: context.c:704
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:714
void CTX_wm_region_set(bContext *C, struct ARegion *region)
Definition: context.c:985
void CTX_wm_menu_set(bContext *C, struct ARegion *menu)
Definition: context.c:996
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1044
void CTX_wm_window_set(bContext *C, struct wmWindow *win)
Definition: context.c:942
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:725
void CTX_wm_area_set(bContext *C, struct ScrArea *area)
Definition: context.c:973
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
void BKE_image_free_unused_gpu_textures(void)
Definition: image_gpu.c:482
struct Image * BKE_image_ensure_viewer(struct Main *bmain, int type, const char *name)
Definition: image.c:3162
struct Depsgraph * BKE_scene_ensure_depsgraph(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer)
Definition: scene.c:3526
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
Definition: BLI_listbase.h:188
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:133
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition: BLI_rect.h:157
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition: BLI_rect.h:153
#define UNUSED_VARS(...)
#define UNUSED(x)
#define ELEM(...)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
@ IMA_TYPE_COMPOSITE
These structs are the foundation for all linked lists in the library system.
Object is a sort of wrapper for general info.
@ OB_CAMERA
@ S3D_DISPLAY_ANAGLYPH
@ S3D_DISPLAY_INTERLACE
@ S3D_DISPLAY_SIDEBYSIDE
@ S3D_DISPLAY_PAGEFLIP
eStereoViews
@ STEREO_LEFT_ID
@ STEREO_RIGHT_ID
#define RGN_ALIGN_ENUM_FROM_MASK(align)
@ RGN_ALIGN_LEFT
@ RGN_ALIGN_RIGHT
@ AREA_FLAG_ACTIVE_TOOL_UPDATE
#define RGN_TYPE_ANY
@ RGN_FLAG_DYNAMIC_SIZE
@ RGN_FLAG_HIDDEN
@ RGN_FLAG_TOO_SMALL
@ RGN_TYPE_WINDOW
@ RGN_TYPE_PREVIEW
@ SNODE_BACKDRAW
@ SPACE_TEXT
@ SPACE_CLIP
@ SPACE_ACTION
@ SPACE_CONSOLE
@ SPACE_OUTLINER
@ SPACE_STATUSBAR
@ SPACE_TOPBAR
@ SPACE_NODE
@ SPACE_USERPREF
@ SPACE_FILE
@ SPACE_PROPERTIES
@ SPACE_NLA
@ SPACE_SEQ
@ SPACE_EMPTY
@ SPACE_SCRIPT
@ SPACE_IMAGE
@ SPACE_GRAPH
@ SPACE_VIEW3D
@ SPACE_INFO
@ SEQ_DRAW_BACKDROP
#define SPACE_TYPE_ANY
bool ED_node_is_compositor(struct SpaceNode *snode)
Definition: node_edit.c:449
void ED_area_update_region_sizes(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *area)
Definition: area.c:1865
void ED_region_do_layout(struct bContext *C, struct ARegion *region)
Definition: area.c:505
float ED_region_blend_alpha(struct ARegion *region)
Definition: screen_ops.c:5116
void ED_region_tag_redraw_partial(struct ARegion *region, const struct rcti *rct, bool rebuild)
void ED_region_tag_redraw_editor_overlays(struct ARegion *region)
Definition: area.c:706
#define ED_screen_areas_iter(win, screen, area_name)
Definition: ED_screen.h:189
void ED_region_tag_redraw_no_rebuild(struct ARegion *region)
Definition: area.c:686
void ED_screen_draw_edges(struct wmWindow *win)
Definition: screen_draw.c:363
void ED_region_do_draw(struct bContext *C, struct ARegion *region)
Definition: area.c:529
void ED_screen_ensure_updated(struct wmWindowManager *wm, struct wmWindow *win, struct bScreen *screen)
Definition: screen_edit.c:552
bool ED_view3d_calc_render_border(const struct Scene *scene, struct Depsgraph *depsgraph, struct View3D *v3d, struct ARegion *region, struct rcti *rect)
static AppView * view
GHOST C-API function and type declarations.
GHOST_TWindowState GHOST_GetWindowState(GHOST_WindowHandle windowhandle)
GHOST_TWindowState
Definition: GHOST_Types.h:144
@ GHOST_kWindowStateMinimized
Definition: GHOST_Types.h:147
@ GHOST_kGrabWrap
Definition: GHOST_Types.h:418
@ GHOST_kGrabHide
Definition: GHOST_Types.h:420
GPUBatch
Definition: GPU_batch.h:93
void GPU_batch_set_shader(GPUBatch *batch, GPUShader *shader)
Definition: gpu_batch.cc:222
void GPU_batch_draw(GPUBatch *batch)
Definition: gpu_batch.cc:234
struct GPUBatch * GPU_batch_preset_quad(void)
void GPU_context_main_lock(void)
Definition: gpu_context.cc:149
void GPU_context_main_unlock(void)
Definition: gpu_context.cc:154
void GPU_debug_group_end(void)
Definition: gpu_debug.cc:48
void GPU_debug_group_begin(const char *name)
Definition: gpu_debug.cc:37
@ GPU_BACKBUFFER_LEFT
@ GPU_BACKBUFFER_RIGHT
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
Definition: gpu_shader.cc:551
struct GPUShader GPUShader
Definition: GPU_shader.h:33
void GPU_shader_uniform_vector(GPUShader *shader, int location, int length, int arraysize, const float *value)
Definition: gpu_shader.cc:617
GPUShader * GPU_shader_get_builtin_shader(eGPUBuiltinShader shader)
void GPU_shader_bind(GPUShader *shader)
Definition: gpu_shader.cc:494
@ GPU_UNIFORM_COLOR
Definition: GPU_shader.h:106
@ GPU_SHADER_2D_IMAGE_RECT_COLOR
Definition: GPU_shader.h:189
int GPU_shader_get_texture_binding(GPUShader *shader, const char *name)
Definition: gpu_shader.cc:585
int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
Definition: gpu_shader.cc:558
@ GPU_BLEND_NONE
Definition: GPU_state.h:55
@ GPU_BLEND_ALPHA_PREMULT
Definition: GPU_state.h:58
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:55
void GPU_bgl_end(void)
Definition: gpu_state.cc:367
void GPU_scissor_test(bool enable)
Definition: gpu_state.cc:199
void GPU_scissor(int x, int y, int width, int height)
Definition: gpu_state.cc:204
struct GPUTexture GPUTexture
Definition: GPU_texture.h:33
void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap, bool use_filter)
Definition: gpu_texture.cc:477
void GPU_texture_unbind(GPUTexture *tex)
Definition: gpu_texture.cc:421
void GPU_texture_bind(GPUTexture *tex, int unit)
Definition: gpu_texture.cc:415
void GPU_viewport_bind(GPUViewport *viewport, int view, const rcti *rect)
Definition: gpu_viewport.c:495
GPUTexture * GPU_viewport_color_texture(GPUViewport *viewport, int view)
Definition: gpu_viewport.c:917
void GPU_viewport_draw_to_screen(GPUViewport *viewport, int view, const rcti *rect)
Definition: gpu_viewport.c:867
GPUViewport * GPU_viewport_create(void)
Definition: gpu_viewport.c:144
bool GPU_viewport_do_update(GPUViewport *viewport)
Definition: gpu_viewport.c:137
GPUViewport * GPU_viewport_stereo_create(void)
Definition: gpu_viewport.c:156
void GPU_viewport_free(GPUViewport *viewport)
Definition: gpu_viewport.c:978
void GPU_viewport_stereo_composite(GPUViewport *viewport, Stereo3dFormat *stereo_format)
Definition: gpu_viewport.c:604
void GPU_viewport_unbind(GPUViewport *viewport)
Read Guarded memory(de)allocation.
#define RE_USE_STEREO_VIEWPORT
Definition: RE_engine.h:65
#define RE_ENGINE_DO_DRAW
Definition: RE_engine.h:72
#define C
Definition: RandGen.cpp:39
void UI_SetTheme(int spacetype, int regionid)
Definition: resources.c:1064
@ WM_GIZMOGROUPTYPE_VR_REDRAWS
#define WM_TOOLSYSTEM_SPACE_MASK
Definition: WM_toolsystem.h:43
Scene scene
const Depsgraph * depsgraph
static CCL_NAMESPACE_BEGIN const double alpha
struct @203::@204 surface
GPUBatch * quad
void GPU_offscreen_free(GPUOffScreen *ofs)
void GPU_offscreen_unbind(GPUOffScreen *UNUSED(ofs), bool restore)
void GPU_backbuffer_bind(eGPUBackBuffer buffer)
void GPU_clear_color(float red, float green, float blue, float alpha)
GPUOffScreen * GPU_offscreen_create(int width, int height, bool depth, bool high_bitdepth, char err_out[256])
void GPU_offscreen_draw_to_screen(GPUOffScreen *ofs, int x, int y)
int GPU_offscreen_width(const GPUOffScreen *ofs)
void GPU_offscreen_bind(GPUOffScreen *ofs, bool save)
GPUTexture * GPU_offscreen_color_texture(const GPUOffScreen *ofs)
int GPU_offscreen_height(const GPUOffScreen *ofs)
void KERNEL_FUNCTION_FULL_NAME() shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int filter, int i, int offset, int sample)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static ulong state[N]
static void area(int d1, int d2, int e1, int e2, float weights[2])
void(* draw_overlay)(const struct bContext *C, struct ARegion *region)
Definition: BKE_screen.h:177
void(* layout)(const struct bContext *C, struct ARegion *region)
Definition: BKE_screen.h:179
short do_draw_paintcursor
void * regiondata
short alignment
struct wmDrawBuffer * draw_buffer
short regiontype
struct wmGizmoMap * gizmo_map
struct ARegionType * type
struct ImageUser iuser
struct ListBase bg_images
char multiview_eye
void * first
Definition: DNA_listBase.h:47
Definition: BKE_main.h:116
void * data
struct RenderEngine * render_engine
RenderEngineType * type
Definition: RE_engine.h:126
struct ImageUser iuser
char multiview_eye
char multiview_eye
struct Object * camera
struct WindowDrawCB * next
Definition: wm_draw.c:355
struct WindowDrawCB * prev
Definition: wm_draw.c:355
void * customdata
Definition: wm_draw.c:358
void(* draw)(const struct wmWindow *, void *)
Definition: wm_draw.c:357
char do_draw_drag
char do_refresh
ListBase regionbase
char do_draw_paintcursor
char do_draw_gesture
struct ARegion * active_region
float xmax
Definition: DNA_vec_types.h:85
float xmin
Definition: DNA_vec_types.h:85
float ymax
Definition: DNA_vec_types.h:86
float ymin
Definition: DNA_vec_types.h:86
int ymin
Definition: DNA_vec_types.h:80
int ymax
Definition: DNA_vec_types.h:80
int xmin
Definition: DNA_vec_types.h:79
int xmax
Definition: DNA_vec_types.h:79
int bound_view
Definition: wm_draw.h:38
struct GPUViewport * viewport
Definition: wm_draw.h:36
bool stereo
Definition: wm_draw.h:37
struct GPUOffScreen * offscreen
Definition: wm_draw.h:35
int y
Definition: WM_types.h:581
int x
Definition: WM_types.h:581
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, rcti *rect)
Definition: wm_dragdrop.c:499
static void wm_draw_callbacks(wmWindow *win)
Definition: wm_draw.c:386
void WM_draw_region_viewport_unbind(ARegion *region)
Definition: wm_draw.c:1141
static void wm_draw_offscreen_texture_parameters(GPUOffScreen *offscreen)
Definition: wm_draw.c:419
static void wm_draw_region_unbind(ARegion *region)
Definition: wm_draw.c:495
static void wm_draw_region_bind(ARegion *region, int view)
Definition: wm_draw.c:474
static bool wm_region_use_viewport_by_type(short space_type, short region_type)
Definition: wm_draw.c:303
static void wm_draw_surface(bContext *C, wmSurface *surface)
Definition: wm_draw.c:930
static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
Definition: wm_draw.c:654
void WM_draw_region_free(ARegion *region, bool hide)
Definition: wm_draw.c:1086
void WM_redraw_windows(bContext *C)
Definition: wm_draw.c:1105
static void wm_draw_region_buffer_free(ARegion *region)
Definition: wm_draw.c:404
GPUTexture * wm_draw_region_texture(ARegion *region, int view)
Definition: wm_draw.c:538
static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region)
Definition: wm_draw.c:84
void wm_draw_region_blend(ARegion *region, int view, bool blend)
Definition: wm_draw.c:551
static void wm_draw_update_clear_window(bContext *C, wmWindow *win)
Definition: wm_draw.c:1010
struct WindowDrawCB WindowDrawCB
bool WM_region_use_viewport(ScrArea *area, ARegion *region)
Definition: wm_draw.c:310
#define SPACE_NAME(space)
static void wm_region_draw_overlay(bContext *C, ScrArea *area, ARegion *region)
Definition: wm_draw.c:138
static bool wm_draw_region_stereo_set(Main *bmain, ScrArea *area, ARegion *region, eStereoViews sview)
Definition: wm_draw.c:153
void WM_draw_cb_exit(wmWindow *win, void *handle)
Definition: wm_draw.c:375
void * WM_draw_cb_activate(wmWindow *win, void(*draw)(const struct wmWindow *, void *), void *customdata)
Definition: wm_draw.c:362
static void wm_region_test_gizmo_do_draw(bContext *C, ScrArea *area, ARegion *region, bool tag_redraw)
Definition: wm_draw.c:221
void WM_draw_region_viewport_bind(ARegion *region)
Definition: wm_draw.c:1136
static void wm_region_test_render_do_draw(const Scene *scene, struct Depsgraph *depsgraph, ScrArea *area, ARegion *region)
Definition: wm_draw.c:259
void wm_draw_region_test(bContext *C, ScrArea *area, ARegion *region)
Definition: wm_draw.c:1094
static void wm_draw_region_buffer_create(ARegion *region, bool stereo, bool use_viewport)
Definition: wm_draw.c:428
static void wm_draw_region_blit(ARegion *region, int view)
Definition: wm_draw.c:512
void wm_draw_region_clear(wmWindow *win, ARegion *UNUSED(region))
Definition: wm_draw.c:1080
GPUViewport * WM_draw_region_get_viewport(ARegion *region)
Definition: wm_draw.c:634
static void wm_draw_window(bContext *C, wmWindow *win)
Definition: wm_draw.c:854
void WM_draw_region_viewport_ensure(ARegion *region, short space_type)
Definition: wm_draw.c:1130
void wm_draw_update(bContext *C)
Definition: wm_draw.c:1033
static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win)
Definition: wm_draw.c:948
static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view)
Definition: wm_draw.c:768
GPUViewport * WM_draw_region_get_bound_viewport(ARegion *region)
Definition: wm_draw.c:644
static const char * wm_area_name(ScrArea *area)
Definition: wm_draw.c:315
void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion *UNUSED(region))
Definition: wm_draw.c:1025
void wm_gesture_draw(wmWindow *win)
Definition: wm_gesture.c:519
bool WM_gizmo_group_type_poll(const bContext *C, const wmGizmoGroupType *gzgt)
const ListBase * WM_gizmomap_group_list(wmGizmoMap *gzmap)
Definition: wm_gizmo_map.c:239
void wm_stereo3d_draw_sidebyside(wmWindow *win, int view)
Definition: wm_stereo.c:57
bool WM_stereo3d_enabled(wmWindow *win, bool skip_stereo3d_check)
Definition: wm_stereo.c:156
void wm_stereo3d_draw_topbottom(wmWindow *win, int view)
Definition: wm_stereo.c:107
void wmViewport(const rcti *winrct)
Definition: wm_subwindow.c:37
void wmWindowViewport(wmWindow *win)
Definition: wm_subwindow.c:88
void wm_surface_clear_drawable(void)
Definition: wm_surface.c:53
void wm_surface_make_drawable(wmSurface *surface)
Definition: wm_surface.c:82
void wm_surfaces_iter(bContext *C, void(*cb)(bContext *C, wmSurface *))
Definition: wm_surface.c:46
void WM_toolsystem_update_from_context(bContext *C, WorkSpace *workspace, ViewLayer *view_layer, ScrArea *area)
int WM_window_pixels_y(const wmWindow *win)
Definition: wm_window.c:2136
void wm_window_swap_buffers(wmWindow *win)
Push rendered buffer to the screen.
Definition: wm_window.c:1884
void wm_window_clear_drawable(wmWindowManager *wm)
Definition: wm_window.c:1047
bScreen * WM_window_get_active_screen(const wmWindow *win)
Definition: wm_window.c:2372
void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win)
Definition: wm_window.c:1054
ViewLayer * WM_window_get_active_view_layer(const wmWindow *win)
Definition: wm_window.c:2286
int WM_window_pixels_x(const wmWindow *win)
Definition: wm_window.c:2130
Scene * WM_window_get_active_scene(const wmWindow *win)
Definition: wm_window.c:2249
void wm_cursor_position_get(wmWindow *win, int *r_x, int *r_y)
Definition: wm_window.c:986