diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-21 10:47:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-21 10:59:40 +0400 |
commit | 9ae0e585b0aab466c978ec1a55c824d902faa3b4 (patch) | |
tree | 6a99d63651f1b66ffacac2582b5f03d58898ad99 /source/blender/editors/space_image | |
parent | 6ee8670fca946d146332e80ceff29e459cd91ed5 (diff) |
View2d: API Cleanup for view<->region conversion
View2D had some inconsistencies making it error prone in some cases.
- Inconstant checking for NULL x/y args.
Disallow NULL args for x/y destination pointers, instead add:
- UI_view2d_region_to_view_x/y
- UI_view2d_view_to_region_x/y
- '_no_clip' suffix wasn't always used for non-clipping conversion,
switch it around and use a '_clip' suffix for all funcs that clip.
- UI_view2d_text_cache_add now clips before adding cache.
- '_clip' funcs return a bool to quickly check if its in the view.
- add conversion for rectangles, since this is a common task:
- UI_view2d_view_to_region_rcti
- UI_view2d_region_to_view_rctf
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_edit.c | 6 |
2 files changed, 7 insertions, 7 deletions
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 158f9ba031b..4e1b60123a6 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -107,7 +107,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar, float zoomx, rcti *tile; /* find window pixel coordinates of origin */ - UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); + UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); glPushMatrix(); glTranslatef(x, y, 0.0f); @@ -509,7 +509,7 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, glaDefine2DArea(&ar->winrct); /* find window pixel coordinates of origin */ - UI_view2d_to_region_no_clip(&ar->v2d, fx, fy, &x, &y); + UI_view2d_view_to_region(&ar->v2d, fx, fy, &x, &y); /* this part is generic image display */ if (sima->flag & SI_SHOW_ALPHA) { @@ -600,7 +600,7 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, /* draw repeated */ for (sy = 0; sy + dy <= ibuf->y; sy += dy) { for (sx = 0; sx + dx <= ibuf->x; sx += dx) { - UI_view2d_to_region_no_clip(&ar->v2d, fx + (float)sx / (float)ibuf->x, fy + (float)sy / (float)ibuf->y, &x, &y); + UI_view2d_view_to_region(&ar->v2d, fx + (float)sx / (float)ibuf->x, fy + (float)sy / (float)ibuf->y, &x, &y); glaDrawPixelsSafe(x, y, dx, dy, dx, GL_RGBA, GL_UNSIGNED_BYTE, rect); } @@ -779,7 +779,7 @@ static void draw_image_paint_helpers(const bContext *C, ARegion *ar, Scene *scen clonerect = get_alpha_clone_image(C, scene, &w, &h); if (clonerect) { - UI_view2d_to_region_no_clip(&ar->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y); + UI_view2d_view_to_region(&ar->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y); glPixelZoom(zoomx, zoomy); diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index deabcfa85f4..9c1bfd230e3 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -257,7 +257,7 @@ void ED_image_mouse_pos(SpaceImage *sima, ARegion *ar, const int mval[2], float ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy); ED_space_image_get_size(sima, &width, &height); - UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); + UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &sx, &sy); co[0] = ((mval[0] - sx) / zoomx) / width; co[1] = ((mval[1] - sy) / zoomy) / height; @@ -271,7 +271,7 @@ void ED_image_point_pos(SpaceImage *sima, ARegion *ar, float x, float y, float * ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy); ED_space_image_get_size(sima, &width, &height); - UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); + UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &sx, &sy); *xr = ((x - sx) / zoomx) / width; *yr = ((y - sy) / zoomy) / height; @@ -283,7 +283,7 @@ void ED_image_point_pos__reverse(SpaceImage *sima, ARegion *ar, const float co[2 int width, height; int sx, sy; - UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); + UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &sx, &sy); ED_space_image_get_size(sima, &width, &height); ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy); |