@@ -54,12 +54,12 @@
static void screen_free_data(ID *id)
{
bScreen *screen = (bScreen *)id;
ARegion *ar;
ARegion *region;

/* No animdata here. */

for (ar = screen->regionbase.first; ar; ar = ar->next) {
BKE_area_region_free(NULL, ar);
for (region = screen->regionbase.first; region; region = region->next) {
BKE_area_region_free(NULL, region);
}

BLI_freelistN(&screen->regionbase);
@@ -204,14 +204,14 @@ bool BKE_spacetype_exists(int spaceid)
void BKE_spacedata_freelist(ListBase *lb)
{
SpaceLink *sl;
ARegion *ar;
ARegion *region;

for (sl = lb->first; sl; sl = sl->next) {
SpaceType *st = BKE_spacetype_from_id(sl->spacetype);

/* free regions for pushed spaces */
for (ar = sl->regionbase.first; ar; ar = ar->next) {
BKE_area_region_free(st, ar);
for (region = sl->regionbase.first; region; region = region->next) {
BKE_area_region_free(st, region);
}

BLI_freelistN(&sl->regionbase);
@@ -238,9 +238,9 @@ static void panel_list_copy(ListBase *newlb, const ListBase *lb)
}
}

ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
ARegion *BKE_area_region_copy(SpaceType *st, ARegion *region)
{
ARegion *newar = MEM_dupallocN(ar);
ARegion *newar = MEM_dupallocN(region);

newar->prev = newar->next = NULL;
BLI_listbase_clear(&newar->handlers);
@@ -255,42 +255,42 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
newar->draw_buffer = NULL;

/* use optional regiondata callback */
if (ar->regiondata) {
ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
if (region->regiondata) {
ARegionType *art = BKE_regiontype_from_id(st, region->regiontype);

if (art && art->duplicate) {
newar->regiondata = art->duplicate(ar->regiondata);
newar->regiondata = art->duplicate(region->regiondata);
}
else if (ar->flag & RGN_FLAG_TEMP_REGIONDATA) {
else if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
newar->regiondata = NULL;
}
else {
newar->regiondata = MEM_dupallocN(ar->regiondata);
newar->regiondata = MEM_dupallocN(region->regiondata);
}
}

if (ar->v2d.tab_offset) {
newar->v2d.tab_offset = MEM_dupallocN(ar->v2d.tab_offset);
if (region->v2d.tab_offset) {
newar->v2d.tab_offset = MEM_dupallocN(region->v2d.tab_offset);
}

panel_list_copy(&newar->panels, &ar->panels);
panel_list_copy(&newar->panels, &region->panels);

BLI_listbase_clear(&newar->ui_previews);
BLI_duplicatelist(&newar->ui_previews, &ar->ui_previews);
BLI_duplicatelist(&newar->ui_previews, &region->ui_previews);

return newar;
}

/* from lb2 to lb1, lb1 is supposed to be freed */
static void region_copylist(SpaceType *st, ListBase *lb1, ListBase *lb2)
{
ARegion *ar;
ARegion *region;

/* to be sure */
BLI_listbase_clear(lb1);

for (ar = lb2->first; ar; ar = ar->next) {
ARegion *arnew = BKE_area_region_copy(st, ar);
for (region = lb2->first; region; region = region->next) {
ARegion *arnew = BKE_area_region_copy(st, region);
BLI_addtail(lb1, arnew);
}
}
@@ -344,19 +344,19 @@ ARegion *BKE_spacedata_find_region_type(const SpaceLink *slink, const ScrArea *s
{
const bool is_slink_active = slink == sa->spacedata.first;
const ListBase *regionbase = (is_slink_active) ? &sa->regionbase : &slink->regionbase;
ARegion *ar = NULL;
ARegion *region = NULL;

BLI_assert(BLI_findindex(&sa->spacedata, slink) != -1);
for (ar = regionbase->first; ar; ar = ar->next) {
if (ar->regiontype == region_type) {
for (region = regionbase->first; region; region = region->next) {
if (region->regiontype == region_type) {
break;
}
}

/* Should really unit test this instead. */
BLI_assert(!is_slink_active || ar == BKE_area_find_region_type(sa, region_type));
BLI_assert(!is_slink_active || region == BKE_area_find_region_type(sa, region_type));

return ar;
return region;
}

static void (*spacedata_id_remap_cb)(struct ScrArea *sa,
@@ -394,11 +394,11 @@ void BKE_screen_gizmo_tag_refresh(struct bScreen *sc)
}

ScrArea *sa;
ARegion *ar;
ARegion *region;
for (sa = sc->areabase.first; sa; sa = sa->next) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->gizmo_map != NULL) {
region_refresh_tag_gizmomap_callback(ar->gizmo_map);
for (region = sa->regionbase.first; region; region = region->next) {
if (region->gizmo_map != NULL) {
region_refresh_tag_gizmomap_callback(region->gizmo_map);
}
}
}
@@ -429,33 +429,33 @@ void BKE_area_region_panels_free(ListBase *lb)
}

/* not region itself */
void BKE_area_region_free(SpaceType *st, ARegion *ar)
void BKE_area_region_free(SpaceType *st, ARegion *region)
{
uiList *uilst;

if (st) {
ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
ARegionType *art = BKE_regiontype_from_id(st, region->regiontype);

if (art && art->free) {
art->free(ar);
art->free(region);
}

if (ar->regiondata) {
if (region->regiondata) {
printf("regiondata free error\n");
}
}
else if (ar->type && ar->type->free) {
ar->type->free(ar);
else if (region->type && region->type->free) {
region->type->free(region);
}

if (ar->v2d.tab_offset) {
MEM_freeN(ar->v2d.tab_offset);
ar->v2d.tab_offset = NULL;
if (region->v2d.tab_offset) {
MEM_freeN(region->v2d.tab_offset);
region->v2d.tab_offset = NULL;
}

BKE_area_region_panels_free(&ar->panels);
BKE_area_region_panels_free(&region->panels);

for (uilst = ar->ui_lists.first; uilst; uilst = uilst->next) {
for (uilst = region->ui_lists.first; uilst; uilst = uilst->next) {
if (uilst->dyn_data) {
uiListDyn *dyn_data = uilst->dyn_data;
if (dyn_data->items_filter_flags) {
@@ -471,24 +471,24 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar)
}
}

if (ar->gizmo_map != NULL) {
region_free_gizmomap_callback(ar->gizmo_map);
if (region->gizmo_map != NULL) {
region_free_gizmomap_callback(region->gizmo_map);
}

BLI_freelistN(&ar->ui_lists);
BLI_freelistN(&ar->ui_previews);
BLI_freelistN(&ar->panels_category);
BLI_freelistN(&ar->panels_category_active);
BLI_freelistN(&region->ui_lists);
BLI_freelistN(&region->ui_previews);
BLI_freelistN(&region->panels_category);
BLI_freelistN(&region->panels_category_active);
}

/* not area itself */
void BKE_screen_area_free(ScrArea *sa)
{
SpaceType *st = BKE_spacetype_from_id(sa->spacetype);
ARegion *ar;
ARegion *region;

for (ar = sa->regionbase.first; ar; ar = ar->next) {
BKE_area_region_free(st, ar);
for (region = sa->regionbase.first; region; region = region->next) {
BKE_area_region_free(st, region);
}

MEM_SAFE_FREE(sa->global);
@@ -722,9 +722,9 @@ void BKE_screen_remove_unused_scrverts(bScreen *sc)
ARegion *BKE_area_find_region_type(const ScrArea *sa, int region_type)
{
if (sa) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == region_type) {
return ar;
for (ARegion *region = sa->regionbase.first; region; region = region->next) {
if (region->regiontype == region_type) {
return region;
}
}
}
@@ -735,9 +735,9 @@ ARegion *BKE_area_find_region_type(const ScrArea *sa, int region_type)
ARegion *BKE_area_find_region_active_win(ScrArea *sa)
{
if (sa) {
ARegion *ar = BLI_findlink(&sa->regionbase, sa->region_active_win);
if (ar && (ar->regiontype == RGN_TYPE_WINDOW)) {
return ar;
ARegion *region = BLI_findlink(&sa->regionbase, sa->region_active_win);
if (region && (region->regiontype == RGN_TYPE_WINDOW)) {
return region;
}

/* fallback to any */
@@ -750,11 +750,11 @@ ARegion *BKE_area_find_region_xy(ScrArea *sa, const int regiontype, int x, int y
{
ARegion *ar_found = NULL;
if (sa) {
ARegion *ar;
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if ((regiontype == RGN_TYPE_ANY) || (ar->regiontype == regiontype)) {
if (BLI_rcti_isect_pt(&ar->winrct, x, y)) {
ar_found = ar;
ARegion *region;
for (region = sa->regionbase.first; region; region = region->next) {
if ((regiontype == RGN_TYPE_ANY) || (region->regiontype == regiontype)) {
if (BLI_rcti_isect_pt(&region->winrct, x, y)) {
ar_found = region;
break;
}
}
@@ -769,10 +769,10 @@ ARegion *BKE_area_find_region_xy(ScrArea *sa, const int regiontype, int x, int y
ARegion *BKE_screen_find_region_xy(bScreen *sc, const int regiontype, int x, int y)
{
ARegion *ar_found = NULL;
for (ARegion *ar = sc->regionbase.first; ar; ar = ar->next) {
if ((regiontype == RGN_TYPE_ANY) || (ar->regiontype == regiontype)) {
if (BLI_rcti_isect_pt(&ar->winrct, x, y)) {
ar_found = ar;
for (ARegion *region = sc->regionbase.first; region; region = region->next) {
if ((regiontype == RGN_TYPE_ANY) || (region->regiontype == regiontype)) {
if (BLI_rcti_isect_pt(&region->winrct, x, y)) {
ar_found = region;
break;
}
}
@@ -847,11 +847,11 @@ void BKE_screen_view3d_sync(View3D *v3d, struct Scene *scene)
v3d->camera = scene->camera;

if (v3d->camera == NULL) {
ARegion *ar;
ARegion *region;

for (ar = v3d->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = ar->regiondata;
for (region = v3d->regionbase.first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
if (rv3d->persp == RV3D_CAMOB) {
rv3d->persp = RV3D_PERSP;
}
@@ -914,20 +914,20 @@ void BKE_screen_header_alignment_reset(bScreen *screen)
{
int alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
for (ARegion *region = sa->regionbase.first; region; region = region->next) {
if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
if (ELEM(sa->spacetype, SPACE_FILE, SPACE_USERPREF, SPACE_OUTLINER, SPACE_PROPERTIES)) {
ar->alignment = RGN_ALIGN_TOP;
region->alignment = RGN_ALIGN_TOP;
continue;
}
ar->alignment = alignment;
region->alignment = alignment;
}
if (ar->regiontype == RGN_TYPE_FOOTER) {
if (region->regiontype == RGN_TYPE_FOOTER) {
if (ELEM(sa->spacetype, SPACE_FILE, SPACE_USERPREF, SPACE_OUTLINER, SPACE_PROPERTIES)) {
ar->alignment = RGN_ALIGN_BOTTOM;
region->alignment = RGN_ALIGN_BOTTOM;
continue;
}
ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
}
}
}
@@ -7001,38 +7001,38 @@ static void direct_link_panel_list(FileData *fd, ListBase *lb)
}
}

static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
static void direct_link_region(FileData *fd, ARegion *region, int spacetype)
{
uiList *ui_list;

direct_link_panel_list(fd, &ar->panels);
direct_link_panel_list(fd, &region->panels);

link_list(fd, &ar->panels_category_active);
link_list(fd, &region->panels_category_active);

link_list(fd, &ar->ui_lists);
link_list(fd, &region->ui_lists);

for (ui_list = ar->ui_lists.first; ui_list; ui_list = ui_list->next) {
for (ui_list = region->ui_lists.first; ui_list; ui_list = ui_list->next) {
ui_list->type = NULL;
ui_list->dyn_data = NULL;
ui_list->properties = newdataadr(fd, ui_list->properties);
IDP_DirectLinkGroup_OrFree(&ui_list->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
}

link_list(fd, &ar->ui_previews);
link_list(fd, &region->ui_previews);

if (spacetype == SPACE_EMPTY) {
/* unknown space type, don't leak regiondata */
ar->regiondata = NULL;
region->regiondata = NULL;
}
else if (ar->flag & RGN_FLAG_TEMP_REGIONDATA) {
else if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
/* Runtime data, don't use. */
ar->regiondata = NULL;
region->regiondata = NULL;
}
else {
ar->regiondata = newdataadr(fd, ar->regiondata);
if (ar->regiondata) {
region->regiondata = newdataadr(fd, region->regiondata);
if (region->regiondata) {
if (spacetype == SPACE_VIEW3D) {
RegionView3D *rv3d = ar->regiondata;
RegionView3D *rv3d = region->regiondata;

rv3d->localvd = newdataadr(fd, rv3d->localvd);
rv3d->clipbb = newdataadr(fd, rv3d->clipbb);
@@ -7047,28 +7047,28 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
}
}

ar->v2d.tab_offset = NULL;
ar->v2d.tab_num = 0;
ar->v2d.tab_cur = 0;
ar->v2d.sms = NULL;
ar->v2d.alpha_hor = ar->v2d.alpha_vert = 255; /* visible by default */
BLI_listbase_clear(&ar->panels_category);
BLI_listbase_clear(&ar->handlers);
BLI_listbase_clear(&ar->uiblocks);
ar->headerstr = NULL;
ar->visible = 0;
ar->type = NULL;
ar->do_draw = 0;
ar->gizmo_map = NULL;
ar->regiontimer = NULL;
ar->draw_buffer = NULL;
memset(&ar->drawrct, 0, sizeof(ar->drawrct));
region->v2d.tab_offset = NULL;
region->v2d.tab_num = 0;
region->v2d.tab_cur = 0;
region->v2d.sms = NULL;
region->v2d.alpha_hor = region->v2d.alpha_vert = 255; /* visible by default */
BLI_listbase_clear(&region->panels_category);
BLI_listbase_clear(&region->handlers);
BLI_listbase_clear(&region->uiblocks);
region->headerstr = NULL;
region->visible = 0;
region->type = NULL;
region->do_draw = 0;
region->gizmo_map = NULL;
region->regiontimer = NULL;
region->draw_buffer = NULL;
memset(&region->drawrct, 0, sizeof(region->drawrct));
}

static void direct_link_area(FileData *fd, ScrArea *area)
{
SpaceLink *sl;
ARegion *ar;
ARegion *region;

link_list(fd, &(area->spacedata));
link_list(fd, &(area->regionbase));
@@ -7094,8 +7094,8 @@ static void direct_link_area(FileData *fd, ScrArea *area)
area->spacetype = SPACE_EMPTY;
}

for (ar = area->regionbase.first; ar; ar = ar->next) {
direct_link_region(fd, ar, area->spacetype);
for (region = area->regionbase.first; region; region = region->next) {
direct_link_region(fd, region, area->spacetype);
}

/* accident can happen when read/save new file with older version */
@@ -7119,8 +7119,8 @@ static void direct_link_area(FileData *fd, ScrArea *area)
sl->spacetype = SPACE_EMPTY;
}

for (ar = sl->regionbase.first; ar; ar = ar->next) {
direct_link_region(fd, ar, sl->spacetype);
for (region = sl->regionbase.first; region; region = region->next) {
direct_link_region(fd, region, sl->spacetype);
}

if (sl->spacetype == SPACE_VIEW3D) {
@@ -7800,9 +7800,9 @@ static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, View
/* Regionbase storage is different depending if the space is active. */
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
&sl->regionbase;
for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = ar->regiondata;
for (ARegion *region = regionbase->first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
if (rv3d->localvd) {
MEM_freeN(rv3d->localvd);
rv3d->localvd = NULL;
@@ -7828,16 +7828,16 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
ARegion *ar;
ARegion *region;

v3d->camera = restore_pointer_by_name(id_map, (ID *)v3d->camera, USER_REAL);
v3d->ob_centre = restore_pointer_by_name(id_map, (ID *)v3d->ob_centre, USER_REAL);

/* Free render engines for now. */
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
for (ar = regionbase->first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = ar->regiondata;
for (region = regionbase->first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
if (rv3d && rv3d->render_engine) {
RE_engine_free(rv3d->render_engine);
rv3d->render_engine = NULL;
@@ -8115,13 +8115,13 @@ void blo_lib_link_restore(Main *oldmain,
/* and as patch for 2.48 and older */
void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions)
{
ARegion *ar;
ARegion *region;

for (ar = regions->first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW && ar->regiondata == NULL) {
for (region = regions->first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_WINDOW && region->regiondata == NULL) {
RegionView3D *rv3d;

rv3d = ar->regiondata = MEM_callocN(sizeof(RegionView3D), "region v3d patch");
rv3d = region->regiondata = MEM_callocN(sizeof(RegionView3D), "region v3d patch");
rv3d->persp = (char)v3d->persp;
rv3d->view = (char)v3d->view;
rv3d->dist = v3d->dist;

Large diffs are not rendered by default.

@@ -1198,15 +1198,15 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_CLIP) {
SpaceClip *sclip = (SpaceClip *)sl;
ARegion *ar;
ARegion *region;
bool hide = false;

for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_PREVIEW) {
if (ar->alignment != RGN_ALIGN_NONE) {
ar->flag |= RGN_FLAG_HIDDEN;
ar->v2d.flag &= ~V2D_IS_INITIALISED;
ar->alignment = RGN_ALIGN_NONE;
for (region = sa->regionbase.first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_PREVIEW) {
if (region->alignment != RGN_ALIGN_NONE) {
region->flag |= RGN_FLAG_HIDDEN;
region->v2d.flag &= ~V2D_IS_INITIALISED;
region->alignment = RGN_ALIGN_NONE;

hide = true;
}
@@ -2263,26 +2263,26 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* add missing (+) expander in node editor */
for (sc = bmain->screens.first; sc; sc = sc->id.next) {
for (sa = sc->areabase.first; sa; sa = sa->next) {
ARegion *ar, *arnew;
ARegion *region, *arnew;

if (sa->spacetype == SPACE_NODE) {
ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
region = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);

if (ar) {
if (region) {
continue;
}

/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
region = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);

/* is error! */
if (ar == NULL) {
if (region == NULL) {
continue;
}

arnew = MEM_callocN(sizeof(ARegion), "node tools");

BLI_insertlinkafter(&sa->regionbase, ar, arnew);
BLI_insertlinkafter(&sa->regionbase, region, arnew);
arnew->regiontype = RGN_TYPE_TOOLS;
arnew->alignment = RGN_ALIGN_LEFT;

@@ -2551,7 +2551,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)

for (space_link = sa->spacedata.first; space_link; space_link = space_link->next) {
if (space_link->spacetype == SPACE_IMAGE) {
ARegion *ar;
ARegion *region;
ListBase *lb;

if (space_link == sa->spacedata.first) {
@@ -2561,13 +2561,13 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
lb = &space_link->regionbase;
}

for (ar = lb->first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_PREVIEW) {
ar->regiontype = RGN_TYPE_TOOLS;
ar->alignment = RGN_ALIGN_LEFT;
for (region = lb->first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_PREVIEW) {
region->regiontype = RGN_TYPE_TOOLS;
region->alignment = RGN_ALIGN_LEFT;
}
else if (ar->regiontype == RGN_TYPE_UI) {
ar->alignment = RGN_ALIGN_RIGHT;
else if (region->regiontype == RGN_TYPE_UI) {
region->alignment = RGN_ALIGN_RIGHT;
}
}
}
@@ -233,18 +233,18 @@ static void do_version_constraints_stretch_to_limits(ListBase *lb)

static void do_version_action_editor_properties_region(ListBase *regionbase)
{
ARegion *ar;
ARegion *region;

for (ar = regionbase->first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_UI) {
for (region = regionbase->first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_UI) {
/* already exists */
return;
}
else if (ar->regiontype == RGN_TYPE_WINDOW) {
else if (region->regiontype == RGN_TYPE_WINDOW) {
/* add new region here */
ARegion *arnew = MEM_callocN(sizeof(ARegion), "buttons for action");

BLI_insertlinkbefore(regionbase, ar, arnew);
BLI_insertlinkbefore(regionbase, region, arnew);

arnew->regiontype = RGN_TYPE_UI;
arnew->alignment = RGN_ALIGN_RIGHT;
@@ -527,11 +527,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
SpaceLink *sl;

for (sl = sa->spacedata.first; sl; sl = sl->next) {
ARegion *ar;
ARegion *region;
ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;

for (ar = lb->first; ar; ar = ar->next) {
BLI_listbase_clear(&ar->ui_previews);
for (region = lb->first; region; region = region->next) {
BLI_listbase_clear(&region->ui_previews);
}
}
}
@@ -855,18 +855,18 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
bScreen *scr;
ScrArea *sa;
SpaceLink *sl;
ARegion *ar;
ARegion *region;

/* Make sure sequencer preview area limits zoom */
for (scr = bmain->screens.first; scr; scr = scr->id.next) {
for (sa = scr->areabase.first; sa; sa = sa->next) {
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_SEQ) {
for (ar = sl->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_PREVIEW) {
ar->v2d.keepzoom |= V2D_LIMITZOOM;
ar->v2d.minzoom = 0.001f;
ar->v2d.maxzoom = 1000.0f;
for (region = sl->regionbase.first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_PREVIEW) {
region->v2d.keepzoom |= V2D_LIMITZOOM;
region->v2d.minzoom = 0.001f;
region->v2d.maxzoom = 1000.0f;
break;
}
}
@@ -1069,12 +1069,12 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
ARegion *ar;
ARegion *region;
ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
for (ar = lb->first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
if (ar->regiondata) {
RegionView3D *rv3d = ar->regiondata;
for (region = lb->first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_WINDOW) {
if (region->regiondata) {
RegionView3D *rv3d = region->regiondata;
if (rv3d->view == RV3D_VIEW_PERSPORTHO) {
rv3d->view = RV3D_VIEW_USER;
}
@@ -1256,23 +1256,23 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (sl->spacetype == SPACE_SEQ) {
SpaceSeq *sseq = (SpaceSeq *)sl;
if (sseq->view == SEQ_VIEW_SEQUENCE) {
for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
for (ARegion *region = regionbase->first; region; region = region->next) {
/* remove preview region for sequencer-only view! */
if (ar->regiontype == RGN_TYPE_PREVIEW) {
ar->flag |= RGN_FLAG_HIDDEN;
ar->alignment = RGN_ALIGN_NONE;
if (region->regiontype == RGN_TYPE_PREVIEW) {
region->flag |= RGN_FLAG_HIDDEN;
region->alignment = RGN_ALIGN_NONE;
break;
}
}
}
}
/* Remove old deprecated region from filebrowsers */
else if (sl->spacetype == SPACE_FILE) {
for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_CHANNELS) {
for (ARegion *region = regionbase->first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_CHANNELS) {
/* Free old deprecated 'channel' region... */
BKE_area_region_free(NULL, ar);
BLI_freelinkN(regionbase, ar);
BKE_area_region_free(NULL, region);
BLI_freelinkN(regionbase, region);
break;
}
}
@@ -595,46 +595,46 @@ static void do_versions_fix_annotations(bGPdata *gpd)
}
}

static void do_versions_remove_region(ListBase *regionbase, ARegion *ar)
static void do_versions_remove_region(ListBase *regionbase, ARegion *region)
{
BLI_freelinkN(regionbase, ar);
BLI_freelinkN(regionbase, region);
}

static void do_versions_remove_regions_by_type(ListBase *regionbase, int regiontype)
{
ARegion *ar, *ar_next;
for (ar = regionbase->first; ar; ar = ar_next) {
ar_next = ar->next;
if (ar->regiontype == regiontype) {
do_versions_remove_region(regionbase, ar);
ARegion *region, *ar_next;
for (region = regionbase->first; region; region = ar_next) {
ar_next = region->next;
if (region->regiontype == regiontype) {
do_versions_remove_region(regionbase, region);
}
}
}

static ARegion *do_versions_find_region_or_null(ListBase *regionbase, int regiontype)
{
for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
if (ar->regiontype == regiontype) {
return ar;
for (ARegion *region = regionbase->first; region; region = region->next) {
if (region->regiontype == regiontype) {
return region;
}
}
return NULL;
}

static ARegion *do_versions_find_region(ListBase *regionbase, int regiontype)
{
ARegion *ar = do_versions_find_region_or_null(regionbase, regiontype);
if (ar == NULL) {
ARegion *region = do_versions_find_region_or_null(regionbase, regiontype);
if (region == NULL) {
BLI_assert(!"Did not find expected region in versioning");
}
return ar;
return region;
}

static ARegion *do_versions_add_region(int regiontype, const char *name)
{
ARegion *ar = MEM_callocN(sizeof(ARegion), name);
ar->regiontype = regiontype;
return ar;
ARegion *region = MEM_callocN(sizeof(ARegion), name);
region->regiontype = regiontype;
return region;
}

static void do_versions_area_ensure_tool_region(Main *bmain,
@@ -646,13 +646,13 @@ static void do_versions_area_ensure_tool_region(Main *bmain,
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == space_type) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
if (!ar) {
ARegion *region = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
if (!region) {
ARegion *header = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
ar = do_versions_add_region(RGN_TYPE_TOOLS, "tools region");
BLI_insertlinkafter(regionbase, header, ar);
ar->alignment = RGN_ALIGN_LEFT;
ar->flag = region_flag;
region = do_versions_add_region(RGN_TYPE_TOOLS, "tools region");
BLI_insertlinkafter(regionbase, header, region);
region->alignment = RGN_ALIGN_LEFT;
region->flag = region_flag;
}
}
}
@@ -2899,9 +2899,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
* fine to always insert headers first. */
BLI_assert(!do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOL_HEADER));

ARegion *ar = do_versions_add_region(RGN_TYPE_HEADER, "header 2.83.1 versioning");
ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
BLI_addhead(regionbase, ar);
ARegion *region = do_versions_add_region(RGN_TYPE_HEADER,
"header 2.83.1 versioning");
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM :
RGN_ALIGN_TOP;
BLI_addhead(regionbase, region);
}
}
}
@@ -2913,7 +2915,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_PROPERTIES) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
ARegion *ar = MEM_callocN(sizeof(ARegion), "navigation bar for properties");
ARegion *region = MEM_callocN(sizeof(ARegion), "navigation bar for properties");
ARegion *ar_header = NULL;

for (ar_header = regionbase->first; ar_header; ar_header = ar_header->next) {
@@ -2923,10 +2925,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
BLI_assert(ar_header);

BLI_insertlinkafter(regionbase, ar_header, ar);
BLI_insertlinkafter(regionbase, ar_header, region);

ar->regiontype = RGN_TYPE_NAV_BAR;
ar->alignment = RGN_ALIGN_LEFT;
region->regiontype = RGN_TYPE_NAV_BAR;
region->alignment = RGN_ALIGN_LEFT;
}
}
}
@@ -3698,11 +3700,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
do_versions_remove_regions_by_type(regionbase, RGN_TYPE_FOOTER);

/* Add footer. */
ARegion *ar = do_versions_add_region(RGN_TYPE_FOOTER, "footer for text");
ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
ARegion *region = do_versions_add_region(RGN_TYPE_FOOTER, "footer for text");
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;

ARegion *ar_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER);
BLI_insertlinkafter(regionbase, ar_header, ar);
BLI_insertlinkafter(regionbase, ar_header, region);
}
}
}
@@ -3788,20 +3790,22 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
/* All spaces that use tools must be eventually added. */
ARegion *ar = NULL;
ARegion *region = NULL;
if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_SEQ) &&
((ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOL_HEADER)) == NULL)) {
((region = do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOL_HEADER)) ==
NULL)) {
/* Add tool header. */
ar = do_versions_add_region(RGN_TYPE_TOOL_HEADER, "tool header");
ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
region = do_versions_add_region(RGN_TYPE_TOOL_HEADER, "tool header");
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;

ARegion *ar_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER);
BLI_insertlinkbefore(regionbase, ar_header, ar);
BLI_insertlinkbefore(regionbase, ar_header, region);
/* Hide by default, enable for painting workspaces (startup only). */
ar->flag |= RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER;
region->flag |= RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER;
}
if (ar != NULL) {
SET_FLAG_FROM_TEST(ar->flag, ar->flag & RGN_FLAG_HIDDEN_BY_USER, RGN_FLAG_HIDDEN);
if (region != NULL) {
SET_FLAG_FROM_TEST(
region->flag, region->flag & RGN_FLAG_HIDDEN_BY_USER, RGN_FLAG_HIDDEN);
}
}
}
@@ -3898,19 +3902,19 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (ELEM(sl->spacetype, SPACE_CLIP, SPACE_GRAPH, SPACE_SEQ)) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;

ARegion *ar = NULL;
ARegion *region = NULL;
if (sl->spacetype == SPACE_CLIP) {
if (((SpaceClip *)sl)->view == SC_VIEW_GRAPH) {
ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_PREVIEW);
region = do_versions_find_region_or_null(regionbase, RGN_TYPE_PREVIEW);
}
}
else {
ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_WINDOW);
region = do_versions_find_region_or_null(regionbase, RGN_TYPE_WINDOW);
}

if (ar != NULL) {
ar->v2d.scroll &= ~V2D_SCROLL_LEFT;
ar->v2d.scroll |= V2D_SCROLL_RIGHT;
if (region != NULL) {
region->v2d.scroll &= ~V2D_SCROLL_LEFT;
region->v2d.scroll |= V2D_SCROLL_RIGHT;
}
}
}
@@ -4049,9 +4053,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_TEXT) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
ARegion *ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_UI);
if (ar) {
ar->alignment = RGN_ALIGN_RIGHT;
ARegion *region = do_versions_find_region_or_null(regionbase, RGN_TYPE_UI);
if (region) {
region->alignment = RGN_ALIGN_RIGHT;
}
}
/* Mark outliners as dirty for syncing and enable synced selection */
@@ -101,11 +101,11 @@ static void blo_update_defaults_screen(bScreen *screen,
{
/* For all app templates. */
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
for (ARegion *region = sa->regionbase.first; region; region = region->next) {
/* Some toolbars have been saved as initialized,
* we don't want them to have odd zoom-level or scrolling set, see: T47047 */
if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) {
ar->v2d.flag &= ~V2D_IS_INITIALISED;
if (ELEM(region->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) {
region->v2d.flag &= ~V2D_IS_INITIALISED;
}
}

@@ -130,15 +130,15 @@ static void blo_update_defaults_screen(bScreen *screen,
}

for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
for (ARegion *region = sa->regionbase.first; region; region = region->next) {
/* Remove all stored panels, we want to use defaults
* (order, open/closed) as defined by UI code here! */
BKE_area_region_panels_free(&ar->panels);
BLI_freelistN(&ar->panels_category_active);
BKE_area_region_panels_free(&region->panels);
BLI_freelistN(&region->panels_category_active);

/* Reset size so it uses consistent defaults from the region types. */
ar->sizex = 0;
ar->sizey = 0;
region->sizex = 0;
region->sizey = 0;
}

if (sa->spacetype == SPACE_IMAGE) {
@@ -156,9 +156,9 @@ static void blo_update_defaults_screen(bScreen *screen,
if (saction->mode == SACTCONT_TIMELINE) {
saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED;

for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_CHANNELS) {
ar->flag |= RGN_FLAG_HIDDEN;
for (ARegion *region = sa->regionbase.first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_CHANNELS) {
region->flag |= RGN_FLAG_HIDDEN;
}
}
}
@@ -213,13 +213,13 @@ static void blo_update_defaults_screen(bScreen *screen,
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;

for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_TOOL_HEADER) {
for (ARegion *region = regionbase->first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_TOOL_HEADER) {
if ((sl->spacetype == SPACE_IMAGE) && hide_image_tool_header) {
ar->flag |= RGN_FLAG_HIDDEN;
region->flag |= RGN_FLAG_HIDDEN;
}
else {
ar->flag &= ~(RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER);
region->flag &= ~(RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER);
}
}
}
@@ -229,7 +229,7 @@ static void blo_update_defaults_screen(bScreen *screen,
/* 2D animation template. */
if (app_template && STREQ(app_template, "2D_Animation")) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
for (ARegion *region = sa->regionbase.first; region; region = region->next) {
if (sa->spacetype == SPACE_ACTION) {
SpaceAction *saction = sa->spacedata.first;
/* Enable Sliders. */
@@ -266,7 +266,7 @@ void BLO_update_defaults_workspace(WorkSpace *workspace, const char *app_templat
bScreen *screen = layout->screen;
if (screen) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
for (ARegion *region = sa->regionbase.first; region; region = region->next) {
if (sa->spacetype == SPACE_VIEW3D) {
View3D *v3d = sa->spacedata.first;
v3d->shading.flag &= ~V3D_SHADING_CAVITY;
@@ -2756,19 +2756,19 @@ static void write_gpencil(WriteData *wd, bGPdata *gpd)
}
}

static void write_region(WriteData *wd, ARegion *ar, int spacetype)
static void write_region(WriteData *wd, ARegion *region, int spacetype)
{
writestruct(wd, DATA, ARegion, 1, ar);
writestruct(wd, DATA, ARegion, 1, region);

if (ar->regiondata) {
if (ar->flag & RGN_FLAG_TEMP_REGIONDATA) {
if (region->regiondata) {
if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
return;
}

switch (spacetype) {
case SPACE_VIEW3D:
if (ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = ar->regiondata;
if (region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
writestruct(wd, DATA, RegionView3D, 1, rv3d);

if (rv3d->localvd) {
@@ -63,7 +63,7 @@ typedef struct DRWUpdateContext {
struct Depsgraph *depsgraph;
struct Scene *scene;
struct ViewLayer *view_layer;
struct ARegion *ar;
struct ARegion *region;
struct View3D *v3d;
struct RenderEngineType *engine_type;
} DRWUpdateContext;
@@ -81,24 +81,24 @@ void DRW_draw_region_engine_info(int xoffset, int yoffset);

void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph,
struct RenderEngineType *engine_type,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
struct GPUViewport *viewport,
const struct bContext *evil_C);
void DRW_draw_render_loop(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
struct GPUViewport *viewport);
void DRW_draw_render_loop_offscreen(struct Depsgraph *depsgraph,
struct RenderEngineType *engine_type,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
const bool draw_background,
const bool do_color_management,
struct GPUOffScreen *ofs,
struct GPUViewport *viewport);
void DRW_draw_select_loop(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
bool use_obedit_skip,
bool draw_surface,
@@ -109,20 +109,20 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
DRW_ObjectFilterFn object_filter_fn,
void *object_filter_user_data);
void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
struct GPUViewport *viewport,
bool use_opengl_context);
void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
struct GPUViewport *viewport);
void DRW_draw_depth_object(struct ARegion *ar,
void DRW_draw_depth_object(struct ARegion *region,
struct View3D *v3d,
struct GPUViewport *viewport,
struct Object *object);
void DRW_draw_select_id(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
const struct rcti *rect);

@@ -90,34 +90,34 @@ uint DRW_select_buffer_context_offset_for_object_elem(struct Depsgraph *depsgrap
struct Object *object,
char elem_type);
uint *DRW_select_buffer_read(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
const rcti *rect,
uint *r_buf_len);
uint *DRW_select_buffer_bitmap_from_rect(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
const struct rcti *rect,
uint *r_bitmap_len);
uint *DRW_select_buffer_bitmap_from_circle(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
const int center[2],
const int radius,
uint *r_bitmap_len);
uint *DRW_select_buffer_bitmap_from_poly(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
const int poly[][2],
const int poly_len,
const struct rcti *rect,
uint *r_bitmap_len);
uint DRW_select_buffer_sample_point(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
const int center[2]);
uint DRW_select_buffer_find_nearest_to_point(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
const int center[2],
const uint id_min,
@@ -88,7 +88,7 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
rect = &fallback_rect;
}
else {
rect = ED_region_visible_rect(draw_ctx->ar);
rect = ED_region_visible_rect(draw_ctx->region);
}

/* Make the viewport width scale the lookdev spheres a bit.
@@ -48,7 +48,7 @@ static struct {
extern char datatoc_effect_motion_blur_frag_glsl[];

static void eevee_motion_blur_camera_get_matrix_at_time(Scene *scene,
ARegion *ar,
ARegion *region,
RegionView3D *rv3d,
View3D *v3d,
Object *camera,
@@ -83,7 +83,7 @@ static void eevee_motion_blur_camera_get_matrix_at_time(Scene *scene,

if (v3d != NULL) {
BKE_camera_params_from_view3d(&params, draw_ctx->depsgraph, v3d, rv3d);
BKE_camera_params_compute_viewplane(&params, ar->winx, ar->winy, 1.0f, 1.0f);
BKE_camera_params_compute_viewplane(&params, region->winx, region->winy, 1.0f, 1.0f);
}
else {
BKE_camera_params_from_object(&params, &cam_cpy);
@@ -115,7 +115,7 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda

View3D *v3d = draw_ctx->v3d;
RegionView3D *rv3d = draw_ctx->rv3d;
ARegion *ar = draw_ctx->ar;
ARegion *region = draw_ctx->region;

if (scene_eval->eevee.flag & SCE_EEVEE_MOTION_BLUR_ENABLED) {
/* Update Motion Blur Matrices */
@@ -151,7 +151,7 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda
/* Current matrix */
if (effects->motion_blur_mat_cached == false) {
eevee_motion_blur_camera_get_matrix_at_time(
scene, ar, rv3d, v3d, ob_camera_eval, ctime, effects->current_world_to_ndc);
scene, region, rv3d, v3d, ob_camera_eval, ctime, effects->current_world_to_ndc);
}

/* Only continue if camera is not being keyed */
@@ -160,12 +160,12 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda
/* Past matrix */
if (effects->motion_blur_mat_cached == false) {
eevee_motion_blur_camera_get_matrix_at_time(
scene, ar, rv3d, v3d, ob_camera_eval, ctime - delta, effects->past_world_to_ndc);
scene, region, rv3d, v3d, ob_camera_eval, ctime - delta, effects->past_world_to_ndc);

#if 0 /* for future high quality blur */
/* Future matrix */
eevee_motion_blur_camera_get_matrix_at_time(
scene, ar, rv3d, v3d, ob_camera_eval, ctime + delta, effects->future_world_to_ndc);
scene, region, rv3d, v3d, ob_camera_eval, ctime + delta, effects->future_world_to_ndc);
#endif
invert_m4_m4(effects->current_ndc_to_world, effects->current_world_to_ndc);
}
@@ -100,7 +100,7 @@ static void external_engine_init(void *vedata)
{
EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl;
const DRWContextState *draw_ctx = DRW_context_state_get();
ARegion *ar = draw_ctx->ar;
ARegion *region = draw_ctx->region;

/* Depth prepass */
if (!e_data.depth_sh) {
@@ -117,7 +117,7 @@ static void external_engine_init(void *vedata)

/* Progressive render samples are tagged with no rebuild, in that case we
* can skip updating the depth buffer */
if (ar && (ar->do_draw & RGN_DRAW_NO_REBUILD)) {
if (region && (region->do_draw & RGN_DRAW_NO_REBUILD)) {
stl->g_data->update_depth = false;
}
}
@@ -182,7 +182,7 @@ static void external_draw_scene_do(void *vedata)
const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
RegionView3D *rv3d = draw_ctx->rv3d;
ARegion *ar = draw_ctx->ar;
ARegion *region = draw_ctx->region;
RenderEngineType *type;

DRW_state_reset_ex(DRW_STATE_DEFAULT & ~DRW_STATE_DEPTH_LESS_EQUAL);
@@ -205,7 +205,7 @@ static void external_draw_scene_do(void *vedata)
/* Rendered draw. */
GPU_matrix_push_projection();
GPU_matrix_push();
ED_region_pixelspace(ar);
ED_region_pixelspace(region);

/* Render result draw. */
type = rv3d->render_engine->type;
@@ -379,7 +379,7 @@ GPUBatch *gpencil_get_buffer_stroke_geom(bGPdata *gpd, short thickness)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
ARegion *ar = draw_ctx->ar;
ARegion *region = draw_ctx->region;
RegionView3D *rv3d = draw_ctx->rv3d;
ToolSettings *ts = scene->toolsettings;
Object *ob = draw_ctx->obact;
@@ -413,13 +413,13 @@ GPUBatch *gpencil_get_buffer_stroke_geom(bGPdata *gpd, short thickness)
ED_gp_get_drawing_reference(scene, ob, gpl, ts->gpencil_v3d_align, origin);

for (int i = 0; i < totpoints; i++, tpt++) {
ED_gpencil_tpoint_to_point(ar, origin, tpt, &pt);
ED_gpencil_tpoint_to_point(region, origin, tpt, &pt);
ED_gp_project_point_to_plane(scene, ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt);

/* first point for adjacency (not drawn) */
if (i == 0) {
if (gpd->runtime.sbuffer_sflag & GP_STROKE_CYCLIC && totpoints > 2) {
ED_gpencil_tpoint_to_point(ar, origin, &points[totpoints - 1], &pt2);
ED_gpencil_tpoint_to_point(region, origin, &points[totpoints - 1], &pt2);
gpencil_set_stroke_point(vbo,
&pt2,
idx,
@@ -432,7 +432,7 @@ GPUBatch *gpencil_get_buffer_stroke_geom(bGPdata *gpd, short thickness)
idx++;
}
else {
ED_gpencil_tpoint_to_point(ar, origin, &points[1], &pt2);
ED_gpencil_tpoint_to_point(region, origin, &points[1], &pt2);
gpencil_set_stroke_point(vbo,
&pt2,
idx,
@@ -455,19 +455,19 @@ GPUBatch *gpencil_get_buffer_stroke_geom(bGPdata *gpd, short thickness)
/* last adjacency point (not drawn) */
if (gpd->runtime.sbuffer_sflag & GP_STROKE_CYCLIC && totpoints > 2) {
/* draw line to first point to complete the cycle */
ED_gpencil_tpoint_to_point(ar, origin, &points[0], &pt2);
ED_gpencil_tpoint_to_point(region, origin, &points[0], &pt2);
gpencil_set_stroke_point(
vbo, &pt2, idx, pos_id, color_id, thickness_id, uvdata_id, thickness, gpd->runtime.scolor);
idx++;
/* now add adjacency point (not drawn) */
ED_gpencil_tpoint_to_point(ar, origin, &points[1], &pt3);
ED_gpencil_tpoint_to_point(region, origin, &points[1], &pt3);
gpencil_set_stroke_point(
vbo, &pt3, idx, pos_id, color_id, thickness_id, uvdata_id, thickness, gpd->runtime.scolor);
idx++;
}
/* last adjacency point (not drawn) */
else {
ED_gpencil_tpoint_to_point(ar, origin, &points[totpoints - 2], &pt2);
ED_gpencil_tpoint_to_point(region, origin, &points[totpoints - 2], &pt2);
gpencil_set_stroke_point(
vbo, &pt2, idx, pos_id, color_id, thickness_id, uvdata_id, thickness, gpd->runtime.scolor);
idx++;
@@ -481,7 +481,7 @@ GPUBatch *gpencil_get_buffer_point_geom(bGPdata *gpd, short thickness)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
ARegion *ar = draw_ctx->ar;
ARegion *region = draw_ctx->region;
RegionView3D *rv3d = draw_ctx->rv3d;
ToolSettings *ts = scene->toolsettings;
Object *ob = draw_ctx->obact;
@@ -513,7 +513,7 @@ GPUBatch *gpencil_get_buffer_point_geom(bGPdata *gpd, short thickness)
ED_gp_get_drawing_reference(scene, ob, gpl, ts->gpencil_v3d_align, origin);

for (int i = 0; i < totpoints; i++, tpt++) {
ED_gpencil_tpoint_to_point(ar, origin, tpt, &pt);
ED_gpencil_tpoint_to_point(region, origin, tpt, &pt);
ED_gp_project_point_to_plane(scene, ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt);

/* use previous point to determine stroke direction (drawing path) */
@@ -524,7 +524,7 @@ GPUBatch *gpencil_get_buffer_point_geom(bGPdata *gpd, short thickness)
if (totpoints > 1) {
/* extrapolate a point before first point */
tGPspoint *tpt2 = &points[1];
ED_gpencil_tpoint_to_point(ar, origin, tpt2, &pt2);
ED_gpencil_tpoint_to_point(region, origin, tpt2, &pt2);
ED_gp_project_point_to_plane(scene, ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt2);

interp_v3_v3v3(ref_pt, &pt2.x, &pt.x, 1.5f);
@@ -535,7 +535,7 @@ GPUBatch *gpencil_get_buffer_point_geom(bGPdata *gpd, short thickness)
}
else {
tGPspoint *tpt2 = &points[i - 1];
ED_gpencil_tpoint_to_point(ar, origin, tpt2, &pt2);
ED_gpencil_tpoint_to_point(region, origin, tpt2, &pt2);
ED_gp_project_point_to_plane(scene, ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt2);

copy_v3_v3(ref_pt, &pt2.x);
@@ -638,7 +638,7 @@ GPUBatch *gpencil_get_buffer_fill_geom(bGPdata *gpd)

const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
ARegion *ar = draw_ctx->ar;
ARegion *region = draw_ctx->region;
ToolSettings *ts = scene->toolsettings;
Object *ob = draw_ctx->obact;

@@ -684,7 +684,7 @@ GPUBatch *gpencil_get_buffer_fill_geom(bGPdata *gpd)
for (int i = 0; i < tot_triangles; i++) {
for (int j = 0; j < 3; j++) {
tpt = &points[tmp_triangles[i][j]];
ED_gpencil_tpoint_to_point(ar, origin, tpt, &pt);
ED_gpencil_tpoint_to_point(region, origin, tpt, &pt);
GPU_vertbuf_attr_set(vbo, pos_id, idx, &pt.x);
GPU_vertbuf_attr_set(vbo, color_id, idx, gpd->runtime.sfill);
idx++;
@@ -739,7 +739,7 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)

bGPdata *gpd_orig = (bGPdata *)DEG_get_original_id(&gpd->id);
if ((draw_ctx->obact == ob) &&
((gpd_orig->runtime.ar == NULL) || (gpd_orig->runtime.ar == draw_ctx->ar))) {
((gpd_orig->runtime.ar == NULL) || (gpd_orig->runtime.ar == draw_ctx->region))) {
gpencil_populate_buffer_strokes(&e_data, vedata, ts, ob);
}

@@ -333,7 +333,7 @@ void OVERLAY_edit_mesh_cache_populate(OVERLAY_Data *vedata, Object *ob)

if (DRW_state_show_text() && (pd->edit_mesh.flag & OVERLAY_EDIT_TEXT)) {
const DRWContextState *draw_ctx = DRW_context_state_get();
DRW_text_edit_mesh_measure_stats(draw_ctx->ar, draw_ctx->v3d, ob, &draw_ctx->scene->unit);
DRW_text_edit_mesh_measure_stats(draw_ctx->region, draw_ctx->v3d, ob, &draw_ctx->scene->unit);
}
}

@@ -136,7 +136,7 @@ static void select_engine_init(void *vedata)
DRW_view_viewmat_get(view_default, viewmat, false);
DRW_view_winmat_get(view_default, winmat, false);
projmat_from_subregion(winmat,
(int[2]){draw_ctx->ar->winx, draw_ctx->ar->winy},
(int[2]){draw_ctx->region->winx, draw_ctx->region->winy},
e_data.context.last_rect.xmin,
e_data.context.last_rect.xmax,
e_data.context.last_rect.ymin,
@@ -634,7 +634,7 @@ bool DRW_state_draw_background(void);
/* Avoid too many lookups while drawing */
typedef struct DRWContextState {

struct ARegion *ar; /* 'CTX_wm_region(C)' */
struct ARegion *region; /* 'CTX_wm_region(C)' */
struct RegionView3D *rv3d; /* 'CTX_wm_region_view3d(C)' */
struct View3D *v3d; /* 'CTX_wm_view3d(C)' */

@@ -1061,7 +1061,7 @@ static void drw_engines_draw_text(void)
PROFILE_START(stime);

if (data->text_draw_cache) {
DRW_text_cache_draw(data->text_draw_cache, DST.draw_ctx.ar, DST.draw_ctx.v3d);
DRW_text_cache_draw(data->text_draw_cache, DST.draw_ctx.region, DST.draw_ctx.v3d);
}

PROFILE_END_UPDATE(data->render_time, stime);
@@ -1226,9 +1226,9 @@ static bool drw_gpencil_engine_needed(Depsgraph *depsgraph, View3D *v3d)
void DRW_notify_view_update(const DRWUpdateContext *update_ctx)
{
RenderEngineType *engine_type = update_ctx->engine_type;
ARegion *ar = update_ctx->ar;
ARegion *region = update_ctx->region;
View3D *v3d = update_ctx->v3d;
RegionView3D *rv3d = ar->regiondata;
RegionView3D *rv3d = region->regiondata;
Depsgraph *depsgraph = update_ctx->depsgraph;
Scene *scene = update_ctx->scene;
ViewLayer *view_layer = update_ctx->view_layer;
@@ -1237,7 +1237,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)

/* Separate update for each stereo view. */
for (int view = 0; view < 2; view++) {
GPUViewport *viewport = WM_draw_region_get_viewport(ar, view);
GPUViewport *viewport = WM_draw_region_get_viewport(region, view);
if (!viewport) {
continue;
}
@@ -1252,7 +1252,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)

DST.viewport = viewport;
DST.draw_ctx = (DRWContextState){
.ar = ar,
.region = region,
.rv3d = rv3d,
.v3d = v3d,
.scene = scene,
@@ -1297,15 +1297,15 @@ void DRW_draw_callbacks_pre_scene(void)
GPU_matrix_set(rv3d->viewmat);

if (DST.draw_ctx.evil_C) {
ED_region_draw_cb_draw(DST.draw_ctx.evil_C, DST.draw_ctx.ar, REGION_DRAW_PRE_VIEW);
ED_region_draw_cb_draw(DST.draw_ctx.evil_C, DST.draw_ctx.region, REGION_DRAW_PRE_VIEW);
DRW_state_reset();
}
}

void DRW_draw_callbacks_post_scene(void)
{
RegionView3D *rv3d = DST.draw_ctx.rv3d;
ARegion *ar = DST.draw_ctx.ar;
ARegion *region = DST.draw_ctx.region;
View3D *v3d = DST.draw_ctx.v3d;
Depsgraph *depsgraph = DST.draw_ctx.depsgraph;

@@ -1330,14 +1330,14 @@ void DRW_draw_callbacks_post_scene(void)
if (do_annotations) {
GPU_depth_test(false);
/* XXX: as scene->gpd is not copied for COW yet */
ED_annotation_draw_view3d(DEG_get_input_scene(depsgraph), depsgraph, v3d, ar, true);
ED_annotation_draw_view3d(DEG_get_input_scene(depsgraph), depsgraph, v3d, region, true);
GPU_depth_test(true);
}

drw_debug_draw();

GPU_depth_test(false);
ED_region_draw_cb_draw(DST.draw_ctx.evil_C, DST.draw_ctx.ar, REGION_DRAW_POST_VIEW);
ED_region_draw_cb_draw(DST.draw_ctx.evil_C, DST.draw_ctx.region, REGION_DRAW_POST_VIEW);

/* Callback can be nasty and do whatever they want with the state.
* Don't trust them! */
@@ -1359,7 +1359,7 @@ void DRW_draw_callbacks_post_scene(void)
if (((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) && (do_annotations)) {
GPU_depth_test(false);
/* XXX: as scene->gpd is not copied for COW yet */
ED_annotation_draw_view3d(DEG_get_input_scene(depsgraph), depsgraph, v3d, ar, false);
ED_annotation_draw_view3d(DEG_get_input_scene(depsgraph), depsgraph, v3d, region, false);
}

if ((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0) {
@@ -1372,7 +1372,7 @@ void DRW_draw_callbacks_post_scene(void)
if (G.debug_value > 20 && G.debug_value < 30) {
GPU_depth_test(false);
/* local coordinate visible rect inside region, to accommodate overlapping ui */
const rcti *rect = ED_region_visible_rect(DST.draw_ctx.ar);
const rcti *rect = ED_region_visible_rect(DST.draw_ctx.region);
DRW_stats_draw(rect);
}

@@ -1401,11 +1401,11 @@ struct DRWTextStore *DRW_text_cache_ensure(void)
void DRW_draw_view(const bContext *C)
{
Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
ARegion *ar = CTX_wm_region(C);
ARegion *region = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = DEG_get_evaluated_scene(depsgraph);
RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
GPUViewport *viewport = WM_draw_region_get_bound_viewport(ar);
GPUViewport *viewport = WM_draw_region_get_bound_viewport(region);

/* Reset before using it. */
drw_state_prepare_clean_for_draw(&DST);
@@ -1414,7 +1414,7 @@ void DRW_draw_view(const bContext *C)
DST.options.draw_background = (scene->r.alphamode == R_ADDSKY) ||
(v3d->shading.type != OB_RENDER);
DST.options.do_color_management = true;
DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, viewport, C);
DRW_draw_render_loop_ex(depsgraph, engine_type, region, v3d, viewport, C);
}

/**
@@ -1423,22 +1423,22 @@ void DRW_draw_view(const bContext *C)
*/
void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph,
RenderEngineType *engine_type,
ARegion *ar,
ARegion *region,
View3D *v3d,
GPUViewport *viewport,
const bContext *evil_C)
{

Scene *scene = DEG_get_evaluated_scene(depsgraph);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
RegionView3D *rv3d = ar->regiondata;
RegionView3D *rv3d = region->regiondata;

DST.draw_ctx.evil_C = evil_C;
DST.viewport = viewport;

/* Setup viewport */
DST.draw_ctx = (DRWContextState){
.ar = ar,
.region = region,
.rv3d = rv3d,
.v3d = v3d,
.scene = scene,
@@ -1535,7 +1535,7 @@ void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph,

DRW_draw_callbacks_post_scene();

if (WM_draw_region_get_bound_viewport(ar)) {
if (WM_draw_region_get_bound_viewport(region)) {
/* Don't unbind the framebuffer yet in this case and let
* GPU_viewport_unbind do it, so that we can still do further
* drawing of action zones on top. */
@@ -1556,7 +1556,7 @@ void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph,
}

void DRW_draw_render_loop(struct Depsgraph *depsgraph,
ARegion *ar,
ARegion *region,
View3D *v3d,
GPUViewport *viewport)
{
@@ -1566,15 +1566,15 @@ void DRW_draw_render_loop(struct Depsgraph *depsgraph,
Scene *scene = DEG_get_evaluated_scene(depsgraph);
RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);

DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, viewport, NULL);
DRW_draw_render_loop_ex(depsgraph, engine_type, region, v3d, viewport, NULL);
}

/**
* \param viewport: can be NULL, in this case we create one.
*/
void DRW_draw_render_loop_offscreen(struct Depsgraph *depsgraph,
RenderEngineType *engine_type,
ARegion *ar,
ARegion *region,
View3D *v3d,
const bool draw_background,
const bool do_color_management,
@@ -1594,7 +1594,7 @@ void DRW_draw_render_loop_offscreen(struct Depsgraph *depsgraph,
DST.options.is_image_render = true;
DST.options.do_color_management = do_color_management;
DST.options.draw_background = draw_background;
DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, render_viewport, NULL);
DRW_draw_render_loop_ex(depsgraph, engine_type, region, v3d, render_viewport, NULL);

if (draw_background) {
/* HACK(fclem): In this case we need to make sure the final alpha is 1.
@@ -2005,7 +2005,7 @@ void DRW_render_instance_buffer_finish(void)
* object mode select-loop, see: ED_view3d_draw_select_loop (legacy drawing).
*/
void DRW_draw_select_loop(struct Depsgraph *depsgraph,
ARegion *ar,
ARegion *region,
View3D *v3d,
bool UNUSED(use_obedit_skip),
bool draw_surface,
@@ -2022,9 +2022,9 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
Object *obact = OBACT(view_layer);
Object *obedit = OBEDIT_FROM_OBACT(obact);
#ifndef USE_GPU_SELECT
UNUSED_VARS(scene, view_layer, v3d, ar, rect);
UNUSED_VARS(scene, view_layer, v3d, region, rect);
#else
RegionView3D *rv3d = ar->regiondata;
RegionView3D *rv3d = region->regiondata;

/* Reset before using it. */
drw_state_prepare_clean_for_draw(&DST);
@@ -2102,7 +2102,7 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,

/* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
DST.draw_ctx = (DRWContextState){
.ar = ar,
.region = region,
.rv3d = rv3d,
.v3d = v3d,
.scene = scene,
@@ -2242,15 +2242,15 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
* object mode select-loop, see: ED_view3d_draw_depth_loop (legacy drawing).
*/
static void drw_draw_depth_loop_imp(struct Depsgraph *depsgraph,
ARegion *ar,
ARegion *region,
View3D *v3d,
GPUViewport *viewport,
const bool use_opengl_context)
{
Scene *scene = DEG_get_evaluated_scene(depsgraph);
RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
RegionView3D *rv3d = ar->regiondata;
RegionView3D *rv3d = region->regiondata;

if (use_opengl_context) {
DRW_opengl_context_enable();
@@ -2261,7 +2261,7 @@ static void drw_draw_depth_loop_imp(struct Depsgraph *depsgraph,

/* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
DST.draw_ctx = (DRWContextState){
.ar = ar,
.region = region,
.rv3d = rv3d,
.v3d = v3d,
.scene = scene,
@@ -2347,7 +2347,7 @@ static void drw_draw_depth_loop_imp(struct Depsgraph *depsgraph,
* object mode select-loop, see: ED_view3d_draw_depth_loop (legacy drawing).
*/
void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
ARegion *ar,
ARegion *region,
View3D *v3d,
GPUViewport *viewport,
bool use_opengl_context)
@@ -2366,14 +2366,14 @@ void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
}
}

drw_draw_depth_loop_imp(depsgraph, ar, v3d, viewport, use_opengl_context);
drw_draw_depth_loop_imp(depsgraph, region, v3d, viewport, use_opengl_context);
}

/**
* Converted from ED_view3d_draw_depth_gpencil (legacy drawing).
*/
void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph,
ARegion *ar,
ARegion *region,
View3D *v3d,
GPUViewport *viewport)
{
@@ -2382,10 +2382,10 @@ void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph,

use_drw_engine(&draw_engine_gpencil_type);

drw_draw_depth_loop_imp(depsgraph, ar, v3d, viewport, true);
drw_draw_depth_loop_imp(depsgraph, region, v3d, viewport, true);
}

void DRW_draw_select_id(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, const rcti *rect)
void DRW_draw_select_id(Depsgraph *depsgraph, ARegion *region, View3D *v3d, const rcti *rect)
{
Scene *scene = DEG_get_evaluated_scene(depsgraph);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
@@ -2395,8 +2395,8 @@ void DRW_draw_select_id(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, const rc

/* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
DST.draw_ctx = (DRWContextState){
.ar = ar,
.rv3d = ar->regiondata,
.region = region,
.rv3d = region->regiondata,
.v3d = v3d,
.scene = scene,
.view_layer = view_layer,
@@ -2407,7 +2407,7 @@ void DRW_draw_select_id(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, const rc
drw_context_state_init();

/* Setup viewport */
DST.viewport = WM_draw_region_get_viewport(ar, 0);
DST.viewport = WM_draw_region_get_viewport(region, 0);
drw_viewport_var_init();

/* Update ubos */
@@ -2463,9 +2463,9 @@ static void draw_world_clip_planes_from_rv3d(GPUBatch *batch, const float world_
/**
* Clears the Depth Buffer and draws only the specified object.
*/
void DRW_draw_depth_object(ARegion *ar, View3D *v3d, GPUViewport *viewport, Object *object)
void DRW_draw_depth_object(ARegion *region, View3D *v3d, GPUViewport *viewport, Object *object)
{
RegionView3D *rv3d = ar->regiondata;
RegionView3D *rv3d = region->regiondata;

DRW_opengl_context_enable();
GPU_matrix_projection_set(rv3d->winmat);
@@ -119,9 +119,9 @@ void DRW_text_cache_add(DRWTextStore *dt,
}
}

void DRW_text_cache_draw(DRWTextStore *dt, ARegion *ar, struct View3D *v3d)
void DRW_text_cache_draw(DRWTextStore *dt, ARegion *region, struct View3D *v3d)
{
RegionView3D *rv3d = ar->regiondata;
RegionView3D *rv3d = region->regiondata;
ViewCachedString *vos;
int tot = 0;

@@ -130,7 +130,7 @@ void DRW_text_cache_draw(DRWTextStore *dt, ARegion *ar, struct View3D *v3d)
BLI_memiter_iter_init(dt->cache_strings, &it);
while ((vos = BLI_memiter_iter_step(&it))) {
if (ED_view3d_project_short_ex(
ar,
region,
(vos->flag & DRW_TEXT_CACHE_GLOBALSPACE) ? rv3d->persmat : rv3d->persmatob,
(vos->flag & DRW_TEXT_CACHE_LOCALCLIP) != 0,
vos->vec,
@@ -153,7 +153,7 @@ void DRW_text_cache_draw(DRWTextStore *dt, ARegion *ar, struct View3D *v3d)

float original_proj[4][4];
GPU_matrix_projection_get(original_proj);
wmOrtho2_region_pixelspace(ar);
wmOrtho2_region_pixelspace(region);

GPU_matrix_push();
GPU_matrix_identity_set();
@@ -192,7 +192,7 @@ void DRW_text_cache_draw(DRWTextStore *dt, ARegion *ar, struct View3D *v3d)
}

/* Copied from drawobject.c */
void DRW_text_edit_mesh_measure_stats(ARegion *ar,
void DRW_text_edit_mesh_measure_stats(ARegion *region,
View3D *v3d,
Object *ob,
const UnitSettings *unit)
@@ -251,9 +251,9 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
if (v3d->overlay.edit_flag &
(V3D_OVERLAY_EDIT_EDGE_LEN | V3D_OVERLAY_EDIT_EDGE_ANG | V3D_OVERLAY_EDIT_INDICES)) {
BoundBox bb;
const rcti rect = {0, ar->winx, 0, ar->winy};
const rcti rect = {0, region->winx, 0, region->winy};

ED_view3d_clipping_calc(&bb, clip_planes, ar, ob, &rect);
ED_view3d_clipping_calc(&bb, clip_planes, region, ob, &rect);
}

if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN) {
@@ -41,9 +41,9 @@ void DRW_text_cache_add(struct DRWTextStore *dt,
short flag,
const uchar col[4]);

void DRW_text_cache_draw(struct DRWTextStore *dt, struct ARegion *ar, struct View3D *v3d);
void DRW_text_cache_draw(struct DRWTextStore *dt, struct ARegion *region, struct View3D *v3d);

void DRW_text_edit_mesh_measure_stats(struct ARegion *ar,
void DRW_text_edit_mesh_measure_stats(struct ARegion *region,
struct View3D *v3d,
struct Object *ob,
const struct UnitSettings *unit);
@@ -48,7 +48,7 @@

/* Main function to read a block of pixels from the select frame buffer. */
uint *DRW_select_buffer_read(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
const rcti *rect,
uint *r_buf_len)
@@ -59,9 +59,9 @@ uint *DRW_select_buffer_read(struct Depsgraph *depsgraph,
/* Clamp rect. */
rcti r = {
.xmin = 0,
.xmax = ar->winx,
.xmax = region->winx,
.ymin = 0,
.ymax = ar->winy,
.ymax = region->winy,
};

/* Make sure that the rect is within the bounds of the viewport.
@@ -72,11 +72,11 @@ uint *DRW_select_buffer_read(struct Depsgraph *depsgraph,

DRW_opengl_context_enable();
/* Update the drawing. */
DRW_draw_select_id(depsgraph, ar, v3d, rect);
DRW_draw_select_id(depsgraph, region, v3d, rect);

if (select_ctx->index_drawn_len > 1) {
BLI_assert(ar->winx == GPU_texture_width(DRW_engine_select_texture_get()) &&
ar->winy == GPU_texture_height(DRW_engine_select_texture_get()));
BLI_assert(region->winx == GPU_texture_width(DRW_engine_select_texture_get()) &&
region->winy == GPU_texture_height(DRW_engine_select_texture_get()));

/* Read the UI32 pixels. */
buf_len = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect);
@@ -126,7 +126,7 @@ uint *DRW_select_buffer_read(struct Depsgraph *depsgraph,
* \returns a #BLI_bitmap the length of \a bitmap_len or NULL on failure.
*/
uint *DRW_select_buffer_bitmap_from_rect(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
const rcti *rect,
uint *r_bitmap_len)
@@ -138,7 +138,7 @@ uint *DRW_select_buffer_bitmap_from_rect(struct Depsgraph *depsgraph,
rect_px.ymax += 1;

uint buf_len;
uint *buf = DRW_select_buffer_read(depsgraph, ar, v3d, &rect_px, &buf_len);
uint *buf = DRW_select_buffer_read(depsgraph, region, v3d, &rect_px, &buf_len);
if (buf == NULL) {
return NULL;
}
@@ -171,7 +171,7 @@ uint *DRW_select_buffer_bitmap_from_rect(struct Depsgraph *depsgraph,
* \returns a #BLI_bitmap the length of \a bitmap_len or NULL on failure.
*/
uint *DRW_select_buffer_bitmap_from_circle(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
const int center[2],
const int radius,
@@ -186,7 +186,7 @@ uint *DRW_select_buffer_bitmap_from_circle(struct Depsgraph *depsgraph,
.ymax = center[1] + radius + 1,
};

const uint *buf = DRW_select_buffer_read(depsgraph, ar, v3d, &rect, NULL);
const uint *buf = DRW_select_buffer_read(depsgraph, region, v3d, &rect, NULL);

if (buf == NULL) {
return NULL;
@@ -241,7 +241,7 @@ static void drw_select_mask_px_cb(int x, int x_end, int y, void *user_data)
* \returns a #BLI_bitmap.
*/
uint *DRW_select_buffer_bitmap_from_poly(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
const int poly[][2],
const int poly_len,
@@ -255,7 +255,7 @@ uint *DRW_select_buffer_bitmap_from_poly(struct Depsgraph *depsgraph,
rect_px.ymax += 1;

uint buf_len;
uint *buf = DRW_select_buffer_read(depsgraph, ar, v3d, &rect_px, &buf_len);
uint *buf = DRW_select_buffer_read(depsgraph, region, v3d, &rect_px, &buf_len);
if (buf == NULL) {
return NULL;
}
@@ -312,7 +312,7 @@ uint *DRW_select_buffer_bitmap_from_poly(struct Depsgraph *depsgraph,
* Samples a single pixel.
*/
uint DRW_select_buffer_sample_point(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
const int center[2])
{
@@ -326,7 +326,7 @@ uint DRW_select_buffer_sample_point(struct Depsgraph *depsgraph,
};

uint buf_len;
uint *buf = DRW_select_buffer_read(depsgraph, ar, v3d, &rect, &buf_len);
uint *buf = DRW_select_buffer_read(depsgraph, region, v3d, &rect, &buf_len);
if (buf) {
BLI_assert(0 != buf_len);
ret = buf[0];
@@ -342,7 +342,7 @@ uint DRW_select_buffer_sample_point(struct Depsgraph *depsgraph,
* when found, this value is set to the distance of the selection that's returned.
*/
uint DRW_select_buffer_find_nearest_to_point(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct ARegion *region,
struct View3D *v3d,
const int center[2],
const uint id_min,
@@ -369,7 +369,7 @@ uint DRW_select_buffer_find_nearest_to_point(struct Depsgraph *depsgraph,
/* Read from selection framebuffer. */

uint buf_len;
const uint *buf = DRW_select_buffer_read(depsgraph, ar, v3d, &rect, &buf_len);
const uint *buf = DRW_select_buffer_read(depsgraph, region, v3d, &rect, &buf_len);

if (buf == NULL) {
return index;
@@ -50,11 +50,11 @@
void DRW_draw_region_info(void)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
ARegion *ar = draw_ctx->ar;
ARegion *region = draw_ctx->region;

DRW_draw_cursor();

view3d_draw_region_info(draw_ctx->evil_C, ar);
view3d_draw_region_info(draw_ctx->evil_C, region);
}

/* **************************** 3D Cursor ******************************** */
@@ -99,7 +99,7 @@ static bool is_cursor_visible(const DRWContextState *draw_ctx, Scene *scene, Vie
void DRW_draw_cursor(void)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
ARegion *ar = draw_ctx->ar;
ARegion *region = draw_ctx->region;
Scene *scene = draw_ctx->scene;
ViewLayer *view_layer = draw_ctx->view_layer;

@@ -114,9 +114,9 @@ void DRW_draw_cursor(void)
const View3DCursor *cursor = &scene->cursor;

if (ED_view3d_project_int_global(
ar, cursor->location, co, V3D_PROJ_TEST_NOP | V3D_PROJ_TEST_CLIP_NEAR) ==
region, cursor->location, co, V3D_PROJ_TEST_NOP | V3D_PROJ_TEST_CLIP_NEAR) ==
V3D_PROJ_RET_OK) {
RegionView3D *rv3d = ar->regiondata;
RegionView3D *rv3d = region->regiondata;

float cursor_quat[4];
BKE_scene_cursor_rot_to_quat(cursor, cursor_quat);
@@ -178,7 +178,7 @@ void DRW_draw_cursor(void)
float original_proj[4][4];
GPU_matrix_projection_get(original_proj);
GPU_matrix_push();
ED_region_pixelspace(ar);
ED_region_pixelspace(region);
GPU_matrix_translate_2f(co[0] + 0.5f, co[1] + 0.5f);
GPU_matrix_scale_2f(U.widget_unit, U.widget_unit);

@@ -202,20 +202,20 @@ void DRW_draw_cursor(void)
void DRW_draw_gizmo_3d(void)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
ARegion *ar = draw_ctx->ar;
ARegion *region = draw_ctx->region;

/* draw depth culled gizmos - gizmos need to be updated *after* view matrix was set up */
/* TODO depth culling gizmos is not yet supported, just drawing _3D here, should
* later become _IN_SCENE (and draw _3D separate) */
WM_gizmomap_draw(ar->gizmo_map, draw_ctx->evil_C, WM_GIZMOMAP_DRAWSTEP_3D);
WM_gizmomap_draw(region->gizmo_map, draw_ctx->evil_C, WM_GIZMOMAP_DRAWSTEP_3D);
}

void DRW_draw_gizmo_2d(void)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
ARegion *ar = draw_ctx->ar;
ARegion *region = draw_ctx->region;

WM_gizmomap_draw(ar->gizmo_map, draw_ctx->evil_C, WM_GIZMOMAP_DRAWSTEP_2D);
WM_gizmomap_draw(region->gizmo_map, draw_ctx->evil_C, WM_GIZMOMAP_DRAWSTEP_2D);

glDepthMask(GL_TRUE);
}
@@ -114,7 +114,7 @@ static void acf_generic_root_backdrop(bAnimContext *ac,
float ymaxc)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
View2D *v2d = &ac->ar->v2d;
View2D *v2d = &ac->region->v2d;
short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0;
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
float color[3];
@@ -145,7 +145,7 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac,
float ymaxc)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
View2D *v2d = &ac->ar->v2d;
View2D *v2d = &ac->region->v2d;
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
float color[3];

@@ -253,7 +253,7 @@ static void acf_generic_channel_backdrop(bAnimContext *ac,
float ymaxc)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
View2D *v2d = &ac->ar->v2d;
View2D *v2d = &ac->region->v2d;
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
float color[3];

@@ -466,7 +466,7 @@ static void acf_summary_color(bAnimContext *UNUSED(ac),
static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
View2D *v2d = &ac->ar->v2d;
View2D *v2d = &ac->region->v2d;
float color[3];

/* set backdrop drawing color */
@@ -874,7 +874,7 @@ static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[
static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
View2D *v2d = &ac->ar->v2d;
View2D *v2d = &ac->region->v2d;
short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0;
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
float color[3];
@@ -1147,7 +1147,7 @@ static void acf_nla_controls_backdrop(bAnimContext *ac,
float ymaxc)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
View2D *v2d = &ac->ar->v2d;
View2D *v2d = &ac->region->v2d;
short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0;
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
float color[3];
@@ -3580,7 +3580,7 @@ static void acf_nlaaction_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, fl
static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
View2D *v2d = &ac->ar->v2d;
View2D *v2d = &ac->region->v2d;
AnimData *adt = ale->adt;
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
float color[4];
@@ -4010,7 +4010,7 @@ void ANIM_channel_draw(
bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc, size_t channel_index)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
View2D *v2d = &ac->ar->v2d;
View2D *v2d = &ac->region->v2d;
short selected, offset;
float y, ymid, ytext;

@@ -4741,7 +4741,7 @@ void ANIM_channel_draw_widgets(const bContext *C,
size_t channel_index)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
View2D *v2d = &ac->ar->v2d;
View2D *v2d = &ac->region->v2d;
float ymid;
const short channel_height = round_fl_to_int(BLI_rctf_size_y(rect));
const bool is_being_renamed = achannel_is_being_renamed(ac, acf, channel_index);
@@ -4871,7 +4871,7 @@ void ANIM_channel_draw_widgets(const bContext *C,
*/
if (acf->name_prop(ale, &ptr, &prop)) {
const short margin_x = 3 * round_fl_to_int(UI_DPI_FAC);
const short width = ac->ar->winx - offset - (margin_x * 2);
const short width = ac->region->winx - offset - (margin_x * 2);
uiBut *but;

UI_block_emboss_set(block, UI_EMBOSS);
@@ -4894,7 +4894,7 @@ void ANIM_channel_draw_widgets(const bContext *C,
NULL);

/* copy what outliner does here, see outliner_buttons */
if (UI_but_active_only(C, ac->ar, block, but) == false) {
if (UI_but_active_only(C, ac->region, block, but) == false) {
ac->ads->renameIndex = 0;

/* send notifiers */
@@ -2553,7 +2553,7 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm
int filter;

SpaceNla *snla = (SpaceNla *)ac->sl;
View2D *v2d = &ac->ar->v2d;
View2D *v2d = &ac->region->v2d;
rctf rectf;

/* convert border-region to view coordinates */
@@ -2736,20 +2736,20 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index)

/* free temp data and tag for refresh */
ANIM_animdata_freelist(&anim_data);
ED_region_tag_redraw(ac->ar);
ED_region_tag_redraw(ac->region);
return success;
}

static int animchannels_channel_get(bAnimContext *ac, const int mval[2])
{
ARegion *ar;
ARegion *region;
View2D *v2d;
int channel_index;
float x, y;

/* get useful pointers from animation context data */
ar = ac->ar;
v2d = &ar->v2d;
region = ac->region;
v2d = &region->v2d;

/* Figure out which channel user clicked in. */
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
@@ -3194,7 +3194,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
bAnimContext ac;
ARegion *ar;
ARegion *region;
View2D *v2d;
int channel_index;
int notifierFlags = 0;
@@ -3207,8 +3207,8 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE
}

/* get useful pointers from animation context data */
ar = ac.ar;
v2d = &ar->v2d;
region = ac.region;
v2d = &region->v2d;

/* select mode is either replace (deselect all, then add) or add/extend */
if (RNA_boolean_get(op->ptr, "extend")) {
@@ -3327,7 +3327,7 @@ static bool select_anim_channel_keys(bAnimContext *ac, int channel_index, bool e
}

/* free temp data and tag for refresh */
ED_region_tag_redraw(ac->ar);
ED_region_tag_redraw(ac->region);
return success;
}

@@ -615,9 +615,9 @@ static bool find_prev_next_keyframes(struct bContext *C, int *nextfra, int *prev

void ANIM_center_frame(struct bContext *C, int smooth_viewtx)
{
ARegion *ar = CTX_wm_region(C);
ARegion *region = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
float w = BLI_rctf_size_x(&ar->v2d.cur);
float w = BLI_rctf_size_x(&region->v2d.cur);
rctf newrct;
int nextfra, prevfra;

@@ -626,8 +626,8 @@ void ANIM_center_frame(struct bContext *C, int smooth_viewtx)
const float fps = FPS;
newrct.xmax = scene->r.cfra + U.view_frame_seconds * fps + 1;
newrct.xmin = scene->r.cfra - U.view_frame_seconds * fps - 1;
newrct.ymax = ar->v2d.cur.ymax;
newrct.ymin = ar->v2d.cur.ymin;
newrct.ymax = region->v2d.cur.ymax;
newrct.ymin = region->v2d.cur.ymin;
break;
}

@@ -636,8 +636,8 @@ void ANIM_center_frame(struct bContext *C, int smooth_viewtx)
if (find_prev_next_keyframes(C, &nextfra, &prevfra)) {
newrct.xmax = nextfra;
newrct.xmin = prevfra;
newrct.ymax = ar->v2d.cur.ymax;
newrct.ymin = ar->v2d.cur.ymin;
newrct.ymax = region->v2d.cur.ymax;
newrct.ymin = region->v2d.cur.ymin;
break;
}
/* else drop through, keep range instead */
@@ -647,11 +647,11 @@ void ANIM_center_frame(struct bContext *C, int smooth_viewtx)
default:
newrct.xmax = scene->r.cfra + (w / 2);
newrct.xmin = scene->r.cfra - (w / 2);
newrct.ymax = ar->v2d.cur.ymax;
newrct.ymin = ar->v2d.cur.ymin;
newrct.ymax = region->v2d.cur.ymax;
newrct.ymin = region->v2d.cur.ymin;
break;
}

UI_view2d_smooth_view(C, ar, &newrct, smooth_viewtx);
UI_view2d_smooth_view(C, region, &newrct, smooth_viewtx);
}
/* *************************************************** */
@@ -397,7 +397,7 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
{
Main *bmain = CTX_data_main(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
ARegion *region = CTX_wm_region(C);
SpaceLink *sl = CTX_wm_space_data(C);
Scene *scene = CTX_data_scene(C);

@@ -416,10 +416,10 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
ac->view_layer = CTX_data_view_layer(C);
ac->obact = (ac->view_layer->basact) ? ac->view_layer->basact->object : NULL;
ac->sa = sa;
ac->ar = ar;
ac->region = region;
ac->sl = sl;
ac->spacetype = (sa) ? sa->spacetype : 0;
ac->regiontype = (ar) ? ar->regiontype : 0;
ac->regiontype = (region) ? region->regiontype : 0;

/* initialise default y-scale factor */
animedit_get_yscale_factor(ac);
@@ -575,7 +575,7 @@ void ED_markers_draw(const bContext *C, int flag)
return;
}

ARegion *ar = CTX_wm_region(C);
ARegion *region = CTX_wm_region(C);
View2D *v2d = UI_view2d_fromcontext(C);
int cfra = CTX_data_scene(C)->r.cfra;

@@ -599,14 +599,14 @@ void ED_markers_draw(const bContext *C, int flag)
for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
if ((marker->flag & SELECT) == 0) {
if (marker_is_in_frame_range(marker, clip_frame_range)) {
draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, ar->winy);
draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, region->winy);
}
}
}
for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
if (marker->flag & SELECT) {
if (marker_is_in_frame_range(marker, clip_frame_range)) {
draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, ar->winy);
draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, region->winy);
}
}
}
@@ -870,10 +870,10 @@ static int ed_marker_move_invoke(bContext *C, wmOperator *op, const wmEvent *eve
{
bool tweak = RNA_boolean_get(op->ptr, "tweak");
if (tweak) {
ARegion *ar = CTX_wm_region(C);
View2D *v2d = &ar->v2d;
ARegion *region = CTX_wm_region(C);
View2D *v2d = &region->v2d;
ListBase *markers = ED_context_get_markers(C);
if (!region_position_is_over_marker(v2d, markers, event->x - ar->winrct.xmin)) {
if (!region_position_is_over_marker(v2d, markers, event->x - region->winrct.xmin)) {
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
}
@@ -1337,11 +1337,11 @@ static void MARKER_OT_select(wmOperatorType *ot)

static int ed_marker_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *ar = CTX_wm_region(C);
View2D *v2d = &ar->v2d;
ARegion *region = CTX_wm_region(C);
View2D *v2d = &region->v2d;

ListBase *markers = ED_context_get_markers(C);
bool over_marker = region_position_is_over_marker(v2d, markers, event->x - ar->winrct.xmin);
bool over_marker = region_position_is_over_marker(v2d, markers, event->x - region->winrct.xmin);

bool tweak = RNA_boolean_get(op->ptr, "tweak");
if (tweak && over_marker) {
@@ -403,16 +403,16 @@ static void ANIM_OT_end_frame_set(wmOperatorType *ot)
static int previewrange_define_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
ARegion *ar = CTX_wm_region(C);
ARegion *region = CTX_wm_region(C);
float sfra, efra;
rcti rect;

/* get min/max values from box select rect (already in region coordinates, not screen) */
WM_operator_properties_border_to_rcti(op, &rect);

/* convert min/max values to frames (i.e. region to 'tot' rect) */
sfra = UI_view2d_region_to_view_x(&ar->v2d, rect.xmin);
efra = UI_view2d_region_to_view_x(&ar->v2d, rect.xmax);
sfra = UI_view2d_region_to_view_x(&region->v2d, rect.xmin);
efra = UI_view2d_region_to_view_x(&region->v2d, rect.xmax);

/* set start/end frames for preview-range
* - must clamp within allowable limits
@@ -46,11 +46,11 @@

#include "RNA_access.h"

static void get_time_scrub_region_rect(const ARegion *ar, rcti *rect)
static void get_time_scrub_region_rect(const ARegion *region, rcti *rect)
{
rect->xmin = 0;
rect->xmax = ar->winx;
rect->ymax = ar->winy;
rect->xmax = region->winx;
rect->ymax = region->winy;
rect->ymin = rect->ymax - UI_TIME_SCRUB_MARGIN_Y;
}

@@ -134,62 +134,62 @@ static void draw_current_frame(const Scene *scene,
color);
}

void ED_time_scrub_draw(const ARegion *ar,
void ED_time_scrub_draw(const ARegion *region,
const Scene *scene,
bool display_seconds,
bool discrete_frames)
{
const View2D *v2d = &ar->v2d;
const View2D *v2d = &region->v2d;

GPU_matrix_push_projection();
wmOrtho2_region_pixelspace(ar);
wmOrtho2_region_pixelspace(region);

rcti scrub_region_rect;
get_time_scrub_region_rect(ar, &scrub_region_rect);
get_time_scrub_region_rect(region, &scrub_region_rect);

draw_background(&scrub_region_rect);

rcti numbers_rect = scrub_region_rect;
numbers_rect.ymin = get_centered_text_y(&scrub_region_rect) - 4 * UI_DPI_FAC;
if (discrete_frames) {
UI_view2d_draw_scale_x__discrete_frames_or_seconds(
ar, v2d, &numbers_rect, scene, display_seconds, TH_TEXT);
region, v2d, &numbers_rect, scene, display_seconds, TH_TEXT);
}
else {
UI_view2d_draw_scale_x__frames_or_seconds(
ar, v2d, &numbers_rect, scene, display_seconds, TH_TEXT);
region, v2d, &numbers_rect, scene, display_seconds, TH_TEXT);
}

draw_current_frame(scene, display_seconds, v2d, &scrub_region_rect, scene->r.cfra);

GPU_matrix_pop_projection();
}

bool ED_time_scrub_event_in_region(const ARegion *ar, const wmEvent *event)
bool ED_time_scrub_event_in_region(const ARegion *region, const wmEvent *event)
{
rcti rect = ar->winrct;
rcti rect = region->winrct;
rect.ymin = rect.ymax - UI_TIME_SCRUB_MARGIN_Y;
return BLI_rcti_isect_pt(&rect, event->x, event->y);
}

void ED_time_scrub_channel_search_draw(const bContext *C, ARegion *ar, bDopeSheet *dopesheet)
void ED_time_scrub_channel_search_draw(const bContext *C, ARegion *region, bDopeSheet *dopesheet)
{
GPU_matrix_push_projection();
wmOrtho2_region_pixelspace(ar);
wmOrtho2_region_pixelspace(region);

rcti rect;
rect.xmin = 0;
rect.xmax = ar->winx;
rect.ymin = ar->winy - UI_TIME_SCRUB_MARGIN_Y;
rect.ymax = ar->winy;
rect.xmax = region->winx;
rect.ymin = region->winy - UI_TIME_SCRUB_MARGIN_Y;
rect.ymax = region->winy;

uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_BACK);
immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
immUnbindProgram();

uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);

PointerRNA ptr;
RNA_pointer_create(&CTX_wm_screen(C)->id, &RNA_DopeSheet, dopesheet, &ptr);
@@ -228,21 +228,21 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, const wmEv

/* temporarily change 3d cursor position */
Scene *scene;
ARegion *ar;
ARegion *region;
View3D *v3d;
float tvec[3], oldcurs[3], mval_f[2];
int retv;

scene = CTX_data_scene(C);
ar = CTX_wm_region(C);
region = CTX_wm_region(C);
v3d = CTX_wm_view3d(C);

View3DCursor *cursor = &scene->cursor;

copy_v3_v3(oldcurs, cursor->location);

copy_v2fl_v2i(mval_f, event->mval);
ED_view3d_win_to_3d(v3d, ar, cursor->location, mval_f, tvec);
ED_view3d_win_to_3d(v3d, region, cursor->location, mval_f, tvec);
copy_v3_v3(cursor->location, tvec);

/* extrude to the where new cursor is and store the operation result */
@@ -88,7 +88,7 @@ typedef struct tPoseSlideOp {
/** area that we're operating in (needed for modal()) */
ScrArea *sa;
/** region that we're operating in (needed for modal()) */
ARegion *ar;
ARegion *region;
/** len of the PoseSlideObject array. */
uint objects_len;

@@ -197,8 +197,8 @@ static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode)

/* get info from context */
pso->scene = CTX_data_scene(C);
pso->sa = CTX_wm_area(C); /* only really needed when doing modal() */
pso->ar = CTX_wm_region(C); /* only really needed when doing modal() */
pso->sa = CTX_wm_area(C); /* only really needed when doing modal() */
pso->region = CTX_wm_region(C); /* only really needed when doing modal() */

pso->cframe = pso->scene->r.cfra;
pso->mode = mode;
@@ -1004,7 +1004,7 @@ static void pose_slide_mouse_update_percentage(tPoseSlideOp *pso,
wmOperator *op,
const wmEvent *event)
{
pso->percentage = (event->x - pso->ar->winrct.xmin) / ((float)pso->ar->winx);
pso->percentage = (event->x - pso->region->winrct.xmin) / ((float)pso->region->winx);
RNA_float_set(op->ptr, "percentage", pso->percentage);
}

@@ -5671,13 +5671,13 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
copy_v3_v3(location, vc.scene->cursor.location);
}

ED_view3d_win_to_3d_int(vc.v3d, vc.ar, location, event->mval, location);
ED_view3d_win_to_3d_int(vc.v3d, vc.region, location, event->mval, location);

if (use_proj) {
const float mval[2] = {UNPACK2(event->mval)};

struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
vc.bmain, vc.scene, vc.depsgraph, 0, vc.ar, vc.v3d);
vc.bmain, vc.scene, vc.depsgraph, 0, vc.region, vc.v3d);

ED_transform_snap_object_project_view3d(
snap_context,