2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * Contributor(s): Blender Foundation, 2002-2009
23 * ***** END GPL LICENSE BLOCK *****
26 /** \file blender/editors/space_image/image_draw.c
35 #include "MEM_guardedalloc.h"
37 #include "DNA_camera_types.h"
38 #include "DNA_object_types.h"
39 #include "DNA_space_types.h"
40 #include "DNA_scene_types.h"
41 #include "DNA_screen_types.h"
42 #include "DNA_brush_types.h"
47 #include "BLI_threads.h"
48 #include "BLI_string.h"
49 #include "BLI_utildefines.h"
51 #include "IMB_imbuf.h"
52 #include "IMB_imbuf_types.h"
53 #include "IMB_colormanagement.h"
55 #include "BKE_context.h"
56 #include "BKE_global.h"
57 #include "BKE_image.h"
58 #include "BKE_paint.h"
61 #include "BIF_glutil.h"
65 #include "ED_gpencil.h"
67 #include "ED_screen.h"
69 #include "UI_interface.h"
70 #include "UI_resources.h"
71 #include "UI_view2d.h"
76 #include "RE_pipeline.h"
78 #include "image_intern.h"
80 #define HEADER_HEIGHT 18
82 static void image_verify_buffer_float(Image *ima, ImBuf *ibuf, int color_manage)
84 /* detect if we need to redo the curve map.
85 * ibuf->rect is zero for compositor and render results after change
86 * convert to 32 bits always... drawing float rects isn't supported well (atis)
88 * NOTE: if float buffer changes, we have to manually remove the rect
91 if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID)) ) {
93 if (ima && ima->source == IMA_SRC_VIEWER)
94 ibuf->profile = IB_PROFILE_LINEAR_RGB;
97 ibuf->profile = IB_PROFILE_NONE;
99 IMB_rect_from_float(ibuf);
103 static void draw_render_info(Scene *scene, Image *ima, ARegion *ar)
107 rr = BKE_image_acquire_renderresult(scene, ima);
109 if (rr && rr->text) {
110 ED_region_info_draw(ar, rr->text, 1, 0.25);
113 BKE_image_release_renderresult(scene, ima);
116 /* used by node view too */
117 void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int y,
118 const unsigned char cp[4], const float fp[4], int *zp, float *zpf)
123 /* XXX colored text not allowed in Blender UI */
125 unsigned char red[3] = {255, 50, 50};
126 unsigned char green[3] = {0, 255, 0};
127 unsigned char blue[3] = {100, 100, 255};
129 unsigned char red[3] = {255, 255, 255};
130 unsigned char green[3] = {255, 255, 255};
131 unsigned char blue[3] = {255, 255, 255};
133 float hue = 0, sat = 0, val = 0, lum = 0, u = 0, v = 0;
134 float col[4], finalcol[4];
136 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
139 /* noisy, high contrast make impossible to read if lower alpha is used. */
140 glColor4ub(0, 0, 0, 190);
141 glRecti(0.0, 0.0, ar->winrct.xmax - ar->winrct.xmin + 1, 20);
144 BLF_size(blf_mono_font, 11, 72);
146 glColor3ub(255, 255, 255);
147 BLI_snprintf(str, sizeof(str), "X:%-4d Y:%-4d |", x, y);
148 // UI_DrawString(6, 6, str); // works ok but fixed width is nicer.
149 BLF_position(blf_mono_font, dx, 6, 0);
150 BLF_draw_ascii(blf_mono_font, str, sizeof(str));
151 dx += BLF_width(blf_mono_font, str);
154 glColor3ub(255, 255, 255);
155 BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f + 0.5f * (((float)*zp) / (float)0x7fffffff));
156 BLF_position(blf_mono_font, dx, 6, 0);
157 BLF_draw_ascii(blf_mono_font, str, sizeof(str));
158 dx += BLF_width(blf_mono_font, str);
161 glColor3ub(255, 255, 255);
162 BLI_snprintf(str, sizeof(str), " Z:%-.3f |", *zpf);
163 BLF_position(blf_mono_font, dx, 6, 0);
164 BLF_draw_ascii(blf_mono_font, str, sizeof(str));
165 dx += BLF_width(blf_mono_font, str);
171 BLI_snprintf(str, sizeof(str), " R:%-.4f", fp[0]);
173 BLI_snprintf(str, sizeof(str), " R:%-3d", cp[0]);
175 BLI_snprintf(str, sizeof(str), " R:-");
176 BLF_position(blf_mono_font, dx, 6, 0);
177 BLF_draw_ascii(blf_mono_font, str, sizeof(str));
178 dx += BLF_width(blf_mono_font, str);
182 BLI_snprintf(str, sizeof(str), " G:%-.4f", fp[1]);
184 BLI_snprintf(str, sizeof(str), " G:%-3d", cp[1]);
186 BLI_snprintf(str, sizeof(str), " G:-");
187 BLF_position(blf_mono_font, dx, 6, 0);
188 BLF_draw_ascii(blf_mono_font, str, sizeof(str));
189 dx += BLF_width(blf_mono_font, str);
193 BLI_snprintf(str, sizeof(str), " B:%-.4f", fp[2]);
195 BLI_snprintf(str, sizeof(str), " B:%-3d", cp[2]);
197 BLI_snprintf(str, sizeof(str), " B:-");
198 BLF_position(blf_mono_font, dx, 6, 0);
199 BLF_draw_ascii(blf_mono_font, str, sizeof(str));
200 dx += BLF_width(blf_mono_font, str);
203 glColor3ub(255, 255, 255);
205 BLI_snprintf(str, sizeof(str), " A:%-.4f", fp[3]);
207 BLI_snprintf(str, sizeof(str), " A:%-3d", cp[3]);
209 BLI_snprintf(str, sizeof(str), "- ");
210 BLF_position(blf_mono_font, dx, 6, 0);
211 BLF_draw_ascii(blf_mono_font, str, sizeof(str));
212 dx += BLF_width(blf_mono_font, str);
216 /* color rectangle */
219 col[0] = col[1] = col[2] = fp[0];
222 col[0] = col[1] = col[2] = (float)cp[0] / 255.0f;
225 col[0] = col[1] = col[2] = 0.0f;
229 else if (channels == 3) {
234 rgb_uchar_to_float(col, cp);
241 else if (channels == 4) {
245 rgba_uchar_to_float(col, cp);
257 linearrgb_to_srgb_v4(finalcol, col);
260 copy_v4_v4(finalcol, col);
263 glColor3fv(finalcol);
268 glVertex2f(dx + 30, 17);
269 glVertex2f(dx + 30, 3);
273 glColor3ub(128, 128, 128);
274 glBegin(GL_LINE_LOOP);
277 glVertex2f(dx + 30, 17);
278 glVertex2f(dx + 30, 3);
283 glColor3ub(255, 255, 255);
286 rgb_to_hsv(fp[0], fp[0], fp[0], &hue, &sat, &val);
287 rgb_to_yuv(fp[0], fp[0], fp[0], &lum, &u, &v);
290 rgb_to_hsv((float)cp[0] / 255.0f, (float)cp[0] / 255.0f, (float)cp[0] / 255.0f, &hue, &sat, &val);
291 rgb_to_yuv((float)cp[0] / 255.0f, (float)cp[0] / 255.0f, (float)cp[0] / 255.0f, &lum, &u, &v);
294 BLI_snprintf(str, sizeof(str), "V:%-.4f", val);
295 BLF_position(blf_mono_font, dx, 6, 0);
296 BLF_draw_ascii(blf_mono_font, str, sizeof(str));
297 dx += BLF_width(blf_mono_font, str);
299 BLI_snprintf(str, sizeof(str), " L:%-.4f", lum);
300 BLF_position(blf_mono_font, dx, 6, 0);
301 BLF_draw_ascii(blf_mono_font, str, sizeof(str));
302 dx += BLF_width(blf_mono_font, str);
304 else if (channels >= 3) {
306 rgb_to_hsv(fp[0], fp[1], fp[2], &hue, &sat, &val);
307 rgb_to_yuv(fp[0], fp[1], fp[2], &lum, &u, &v);
310 rgb_to_hsv((float)cp[0] / 255.0f, (float)cp[1] / 255.0f, (float)cp[2] / 255.0f, &hue, &sat, &val);
311 rgb_to_yuv((float)cp[0] / 255.0f, (float)cp[1] / 255.0f, (float)cp[2] / 255.0f, &lum, &u, &v);
314 BLI_snprintf(str, sizeof(str), "H:%-.4f", hue);
315 BLF_position(blf_mono_font, dx, 6, 0);
316 BLF_draw_ascii(blf_mono_font, str, sizeof(str));
317 dx += BLF_width(blf_mono_font, str);
319 BLI_snprintf(str, sizeof(str), " S:%-.4f", sat);
320 BLF_position(blf_mono_font, dx, 6, 0);
321 BLF_draw_ascii(blf_mono_font, str, sizeof(str));
322 dx += BLF_width(blf_mono_font, str);
324 BLI_snprintf(str, sizeof(str), " V:%-.4f", val);
325 BLF_position(blf_mono_font, dx, 6, 0);
326 BLF_draw_ascii(blf_mono_font, str, sizeof(str));
327 dx += BLF_width(blf_mono_font, str);
329 BLI_snprintf(str, sizeof(str), " L:%-.4f", lum);
330 BLF_position(blf_mono_font, dx, 6, 0);
331 BLF_draw_ascii(blf_mono_font, str, sizeof(str));
332 dx += BLF_width(blf_mono_font, str);
340 static void sima_draw_alpha_pixels(float x1, float y1, int rectx, int recty, unsigned int *recti)
343 /* swap bytes, so alpha is most significant one, then just draw it as luminance int */
344 if (ENDIAN_ORDER == B_ENDIAN)
345 glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
347 glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_UNSIGNED_INT, recti);
348 glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
351 static void sima_draw_alpha_pixelsf(float x1, float y1, int rectx, int recty, float *rectf)
353 float *trectf = MEM_mallocN(rectx * recty * 4, "temp");
356 for (a = rectx * recty - 1, b = 4 * a + 3; a >= 0; a--, b -= 4)
357 trectf[a] = rectf[b];
359 glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_FLOAT, trectf);
361 /* ogl trick below is slower... (on ATI 9600) */
362 // glColorMask(1, 0, 0, 0);
363 // glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf+3);
364 // glColorMask(0, 1, 0, 0);
365 // glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf+2);
366 // glColorMask(0, 0, 1, 0);
367 // glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf+1);
368 // glColorMask(1, 1, 1, 1);
371 static void sima_draw_zbuf_pixels(float x1, float y1, int rectx, int recty, int *recti)
373 /* zbuffer values are signed, so we need to shift color range */
374 glPixelTransferf(GL_RED_SCALE, 0.5f);
375 glPixelTransferf(GL_GREEN_SCALE, 0.5f);
376 glPixelTransferf(GL_BLUE_SCALE, 0.5f);
377 glPixelTransferf(GL_RED_BIAS, 0.5f);
378 glPixelTransferf(GL_GREEN_BIAS, 0.5f);
379 glPixelTransferf(GL_BLUE_BIAS, 0.5f);
381 glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_INT, recti);
383 glPixelTransferf(GL_RED_SCALE, 1.0f);
384 glPixelTransferf(GL_GREEN_SCALE, 1.0f);
385 glPixelTransferf(GL_BLUE_SCALE, 1.0f);
386 glPixelTransferf(GL_RED_BIAS, 0.0f);
387 glPixelTransferf(GL_GREEN_BIAS, 0.0f);
388 glPixelTransferf(GL_BLUE_BIAS, 0.0f);
391 static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rectx, int recty, float *rect_float)
393 float bias, scale, *rectf, clipend;
396 if (scene->camera && scene->camera->type == OB_CAMERA) {
397 bias = ((Camera *)scene->camera->data)->clipsta;
398 clipend = ((Camera *)scene->camera->data)->clipend;
399 scale = 1.0f / (clipend - bias);
407 rectf = MEM_mallocN(rectx * recty * 4, "temp");
408 for (a = rectx * recty - 1; a >= 0; a--) {
409 if (rect_float[a] > clipend)
411 else if (rect_float[a] < bias)
414 rectf[a] = 1.0f - (rect_float[a] - bias) * scale;
415 rectf[a] *= rectf[a];
418 glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_FLOAT, rectf);
423 static void draw_image_buffer(wmWindow *win, SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
426 int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
429 glPixelZoom(zoomx, zoomy);
431 /* find window pixel coordinates of origin */
432 UI_view2d_to_region_no_clip(&ar->v2d, fx, fy, &x, &y);
434 /* this part is generic image display */
435 if (sima->flag & SI_SHOW_ALPHA) {
437 sima_draw_alpha_pixels(x, y, ibuf->x, ibuf->y, ibuf->rect);
438 else if (ibuf->rect_float && ibuf->channels == 4)
439 sima_draw_alpha_pixelsf(x, y, ibuf->x, ibuf->y, ibuf->rect_float);
441 else if (sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels == 1))) {
443 sima_draw_zbuf_pixels(x, y, ibuf->x, ibuf->y, ibuf->zbuf);
444 else if (ibuf->zbuf_float)
445 sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->zbuf_float);
446 else if (ibuf->channels == 1)
447 sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float);
450 const ColorManagedViewSettings *view_settings;
451 unsigned char *display_buffer;
454 if (sima->flag & SI_USE_ALPHA) {
455 fdrawcheckerboard(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy);
458 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
461 /* we don't draw floats buffers directly but
462 * convert them, and optionally apply curves */
463 image_verify_buffer_float(ima, ibuf, color_manage);
465 view_settings = IMB_view_settings_get_effective(win, &sima->view_settings);
466 display_buffer = IMB_display_buffer_acquire(ibuf, view_settings, &win->display_settings, &cache_handle);
469 glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
472 glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_FLOAT, ibuf->rect_float);
475 IMB_display_buffer_release(cache_handle);
477 if (sima->flag & SI_USE_ALPHA)
482 glPixelZoom(1.0f, 1.0f);
485 static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty, short endx, short endy)
487 unsigned int *rt, *rp, *rectmain;
488 short y, heigth, len;
490 /* the right offset in rectot */
492 rt = ibuf->rect + (starty * ibuf->x + startx);
494 len = (endx - startx);
495 heigth = (endy - starty);
497 rp = rectmain = MEM_mallocN(heigth * len * sizeof(int), "rect");
499 for (y = 0; y < heigth; y++) {
500 memcpy(rp, rt, len * 4);
507 static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
510 int dx, dy, sx, sy, x, y;
511 int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
513 /* verify valid values, just leave this a while */
514 if (ima->xrep < 1) return;
515 if (ima->yrep < 1) return;
517 glPixelZoom(zoomx, zoomy);
519 if (sima->curtile >= ima->xrep * ima->yrep)
520 sima->curtile = ima->xrep * ima->yrep - 1;
522 /* create char buffer from float if needed */
523 image_verify_buffer_float(ima, ibuf, color_manage);
525 /* retrieve part of image buffer */
526 dx = ibuf->x / ima->xrep;
527 dy = ibuf->y / ima->yrep;
528 sx = (sima->curtile % ima->xrep) * dx;
529 sy = (sima->curtile / ima->xrep) * dy;
530 rect = get_part_from_ibuf(ibuf, sx, sy, sx + dx, sy + dy);
533 for (sy = 0; sy + dy <= ibuf->y; sy += dy) {
534 for (sx = 0; sx + dx <= ibuf->x; sx += dx) {
535 UI_view2d_to_region_no_clip(&ar->v2d, fx + (float)sx / (float)ibuf->x, fy + (float)sy / (float)ibuf->y, &x, &y);
537 glaDrawPixelsSafe(x, y, dx, dy, dx, GL_RGBA, GL_UNSIGNED_BYTE, rect);
541 glPixelZoom(1.0f, 1.0f);
546 static void draw_image_buffer_repeated(wmWindow *win, SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float zoomx, float zoomy)
548 const double time_current = PIL_check_seconds_timer();
550 const int xmax = ceil(ar->v2d.cur.xmax);
551 const int ymax = ceil(ar->v2d.cur.ymax);
552 const int xmin = floor(ar->v2d.cur.xmin);
553 const int ymin = floor(ar->v2d.cur.ymin);
557 for (x = xmin; x < xmax; x++) {
559 for (y = ymin; y < ymax; y++) {
560 if (ima && (ima->tpageflag & IMA_TILES))
561 draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy);
563 draw_image_buffer(win, sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy);
565 /* only draw until running out of time */
566 if ((PIL_check_seconds_timer() - time_current) > 0.25)
574 /* draw grease pencil */
575 void draw_image_grease_pencil(bContext *C, short onlyv2d)
577 /* draw in View2D space? */
579 /* draw grease-pencil ('image' strokes) */
580 draw_gpencil_2dimage(C);
583 /* assume that UI_view2d_restore(C) has been called... */
584 //SpaceImage *sima= (SpaceImage *)CTX_wm_space_data(C);
586 /* draw grease-pencil ('screen' strokes) */
587 draw_gpencil_view2d(C, 0);
591 void draw_image_sample_line(SpaceImage *sima)
593 if (sima->sample_line_hist.flag & HISTO_FLAG_SAMPLELINE) {
594 Histogram *hist = &sima->sample_line_hist;
598 glVertex2fv(hist->co[0]);
599 glVertex2fv(hist->co[1]);
604 glColor3ub(255, 255, 255);
605 glVertex2fv(hist->co[0]);
606 glVertex2fv(hist->co[1]);
613 /* XXX becomes WM paint cursor */
615 static void draw_image_view_tool(Scene *scene)
617 ToolSettings *settings = scene->toolsettings;
618 Brush *brush = settings->imapaint.brush;
624 if (settings->imapaint.flag & IMAGEPAINT_DRAWING) {
625 if (settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL_DRAWING)
628 else if (settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL)
632 getmouseco_areawin(mval);
634 radius = BKE_brush_size_get(brush) * G.sima->zoom;
635 fdrawXORcirc(mval[0], mval[1], radius);
637 if (brush->innerradius != 1.0) {
638 radius *= brush->innerradius;
639 fdrawXORcirc(mval[0], mval[1], radius);
646 static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *height)
648 Brush *brush = paint_brush(&scene->toolsettings->imapaint.paint);
650 unsigned int size, alpha;
651 unsigned char *rect, *cp;
653 if (!brush || !brush->clone.image)
656 ibuf = BKE_image_get_ibuf(brush->clone.image, NULL);
658 if (!ibuf || !ibuf->rect)
661 rect = MEM_dupallocN(ibuf->rect);
668 size = (*width) * (*height);
669 alpha = (unsigned char)255 * brush->clone.alpha;
680 static void draw_image_paint_helpers(ARegion *ar, Scene *scene, float zoomx, float zoomy)
684 unsigned char *clonerect;
686 brush = paint_brush(&scene->toolsettings->imapaint.paint);
688 if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) {
689 /* this is not very efficient, but glDrawPixels doesn't allow
690 * drawing with alpha */
691 clonerect = get_alpha_clone_image(scene, &w, &h);
694 UI_view2d_to_region_no_clip(&ar->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y);
696 glPixelZoom(zoomx, zoomy);
699 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
700 glaDrawPixelsSafe(x, y, w, h, w, GL_RGBA, GL_UNSIGNED_BYTE, clonerect);
703 glPixelZoom(1.0, 1.0);
705 MEM_freeN(clonerect);
710 /* draw main image area */
712 void draw_image_main(const bContext *C, ARegion *ar)
714 SpaceImage *sima = CTX_wm_space_image(C);
715 Scene *scene = CTX_data_scene(C);
716 wmWindow *win = CTX_wm_window(C);
720 int show_viewer, show_render;
723 /* XXX can we do this in refresh? */
728 ED_image_aspect(sima->image, &xuser_asp, &yuser_asp);
730 /* UGLY hack? until now iusers worked fine... but for flipbook viewer we need this */
731 if (sima->image->type == IMA_TYPE_COMPOSITE) {
732 ImageUser *iuser = ntree_get_active_iuser(scene->nodetree);
734 BKE_image_user_calc_imanr(iuser, scene->r.cfra, 0);
735 sima->iuser = *iuser;
738 /* and we check for spare */
739 ibuf = ED_space_image_buffer(sima);
743 /* retrieve the image and information about it */
744 ima = ED_space_image(sima);
745 ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
746 ibuf = ED_space_image_acquire_buffer(sima, &lock);
748 show_viewer = (ima && ima->source == IMA_SRC_VIEWER);
749 show_render = (show_viewer && ima->type == IMA_TYPE_R_RESULT);
751 /* draw the image or grid */
753 ED_region_grid_draw(ar, zoomx, zoomy);
754 else if (sima->flag & SI_DRAW_TILE)
755 draw_image_buffer_repeated(win, sima, ar, scene, ima, ibuf, zoomx, zoomy);
756 else if (ima && (ima->tpageflag & IMA_TILES))
757 draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, 0.0f, 0.0, zoomx, zoomy);
759 draw_image_buffer(win, sima, ar, scene, ima, ibuf, 0.0f, 0.0f, zoomx, zoomy);
762 if (sima->flag & SI_DRAWTOOL)
763 draw_image_paint_helpers(ar, scene, zoomx, zoomy);
766 /* XXX integrate this code */
769 float xoffs = 0.0f, yoffs = 0.0f;
771 if (image_preview_active(sa, &xim, &yim)) {
772 xoffs = scene->r.disprect.xmin;
773 yoffs = scene->r.disprect.ymin;
775 calc_image_view(sima, 'f');
776 myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
777 glRectf(0.0f, 0.0f, 1.0f, 1.0f);
783 ED_space_image_release_buffer(sima, lock);
786 if (ima && show_render)
787 draw_render_info(scene, ima, ar);