Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2015-10-30 14:06:00 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-10-30 14:07:10 +0300
commit43bf78c946c478fd944d70f11b940ac4dd630fcf (patch)
tree556f8a6468a7cd30173324648dae032212ea2bd1
parente6abc3ad5751a272930841757e588bc25ce0bde7 (diff)
Image editor: Add options to display separate R, G and B channels
Works totally similar to backdrop in the compositor. Requested by Sean Kennedy, but could be useful for lots for VFX guys. Reviewers: campbellbarton Reviewed By: campbellbarton Subscribers: sebastian_k, hype Differential Revision: https://developer.blender.org/D1590
-rw-r--r--source/blender/editors/space_image/image_draw.c48
-rw-r--r--source/blender/makesdna/DNA_space_types.h6
-rw-r--r--source/blender/makesrna/intern/rna_space.c7
3 files changed, 57 insertions, 4 deletions
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index b71462880b7..81711df355c 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -478,6 +478,19 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec
MEM_freeN(rectf);
}
+static int draw_image_channel_offset(SpaceImage *sima)
+{
+#ifdef __BIG_ENDIAN__
+ if (sima->flag & SI_SHOW_R) return 2;
+ else if (sima->flag & SI_SHOW_G) return 1;
+ else return 0;
+#else
+ if (sima->flag & SI_SHOW_R) return 1;
+ else if (sima->flag & SI_SHOW_G) return 2;
+ else return 3;
+#endif
+}
+
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;
@@ -513,7 +526,27 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
fdrawcheckerboard(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy);
}
- glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST);
+ if ((sima->flag & (SI_SHOW_R | SI_SHOW_G | SI_SHOW_B)) == 0) {
+ glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST);
+ }
+ else {
+ unsigned char *display_buffer;
+ void *cache_handle;
+
+ /* TODO(sergey): Ideally GLSL shading should be capable of either
+ * disabling some channels or displaying buffer with custom offset.
+ */
+ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
+
+ if (display_buffer != NULL) {
+ int channel_offset = draw_image_channel_offset(sima);
+ glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT,
+ display_buffer + channel_offset);
+ }
+ if (cache_handle != NULL) {
+ IMB_display_buffer_release(cache_handle);
+ }
+ }
if (sima->flag & SI_USE_ALPHA)
glDisable(GL_BLEND);
@@ -551,6 +584,7 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene,
unsigned int *rect;
int dx, dy, sx, sy, x, y;
void *cache_handle;
+ int channel_offset = -1;
/* verify valid values, just leave this a while */
if (ima->xrep < 1) return;
@@ -577,11 +611,19 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene,
rect = get_part_from_buffer((unsigned int *)display_buffer, ibuf->x, sx, sy, sx + dx, sy + dy);
/* draw repeated */
+ if ((sima->flag & (SI_SHOW_R | SI_SHOW_G | SI_SHOW_B)) != 0) {
+ channel_offset = draw_image_channel_offset(sima);
+ }
for (sy = 0; sy + dy <= ibuf->y; sy += dy) {
for (sx = 0; sx + dx <= ibuf->x; sx += dx) {
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);
+ if (channel_offset == -1) {
+ glaDrawPixelsSafe(x, y, dx, dy, dx, GL_RGBA, GL_UNSIGNED_BYTE, rect);
+ }
+ else {
+ glaDrawPixelsSafe(x, y, dx, dy, dx, GL_LUMINANCE, GL_UNSIGNED_INT,
+ (unsigned char*)rect + channel_offset);
+ }
}
}
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index d9d3b5cc37d..a0820eddb0e 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -966,7 +966,11 @@ typedef enum eSpaceImage_Flag {
SI_COLOR_CORRECTION = (1 << 24),
SI_NO_DRAW_TEXPAINT = (1 << 25),
- SI_DRAW_METADATA = (1 << 26)
+ SI_DRAW_METADATA = (1 << 26),
+
+ SI_SHOW_R = (1 << 27),
+ SI_SHOW_G = (1 << 28),
+ SI_SHOW_B = (1 << 29),
} eSpaceImage_Flag;
/* Text Editor ============================================ */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 9e660ad01e8..65de2195c51 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -142,6 +142,9 @@ static EnumPropertyItem draw_channels_items[] = {
{SI_SHOW_ALPHA, "ALPHA", ICON_IMAGE_ALPHA, "Alpha", "Draw alpha transparency channel"},
{SI_SHOW_ZBUF, "Z_BUFFER", ICON_IMAGE_ZDEPTH, "Z-Buffer",
"Draw Z-buffer associated with image (mapped from camera clip start to end)"},
+ {SI_SHOW_R, "RED", ICON_COLOR_RED, "Red", ""},
+ {SI_SHOW_G, "GREEN", ICON_COLOR_GREEN, "Green", ""},
+ {SI_SHOW_B, "BLUE", ICON_COLOR_BLUE, "Blue", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -838,6 +841,10 @@ static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *UNUS
RNA_enum_items_add_value(&item, &totitem, draw_channels_items, 0);
}
+ RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_SHOW_R);
+ RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_SHOW_G);
+ RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_SHOW_B);
+
RNA_enum_item_end(&item, &totitem);
*r_free = true;