diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-04-02 21:28:37 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-04-02 21:28:37 +0400 |
commit | 752ad1bc375663f4bab649dd558f7334cbe03a1c (patch) | |
tree | 9f528055a06ee2d6a6e1c3cf2c6f4e02fd2dff23 /source/blender/editors/space_clip | |
parent | f871d9a82f06e70fb26cbe0bfbd4db18d481059c (diff) |
More usage of GLSL for color managed image drawing
Uses GLSL for drawing image in Image Editor space.
This requires change in image_buffer_rect_update, so
original float buffer is being updated as well. This
is unlikely be something bad, but will keep an eye
on this change.
Also no byte buffer allocation happens there, this
is so because byte buffer used for display only
and in case of GLSL display such allocation and
partial update is just waste of time.
Also switched OpenGL render from using CPU color
space linearization to GLSL color space transform.
Makes OpenGL rendering pretty much faster (but
still slower than in 2.60).
internal changes:
- Added functions to setup GLSL shader for color
space conversion in colormanagement.c. Currently
conversion form a colorspace defined by a role to
linear space is implemented. Easy to extend to
other cases.
- Added helper functions to glutil.c which does
smarter image buffer draw (calling all needed OCIO
stuff, editors now could draw image buffer with a
single function call -- all the checks are done in
glutil.c).
- Also added helper function for buffer linearization
from a given role to glutil.c. Everyone now able to
linearize buffer with a single call.
This function will do nothing is GLSL routines fails
or not supported.
And one last this: this function uses offscreen
drawing, could potentially give issues on some
cards, also will keep an eye on this.
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r-- | source/blender/editors/space_clip/clip_draw.c | 69 |
1 files changed, 9 insertions, 60 deletions
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index cbca2f0c46e..774220764e7 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -248,53 +248,6 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar) ED_region_info_draw(ar, str, block, 0.6f); } -static void draw_movieclip_buffer_glsl(SpaceClip *sc, ImBuf *ibuf, int x, int y, - float zoomx, float zoomy) -{ - MovieClip *clip = ED_space_clip_get_clip(sc); - int filter = GL_LINEAR; - - glPushMatrix(); - glTranslatef(x, y, 0.0f); - glScalef(zoomx, zoomy, 1.0f); - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - glColor4f(1.0, 1.0, 1.0, 1.0); - - /* non-scaled proxy shouldn;t use diltering */ - if ((clip->flag & MCLIP_USE_PROXY) == 0 || - ELEM(sc->user.render_size, MCLIP_PROXY_RENDER_SIZE_FULL, MCLIP_PROXY_RENDER_SIZE_100)) - { - filter = GL_NEAREST; - } - - glaDrawPixelsTex(0, 0, ibuf->x, ibuf->y, GL_FLOAT, filter, ibuf->rect_float); - - glPopMatrix(); -} - -static void draw_movieclip_buffer_fallback(const bContext *C, ImBuf *ibuf, int x, int y, - int width, int height, float zoomx, float zoomy) -{ - unsigned char *display_buffer; - void *cache_handle; - - display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); - - if (display_buffer) { - /* set zoom */ - glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y); - - glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer); - - /* reset zoom */ - glPixelZoom(1.0f, 1.0f); - } - - IMB_display_buffer_release(cache_handle); -} - static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, ImBuf *ibuf, int width, int height, float zoomx, float zoomy) { @@ -308,7 +261,8 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, glRectf(x, y, x + zoomx * width, y + zoomy * height); } else { - bool need_fallback = true; + MovieClip *clip = ED_space_clip_get_clip(sc); + int filter = GL_LINEAR; /* checkerboard for case alpha */ if (ibuf->planes == 32) { @@ -318,19 +272,14 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, fdrawcheckerboard(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y); } - /* GLSL display transform for byte buffers is not supported yet */ - if (ibuf->rect_float && IMB_coloemanagement_setup_glsl_draw_from_ctx(C)) { - draw_movieclip_buffer_glsl(sc, ibuf, x, y, zoomx, zoomy); - - IMB_coloemanagement_finish_glsl_draw(); - - need_fallback = false; - } + /* non-scaled proxy shouldn't use filtering */ + if ((clip->flag & MCLIP_USE_PROXY) == 0 || + ELEM(sc->user.render_size, MCLIP_PROXY_RENDER_SIZE_FULL, MCLIP_PROXY_RENDER_SIZE_100)) + { + filter = GL_NEAREST; + } - /* if GLSL display failed, fallback to regular glaDrawPixelsAuto method */ - if (need_fallback) { - draw_movieclip_buffer_fallback(C, ibuf, x, y, width, height, zoomx, zoomy); - } + glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST); if (ibuf->planes == 32) glDisable(GL_BLEND); |