[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50419] branches/soc-2011-tomato/source/ blender/editors: Color Management: fix for tiled image draw and remove unused code
Sergey Sharybin
sergey.vfx at gmail.com
Wed Sep 5 14:14:10 CEST 2012
Revision: 50419
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50419
Author: nazgul
Date: 2012-09-05 12:14:09 +0000 (Wed, 05 Sep 2012)
Log Message:
-----------
Color Management: fix for tiled image draw and remove unused code
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c
Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c 2012-09-05 12:06:44 UTC (rev 50418)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c 2012-09-05 12:14:09 UTC (rev 50419)
@@ -247,19 +247,6 @@
ED_region_info_draw(ar, str, block, 0.6f);
}
-/* OCIO_TODO: after finishing proper color management pipeline integration
- * this wouldn't be needed -- color managed display buffer
- * would be used unstead
- */
-#if 0
-static void verify_buffer_float(ImBuf *ibuf)
-{
- if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID))) {
- IMB_rect_from_float(ibuf);
- }
-}
-#endif
-
static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
int width, int height, float zoomx, float zoomy)
{
@@ -277,9 +264,6 @@
unsigned char *display_buffer;
void *cache_handle;
- /* OCIO_TODO: finally get rid of this stuff */
- /* verify_buffer_float(ibuf); */
-
display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
if (display_buffer) {
Modified: branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c 2012-09-05 12:06:44 UTC (rev 50418)
+++ branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c 2012-09-05 12:14:09 UTC (rev 50419)
@@ -80,36 +80,6 @@
#define HEADER_HEIGHT 18
-/* OCIO_TODO: after finishing proper color management pipeline integration
- * this wouldn't be needed -- color managed display buffer
- * would be used unstead
- */
-static void image_verify_buffer_float(Image *ima, ImBuf *ibuf, int color_manage)
-{
- /* detect if we need to redo the curve map.
- * ibuf->rect is zero for compositor and render results after change
- * convert to 32 bits always... drawing float rects isn't supported well (atis)
- *
- * NOTE: if float buffer changes, we have to manually remove the rect
- */
-
- if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID)) ) {
- if (color_manage) {
- if (ima && ima->source == IMA_SRC_VIEWER)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
- }
- else
- ibuf->profile = IB_PROFILE_NONE;
-
- /* OCIO_TODO: currently only get rid of old-style color managed byte
- * buffer calculation to save some time on buffer display,
- * but still need to set image buffer's profile to prevent
- * comatibility breackage
- */
- /* IMB_rect_from_float(ibuf); */
- }
-}
-
static void draw_render_info(Scene *scene, Image *ima, ARegion *ar)
{
RenderResult *rr;
@@ -442,10 +412,9 @@
MEM_freeN(rectf);
}
-static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
+static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, Scene *scene, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
{
int x, y;
- int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
/* set zoom */
glPixelZoom(zoomx, zoomy);
@@ -479,10 +448,6 @@
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
- /* we don't draw floats buffers directly but
- * convert them, and optionally apply curves */
- image_verify_buffer_float(ima, ibuf, color_manage);
-
display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
if (display_buffer)
@@ -502,14 +467,14 @@
glPixelZoom(1.0f, 1.0f);
}
-static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty, short endx, short endy)
+static unsigned int *get_part_from_buffer(unsigned int *buffer, int width, short startx, short starty, short endx, short endy)
{
unsigned int *rt, *rp, *rectmain;
short y, heigth, len;
/* the right offset in rectot */
- rt = ibuf->rect + (starty * ibuf->x + startx);
+ rt = buffer + (starty * width + startx);
len = (endx - startx);
heigth = (endy - starty);
@@ -518,7 +483,7 @@
for (y = 0; y < heigth; y++) {
memcpy(rp, rt, len * 4);
- rt += ibuf->x;
+ rt += width;
rp += len;
}
return rectmain;
@@ -526,28 +491,31 @@
static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
{
- unsigned int *rect;
+ unsigned int *display_buffer, *rect;
int dx, dy, sx, sy, x, y;
- int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
+ void *cache_handle;
/* verify valid values, just leave this a while */
if (ima->xrep < 1) return;
if (ima->yrep < 1) return;
-
+
+ display_buffer = (unsigned int *) IMB_display_buffer_acquire(ibuf, &scene->view_settings,
+ &scene->display_settings, &cache_handle);
+
+ if (!display_buffer)
+ return;
+
glPixelZoom(zoomx, zoomy);
if (sima->curtile >= ima->xrep * ima->yrep)
sima->curtile = ima->xrep * ima->yrep - 1;
- /* create char buffer from float if needed */
- image_verify_buffer_float(ima, ibuf, color_manage);
-
/* retrieve part of image buffer */
dx = ibuf->x / ima->xrep;
dy = ibuf->y / ima->yrep;
sx = (sima->curtile % ima->xrep) * dx;
sy = (sima->curtile / ima->xrep) * dy;
- rect = get_part_from_ibuf(ibuf, sx, sy, sx + dx, sy + dy);
+ rect = get_part_from_buffer(display_buffer, ibuf->x, sx, sy, sx + dx, sy + dy);
/* draw repeated */
for (sy = 0; sy + dy <= ibuf->y; sy += dy) {
@@ -560,6 +528,8 @@
glPixelZoom(1.0f, 1.0f);
+ IMB_display_buffer_release(cache_handle);
+
MEM_freeN(rect);
}
@@ -580,7 +550,7 @@
if (ima && (ima->tpageflag & IMA_TILES))
draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy);
else
- draw_image_buffer(C, sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy);
+ draw_image_buffer(C, sima, ar, scene, ibuf, x, y, zoomx, zoomy);
/* only draw until running out of time */
if ((PIL_check_seconds_timer() - time_current) > 0.25)
@@ -798,7 +768,7 @@
else if (ima && (ima->tpageflag & IMA_TILES))
draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, 0.0f, 0.0, zoomx, zoomy);
else
- draw_image_buffer(C, sima, ar, scene, ima, ibuf, 0.0f, 0.0f, zoomx, zoomy);
+ draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy);
/* paint helpers */
if (sima->mode == SI_MODE_PAINT)
More information about the Bf-blender-cvs
mailing list