diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-31 03:49:35 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-31 03:49:35 +0400 |
commit | 60ff60dcdc9f43891fb8a19e10f9bb7964a539bf (patch) | |
tree | ced8e2887295b713d67dfd496728703c71f53442 /source/blender/imbuf | |
parent | 6785874e7adf5ef15e7a28b134b2bd4e8b3a8988 (diff) |
RenderEngine API: add viewport draw utility functions to bind a GLSL fragment
shader for converting colors from linear to display space, based on the scene
color management settings.
if engine.support_display_space_shader(scene): # test graphics card support
engine.bind_display_space_shader(scene)
# draw pixels ..
engine.unbind_display_space_shader()
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/IMB_colormanagement.h | 9 | ||||
-rw-r--r-- | source/blender/imbuf/intern/colormanagement.c | 25 |
2 files changed, 26 insertions, 8 deletions
diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h index 7399b8554aa..3d2eab56d14 100644 --- a/source/blender/imbuf/IMB_colormanagement.h +++ b/source/blender/imbuf/IMB_colormanagement.h @@ -159,15 +159,20 @@ void IMB_colormanagement_processor_free(struct ColormanageProcessor *cm_processo /* ** OpenGL drawing routines using GLSL for color space transform ** */ +/* Test if GLSL drawing is supported for combination of graphics card and this configuration */ +int IMB_colormanagement_support_glsl_draw(const struct ColorManagedViewSettings *view_settings, + int skip_curves); /* Configures GLSL shader for conversion from scene linear to display space */ int IMB_colormanagement_setup_glsl_draw(const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings, - int predivide); + int predivide, + int skip_curves); /* Same as above, but display space conversion happens from a specified space */ int IMB_colormanagement_setup_glsl_draw_from_space(const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings, struct ColorSpace *colorspace, - int predivide); + int predivide, + int skip_curves); /* Same as setup_glsl_draw, but color management settings are guessing from a given context */ int IMB_colormanagement_setup_glsl_draw_ctx(const struct bContext *C, int predivide); /* Same as setup_glsl_draw_from_space, but color management settings are guessing from a given context */ diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index 0167eaccef0..2c4863c3598 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -2807,6 +2807,17 @@ static void update_glsl_display_processor(const ColorManagedViewSettings *view_s } } +int IMB_colormanagement_support_glsl_draw(const ColorManagedViewSettings *view_settings, + int skip_curves) +{ + /* curves not supported yet */ + if (!skip_curves) + if (view_settings && (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES)) + return 0; + + return OCIO_supportGLSLDraw(); +} + /** * Configures GLSL shader for conversion from specified to * display color space @@ -2822,7 +2833,8 @@ static void update_glsl_display_processor(const ColorManagedViewSettings *view_s */ int IMB_colormanagement_setup_glsl_draw_from_space(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, - struct ColorSpace *from_colorspace, int predivide) + struct ColorSpace *from_colorspace, int predivide, + int skip_curves) { ColorManagedViewSettings default_view_settings; const ColorManagedViewSettings *applied_view_settings; @@ -2840,8 +2852,9 @@ int IMB_colormanagement_setup_glsl_draw_from_space(const ColorManagedViewSetting } /* RGB curves mapping is not supported on GPU yet. */ - if (applied_view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) - return FALSE; + if (!skip_curves) + if (applied_view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) + return FALSE; /* Make sure OCIO processor is up-to-date. */ update_glsl_display_processor(applied_view_settings, display_settings, @@ -2853,10 +2866,10 @@ int IMB_colormanagement_setup_glsl_draw_from_space(const ColorManagedViewSetting /* Configures GLSL shader for conversion from scene linear to display space */ int IMB_colormanagement_setup_glsl_draw(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, - int predivide) + int predivide, int skip_curves) { return IMB_colormanagement_setup_glsl_draw_from_space(view_settings, display_settings, - NULL, predivide); + NULL, predivide, skip_curves); } /* Same as setup_glsl_draw_from_space, but color management settings are guessing from a given context */ @@ -2867,7 +2880,7 @@ int IMB_colormanagement_setup_glsl_draw_from_space_ctx(const struct bContext *C, IMB_colormanagement_display_settings_from_ctx(C, &view_settings, &display_settings); - return IMB_colormanagement_setup_glsl_draw_from_space(view_settings, display_settings, from_colorspace, predivide); + return IMB_colormanagement_setup_glsl_draw_from_space(view_settings, display_settings, from_colorspace, predivide, FALSE); } /* Same as setup_glsl_draw, but color management settings are guessing from a given context */ |