2011-10-10 09:38:02 +00:00
|
|
|
/*
|
2006-12-20 17:57:56 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2006-12-20 17:57:56 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
2009-01-04 14:14:06 +00:00
|
|
|
* Contributor(s): Blender Foundation, 2006, full recode
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
2006-12-20 17:57:56 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-27 20:40:57 +00:00
|
|
|
/** \file blender/blenkernel/intern/image.c
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <math.h>
|
2012-06-23 23:22:19 +00:00
|
|
|
#ifndef WIN32
|
2013-12-12 13:10:03 +06:00
|
|
|
# include <unistd.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
#else
|
2013-12-12 13:10:03 +06:00
|
|
|
# include <io.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif
|
|
|
|
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
#include "IMB_colormanagement.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
#include "IMB_imbuf.h"
|
2013-12-13 16:22:08 +06:00
|
|
|
#include "IMB_moviecache.h"
|
2006-12-21 01:16:25 +00:00
|
|
|
|
|
|
|
#ifdef WITH_OPENEXR
|
2013-12-12 13:10:03 +06:00
|
|
|
# include "intern/openexr/openexr_multi.h"
|
2006-12-21 01:16:25 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "DNA_packedFile_types.h"
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2011-01-13 19:16:35 +00:00
|
|
|
#include "DNA_object_types.h"
|
2007-10-20 16:17:27 +00:00
|
|
|
#include "DNA_camera_types.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include "DNA_sequence_types.h"
|
2011-10-23 17:52:20 +00:00
|
|
|
#include "DNA_brush_types.h"
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_meshdata_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2014-10-02 19:04:38 +06:00
|
|
|
#include "BLI_math_vector.h"
|
2006-12-20 17:57:56 +00:00
|
|
|
#include "BLI_threads.h"
|
2014-01-29 20:01:30 +11:00
|
|
|
#include "BLI_timecode.h" /* for stamp timecode format */
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
Biiig commit! Thanks to 2-3 weeks of cvs freeze...
Render:
- New; support for dual CPU render (SDL thread)
Currently only works with alternating scanlines, but gives excellent
performance. For both normal render as unified implemented.
Note the "mutex" locks on z-transp buffer render and imbuf loads.
- This has been made possible by major cleanups in render code, especially
getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct
OSA or using Materials or Texture data to write to.
- Made normal render fully 4x32 floats too, and removed all old optimizes
with chars or shorts.
- Made normal render and unified render use same code for sky and halo
render, giving equal (and better) results for halo render. Old render
now also uses PostProcess options (brightness, mul, gamma)
- Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer
after render. Using PostProcess menu you will note an immediate re-
display of image too (32 bits RGBA)
- Added "Hue" and "Saturation" sliders to PostProcess options
- Render module is still not having a "nice" API, but amount of dependencies
went down a lot. Next todo: remove abusive "previewrender" code.
The last main global in Render (struct Render) now can be re-used for fully
controlling a render, to allow multiple "instances" of render to open.
- Renderwindow now displays a smal bar on top with the stats, and keeps the
stats after render too. Including "spare" page support.
Not only easier visible that way, but also to remove the awkward code that
was drawing stats in the Info header (extreme slow on some ATIs too)
- Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping
defines.
- I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
|
|
|
#include "BKE_bmfont.h"
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
#include "BKE_colortools.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_global.h"
|
2005-12-21 22:21:43 +00:00
|
|
|
#include "BKE_icons.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_image.h"
|
2006-12-20 17:57:56 +00:00
|
|
|
#include "BKE_library.h"
|
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_packedFile.h"
|
2015-05-22 23:28:41 +02:00
|
|
|
#include "BKE_report.h"
|
Biiig commit! Thanks to 2-3 weeks of cvs freeze...
Render:
- New; support for dual CPU render (SDL thread)
Currently only works with alternating scanlines, but gives excellent
performance. For both normal render as unified implemented.
Note the "mutex" locks on z-transp buffer render and imbuf loads.
- This has been made possible by major cleanups in render code, especially
getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct
OSA or using Materials or Texture data to write to.
- Made normal render fully 4x32 floats too, and removed all old optimizes
with chars or shorts.
- Made normal render and unified render use same code for sky and halo
render, giving equal (and better) results for halo render. Old render
now also uses PostProcess options (brightness, mul, gamma)
- Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer
after render. Using PostProcess menu you will note an immediate re-
display of image too (32 bits RGBA)
- Added "Hue" and "Saturation" sliders to PostProcess options
- Render module is still not having a "nice" API, but amount of dependencies
went down a lot. Next todo: remove abusive "previewrender" code.
The last main global in Render (struct Render) now can be re-used for fully
controlling a render, to allow multiple "instances" of render to open.
- Renderwindow now displays a smal bar on top with the stats, and keeps the
stats after render too. Including "spare" page support.
Not only easier visible that way, but also to remove the awkward code that
was drawing stats in the Info header (extreme slow on some ATIs too)
- Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping
defines.
- I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
|
|
|
#include "BKE_scene.h"
|
2010-09-13 06:08:26 +00:00
|
|
|
#include "BKE_node.h"
|
2011-02-17 22:34:41 +00:00
|
|
|
#include "BKE_sequencer.h" /* seq_foreground_frame_get() */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-08-18 19:26:53 +00:00
|
|
|
#include "BLF_api.h"
|
|
|
|
|
2005-07-27 07:43:48 +00:00
|
|
|
#include "PIL_time.h"
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
#include "RE_pipeline.h"
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include "GPU_draw.h"
|
|
|
|
|
2013-05-28 19:35:26 +00:00
|
|
|
#include "BLI_sys_types.h" // for intptr_t support
|
2008-08-17 17:12:10 +00:00
|
|
|
|
2012-06-04 10:41:18 +00:00
|
|
|
/* for image user iteration */
|
|
|
|
#include "DNA_node_types.h"
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
#include "DNA_view3d_types.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
static SpinLock image_spin;
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* prototypes */
|
2015-10-24 01:01:10 +11:00
|
|
|
static int image_num_files(struct Image *ima);
|
2015-05-08 07:25:39 +10:00
|
|
|
static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock);
|
2015-04-06 10:40:12 -03:00
|
|
|
static void image_update_views_format(Image *ima, ImageUser *iuser);
|
|
|
|
static void image_add_view(Image *ima, const char *viewname, const char *filepath);
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* max int, to indicate we don't store sequences in ibuf */
|
2012-05-06 15:15:33 +00:00
|
|
|
#define IMA_NO_INDEX 0x7FEFEFEF
|
2006-12-20 17:57:56 +00:00
|
|
|
|
|
|
|
/* quick lookup: supports 1 million frames, thousand passes */
|
2012-05-06 15:15:33 +00:00
|
|
|
#define IMA_MAKE_INDEX(frame, index) ((frame) << 10) + index
|
|
|
|
#define IMA_INDEX_FRAME(index) (index >> 10)
|
2013-12-18 00:20:18 +11:00
|
|
|
/*
|
2012-05-06 15:15:33 +00:00
|
|
|
#define IMA_INDEX_PASS(index) (index & ~1023)
|
2013-12-18 00:20:18 +11:00
|
|
|
*/
|
2006-12-20 17:57:56 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
/* ******** IMAGE CACHE ************* */
|
|
|
|
|
|
|
|
typedef struct ImageCacheKey {
|
|
|
|
int index;
|
|
|
|
} ImageCacheKey;
|
|
|
|
|
|
|
|
static unsigned int imagecache_hashhash(const void *key_v)
|
|
|
|
{
|
2015-01-01 23:26:03 +11:00
|
|
|
const ImageCacheKey *key = key_v;
|
2013-12-13 16:22:08 +06:00
|
|
|
return key->index;
|
|
|
|
}
|
|
|
|
|
2014-09-25 06:15:52 +10:00
|
|
|
static bool imagecache_hashcmp(const void *a_v, const void *b_v)
|
2013-12-13 16:22:08 +06:00
|
|
|
{
|
2015-01-01 23:26:03 +11:00
|
|
|
const ImageCacheKey *a = a_v;
|
|
|
|
const ImageCacheKey *b = b_v;
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2014-09-25 06:15:52 +10:00
|
|
|
return (a->index != b->index);
|
2013-12-13 16:22:08 +06:00
|
|
|
}
|
|
|
|
|
2014-04-02 16:50:06 +06:00
|
|
|
static void imagecache_keydata(void *userkey, int *framenr, int *proxy, int *render_flags)
|
|
|
|
{
|
2015-01-01 23:26:03 +11:00
|
|
|
ImageCacheKey *key = userkey;
|
2014-04-02 16:50:06 +06:00
|
|
|
|
|
|
|
*framenr = IMA_INDEX_FRAME(key->index);
|
|
|
|
*proxy = IMB_PROXY_NONE;
|
|
|
|
*render_flags = 0;
|
|
|
|
}
|
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
static void imagecache_put(Image *image, int index, ImBuf *ibuf)
|
|
|
|
{
|
|
|
|
ImageCacheKey key;
|
|
|
|
|
|
|
|
if (image->cache == NULL) {
|
2014-01-13 18:42:40 +06:00
|
|
|
// char cache_name[64];
|
|
|
|
// BLI_snprintf(cache_name, sizeof(cache_name), "Image Datablock %s", image->id.name);
|
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
image->cache = IMB_moviecache_create("Image Datablock Cache", sizeof(ImageCacheKey),
|
|
|
|
imagecache_hashhash, imagecache_hashcmp);
|
2014-04-02 16:50:06 +06:00
|
|
|
IMB_moviecache_set_getdata_callback(image->cache, imagecache_keydata);
|
2013-12-13 16:22:08 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
key.index = index;
|
|
|
|
|
|
|
|
IMB_moviecache_put(image->cache, &key, ibuf);
|
|
|
|
}
|
|
|
|
|
2013-12-18 15:35:31 +11:00
|
|
|
static struct ImBuf *imagecache_get(Image *image, int index)
|
2013-12-13 16:22:08 +06:00
|
|
|
{
|
|
|
|
if (image->cache) {
|
|
|
|
ImageCacheKey key;
|
|
|
|
key.index = index;
|
|
|
|
return IMB_moviecache_get(image->cache, &key);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
void BKE_images_init(void)
|
|
|
|
{
|
|
|
|
BLI_spin_init(&image_spin);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_images_exit(void)
|
|
|
|
{
|
|
|
|
BLI_spin_end(&image_spin);
|
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* ******** IMAGE PROCESSING ************* */
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
struct ImBuf *tbuf1, *tbuf2;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
if (ibuf == NULL) return;
|
2006-12-20 17:57:56 +00:00
|
|
|
if (ibuf->flags & IB_fields) return;
|
|
|
|
ibuf->flags |= IB_fields;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
if (ibuf->rect) {
|
|
|
|
/* make copies */
|
2012-06-07 18:33:36 +00:00
|
|
|
tbuf1 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, (int)IB_rect);
|
|
|
|
tbuf2 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, (int)IB_rect);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
ibuf->x *= 2;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
|
|
|
|
IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
ibuf->x /= 2;
|
|
|
|
IMB_rectcpy(ibuf, tbuf1, 0, 0, 0, 0, tbuf1->x, tbuf1->y);
|
|
|
|
IMB_rectcpy(ibuf, tbuf2, 0, tbuf2->y, 0, 0, tbuf2->x, tbuf2->y);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
IMB_freeImBuf(tbuf1);
|
|
|
|
IMB_freeImBuf(tbuf2);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
ibuf->y /= 2;
|
|
|
|
}
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
struct ImBuf *tbuf1, *tbuf2;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
if (ibuf == NULL) return;
|
2006-12-20 17:57:56 +00:00
|
|
|
if (ibuf->flags & IB_fields) return;
|
|
|
|
ibuf->flags |= IB_fields;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
if (ibuf->rect) {
|
|
|
|
/* make copies */
|
2012-06-07 18:33:36 +00:00
|
|
|
tbuf1 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, IB_rect);
|
|
|
|
tbuf2 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, IB_rect);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
ibuf->x *= 2;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
|
|
|
|
IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
ibuf->x /= 2;
|
|
|
|
IMB_rectcpy(ibuf, tbuf2, 0, 0, 0, 0, tbuf2->x, tbuf2->y);
|
|
|
|
IMB_rectcpy(ibuf, tbuf1, 0, tbuf2->y, 0, 0, tbuf1->x, tbuf1->y);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
IMB_freeImBuf(tbuf1);
|
|
|
|
IMB_freeImBuf(tbuf2);
|
|
|
|
}
|
|
|
|
ibuf->y /= 2;
|
|
|
|
}
|
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_image_de_interlace(Image *ima, int odd)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2012-11-15 15:59:58 +00:00
|
|
|
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ibuf) {
|
|
|
|
if (odd)
|
2006-12-20 17:57:56 +00:00
|
|
|
de_interlace_st(ibuf);
|
|
|
|
else
|
|
|
|
de_interlace_ng(ibuf);
|
|
|
|
}
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(ima, ibuf, NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* ***************** ALLOC & FREE, DATA MANAGING *************** */
|
|
|
|
|
2014-10-17 12:37:40 +02:00
|
|
|
static void image_free_cached_frames(Image *image)
|
2006-06-05 11:07:15 +00:00
|
|
|
{
|
2013-12-13 16:22:08 +06:00
|
|
|
if (image->cache) {
|
|
|
|
IMB_moviecache_free(image->cache);
|
|
|
|
image->cache = NULL;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2013-10-28 12:16:17 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void image_free_packedfiles(Image *ima)
|
|
|
|
{
|
|
|
|
while (ima->packedfiles.last) {
|
|
|
|
ImagePackedFile *imapf = ima->packedfiles.last;
|
|
|
|
if (imapf->packedfile) {
|
|
|
|
freePackedFile(imapf->packedfile);
|
|
|
|
}
|
|
|
|
BLI_remlink(&ima->packedfiles, imapf);
|
|
|
|
MEM_freeN(imapf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_free_packedfiles(Image *ima)
|
|
|
|
{
|
|
|
|
image_free_packedfiles(ima);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_free_views(Image *image)
|
|
|
|
{
|
2015-10-11 01:14:02 +02:00
|
|
|
BLI_freelistN(&image->views);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void image_free_anims(Image *ima)
|
|
|
|
{
|
|
|
|
while (ima->anims.last) {
|
|
|
|
ImageAnim *ia = ima->anims.last;
|
|
|
|
if (ia->anim) {
|
|
|
|
IMB_free_anim(ia->anim);
|
|
|
|
ia->anim = NULL;
|
|
|
|
}
|
|
|
|
BLI_remlink(&ima->anims, ia);
|
|
|
|
MEM_freeN(ia);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-22 11:58:07 +10:00
|
|
|
/**
|
|
|
|
* Simply free the image data from memory,
|
|
|
|
* on display the image can load again (except for render buffers).
|
|
|
|
*/
|
2014-05-22 17:40:35 +10:00
|
|
|
void BKE_image_free_buffers(Image *ima)
|
2013-10-28 12:16:17 +00:00
|
|
|
{
|
2014-10-17 12:37:40 +02:00
|
|
|
image_free_cached_frames(ima);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
image_free_anims(ima);
|
2010-03-27 15:35:34 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ima->rr) {
|
2006-12-20 17:57:56 +00:00
|
|
|
RE_FreeRenderResult(ima->rr);
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->rr = NULL;
|
2012-06-23 23:22:19 +00:00
|
|
|
}
|
|
|
|
|
2014-12-02 14:50:36 +05:00
|
|
|
if (!G.background) {
|
|
|
|
/* Background mode doesn't use opnegl,
|
|
|
|
* so we can avoid freeing GPU images and save some
|
|
|
|
* time by skipping mutex lock.
|
|
|
|
*/
|
|
|
|
GPU_free_image(ima);
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->ok = IMA_OK;
|
2006-06-05 11:07:15 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* called by library too, do not free ima itself */
|
2012-05-05 14:03:12 +00:00
|
|
|
void BKE_image_free(Image *ima)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2010-03-27 15:35:34 +00:00
|
|
|
int a;
|
|
|
|
|
2014-05-22 17:40:35 +10:00
|
|
|
BKE_image_free_buffers(ima);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
image_free_packedfiles(ima);
|
|
|
|
|
2015-05-11 16:29:12 +02:00
|
|
|
BKE_icon_id_delete(&ima->id);
|
2005-12-21 22:21:43 +00:00
|
|
|
ima->id.icon_id = 0;
|
2010-07-14 14:11:03 +00:00
|
|
|
|
|
|
|
BKE_previewimg_free(&ima->preview);
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (a = 0; a < IMA_MAX_RENDER_SLOT; a++) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ima->renders[a]) {
|
2010-03-27 15:35:34 +00:00
|
|
|
RE_FreeRenderResult(ima->renders[a]);
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->renders[a] = NULL;
|
2010-03-27 15:35:34 +00:00
|
|
|
}
|
2009-07-10 16:55:49 +00:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-10-11 01:14:02 +02:00
|
|
|
BKE_image_free_views(ima);
|
2015-04-06 10:40:12 -03:00
|
|
|
MEM_freeN(ima->stereo3d_format);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* only image block itself */
|
2013-02-05 12:46:15 +00:00
|
|
|
static Image *image_alloc(Main *bmain, const char *name, short source, short type)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
|
|
|
Image *ima;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2014-01-15 16:37:03 +01:00
|
|
|
ima = BKE_libblock_alloc(bmain, ID_IM, name);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ima) {
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->ok = IMA_OK;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->xrep = ima->yrep = 1;
|
|
|
|
ima->aspx = ima->aspy = 1.0;
|
|
|
|
ima->gen_x = 1024; ima->gen_y = 1024;
|
|
|
|
ima->gen_type = 1; /* no defines yet? */
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->source = source;
|
|
|
|
ima->type = type;
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
|
|
|
|
if (source == IMA_SRC_VIEWER)
|
|
|
|
ima->flag |= IMA_VIEW_AS_RENDER;
|
|
|
|
|
|
|
|
BKE_color_managed_colorspace_settings_init(&ima->colorspace_settings);
|
2015-04-06 10:40:12 -03:00
|
|
|
ima->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Image Stereo Format");
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
return ima;
|
|
|
|
}
|
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
/* Get the ibuf from an image cache by it's index and frame.
|
|
|
|
* Local use here only.
|
|
|
|
*
|
|
|
|
* Returns referenced image buffer if it exists, callee is to
|
|
|
|
* call IMB_freeImBuf to de-reference the image buffer after
|
|
|
|
* it's done handling it.
|
|
|
|
*/
|
|
|
|
static ImBuf *image_get_cached_ibuf_for_index_frame(Image *ima, int index, int frame)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2013-12-13 16:22:08 +06:00
|
|
|
if (index != IMA_NO_INDEX) {
|
2012-05-06 15:15:33 +00:00
|
|
|
index = IMA_MAKE_INDEX(frame, index);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
return imagecache_get(ima, index);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* no ima->ibuf anymore, but listbase */
|
|
|
|
static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame)
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ibuf) {
|
2012-05-06 15:15:33 +00:00
|
|
|
if (index != IMA_NO_INDEX)
|
|
|
|
index = IMA_MAKE_INDEX(frame, index);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
imagecache_put(ima, index, ibuf);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void copy_image_packedfiles(ListBase *lb_dst, const ListBase *lb_src)
|
|
|
|
{
|
|
|
|
const ImagePackedFile *imapf_src;
|
|
|
|
|
|
|
|
BLI_listbase_clear(lb_dst);
|
|
|
|
for (imapf_src = lb_src->first; imapf_src; imapf_src = imapf_src->next) {
|
|
|
|
ImagePackedFile *imapf_dst = MEM_mallocN(sizeof(ImagePackedFile), "Image Packed Files (copy)");
|
|
|
|
BLI_strncpy(imapf_dst->filepath, imapf_src->filepath, sizeof(imapf_dst->filepath));
|
|
|
|
|
|
|
|
if (imapf_src->packedfile)
|
|
|
|
imapf_dst->packedfile = dupPackedFile(imapf_src->packedfile);
|
|
|
|
|
|
|
|
BLI_addtail(lb_dst, imapf_dst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-27 19:32:44 +00:00
|
|
|
/* empty image block, of similar type and filename */
|
2013-02-08 15:56:14 +00:00
|
|
|
Image *BKE_image_copy(Main *bmain, Image *ima)
|
2009-01-27 19:32:44 +00:00
|
|
|
{
|
2013-02-08 15:56:14 +00:00
|
|
|
Image *nima = image_alloc(bmain, ima->id.name + 2, ima->source, ima->type);
|
2009-01-27 19:32:44 +00:00
|
|
|
|
2010-07-30 06:09:23 +00:00
|
|
|
BLI_strncpy(nima->name, ima->name, sizeof(ima->name));
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
nima->flag = ima->flag;
|
|
|
|
nima->tpageflag = ima->tpageflag;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
nima->gen_x = ima->gen_x;
|
|
|
|
nima->gen_y = ima->gen_y;
|
|
|
|
nima->gen_type = ima->gen_type;
|
2014-10-02 19:04:38 +06:00
|
|
|
copy_v4_v4(nima->gen_color, ima->gen_color);
|
2010-07-30 06:09:23 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
nima->animspeed = ima->animspeed;
|
2010-07-30 06:09:23 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
nima->aspx = ima->aspx;
|
|
|
|
nima->aspy = ima->aspy;
|
2010-07-30 06:09:23 +00:00
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
BKE_color_managed_colorspace_settings_copy(&nima->colorspace_settings, &ima->colorspace_settings);
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
copy_image_packedfiles(&nima->packedfiles, &ima->packedfiles);
|
|
|
|
|
|
|
|
nima->stereo3d_format = MEM_dupallocN(ima->stereo3d_format);
|
|
|
|
BLI_duplicatelist(&nima->views, &ima->views);
|
2013-02-08 15:56:14 +00:00
|
|
|
|
2015-01-09 09:52:51 +01:00
|
|
|
if (ima->id.lib) {
|
|
|
|
BKE_id_lib_local_paths(bmain, ima->id.lib, &nima->id);
|
|
|
|
}
|
|
|
|
|
2010-07-30 06:09:23 +00:00
|
|
|
return nima;
|
2009-01-27 19:32:44 +00:00
|
|
|
}
|
|
|
|
|
2011-10-23 17:52:20 +00:00
|
|
|
static void extern_local_image(Image *UNUSED(ima))
|
|
|
|
{
|
|
|
|
/* Nothing to do: images don't link to other IDs. This function exists to
|
2012-03-03 20:19:11 +00:00
|
|
|
* match id_make_local pattern. */
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
|
2012-05-05 14:52:04 +00:00
|
|
|
void BKE_image_make_local(struct Image *ima)
|
2011-10-26 21:22:35 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
Main *bmain = G.main;
|
2011-10-23 17:52:20 +00:00
|
|
|
Tex *tex;
|
|
|
|
Brush *brush;
|
|
|
|
Mesh *me;
|
2014-04-01 11:34:00 +11:00
|
|
|
bool is_local = false, is_lib = false;
|
2011-10-23 17:52:20 +00:00
|
|
|
|
|
|
|
/* - only lib users: do nothing
|
|
|
|
* - only local users: set flag
|
|
|
|
* - mixed: make copy
|
|
|
|
*/
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ima->id.lib == NULL) return;
|
2011-10-23 17:52:20 +00:00
|
|
|
|
|
|
|
/* Can't take short cut here: must check meshes at least because of bogus
|
2012-03-03 20:19:11 +00:00
|
|
|
* texface ID refs. - z0r */
|
2011-10-26 21:22:35 +00:00
|
|
|
#if 0
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ima->id.us == 1) {
|
2011-10-27 05:34:39 +00:00
|
|
|
id_clear_lib_data(bmain, &ima->id);
|
2011-10-23 17:52:20 +00:00
|
|
|
extern_local_image(ima);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (tex = bmain->tex.first; tex; tex = tex->id.next) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tex->ima == ima) {
|
2014-04-01 11:34:00 +11:00
|
|
|
if (tex->id.lib) is_lib = true;
|
|
|
|
else is_local = true;
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
for (brush = bmain->brush.first; brush; brush = brush->id.next) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (brush->clone.image == ima) {
|
2014-04-01 11:34:00 +11:00
|
|
|
if (brush->id.lib) is_lib = true;
|
|
|
|
else is_local = true;
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
for (me = bmain->mesh.first; me; me = me->id.next) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (me->mtface) {
|
2011-10-23 17:52:20 +00:00
|
|
|
MTFace *tface;
|
|
|
|
int a, i;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (i = 0; i < me->fdata.totlayer; i++) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (me->fdata.layers[i].type == CD_MTFACE) {
|
2012-05-06 15:15:33 +00:00
|
|
|
tface = (MTFace *)me->fdata.layers[i].data;
|
2011-10-23 17:52:20 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (a = 0; a < me->totface; a++, tface++) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tface->tpage == ima) {
|
2014-04-01 11:34:00 +11:00
|
|
|
if (me->id.lib) is_lib = true;
|
|
|
|
else is_local = true;
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-16 12:19:02 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (me->mtpoly) {
|
2012-02-16 12:19:02 +00:00
|
|
|
MTexPoly *mtpoly;
|
|
|
|
int a, i;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (i = 0; i < me->pdata.totlayer; i++) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (me->pdata.layers[i].type == CD_MTEXPOLY) {
|
2012-05-06 15:15:33 +00:00
|
|
|
mtpoly = (MTexPoly *)me->pdata.layers[i].data;
|
2012-02-16 12:19:02 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (a = 0; a < me->totpoly; a++, mtpoly++) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (mtpoly->tpage == ima) {
|
2014-04-01 11:34:00 +11:00
|
|
|
if (me->id.lib) is_lib = true;
|
|
|
|
else is_local = true;
|
2012-02-16 12:19:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
if (is_local && is_lib == false) {
|
2011-10-27 05:34:39 +00:00
|
|
|
id_clear_lib_data(bmain, &ima->id);
|
2011-10-23 17:52:20 +00:00
|
|
|
extern_local_image(ima);
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (is_local && is_lib) {
|
2013-02-08 15:56:14 +00:00
|
|
|
Image *ima_new = BKE_image_copy(bmain, ima);
|
2011-10-26 21:22:35 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ima_new->id.us = 0;
|
2011-10-23 17:52:20 +00:00
|
|
|
|
|
|
|
/* Remap paths of new ID using old library as base. */
|
2011-11-30 00:32:13 +00:00
|
|
|
BKE_id_lib_local_paths(bmain, ima->id.lib, &ima_new->id);
|
2011-10-23 17:52:20 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
tex = bmain->tex.first;
|
2012-03-24 06:18:31 +00:00
|
|
|
while (tex) {
|
2012-05-06 15:15:33 +00:00
|
|
|
if (tex->id.lib == NULL) {
|
|
|
|
if (tex->ima == ima) {
|
2011-11-30 00:32:13 +00:00
|
|
|
tex->ima = ima_new;
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_plus(&ima_new->id);
|
|
|
|
id_us_min(&ima->id);
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
tex = tex->id.next;
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
brush = bmain->brush.first;
|
2012-03-24 06:18:31 +00:00
|
|
|
while (brush) {
|
2012-05-06 15:15:33 +00:00
|
|
|
if (brush->id.lib == NULL) {
|
|
|
|
if (brush->clone.image == ima) {
|
2011-11-30 00:32:13 +00:00
|
|
|
brush->clone.image = ima_new;
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_plus(&ima_new->id);
|
|
|
|
id_us_min(&ima->id);
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
brush = brush->id.next;
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
/* Transfer references in texfaces. Texfaces don't add to image ID
|
2012-03-03 20:19:11 +00:00
|
|
|
* user count *unless* there are no other users. See
|
|
|
|
* readfile.c:lib_link_mtface. */
|
2012-05-06 15:15:33 +00:00
|
|
|
me = bmain->mesh.first;
|
2012-03-24 06:18:31 +00:00
|
|
|
while (me) {
|
|
|
|
if (me->mtface) {
|
2011-10-23 17:52:20 +00:00
|
|
|
MTFace *tface;
|
|
|
|
int a, i;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (i = 0; i < me->fdata.totlayer; i++) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (me->fdata.layers[i].type == CD_MTFACE) {
|
2012-05-06 15:15:33 +00:00
|
|
|
tface = (MTFace *)me->fdata.layers[i].data;
|
2011-10-23 17:52:20 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (a = 0; a < me->totface; a++, tface++) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tface->tpage == ima) {
|
2011-11-30 00:32:13 +00:00
|
|
|
tface->tpage = ima_new;
|
2015-11-11 20:18:50 +01:00
|
|
|
id_us_ensure_real((ID *)ima_new);
|
2012-05-06 15:15:33 +00:00
|
|
|
id_lib_extern((ID *)ima_new);
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-16 12:19:02 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (me->mtpoly) {
|
2012-02-16 12:19:02 +00:00
|
|
|
MTexPoly *mtpoly;
|
|
|
|
int a, i;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (i = 0; i < me->pdata.totlayer; i++) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (me->pdata.layers[i].type == CD_MTEXPOLY) {
|
2012-05-06 15:15:33 +00:00
|
|
|
mtpoly = (MTexPoly *)me->pdata.layers[i].data;
|
2012-02-16 12:19:02 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (a = 0; a < me->totpoly; a++, mtpoly++) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (mtpoly->tpage == ima) {
|
2012-02-16 12:19:02 +00:00
|
|
|
mtpoly->tpage = ima_new;
|
2015-11-11 20:18:50 +01:00
|
|
|
id_us_ensure_real((ID *)ima_new);
|
2012-05-06 15:15:33 +00:00
|
|
|
id_lib_extern((ID *)ima_new);
|
2012-02-16 12:19:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
me = me->id.next;
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-27 19:32:44 +00:00
|
|
|
void BKE_image_merge(Image *dest, Image *source)
|
|
|
|
{
|
2009-02-25 09:54:41 +00:00
|
|
|
/* sanity check */
|
2012-05-06 15:15:33 +00:00
|
|
|
if (dest && source && dest != source) {
|
2013-12-13 16:22:08 +06:00
|
|
|
BLI_spin_lock(&image_spin);
|
|
|
|
if (source->cache != NULL) {
|
|
|
|
struct MovieCacheIter *iter;
|
|
|
|
iter = IMB_moviecacheIter_new(source->cache);
|
|
|
|
while (!IMB_moviecacheIter_done(iter)) {
|
|
|
|
ImBuf *ibuf = IMB_moviecacheIter_getImBuf(iter);
|
|
|
|
ImageCacheKey *key = IMB_moviecacheIter_getUserKey(iter);
|
|
|
|
imagecache_put(dest, key->index, ibuf);
|
|
|
|
IMB_moviecacheIter_step(iter);
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_free(iter);
|
2009-02-25 09:54:41 +00:00
|
|
|
}
|
2013-12-13 16:22:08 +06:00
|
|
|
BLI_spin_unlock(&image_spin);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2014-01-15 16:37:03 +01:00
|
|
|
BKE_libblock_free(G.main, source);
|
2009-02-25 09:54:41 +00:00
|
|
|
}
|
2009-01-27 19:32:44 +00:00
|
|
|
}
|
|
|
|
|
2012-05-17 15:26:11 +00:00
|
|
|
/* note, we could be clever and scale all imbuf's but since some are mipmaps its not so simple */
|
2014-02-03 18:55:59 +11:00
|
|
|
bool BKE_image_scale(Image *image, int width, int height)
|
2012-05-17 15:26:11 +00:00
|
|
|
{
|
|
|
|
ImBuf *ibuf;
|
|
|
|
void *lock;
|
|
|
|
|
|
|
|
ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
|
|
|
|
|
2012-06-29 10:52:37 +00:00
|
|
|
if (ibuf) {
|
|
|
|
IMB_scaleImBuf(ibuf, width, height);
|
|
|
|
ibuf->userflags |= IB_BITMAPDIRTY;
|
|
|
|
}
|
2012-05-17 15:26:11 +00:00
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(image, ibuf, lock);
|
2012-06-29 10:52:37 +00:00
|
|
|
|
|
|
|
return (ibuf != NULL);
|
2012-05-17 15:26:11 +00:00
|
|
|
}
|
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
bool BKE_image_has_bindcode(Image *ima)
|
|
|
|
{
|
|
|
|
bool has_bindcode = false;
|
|
|
|
for (int i = 0; i < TEXTARGET_COUNT; i++) {
|
|
|
|
if (ima->bindcode[i]) {
|
|
|
|
has_bindcode = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return has_bindcode;
|
|
|
|
}
|
|
|
|
|
2012-12-31 13:52:13 +00:00
|
|
|
static void image_init_color_management(Image *ima)
|
|
|
|
{
|
|
|
|
ImBuf *ibuf;
|
|
|
|
char name[FILE_MAX];
|
|
|
|
|
|
|
|
BKE_image_user_file_path(NULL, ima, name);
|
|
|
|
|
|
|
|
/* will set input color space to image format default's */
|
|
|
|
ibuf = IMB_loadiffname(name, IB_test | IB_alphamode_detect, ima->colorspace_settings.name);
|
|
|
|
|
|
|
|
if (ibuf) {
|
|
|
|
if (ibuf->flags & IB_alphamode_premul)
|
|
|
|
ima->alpha_mode = IMA_ALPHA_PREMUL;
|
|
|
|
else
|
|
|
|
ima->alpha_mode = IMA_ALPHA_STRAIGHT;
|
|
|
|
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-31 03:09:01 +11:00
|
|
|
char BKE_image_alpha_mode_from_extension_ex(const char *filepath)
|
2013-02-19 08:37:08 +00:00
|
|
|
{
|
2014-01-31 03:09:01 +11:00
|
|
|
if (BLI_testextensie_n(filepath, ".exr", ".cin", ".dpx", ".hdr", NULL)) {
|
|
|
|
return IMA_ALPHA_PREMUL;
|
2013-02-19 08:37:08 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-01-31 03:09:01 +11:00
|
|
|
return IMA_ALPHA_STRAIGHT;
|
2013-02-19 08:37:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-31 03:09:01 +11:00
|
|
|
void BKE_image_alpha_mode_from_extension(Image *image)
|
|
|
|
{
|
|
|
|
image->alpha_mode = BKE_image_alpha_mode_from_extension_ex(image->name);
|
|
|
|
}
|
|
|
|
|
2013-02-05 12:46:15 +00:00
|
|
|
Image *BKE_image_load(Main *bmain, const char *filepath)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
Image *ima;
|
2015-10-06 19:49:58 +11:00
|
|
|
int file;
|
2012-05-05 14:52:04 +00:00
|
|
|
char str[FILE_MAX];
|
|
|
|
|
|
|
|
BLI_strncpy(str, filepath, sizeof(str));
|
2013-02-05 12:46:15 +00:00
|
|
|
BLI_path_abs(str, bmain->name);
|
2012-05-05 14:52:04 +00:00
|
|
|
|
2007-03-29 12:42:30 +00:00
|
|
|
/* exists? */
|
2012-05-06 15:15:33 +00:00
|
|
|
file = BLI_open(str, O_BINARY | O_RDONLY, 0);
|
2014-04-22 16:40:17 +10:00
|
|
|
if (file == -1)
|
2013-08-04 17:30:47 +00:00
|
|
|
return NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
close(file);
|
2012-05-05 14:52:04 +00:00
|
|
|
|
2015-10-06 19:49:58 +11:00
|
|
|
ima = image_alloc(bmain, BLI_path_basename(filepath), IMA_SRC_FILE, IMA_TYPE_IMAGE);
|
2012-05-05 14:52:04 +00:00
|
|
|
BLI_strncpy(ima->name, filepath, sizeof(ima->name));
|
|
|
|
|
|
|
|
if (BLI_testextensie_array(filepath, imb_ext_movie))
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->source = IMA_SRC_MOVIE;
|
2012-05-05 14:52:04 +00:00
|
|
|
|
2012-12-31 13:52:13 +00:00
|
|
|
image_init_color_management(ima);
|
|
|
|
|
2012-05-05 14:52:04 +00:00
|
|
|
return ima;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* checks if image was already loaded, then returns same image */
|
|
|
|
/* otherwise creates new. */
|
|
|
|
/* does not load ibuf itself */
|
|
|
|
/* pass on optional frame for #name images */
|
2014-11-23 22:00:26 +01:00
|
|
|
Image *BKE_image_load_exists_ex(const char *filepath, bool *r_exists)
|
2012-05-05 14:52:04 +00:00
|
|
|
{
|
|
|
|
Image *ima;
|
|
|
|
char str[FILE_MAX], strtest[FILE_MAX];
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-05 14:52:04 +00:00
|
|
|
BLI_strncpy(str, filepath, sizeof(str));
|
|
|
|
BLI_path_abs(str, G.main->name);
|
|
|
|
|
2015-10-06 19:40:15 +11:00
|
|
|
/* first search an identical filepath */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (ima = G.main->image.first; ima; ima = ima->id.next) {
|
|
|
|
if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) {
|
2006-12-20 17:57:56 +00:00
|
|
|
BLI_strncpy(strtest, ima->name, sizeof(ima->name));
|
2013-07-15 11:26:43 +00:00
|
|
|
BLI_path_abs(strtest, ID_BLEND_PATH(G.main, &ima->id));
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (BLI_path_cmp(strtest, str) == 0) {
|
2015-04-06 10:40:12 -03:00
|
|
|
if ((BKE_image_has_anim(ima) == false) ||
|
|
|
|
(ima->id.us == 0))
|
|
|
|
{
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_plus(&ima->id); /* officially should not, it doesn't link here! */
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ima->ok == 0)
|
|
|
|
ima->ok = IMA_OK;
|
2014-11-23 22:00:26 +01:00
|
|
|
if (r_exists)
|
|
|
|
*r_exists = true;
|
2006-12-20 17:57:56 +00:00
|
|
|
return ima;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-05-05 14:52:04 +00:00
|
|
|
|
2014-11-23 22:00:26 +01:00
|
|
|
if (r_exists)
|
|
|
|
*r_exists = false;
|
2013-02-05 12:46:15 +00:00
|
|
|
return BKE_image_load(G.main, filepath);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2014-11-23 22:00:26 +01:00
|
|
|
Image *BKE_image_load_exists(const char *filepath)
|
|
|
|
{
|
|
|
|
return BKE_image_load_exists_ex(filepath, NULL);
|
|
|
|
}
|
|
|
|
|
2012-09-21 20:44:41 +00:00
|
|
|
static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type,
|
2013-08-07 22:40:03 +00:00
|
|
|
const float color[4], ColorManagedColorspaceSettings *colorspace_settings)
|
2005-09-16 20:17:09 +00:00
|
|
|
{
|
2006-12-20 17:57:56 +00:00
|
|
|
ImBuf *ibuf;
|
2012-05-06 15:15:33 +00:00
|
|
|
unsigned char *rect = NULL;
|
|
|
|
float *rect_float = NULL;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2007-12-29 05:17:19 +00:00
|
|
|
if (floatbuf) {
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf = IMB_allocImBuf(width, height, depth, IB_rectfloat);
|
2012-09-23 14:41:03 +00:00
|
|
|
|
|
|
|
if (colorspace_settings->name[0] == '\0') {
|
|
|
|
const char *colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_FLOAT);
|
|
|
|
|
|
|
|
BLI_strncpy(colorspace_settings->name, colorspace, sizeof(colorspace_settings->name));
|
|
|
|
}
|
2012-09-25 08:42:24 +00:00
|
|
|
|
2013-12-16 16:42:48 +06:00
|
|
|
if (ibuf != NULL) {
|
|
|
|
rect_float = ibuf->rect_float;
|
|
|
|
IMB_colormanagement_check_is_data(ibuf, colorspace_settings->name);
|
|
|
|
}
|
2007-12-29 05:17:19 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf = IMB_allocImBuf(width, height, depth, IB_rect);
|
2012-09-21 20:44:41 +00:00
|
|
|
|
2012-09-23 14:41:03 +00:00
|
|
|
if (colorspace_settings->name[0] == '\0') {
|
|
|
|
const char *colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE);
|
|
|
|
|
|
|
|
BLI_strncpy(colorspace_settings->name, colorspace, sizeof(colorspace_settings->name));
|
|
|
|
}
|
|
|
|
|
2013-12-16 16:42:48 +06:00
|
|
|
if (ibuf != NULL) {
|
|
|
|
rect = (unsigned char *)ibuf->rect;
|
|
|
|
IMB_colormanagement_assign_rect_colorspace(ibuf, colorspace_settings->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ibuf) {
|
|
|
|
return NULL;
|
2007-12-29 05:17:19 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2010-10-15 12:29:02 +00:00
|
|
|
BLI_strncpy(ibuf->name, name, sizeof(ibuf->name));
|
2006-12-20 17:57:56 +00:00
|
|
|
ibuf->userflags |= IB_BITMAPDIRTY;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-08-29 08:17:38 +00:00
|
|
|
switch (gen_type) {
|
|
|
|
case IMA_GENTYPE_GRID:
|
2012-05-06 15:15:33 +00:00
|
|
|
BKE_image_buf_fill_checker(rect, rect_float, width, height);
|
|
|
|
break;
|
2012-08-29 08:17:38 +00:00
|
|
|
case IMA_GENTYPE_GRID_COLOR:
|
2012-05-06 15:15:33 +00:00
|
|
|
BKE_image_buf_fill_checker_color(rect, rect_float, width, height);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BKE_image_buf_fill_color(rect, rect_float, width, height, color);
|
2013-07-21 08:16:37 +00:00
|
|
|
break;
|
2010-03-22 09:30:00 +00:00
|
|
|
}
|
2008-01-06 16:04:48 +00:00
|
|
|
|
2012-11-26 17:38:03 +00:00
|
|
|
if (rect_float) {
|
|
|
|
/* both byte and float buffers are filling in sRGB space, need to linearize float buffer after BKE_image_buf_fill* functions */
|
|
|
|
|
|
|
|
IMB_buffer_float_from_float(rect_float, rect_float, ibuf->channels, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB,
|
2014-04-01 11:34:00 +11:00
|
|
|
true, ibuf->x, ibuf->y, ibuf->x, ibuf->x);
|
2012-11-26 17:38:03 +00:00
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
return ibuf;
|
|
|
|
}
|
2005-09-16 20:17:09 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* adds new image block, creates ImBuf and initializes color */
|
2016-01-11 12:32:29 +11:00
|
|
|
Image *BKE_image_add_generated(
|
|
|
|
Main *bmain, unsigned int width, unsigned int height, const char *name,
|
|
|
|
int depth, int floatbuf, short gen_type, const float color[4], const bool stereo3d)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
|
|
|
/* on save, type is changed to FILE in editsima.c */
|
2013-02-05 12:46:15 +00:00
|
|
|
Image *ima = image_alloc(bmain, name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
if (ima) {
|
2015-10-24 01:01:10 +11:00
|
|
|
int view_id;
|
2015-04-06 10:40:12 -03:00
|
|
|
const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-03-18 07:38:51 +00:00
|
|
|
/* BLI_strncpy(ima->name, name, FILE_MAX); */ /* don't do this, this writes in ain invalid filepath! */
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->gen_x = width;
|
|
|
|
ima->gen_y = height;
|
2012-08-29 08:17:38 +00:00
|
|
|
ima->gen_type = gen_type;
|
2011-07-21 00:41:00 +00:00
|
|
|
ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
|
2013-08-12 07:47:44 +00:00
|
|
|
ima->gen_depth = depth;
|
2014-10-02 19:04:38 +06:00
|
|
|
copy_v4_v4(ima->gen_color, color);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
for (view_id = 0; view_id < 2; view_id++) {
|
|
|
|
ImBuf *ibuf;
|
|
|
|
ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, gen_type, color, &ima->colorspace_settings);
|
|
|
|
image_assign_ibuf(ima, ibuf, stereo3d ? view_id : IMA_NO_INDEX, 0);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* image_assign_ibuf puts buffer to the cache, which increments user counter. */
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
if (!stereo3d) break;
|
|
|
|
|
|
|
|
image_add_view(ima, names[view_id], "");
|
|
|
|
}
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->ok = IMA_OK_LOADED;
|
2005-09-16 20:17:09 +00:00
|
|
|
}
|
|
|
|
|
2010-03-08 20:08:04 +00:00
|
|
|
return ima;
|
|
|
|
}
|
|
|
|
|
2015-02-09 12:02:59 +01:00
|
|
|
/* Create an image image from ibuf. The refcount of ibuf is increased,
|
|
|
|
* caller should take care to drop its reference by calling
|
|
|
|
* IMB_freeImBuf if needed. */
|
2015-05-04 12:25:33 +10:00
|
|
|
Image *BKE_image_add_from_imbuf(ImBuf *ibuf, const char *name)
|
2010-03-08 20:08:04 +00:00
|
|
|
{
|
|
|
|
/* on save, type is changed to FILE in editsima.c */
|
2010-03-08 21:33:51 +00:00
|
|
|
Image *ima;
|
|
|
|
|
2015-05-04 12:25:33 +10:00
|
|
|
if (name == NULL) {
|
|
|
|
name = BLI_path_basename(ibuf->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
ima = image_alloc(G.main, name, IMA_SRC_FILE, IMA_TYPE_IMAGE);
|
2010-03-08 20:08:04 +00:00
|
|
|
|
|
|
|
if (ima) {
|
|
|
|
BLI_strncpy(ima->name, ibuf->name, FILE_MAX);
|
|
|
|
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->ok = IMA_OK_LOADED;
|
2010-03-08 20:08:04 +00:00
|
|
|
}
|
|
|
|
|
2005-09-16 20:17:09 +00:00
|
|
|
return ima;
|
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* packs rects from memory as PNG
|
|
|
|
* convert multiview images to R_IMF_VIEWS_INDIVIDUAL
|
|
|
|
*/
|
|
|
|
static void image_memorypack_multiview(Image *ima)
|
|
|
|
{
|
|
|
|
ImageView *iv;
|
2015-10-24 01:01:10 +11:00
|
|
|
int i;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
image_free_packedfiles(ima);
|
|
|
|
|
|
|
|
for (i = 0, iv = ima->views.first; iv; iv = iv->next, i++) {
|
|
|
|
ImBuf *ibuf = image_get_cached_ibuf_for_index_frame(ima, i, 0);
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_PNG;
|
2015-04-06 10:40:12 -03:00
|
|
|
ibuf->planes = R_IMF_PLANES_RGBA;
|
|
|
|
|
|
|
|
/* if the image was a R_IMF_VIEWS_STEREO_3D we force _L, _R suffices */
|
|
|
|
if (ima->views_format == R_IMF_VIEWS_STEREO_3D) {
|
|
|
|
const char *suffix[2] = {STEREO_LEFT_SUFFIX, STEREO_RIGHT_SUFFIX};
|
|
|
|
BLI_path_suffix(iv->filepath, FILE_MAX, suffix[i], "");
|
|
|
|
}
|
|
|
|
|
|
|
|
IMB_saveiff(ibuf, iv->filepath, IB_rect | IB_mem);
|
|
|
|
|
|
|
|
if (ibuf->encodedbuffer == NULL) {
|
|
|
|
printf("memory save for pack error\n");
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
image_free_packedfiles(ima);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ImagePackedFile *imapf;
|
|
|
|
PackedFile *pf = MEM_callocN(sizeof(*pf), "PackedFile");
|
|
|
|
|
|
|
|
pf->data = ibuf->encodedbuffer;
|
|
|
|
pf->size = ibuf->encodedsize;
|
|
|
|
|
|
|
|
imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image PackedFile");
|
|
|
|
BLI_strncpy(imapf->filepath, iv->filepath, sizeof(imapf->filepath));
|
|
|
|
imapf->packedfile = pf;
|
|
|
|
BLI_addtail(&ima->packedfiles, imapf);
|
|
|
|
|
|
|
|
ibuf->encodedbuffer = NULL;
|
|
|
|
ibuf->encodedsize = 0;
|
|
|
|
ibuf->userflags &= ~IB_BITMAPDIRTY;
|
|
|
|
}
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ima->source == IMA_SRC_GENERATED) {
|
|
|
|
ima->source = IMA_SRC_FILE;
|
|
|
|
ima->type = IMA_TYPE_IMAGE;
|
|
|
|
}
|
|
|
|
ima->views_format = R_IMF_VIEWS_INDIVIDUAL;
|
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* packs rect from memory as PNG */
|
|
|
|
void BKE_image_memorypack(Image *ima)
|
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
2015-10-11 01:14:02 +02:00
|
|
|
if (BKE_image_is_multiview(ima)) {
|
2015-04-19 22:03:42 +10:00
|
|
|
image_memorypack_multiview(ima);
|
|
|
|
return;
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
ibuf = image_get_cached_ibuf_for_index_frame(ima, IMA_NO_INDEX, 0);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ibuf == NULL)
|
2006-12-20 17:57:56 +00:00
|
|
|
return;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
image_free_packedfiles(ima);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_PNG;
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->planes = R_IMF_PLANES_RGBA;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
IMB_saveiff(ibuf, ibuf->name, IB_rect | IB_mem);
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ibuf->encodedbuffer == NULL) {
|
2006-12-20 17:57:56 +00:00
|
|
|
printf("memory save for pack error\n");
|
|
|
|
}
|
|
|
|
else {
|
2015-04-06 10:40:12 -03:00
|
|
|
ImagePackedFile *imapf;
|
2006-12-20 17:57:56 +00:00
|
|
|
PackedFile *pf = MEM_callocN(sizeof(*pf), "PackedFile");
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
pf->data = ibuf->encodedbuffer;
|
|
|
|
pf->size = ibuf->encodedsize;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image PackedFile");
|
|
|
|
BLI_strncpy(imapf->filepath, ima->name, sizeof(imapf->filepath));
|
|
|
|
imapf->packedfile = pf;
|
|
|
|
BLI_addtail(&ima->packedfiles, imapf);
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->encodedbuffer = NULL;
|
|
|
|
ibuf->encodedsize = 0;
|
2006-12-20 17:57:56 +00:00
|
|
|
ibuf->userflags &= ~IB_BITMAPDIRTY;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ima->source == IMA_SRC_GENERATED) {
|
|
|
|
ima->source = IMA_SRC_FILE;
|
|
|
|
ima->type = IMA_TYPE_IMAGE;
|
2006-12-21 13:39:02 +00:00
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2013-12-13 16:22:08 +06:00
|
|
|
|
|
|
|
IMB_freeImBuf(ibuf);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
void BKE_image_packfiles(ReportList *reports, Image *ima, const char *basepath)
|
|
|
|
{
|
2015-10-24 01:01:10 +11:00
|
|
|
const int totfiles = image_num_files(ima);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
if (totfiles == 1) {
|
|
|
|
ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image packed file");
|
|
|
|
BLI_addtail(&ima->packedfiles, imapf);
|
|
|
|
imapf->packedfile = newPackedFile(reports, ima->name, basepath);
|
2015-05-26 13:45:45 +02:00
|
|
|
if (imapf->packedfile) {
|
|
|
|
BLI_strncpy(imapf->filepath, ima->name, sizeof(imapf->filepath));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_freelinkN(&ima->packedfiles, imapf);
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ImageView *iv;
|
|
|
|
for (iv = ima->views.first; iv; iv = iv->next) {
|
|
|
|
ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image packed file");
|
|
|
|
BLI_addtail(&ima->packedfiles, imapf);
|
|
|
|
|
|
|
|
imapf->packedfile = newPackedFile(reports, iv->filepath, basepath);
|
2015-05-26 13:45:45 +02:00
|
|
|
if (imapf->packedfile) {
|
|
|
|
BLI_strncpy(imapf->filepath, iv->filepath, sizeof(imapf->filepath));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_freelinkN(&ima->packedfiles, imapf);
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-22 23:28:41 +02:00
|
|
|
void BKE_image_packfiles_from_mem(ReportList *reports, Image *ima, char *data, const size_t data_len)
|
|
|
|
{
|
2015-10-24 01:01:10 +11:00
|
|
|
const int totfiles = image_num_files(ima);
|
2015-05-22 23:28:41 +02:00
|
|
|
|
|
|
|
if (totfiles != 1) {
|
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot pack multiview images from raw data currently...");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), __func__);
|
|
|
|
BLI_addtail(&ima->packedfiles, imapf);
|
|
|
|
imapf->packedfile = newPackedFileMemory(data, data_len);
|
|
|
|
BLI_strncpy(imapf->filepath, ima->name, sizeof(imapf->filepath));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_image_tag_time(Image *ima)
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
{
|
2015-02-01 01:57:45 +11:00
|
|
|
ima->lastused = PIL_check_seconds_timer_i();
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
}
|
|
|
|
|
2008-12-26 14:19:25 +00:00
|
|
|
#if 0
|
2012-06-23 23:22:19 +00:00
|
|
|
static void tag_all_images_time()
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
Image *ima;
|
2015-02-01 01:57:45 +11:00
|
|
|
int ctime = PIL_check_seconds_timer_i();
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ima = G.main->image.first;
|
2012-03-24 06:18:31 +00:00
|
|
|
while (ima) {
|
|
|
|
if (ima->bindcode || ima->repbind || ima->ibufs.first) {
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
ima->lastused = ctime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-12-26 14:19:25 +00:00
|
|
|
#endif
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
static uintptr_t image_mem_size(Image *image)
|
2008-02-01 12:14:15 +00:00
|
|
|
{
|
2008-08-17 17:08:00 +00:00
|
|
|
uintptr_t size = 0;
|
2008-02-01 12:14:15 +00:00
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
/* viewers have memory depending on other rules, has no valid rect pointer */
|
2013-12-13 16:22:08 +06:00
|
|
|
if (image->source == IMA_SRC_VIEWER)
|
2009-06-08 20:08:19 +00:00
|
|
|
return 0;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
BLI_spin_lock(&image_spin);
|
|
|
|
if (image->cache != NULL) {
|
|
|
|
struct MovieCacheIter *iter = IMB_moviecacheIter_new(image->cache);
|
|
|
|
|
|
|
|
while (!IMB_moviecacheIter_done(iter)) {
|
|
|
|
ImBuf *ibuf = IMB_moviecacheIter_getImBuf(iter);
|
|
|
|
ImBuf *ibufm;
|
|
|
|
int level;
|
2008-02-01 12:14:15 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
if (ibuf->rect) {
|
|
|
|
size += MEM_allocN_len(ibuf->rect);
|
|
|
|
}
|
|
|
|
if (ibuf->rect_float) {
|
|
|
|
size += MEM_allocN_len(ibuf->rect_float);
|
2008-02-01 12:14:15 +00:00
|
|
|
}
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2015-07-13 22:00:07 +10:00
|
|
|
for (level = 0; level < IMB_MIPMAP_LEVELS; level++) {
|
2013-12-13 16:22:08 +06:00
|
|
|
ibufm = ibuf->mipmap[level];
|
|
|
|
if (ibufm) {
|
|
|
|
if (ibufm->rect) {
|
|
|
|
size += MEM_allocN_len(ibufm->rect);
|
|
|
|
}
|
|
|
|
if (ibufm->rect_float) {
|
|
|
|
size += MEM_allocN_len(ibufm->rect_float);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IMB_moviecacheIter_step(iter);
|
2008-02-01 12:14:15 +00:00
|
|
|
}
|
2013-12-13 16:22:08 +06:00
|
|
|
IMB_moviecacheIter_free(iter);
|
2008-02-01 12:14:15 +00:00
|
|
|
}
|
2013-12-13 16:22:08 +06:00
|
|
|
BLI_spin_unlock(&image_spin);
|
2008-02-01 12:14:15 +00:00
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_print_memlist(void)
|
|
|
|
{
|
|
|
|
Image *ima;
|
2012-05-06 15:15:33 +00:00
|
|
|
uintptr_t size, totsize = 0;
|
2008-02-01 12:14:15 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (ima = G.main->image.first; ima; ima = ima->id.next)
|
2008-02-01 12:14:15 +00:00
|
|
|
totsize += image_mem_size(ima);
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
printf("\ntotal image memory len: %.3f MB\n", (double)totsize / (double)(1024 * 1024));
|
2008-02-01 12:14:15 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (ima = G.main->image.first; ima; ima = ima->id.next) {
|
|
|
|
size = image_mem_size(ima);
|
2008-02-01 12:14:15 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (size)
|
2012-05-06 15:15:33 +00:00
|
|
|
printf("%s len: %.3f MB\n", ima->id.name + 2, (double)size / (double)(1024 * 1024));
|
2008-02-01 12:14:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
static bool imagecache_check_dirty(ImBuf *ibuf, void *UNUSED(userkey), void *UNUSED(userdata))
|
|
|
|
{
|
|
|
|
return (ibuf->userflags & IB_BITMAPDIRTY) == 0;
|
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
void BKE_image_free_all_textures(void)
|
2006-02-11 23:17:41 +00:00
|
|
|
{
|
2013-12-13 16:22:08 +06:00
|
|
|
#undef CHECK_FREED_SIZE
|
|
|
|
|
2006-02-11 23:17:41 +00:00
|
|
|
Tex *tex;
|
|
|
|
Image *ima;
|
2013-12-13 16:22:08 +06:00
|
|
|
#ifdef CHECK_FREED_SIZE
|
|
|
|
uintptr_t tot_freed_size = 0;
|
|
|
|
#endif
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (ima = G.main->image.first; ima; ima = ima->id.next)
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
ima->id.tag &= ~LIB_TAG_DOIT;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (tex = G.main->tex.first; tex; tex = tex->id.next)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tex->ima)
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
tex->ima->id.tag |= LIB_TAG_DOIT;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (ima = G.main->image.first; ima; ima = ima->id.next) {
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
if (ima->cache && (ima->id.tag & LIB_TAG_DOIT)) {
|
2013-12-13 16:22:08 +06:00
|
|
|
#ifdef CHECK_FREED_SIZE
|
|
|
|
uintptr_t old_size = image_mem_size(ima);
|
|
|
|
#endif
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
IMB_moviecache_cleanup(ima->cache, imagecache_check_dirty, NULL);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
#ifdef CHECK_FREED_SIZE
|
|
|
|
tot_freed_size += old_size - image_mem_size(ima);
|
2012-03-03 20:19:11 +00:00
|
|
|
#endif
|
2006-02-11 23:17:41 +00:00
|
|
|
}
|
|
|
|
}
|
2013-12-13 16:22:08 +06:00
|
|
|
#ifdef CHECK_FREED_SIZE
|
|
|
|
printf("%s: freed total %lu MB\n", __func__, tot_freed_size / (1024 * 1024));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool imagecache_check_free_anim(ImBuf *ibuf, void *UNUSED(userkey), void *userdata)
|
|
|
|
{
|
|
|
|
int except_frame = *(int *)userdata;
|
|
|
|
return (ibuf->userflags & IB_BITMAPDIRTY) == 0 &&
|
|
|
|
(ibuf->index != IMA_NO_INDEX) &&
|
|
|
|
(except_frame != IMA_INDEX_FRAME(ibuf->index));
|
2006-02-11 23:17:41 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* except_frame is weak, only works for seqs without offset... */
|
|
|
|
void BKE_image_free_anim_ibufs(Image *ima, int except_frame)
|
|
|
|
{
|
2013-12-16 16:30:28 +06:00
|
|
|
BLI_spin_lock(&image_spin);
|
|
|
|
if (ima->cache != NULL) {
|
|
|
|
IMB_moviecache_cleanup(ima->cache, imagecache_check_free_anim, &except_frame);
|
|
|
|
}
|
|
|
|
BLI_spin_unlock(&image_spin);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_all_free_anim_ibufs(int cfra)
|
|
|
|
{
|
|
|
|
Image *ima;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (ima = G.main->image.first; ima; ima = ima->id.next)
|
2014-01-14 04:59:58 +11:00
|
|
|
if (BKE_image_is_animated(ima))
|
2006-12-20 17:57:56 +00:00
|
|
|
BKE_image_free_anim_ibufs(ima, cfra);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* *********** READ AND WRITE ************** */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
int BKE_image_imtype_to_ftype(const char imtype, ImbFormatOptions *r_options)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2015-07-13 13:58:17 +02:00
|
|
|
memset(r_options, 0, sizeof(*r_options));
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (imtype == R_IMF_IMTYPE_TARGA)
|
2015-07-13 13:58:17 +02:00
|
|
|
return IMB_FTYPE_TGA;
|
|
|
|
else if (imtype == R_IMF_IMTYPE_RAWTGA) {
|
|
|
|
r_options->flag = RAWTGA;
|
|
|
|
return IMB_FTYPE_TGA;
|
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_IRIS)
|
2015-07-13 13:58:17 +02:00
|
|
|
return IMB_FTYPE_IMAGIC;
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_HDR
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_RADHDR)
|
2015-07-13 13:58:17 +02:00
|
|
|
return IMB_FTYPE_RADHDR;
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_PNG) {
|
|
|
|
r_options->quality = 15;
|
|
|
|
return IMB_FTYPE_PNG;
|
|
|
|
}
|
2007-06-25 19:50:25 +00:00
|
|
|
#ifdef WITH_DDS
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_DDS)
|
2015-07-13 13:58:17 +02:00
|
|
|
return IMB_FTYPE_DDS;
|
2007-06-25 19:50:25 +00:00
|
|
|
#endif
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_BMP)
|
2015-07-13 13:58:17 +02:00
|
|
|
return IMB_FTYPE_BMP;
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_TIFF
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_TIFF)
|
2015-07-13 13:58:17 +02:00
|
|
|
return IMB_FTYPE_TIF;
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER)
|
2015-07-13 13:58:17 +02:00
|
|
|
return IMB_FTYPE_OPENEXR;
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_CINEON
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_CINEON)
|
2015-07-13 13:58:17 +02:00
|
|
|
return IMB_FTYPE_CINEON;
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_DPX)
|
2015-07-13 13:58:17 +02:00
|
|
|
return IMB_FTYPE_DPX;
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2009-01-26 08:34:40 +00:00
|
|
|
#ifdef WITH_OPENJPEG
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_JP2)
|
2015-07-13 13:58:17 +02:00
|
|
|
return IMB_FTYPE_JP2;
|
2009-01-26 08:34:40 +00:00
|
|
|
#endif
|
2015-07-13 13:58:17 +02:00
|
|
|
else {
|
|
|
|
r_options->quality = 90;
|
|
|
|
return IMB_FTYPE_JPG;
|
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
char BKE_image_ftype_to_imtype(const int ftype, const ImbFormatOptions *options)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ftype == 0)
|
2011-11-22 00:35:26 +00:00
|
|
|
return R_IMF_IMTYPE_TARGA;
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_IMAGIC)
|
2011-11-22 00:35:26 +00:00
|
|
|
return R_IMF_IMTYPE_IRIS;
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_HDR
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_RADHDR)
|
2011-11-22 00:35:26 +00:00
|
|
|
return R_IMF_IMTYPE_RADHDR;
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_PNG)
|
2011-11-22 00:35:26 +00:00
|
|
|
return R_IMF_IMTYPE_PNG;
|
2007-06-25 19:50:25 +00:00
|
|
|
#ifdef WITH_DDS
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_DDS)
|
2011-11-22 00:35:26 +00:00
|
|
|
return R_IMF_IMTYPE_DDS;
|
2007-06-25 19:50:25 +00:00
|
|
|
#endif
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_BMP)
|
2011-11-22 00:35:26 +00:00
|
|
|
return R_IMF_IMTYPE_BMP;
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_TIFF
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_TIF)
|
2011-11-22 00:35:26 +00:00
|
|
|
return R_IMF_IMTYPE_TIFF;
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_OPENEXR)
|
2011-11-22 00:35:26 +00:00
|
|
|
return R_IMF_IMTYPE_OPENEXR;
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_CINEON
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_CINEON)
|
2011-11-22 00:35:26 +00:00
|
|
|
return R_IMF_IMTYPE_CINEON;
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_DPX)
|
2011-11-22 00:35:26 +00:00
|
|
|
return R_IMF_IMTYPE_DPX;
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_TGA) {
|
|
|
|
if (options && (options->flag & RAWTGA))
|
|
|
|
return R_IMF_IMTYPE_RAWTGA;
|
|
|
|
else
|
|
|
|
return R_IMF_IMTYPE_TARGA;
|
|
|
|
}
|
2009-01-26 08:34:40 +00:00
|
|
|
#ifdef WITH_OPENJPEG
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_JP2)
|
2011-11-22 00:35:26 +00:00
|
|
|
return R_IMF_IMTYPE_JP2;
|
2009-01-26 08:34:40 +00:00
|
|
|
#endif
|
2006-12-20 17:57:56 +00:00
|
|
|
else
|
2011-11-22 00:35:26 +00:00
|
|
|
return R_IMF_IMTYPE_JPEG90;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-09 05:35:49 +00:00
|
|
|
bool BKE_imtype_is_movie(const char imtype)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (imtype) {
|
2012-05-06 15:15:33 +00:00
|
|
|
case R_IMF_IMTYPE_AVIRAW:
|
|
|
|
case R_IMF_IMTYPE_AVIJPEG:
|
|
|
|
case R_IMF_IMTYPE_QUICKTIME:
|
|
|
|
case R_IMF_IMTYPE_FFMPEG:
|
|
|
|
case R_IMF_IMTYPE_H264:
|
|
|
|
case R_IMF_IMTYPE_THEORA:
|
|
|
|
case R_IMF_IMTYPE_XVID:
|
|
|
|
case R_IMF_IMTYPE_FRAMESERVER:
|
2013-03-09 05:35:49 +00:00
|
|
|
return true;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2013-03-09 05:35:49 +00:00
|
|
|
return false;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2011-11-22 00:06:54 +00:00
|
|
|
int BKE_imtype_supports_zbuf(const char imtype)
|
2011-11-21 20:19:58 +00:00
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (imtype) {
|
2012-05-06 15:15:33 +00:00
|
|
|
case R_IMF_IMTYPE_IRIZ:
|
|
|
|
case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */
|
2011-11-21 20:19:58 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-22 00:06:54 +00:00
|
|
|
int BKE_imtype_supports_compress(const char imtype)
|
2011-11-21 20:19:58 +00:00
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (imtype) {
|
2012-05-06 15:15:33 +00:00
|
|
|
case R_IMF_IMTYPE_PNG:
|
2011-11-21 20:19:58 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-22 00:06:54 +00:00
|
|
|
int BKE_imtype_supports_quality(const char imtype)
|
2011-11-21 20:19:58 +00:00
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (imtype) {
|
2012-05-06 15:15:33 +00:00
|
|
|
case R_IMF_IMTYPE_JPEG90:
|
|
|
|
case R_IMF_IMTYPE_JP2:
|
|
|
|
case R_IMF_IMTYPE_AVIJPEG:
|
2011-11-21 20:19:58 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-24 11:56:07 +00:00
|
|
|
int BKE_imtype_requires_linear_float(const char imtype)
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
{
|
|
|
|
switch (imtype) {
|
|
|
|
case R_IMF_IMTYPE_CINEON:
|
|
|
|
case R_IMF_IMTYPE_DPX:
|
|
|
|
case R_IMF_IMTYPE_RADHDR:
|
|
|
|
case R_IMF_IMTYPE_OPENEXR:
|
|
|
|
case R_IMF_IMTYPE_MULTILAYER:
|
2014-04-01 11:34:00 +11:00
|
|
|
return true;
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-31 14:20:55 +09:00
|
|
|
char BKE_imtype_valid_channels(const char imtype, bool write_file)
|
2011-11-25 03:47:34 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
char chan_flag = IMA_CHAN_FLAG_RGB; /* assume all support rgb */
|
2011-11-25 03:47:34 +00:00
|
|
|
|
|
|
|
/* alpha */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (imtype) {
|
2014-03-31 14:20:55 +09:00
|
|
|
case R_IMF_IMTYPE_BMP:
|
|
|
|
if (write_file) break;
|
|
|
|
/* fall-through */
|
2012-05-06 15:15:33 +00:00
|
|
|
case R_IMF_IMTYPE_TARGA:
|
2015-10-21 20:06:49 +02:00
|
|
|
case R_IMF_IMTYPE_RAWTGA:
|
2012-05-06 15:15:33 +00:00
|
|
|
case R_IMF_IMTYPE_IRIS:
|
|
|
|
case R_IMF_IMTYPE_PNG:
|
|
|
|
case R_IMF_IMTYPE_RADHDR:
|
|
|
|
case R_IMF_IMTYPE_TIFF:
|
|
|
|
case R_IMF_IMTYPE_OPENEXR:
|
|
|
|
case R_IMF_IMTYPE_MULTILAYER:
|
|
|
|
case R_IMF_IMTYPE_DDS:
|
|
|
|
case R_IMF_IMTYPE_JP2:
|
|
|
|
case R_IMF_IMTYPE_QUICKTIME:
|
Patch #27397: Improved DPX/Cineon code
Patch by Julien Enche, thanks!
From the patch comment:
It allows Blender to load:
- 1, 8, 10, 12 and 16 bits files. For 10 and 12 bits files, packed or
filled type A/B are supported.
- RGB, Log, Luma and YCbCr colorspaces.
- Big and little endian storage.
- Multi-elements (planar) storage.
It allows Blender to save :
- 8, 10, 12 and 16 bits file. For 10 and 12 bits files, the most used
type A padding is used.
- RGB and Log colorspaces (Cineon can only be saved in Log colorspace).
For Log colorspace, the common default values are used for gamma,
reference black and reference white (respectively 1.7, 95 and 685 for
10 bits files).
- Saved DPX/Cineon files now match the viewer.
Some files won't load (mostly because I haven't seen any of them):
- Compressed files
- 32 and 64 bits files
- Image orientation information are not taken in account. Here too,
I haven't seen any file that was not top-bottom/left-right oriented.
2012-10-22 12:49:00 +00:00
|
|
|
case R_IMF_IMTYPE_DPX:
|
2011-11-25 03:47:34 +00:00
|
|
|
chan_flag |= IMA_CHAN_FLAG_ALPHA;
|
2013-07-21 08:16:37 +00:00
|
|
|
break;
|
2011-11-25 03:47:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* bw */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (imtype) {
|
2012-05-06 15:15:33 +00:00
|
|
|
case R_IMF_IMTYPE_PNG:
|
|
|
|
case R_IMF_IMTYPE_JPEG90:
|
|
|
|
case R_IMF_IMTYPE_TARGA:
|
|
|
|
case R_IMF_IMTYPE_RAWTGA:
|
|
|
|
case R_IMF_IMTYPE_TIFF:
|
|
|
|
case R_IMF_IMTYPE_IRIS:
|
2011-11-25 03:47:34 +00:00
|
|
|
chan_flag |= IMA_CHAN_FLAG_BW;
|
2013-07-21 08:16:37 +00:00
|
|
|
break;
|
2011-11-25 03:47:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return chan_flag;
|
|
|
|
}
|
|
|
|
|
2011-11-22 00:06:54 +00:00
|
|
|
char BKE_imtype_valid_depths(const char imtype)
|
2011-11-21 20:19:58 +00:00
|
|
|
{
|
|
|
|
switch (imtype) {
|
2012-05-06 15:15:33 +00:00
|
|
|
case R_IMF_IMTYPE_RADHDR:
|
|
|
|
return R_IMF_CHAN_DEPTH_32;
|
|
|
|
case R_IMF_IMTYPE_TIFF:
|
|
|
|
return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_16;
|
|
|
|
case R_IMF_IMTYPE_OPENEXR:
|
|
|
|
return R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_32;
|
|
|
|
case R_IMF_IMTYPE_MULTILAYER:
|
2015-06-19 13:00:18 +02:00
|
|
|
return R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_32;
|
Patch #27397: Improved DPX/Cineon code
Patch by Julien Enche, thanks!
From the patch comment:
It allows Blender to load:
- 1, 8, 10, 12 and 16 bits files. For 10 and 12 bits files, packed or
filled type A/B are supported.
- RGB, Log, Luma and YCbCr colorspaces.
- Big and little endian storage.
- Multi-elements (planar) storage.
It allows Blender to save :
- 8, 10, 12 and 16 bits file. For 10 and 12 bits files, the most used
type A padding is used.
- RGB and Log colorspaces (Cineon can only be saved in Log colorspace).
For Log colorspace, the common default values are used for gamma,
reference black and reference white (respectively 1.7, 95 and 685 for
10 bits files).
- Saved DPX/Cineon files now match the viewer.
Some files won't load (mostly because I haven't seen any of them):
- Compressed files
- 32 and 64 bits files
- Image orientation information are not taken in account. Here too,
I haven't seen any file that was not top-bottom/left-right oriented.
2012-10-22 12:49:00 +00:00
|
|
|
/* eeh, cineon does some strange 10bits per channel */
|
2012-05-06 15:15:33 +00:00
|
|
|
case R_IMF_IMTYPE_DPX:
|
Patch #27397: Improved DPX/Cineon code
Patch by Julien Enche, thanks!
From the patch comment:
It allows Blender to load:
- 1, 8, 10, 12 and 16 bits files. For 10 and 12 bits files, packed or
filled type A/B are supported.
- RGB, Log, Luma and YCbCr colorspaces.
- Big and little endian storage.
- Multi-elements (planar) storage.
It allows Blender to save :
- 8, 10, 12 and 16 bits file. For 10 and 12 bits files, the most used
type A padding is used.
- RGB and Log colorspaces (Cineon can only be saved in Log colorspace).
For Log colorspace, the common default values are used for gamma,
reference black and reference white (respectively 1.7, 95 and 685 for
10 bits files).
- Saved DPX/Cineon files now match the viewer.
Some files won't load (mostly because I haven't seen any of them):
- Compressed files
- 32 and 64 bits files
- Image orientation information are not taken in account. Here too,
I haven't seen any file that was not top-bottom/left-right oriented.
2012-10-22 12:49:00 +00:00
|
|
|
return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_10 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16;
|
2012-05-06 15:15:33 +00:00
|
|
|
case R_IMF_IMTYPE_CINEON:
|
Patch #27397: Improved DPX/Cineon code
Patch by Julien Enche, thanks!
From the patch comment:
It allows Blender to load:
- 1, 8, 10, 12 and 16 bits files. For 10 and 12 bits files, packed or
filled type A/B are supported.
- RGB, Log, Luma and YCbCr colorspaces.
- Big and little endian storage.
- Multi-elements (planar) storage.
It allows Blender to save :
- 8, 10, 12 and 16 bits file. For 10 and 12 bits files, the most used
type A padding is used.
- RGB and Log colorspaces (Cineon can only be saved in Log colorspace).
For Log colorspace, the common default values are used for gamma,
reference black and reference white (respectively 1.7, 95 and 685 for
10 bits files).
- Saved DPX/Cineon files now match the viewer.
Some files won't load (mostly because I haven't seen any of them):
- Compressed files
- 32 and 64 bits files
- Image orientation information are not taken in account. Here too,
I haven't seen any file that was not top-bottom/left-right oriented.
2012-10-22 12:49:00 +00:00
|
|
|
return R_IMF_CHAN_DEPTH_10;
|
2012-05-06 15:15:33 +00:00
|
|
|
case R_IMF_IMTYPE_JP2:
|
|
|
|
return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16;
|
2012-12-30 13:01:47 +00:00
|
|
|
case R_IMF_IMTYPE_PNG:
|
|
|
|
return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_16;
|
2012-05-06 15:15:33 +00:00
|
|
|
/* most formats are 8bit only */
|
|
|
|
default:
|
|
|
|
return R_IMF_CHAN_DEPTH_8;
|
2011-11-21 20:19:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-24 05:18:26 +00:00
|
|
|
|
|
|
|
/* string is from command line --render-format arg, keep in sync with
|
|
|
|
* creator.c help info */
|
|
|
|
char BKE_imtype_from_arg(const char *imtype_arg)
|
|
|
|
{
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(imtype_arg, "TGA")) return R_IMF_IMTYPE_TARGA;
|
|
|
|
else if (STREQ(imtype_arg, "IRIS")) return R_IMF_IMTYPE_IRIS;
|
2011-11-24 05:18:26 +00:00
|
|
|
#ifdef WITH_DDS
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(imtype_arg, "DDS")) return R_IMF_IMTYPE_DDS;
|
2011-11-24 05:18:26 +00:00
|
|
|
#endif
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(imtype_arg, "JPEG")) return R_IMF_IMTYPE_JPEG90;
|
|
|
|
else if (STREQ(imtype_arg, "IRIZ")) return R_IMF_IMTYPE_IRIZ;
|
|
|
|
else if (STREQ(imtype_arg, "RAWTGA")) return R_IMF_IMTYPE_RAWTGA;
|
|
|
|
else if (STREQ(imtype_arg, "AVIRAW")) return R_IMF_IMTYPE_AVIRAW;
|
|
|
|
else if (STREQ(imtype_arg, "AVIJPEG")) return R_IMF_IMTYPE_AVIJPEG;
|
|
|
|
else if (STREQ(imtype_arg, "PNG")) return R_IMF_IMTYPE_PNG;
|
|
|
|
else if (STREQ(imtype_arg, "QUICKTIME")) return R_IMF_IMTYPE_QUICKTIME;
|
|
|
|
else if (STREQ(imtype_arg, "BMP")) return R_IMF_IMTYPE_BMP;
|
2011-11-24 05:18:26 +00:00
|
|
|
#ifdef WITH_HDR
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(imtype_arg, "HDR")) return R_IMF_IMTYPE_RADHDR;
|
2011-11-24 05:18:26 +00:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_TIFF
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(imtype_arg, "TIFF")) return R_IMF_IMTYPE_TIFF;
|
2011-11-24 05:18:26 +00:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_OPENEXR
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(imtype_arg, "EXR")) return R_IMF_IMTYPE_OPENEXR;
|
|
|
|
else if (STREQ(imtype_arg, "MULTILAYER")) return R_IMF_IMTYPE_MULTILAYER;
|
2011-11-24 05:18:26 +00:00
|
|
|
#endif
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(imtype_arg, "MPEG")) return R_IMF_IMTYPE_FFMPEG;
|
|
|
|
else if (STREQ(imtype_arg, "FRAMESERVER")) return R_IMF_IMTYPE_FRAMESERVER;
|
2011-11-24 05:18:26 +00:00
|
|
|
#ifdef WITH_CINEON
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(imtype_arg, "CINEON")) return R_IMF_IMTYPE_CINEON;
|
|
|
|
else if (STREQ(imtype_arg, "DPX")) return R_IMF_IMTYPE_DPX;
|
2011-11-24 05:18:26 +00:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_OPENJPEG
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(imtype_arg, "JP2")) return R_IMF_IMTYPE_JP2;
|
2011-11-24 05:18:26 +00:00
|
|
|
#endif
|
|
|
|
else return R_IMF_IMTYPE_INVALID;
|
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static bool do_add_image_extension(char *string, const char imtype, const ImageFormatData *im_format)
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
const char *extension = NULL;
|
2014-01-31 03:09:01 +11:00
|
|
|
const char *extension_test;
|
2012-12-23 16:09:26 +00:00
|
|
|
(void)im_format; /* may be unused, depends on build options */
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (imtype == R_IMF_IMTYPE_IRIS) {
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!BLI_testextensie(string, extension_test = ".rgb"))
|
|
|
|
extension = extension_test;
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_IRIZ) {
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!BLI_testextensie(string, extension_test = ".rgb"))
|
|
|
|
extension = extension_test;
|
2005-11-20 14:32:07 +00:00
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_HDR
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_RADHDR) {
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!BLI_testextensie(string, extension_test = ".hdr"))
|
|
|
|
extension = extension_test;
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2014-07-20 01:30:29 +10:00
|
|
|
else if (ELEM(imtype, R_IMF_IMTYPE_PNG, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID)) {
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!BLI_testextensie(string, extension_test = ".png"))
|
|
|
|
extension = extension_test;
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
}
|
2007-06-25 19:50:25 +00:00
|
|
|
#ifdef WITH_DDS
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_DDS) {
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!BLI_testextensie(string, extension_test = ".dds"))
|
|
|
|
extension = extension_test;
|
2007-06-25 19:50:25 +00:00
|
|
|
}
|
|
|
|
#endif
|
2014-01-31 03:09:01 +11:00
|
|
|
else if (ELEM(imtype, R_IMF_IMTYPE_TARGA, R_IMF_IMTYPE_RAWTGA)) {
|
|
|
|
if (!BLI_testextensie(string, extension_test = ".tga"))
|
|
|
|
extension = extension_test;
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_BMP) {
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!BLI_testextensie(string, extension_test = ".bmp"))
|
|
|
|
extension = extension_test;
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
}
|
2010-05-21 03:25:38 +00:00
|
|
|
#ifdef WITH_TIFF
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_TIFF) {
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!BLI_testextensie_n(string, extension_test = ".tif", ".tiff", NULL)) {
|
|
|
|
extension = extension_test;
|
2012-04-28 06:31:57 +00:00
|
|
|
}
|
2005-11-22 18:50:03 +00:00
|
|
|
}
|
2010-05-21 03:25:38 +00:00
|
|
|
#endif
|
2013-10-11 16:38:04 +00:00
|
|
|
#ifdef WITH_OPENIMAGEIO
|
2013-10-08 21:17:24 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_PSD) {
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!BLI_testextensie(string, extension_test = ".psd"))
|
|
|
|
extension = extension_test;
|
2013-10-08 21:17:24 +00:00
|
|
|
}
|
|
|
|
#endif
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 00:40:35 +00:00
|
|
|
#ifdef WITH_OPENEXR
|
2015-04-06 10:40:12 -03:00
|
|
|
else if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) {
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!BLI_testextensie(string, extension_test = ".exr"))
|
|
|
|
extension = extension_test;
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 00:40:35 +00:00
|
|
|
}
|
|
|
|
#endif
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_CINEON
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_CINEON) {
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!BLI_testextensie(string, extension_test = ".cin"))
|
|
|
|
extension = extension_test;
|
2006-03-12 14:11:23 +00:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_DPX) {
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!BLI_testextensie(string, extension_test = ".dpx"))
|
|
|
|
extension = extension_test;
|
2006-03-12 14:11:23 +00:00
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2009-01-26 08:34:40 +00:00
|
|
|
#ifdef WITH_OPENJPEG
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_JP2) {
|
2012-12-23 13:57:09 +00:00
|
|
|
if (im_format) {
|
|
|
|
if (im_format->jp2_codec == R_IMF_JP2_CODEC_JP2) {
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!BLI_testextensie(string, extension_test = ".jp2"))
|
|
|
|
extension = extension_test;
|
2012-12-23 13:57:09 +00:00
|
|
|
}
|
|
|
|
else if (im_format->jp2_codec == R_IMF_JP2_CODEC_J2K) {
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!BLI_testextensie(string, extension_test = ".j2c"))
|
|
|
|
extension = extension_test;
|
2012-12-23 13:57:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
BLI_assert(!"Unsupported jp2 codec was specified in im_format->jp2_codec");
|
|
|
|
}
|
|
|
|
else {
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!BLI_testextensie(string, extension_test = ".jp2"))
|
|
|
|
extension = extension_test;
|
2012-12-23 13:57:09 +00:00
|
|
|
}
|
2009-01-26 08:34:40 +00:00
|
|
|
}
|
|
|
|
#endif
|
2012-08-02 21:50:49 +00:00
|
|
|
else { // R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90, R_IMF_IMTYPE_QUICKTIME etc
|
2014-01-31 03:09:01 +11:00
|
|
|
if (!(BLI_testextensie_n(string, extension_test = ".jpg", ".jpeg", NULL)))
|
|
|
|
extension = extension_test;
|
2008-07-06 09:21:39 +00:00
|
|
|
}
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (extension) {
|
2010-10-26 23:28:10 +00:00
|
|
|
/* prefer this in many cases to avoid .png.tga, but in certain cases it breaks */
|
2011-03-14 21:13:30 +00:00
|
|
|
/* remove any other known image extension */
|
2012-04-21 15:11:03 +00:00
|
|
|
if (BLI_testextensie_array(string, imb_ext_image) ||
|
|
|
|
(G.have_quicktime && BLI_testextensie_array(string, imb_ext_image_qt)))
|
|
|
|
{
|
2011-03-14 21:13:30 +00:00
|
|
|
return BLI_replace_extension(string, FILE_MAX, extension);
|
2012-01-20 23:03:41 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-10-31 00:23:42 +00:00
|
|
|
return BLI_ensure_extension(string, FILE_MAX, extension);
|
2011-03-14 21:13:30 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2010-09-17 05:58:06 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2010-09-17 05:58:06 +00:00
|
|
|
}
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
int BKE_image_path_ensure_ext_from_imformat(char *string, const ImageFormatData *im_format)
|
2012-12-23 13:57:09 +00:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
return do_add_image_extension(string, im_format->imtype, im_format);
|
2012-12-23 13:57:09 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
int BKE_image_path_ensure_ext_from_imtype(char *string, const char imtype)
|
2012-12-23 13:57:09 +00:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
return do_add_image_extension(string, imtype, NULL);
|
2012-12-23 13:57:09 +00:00
|
|
|
}
|
|
|
|
|
2012-04-24 02:01:23 +00:00
|
|
|
void BKE_imformat_defaults(ImageFormatData *im_format)
|
|
|
|
{
|
|
|
|
memset(im_format, 0, sizeof(*im_format));
|
2013-09-10 13:25:37 +00:00
|
|
|
im_format->planes = R_IMF_PLANES_RGBA;
|
2012-04-24 02:01:23 +00:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_PNG;
|
2012-12-31 14:02:33 +00:00
|
|
|
im_format->depth = R_IMF_CHAN_DEPTH_8;
|
2012-04-24 02:01:23 +00:00
|
|
|
im_format->quality = 90;
|
2013-11-25 16:22:55 +06:00
|
|
|
im_format->compress = 15;
|
2012-09-18 10:11:46 +00:00
|
|
|
|
|
|
|
BKE_color_managed_display_settings_init(&im_format->display_settings);
|
|
|
|
BKE_color_managed_view_settings_init(&im_format->view_settings);
|
2012-04-24 02:01:23 +00:00
|
|
|
}
|
|
|
|
|
2012-06-22 15:40:49 +00:00
|
|
|
void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *imbuf)
|
|
|
|
{
|
2015-07-13 13:58:17 +02:00
|
|
|
int ftype = imbuf->ftype;
|
|
|
|
int custom_flags = imbuf->foptions.flag;
|
|
|
|
char quality = imbuf->foptions.quality;
|
2012-08-17 23:29:39 +00:00
|
|
|
|
2012-06-22 15:40:49 +00:00
|
|
|
BKE_imformat_defaults(im_format);
|
|
|
|
|
2012-07-06 23:56:59 +00:00
|
|
|
/* file type */
|
2012-06-22 15:40:49 +00:00
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
if (ftype == IMB_FTYPE_IMAGIC)
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_IRIS;
|
|
|
|
|
|
|
|
#ifdef WITH_HDR
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_RADHDR)
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_RADHDR;
|
|
|
|
#endif
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_PNG) {
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_PNG;
|
|
|
|
|
2012-12-30 13:01:47 +00:00
|
|
|
if (custom_flags & PNG_16BIT)
|
|
|
|
im_format->depth = R_IMF_CHAN_DEPTH_16;
|
2015-07-13 13:58:17 +02:00
|
|
|
|
|
|
|
im_format->compress = quality;
|
2012-12-30 13:01:47 +00:00
|
|
|
}
|
|
|
|
|
2012-06-22 15:40:49 +00:00
|
|
|
#ifdef WITH_DDS
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_DDS)
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_DDS;
|
|
|
|
#endif
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_BMP)
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_BMP;
|
|
|
|
|
|
|
|
#ifdef WITH_TIFF
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_TIF) {
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_TIFF;
|
2012-08-17 23:29:39 +00:00
|
|
|
if (custom_flags & TIF_16BIT)
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->depth = R_IMF_CHAN_DEPTH_16;
|
2016-01-14 15:02:13 +05:00
|
|
|
if (custom_flags & TIF_COMPRESS_NONE)
|
|
|
|
im_format->tiff_codec = R_IMF_TIFF_CODEC_NONE;
|
|
|
|
if (custom_flags & TIF_COMPRESS_DEFLATE)
|
|
|
|
im_format->tiff_codec = R_IMF_TIFF_CODEC_DEFLATE;
|
|
|
|
if (custom_flags & TIF_COMPRESS_LZW)
|
|
|
|
im_format->tiff_codec = R_IMF_TIFF_CODEC_LZW;
|
|
|
|
if (custom_flags & TIF_COMPRESS_PACKBITS)
|
|
|
|
im_format->tiff_codec = R_IMF_TIFF_CODEC_PACKBITS;
|
2012-06-22 15:40:49 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WITH_OPENEXR
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_OPENEXR) {
|
2012-06-23 23:22:19 +00:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_OPENEXR;
|
2012-08-17 23:29:39 +00:00
|
|
|
if (custom_flags & OPENEXR_HALF)
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->depth = R_IMF_CHAN_DEPTH_16;
|
2012-08-17 23:29:39 +00:00
|
|
|
if (custom_flags & OPENEXR_COMPRESS)
|
2012-06-23 23:22:19 +00:00
|
|
|
im_format->exr_codec = R_IMF_EXR_CODEC_ZIP; // Can't determine compression
|
2012-06-22 15:40:49 +00:00
|
|
|
if (imbuf->zbuf_float)
|
|
|
|
im_format->flag |= R_IMF_FLAG_ZBUF;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WITH_CINEON
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_CINEON)
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_CINEON;
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_DPX)
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_DPX;
|
|
|
|
#endif
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_TGA) {
|
|
|
|
if (custom_flags & RAWTGA)
|
|
|
|
im_format->imtype = R_IMF_IMTYPE_RAWTGA;
|
|
|
|
else
|
|
|
|
im_format->imtype = R_IMF_IMTYPE_TARGA;
|
2012-06-22 15:40:49 +00:00
|
|
|
}
|
|
|
|
#ifdef WITH_OPENJPEG
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (ftype == IMB_FTYPE_JP2) {
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_JP2;
|
2015-07-13 13:58:17 +02:00
|
|
|
im_format->quality = quality;
|
2012-06-22 15:40:49 +00:00
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
if (custom_flags & JP2_16BIT)
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->depth = R_IMF_CHAN_DEPTH_16;
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (custom_flags & JP2_12BIT)
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->depth = R_IMF_CHAN_DEPTH_12;
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
if (custom_flags & JP2_YCC)
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->jp2_flag |= R_IMF_JP2_FLAG_YCC;
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
if (custom_flags & JP2_CINE) {
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_PRESET;
|
2015-07-13 13:58:17 +02:00
|
|
|
if (custom_flags & JP2_CINE_48FPS)
|
2012-06-22 15:40:49 +00:00
|
|
|
im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_48;
|
|
|
|
}
|
2012-12-23 13:57:09 +00:00
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
if (custom_flags & JP2_JP2)
|
2012-12-23 13:57:09 +00:00
|
|
|
im_format->jp2_codec = R_IMF_JP2_CODEC_JP2;
|
2015-07-13 13:58:17 +02:00
|
|
|
else if (custom_flags & JP2_J2K)
|
2012-12-23 13:57:09 +00:00
|
|
|
im_format->jp2_codec = R_IMF_JP2_CODEC_J2K;
|
|
|
|
else
|
|
|
|
BLI_assert(!"Unsupported jp2 codec was specified in file type");
|
2012-06-22 15:40:49 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
else {
|
|
|
|
im_format->imtype = R_IMF_IMTYPE_JPEG90;
|
2015-07-13 13:58:17 +02:00
|
|
|
im_format->quality = quality;
|
2012-06-22 15:40:49 +00:00
|
|
|
}
|
|
|
|
|
2012-07-06 23:56:59 +00:00
|
|
|
/* planes */
|
2013-12-19 17:17:40 +06:00
|
|
|
/* TODO(sergey): Channels doesn't correspond actual planes used for image buffer
|
|
|
|
* For example byte buffer will have 4 channels but it might easily
|
|
|
|
* be BW or RGB image.
|
|
|
|
*
|
|
|
|
* Need to use im_format->planes = imbuf->planes instead?
|
|
|
|
*/
|
2012-06-22 15:40:49 +00:00
|
|
|
switch (imbuf->channels) {
|
|
|
|
case 0:
|
|
|
|
case 4: im_format->planes = R_IMF_PLANES_RGBA;
|
2012-06-23 23:22:19 +00:00
|
|
|
break;
|
2012-06-22 15:40:49 +00:00
|
|
|
case 3: im_format->planes = R_IMF_PLANES_RGB;
|
2012-06-23 23:22:19 +00:00
|
|
|
break;
|
2012-06-22 15:40:49 +00:00
|
|
|
case 1: im_format->planes = R_IMF_PLANES_BW;
|
2012-06-23 23:22:19 +00:00
|
|
|
break;
|
|
|
|
default: im_format->planes = R_IMF_PLANES_RGB;
|
|
|
|
break;
|
2012-06-22 15:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-07-09 10:55:41 +00:00
|
|
|
|
2012-12-11 15:14:35 +00:00
|
|
|
#define STAMP_NAME_SIZE ((MAX_ID_NAME - 2) + 16)
|
|
|
|
/* could allow access externally - 512 is for long names,
|
|
|
|
* STAMP_NAME_SIZE is for id names, allowing them some room for description */
|
2007-10-28 22:27:07 +00:00
|
|
|
typedef struct StampData {
|
2012-05-06 15:15:33 +00:00
|
|
|
char file[512];
|
|
|
|
char note[512];
|
|
|
|
char date[512];
|
|
|
|
char marker[512];
|
|
|
|
char time[512];
|
|
|
|
char frame[512];
|
2012-12-11 15:14:35 +00:00
|
|
|
char camera[STAMP_NAME_SIZE];
|
|
|
|
char cameralens[STAMP_NAME_SIZE];
|
|
|
|
char scene[STAMP_NAME_SIZE];
|
|
|
|
char strip[STAMP_NAME_SIZE];
|
|
|
|
char rendertime[STAMP_NAME_SIZE];
|
2007-10-28 22:27:07 +00:00
|
|
|
} StampData;
|
2012-12-11 15:14:35 +00:00
|
|
|
#undef STAMP_NAME_SIZE
|
2007-10-28 22:27:07 +00:00
|
|
|
|
2011-04-30 05:26:09 +00:00
|
|
|
static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int do_prefix)
|
2007-10-20 16:17:27 +00:00
|
|
|
{
|
2007-10-28 22:27:07 +00:00
|
|
|
char text[256];
|
2007-10-20 16:17:27 +00:00
|
|
|
struct tm *tl;
|
|
|
|
time_t t;
|
2010-04-04 21:57:51 +00:00
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
if (scene->r.stamp & R_STAMP_FILENAME) {
|
2012-05-06 15:15:33 +00:00
|
|
|
BLI_snprintf(stamp_data->file, sizeof(stamp_data->file), do_prefix ? "File %s" : "%s", G.relbase_valid ? G.main->name : "<untitled>");
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-11-08 13:02:59 +00:00
|
|
|
stamp_data->file[0] = '\0';
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
if (scene->r.stamp & R_STAMP_NOTE) {
|
2007-12-24 18:38:03 +00:00
|
|
|
/* Never do prefix for Note */
|
2011-02-12 16:54:24 +00:00
|
|
|
BLI_snprintf(stamp_data->note, sizeof(stamp_data->note), "%s", scene->r.stamp_udata);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-10-28 22:27:07 +00:00
|
|
|
stamp_data->note[0] = '\0';
|
Patch by GSR #7628, I also added alpha for text background.
The list of changes (some are fixes):
- Properly horizontally centered tags in all fields (bug?).
- File area does not have trailing space and has leading "File " at
start instead (probably a bug).
- Small separation between to time related fields, space saving.
- Removed colons, for consistency and space saving again.
- Frame field is zero aligned for higher visual stability.
- Marker name shows a rarer name, "<none>" (using <> is typical for cases
in which there is nothing: <none>, <empty>, <blank>, etc).
- Top area for misc info that can be really long (file, note and render date).
- Bottom area for more constantly changing but short ones (marker, SMPTE,
frame, camera and scene).
- Only render date moves a line (when note field is not used), and frame one
moves if no SMPTE (still in same line, so no big jump), for extra visual
stability (marker is fixed, assuming most people would show frame and or
SMPTE).
- ISO 8601 date format for render date, localization independant.
Comparision images:
http://www.infernal-iceberg.com/blender/stamp-original.png
http://www.infernal-iceberg.com/blender/stamp-cleanup.png
2007-10-23 22:51:50 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
if (scene->r.stamp & R_STAMP_DATE) {
|
2011-02-12 16:54:24 +00:00
|
|
|
t = time(NULL);
|
|
|
|
tl = localtime(&t);
|
2012-05-06 15:15:33 +00:00
|
|
|
BLI_snprintf(text, sizeof(text), "%04d/%02d/%02d %02d:%02d:%02d", tl->tm_year + 1900, tl->tm_mon + 1, tl->tm_mday, tl->tm_hour, tl->tm_min, tl->tm_sec);
|
|
|
|
BLI_snprintf(stamp_data->date, sizeof(stamp_data->date), do_prefix ? "Date %s" : "%s", text);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-10-28 22:27:07 +00:00
|
|
|
stamp_data->date[0] = '\0';
|
Patch by GSR #7628, I also added alpha for text background.
The list of changes (some are fixes):
- Properly horizontally centered tags in all fields (bug?).
- File area does not have trailing space and has leading "File " at
start instead (probably a bug).
- Small separation between to time related fields, space saving.
- Removed colons, for consistency and space saving again.
- Frame field is zero aligned for higher visual stability.
- Marker name shows a rarer name, "<none>" (using <> is typical for cases
in which there is nothing: <none>, <empty>, <blank>, etc).
- Top area for misc info that can be really long (file, note and render date).
- Bottom area for more constantly changing but short ones (marker, SMPTE,
frame, camera and scene).
- Only render date moves a line (when note field is not used), and frame one
moves if no SMPTE (still in same line, so no big jump), for extra visual
stability (marker is fixed, assuming most people would show frame and or
SMPTE).
- ISO 8601 date format for render date, localization independant.
Comparision images:
http://www.infernal-iceberg.com/blender/stamp-original.png
http://www.infernal-iceberg.com/blender/stamp-cleanup.png
2007-10-23 22:51:50 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
if (scene->r.stamp & R_STAMP_MARKER) {
|
2014-04-27 00:20:13 +10:00
|
|
|
const char *name = BKE_scene_find_last_marker_name(scene, CFRA);
|
2011-10-19 23:10:54 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (name) BLI_strncpy(text, name, sizeof(text));
|
|
|
|
else BLI_strncpy(text, "<none>", sizeof(text));
|
2011-02-12 16:54:24 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
BLI_snprintf(stamp_data->marker, sizeof(stamp_data->marker), do_prefix ? "Marker %s" : "%s", text);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-10-28 22:27:07 +00:00
|
|
|
stamp_data->marker[0] = '\0';
|
Patch by GSR #7628, I also added alpha for text background.
The list of changes (some are fixes):
- Properly horizontally centered tags in all fields (bug?).
- File area does not have trailing space and has leading "File " at
start instead (probably a bug).
- Small separation between to time related fields, space saving.
- Removed colons, for consistency and space saving again.
- Frame field is zero aligned for higher visual stability.
- Marker name shows a rarer name, "<none>" (using <> is typical for cases
in which there is nothing: <none>, <empty>, <blank>, etc).
- Top area for misc info that can be really long (file, note and render date).
- Bottom area for more constantly changing but short ones (marker, SMPTE,
frame, camera and scene).
- Only render date moves a line (when note field is not used), and frame one
moves if no SMPTE (still in same line, so no big jump), for extra visual
stability (marker is fixed, assuming most people would show frame and or
SMPTE).
- ISO 8601 date format for render date, localization independant.
Comparision images:
http://www.infernal-iceberg.com/blender/stamp-original.png
http://www.infernal-iceberg.com/blender/stamp-cleanup.png
2007-10-23 22:51:50 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
if (scene->r.stamp & R_STAMP_TIME) {
|
2014-01-29 20:01:30 +11:00
|
|
|
const short timecode_style = USER_TIMECODE_SMPTE_FULL;
|
|
|
|
BLI_timecode_string_from_time(text, sizeof(text), 0, FRA2TIME(scene->r.cfra), FPS, timecode_style);
|
|
|
|
BLI_snprintf(stamp_data->time, sizeof(stamp_data->time), do_prefix ? "Timecode %s" : "%s", text);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-10-28 22:27:07 +00:00
|
|
|
stamp_data->time[0] = '\0';
|
2007-10-20 16:17:27 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
if (scene->r.stamp & R_STAMP_FRAME) {
|
2012-01-11 09:33:44 +00:00
|
|
|
char fmtstr[32];
|
2012-05-06 15:15:33 +00:00
|
|
|
int digits = 1;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (scene->r.efra > 9)
|
|
|
|
digits = 1 + (int) log10(scene->r.efra);
|
2011-02-12 16:54:24 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
BLI_snprintf(fmtstr, sizeof(fmtstr), do_prefix ? "Frame %%0%di" : "%%0%di", digits);
|
|
|
|
BLI_snprintf(stamp_data->frame, sizeof(stamp_data->frame), fmtstr, scene->r.cfra);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-10-28 22:27:07 +00:00
|
|
|
stamp_data->frame[0] = '\0';
|
2007-10-20 16:17:27 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
if (scene->r.stamp & R_STAMP_CAMERA) {
|
2012-05-06 15:15:33 +00:00
|
|
|
BLI_snprintf(stamp_data->camera, sizeof(stamp_data->camera), do_prefix ? "Camera %s" : "%s", camera ? camera->id.name + 2 : "<none>");
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-10-28 22:27:07 +00:00
|
|
|
stamp_data->camera[0] = '\0';
|
2007-10-20 16:17:27 +00:00
|
|
|
}
|
|
|
|
|
2011-01-13 19:16:35 +00:00
|
|
|
if (scene->r.stamp & R_STAMP_CAMERALENS) {
|
2011-04-30 05:26:09 +00:00
|
|
|
if (camera && camera->type == OB_CAMERA) {
|
|
|
|
BLI_snprintf(text, sizeof(text), "%.2f", ((Camera *)camera->data)->lens);
|
2011-01-13 19:16:35 +00:00
|
|
|
}
|
2013-03-09 03:46:30 +00:00
|
|
|
else {
|
|
|
|
BLI_strncpy(text, "<none>", sizeof(text));
|
|
|
|
}
|
2011-01-13 19:16:35 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
BLI_snprintf(stamp_data->cameralens, sizeof(stamp_data->cameralens), do_prefix ? "Lens %s" : "%s", text);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-01-13 19:16:35 +00:00
|
|
|
stamp_data->cameralens[0] = '\0';
|
|
|
|
}
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
if (scene->r.stamp & R_STAMP_SCENE) {
|
2012-05-06 15:15:33 +00:00
|
|
|
BLI_snprintf(stamp_data->scene, sizeof(stamp_data->scene), do_prefix ? "Scene %s" : "%s", scene->id.name + 2);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-10-28 22:27:07 +00:00
|
|
|
stamp_data->scene[0] = '\0';
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
if (scene->r.stamp & R_STAMP_SEQSTRIP) {
|
2012-08-08 11:15:40 +00:00
|
|
|
Sequence *seq = BKE_sequencer_foreground_frame_get(scene, scene->r.cfra);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (seq) BLI_strncpy(text, seq->name + 2, sizeof(text));
|
|
|
|
else BLI_strncpy(text, "<none>", sizeof(text));
|
2011-02-12 16:54:24 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
BLI_snprintf(stamp_data->strip, sizeof(stamp_data->strip), do_prefix ? "Strip %s" : "%s", text);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-11-08 13:02:59 +00:00
|
|
|
stamp_data->strip[0] = '\0';
|
|
|
|
}
|
2009-10-15 19:18:40 +00:00
|
|
|
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
Render *re = RE_GetRender(scene->id.name);
|
|
|
|
RenderStats *stats = re ? RE_GetStats(re) : NULL;
|
2009-10-15 19:18:40 +00:00
|
|
|
|
|
|
|
if (stats && (scene->r.stamp & R_STAMP_RENDERTIME)) {
|
2015-06-30 14:47:31 +10:00
|
|
|
BLI_timecode_string_from_time_simple(text, sizeof(text), stats->lastframetime);
|
2009-10-15 19:18:40 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), do_prefix ? "RenderTime %s" : "%s", text);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-10-15 19:18:40 +00:00
|
|
|
stamp_data->rendertime[0] = '\0';
|
|
|
|
}
|
|
|
|
}
|
2007-10-28 22:27:07 +00:00
|
|
|
}
|
|
|
|
|
2015-01-24 16:48:23 +11:00
|
|
|
void BKE_image_stamp_buf(
|
|
|
|
Scene *scene, Object *camera,
|
|
|
|
unsigned char *rect, float *rectf, int width, int height, int channels)
|
2007-10-28 22:27:07 +00:00
|
|
|
{
|
|
|
|
struct StampData stamp_data;
|
2009-08-18 19:26:53 +00:00
|
|
|
float w, h, pad;
|
2011-04-30 11:21:46 +00:00
|
|
|
int x, y, y_ofs;
|
2010-05-25 17:04:32 +00:00
|
|
|
float h_fixed;
|
2012-05-06 15:15:33 +00:00
|
|
|
const int mono = blf_mono_font_render; // XXX
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
struct ColorManagedDisplay *display;
|
|
|
|
const char *display_device;
|
2011-05-04 15:09:48 +00:00
|
|
|
|
2015-09-18 20:37:53 +10:00
|
|
|
/* vars for calculating wordwrap */
|
|
|
|
struct {
|
|
|
|
struct ResultBLF info;
|
|
|
|
rctf rect;
|
|
|
|
} wrap;
|
|
|
|
|
2012-08-12 22:50:21 +00:00
|
|
|
/* this could be an argument if we want to operate on non linear float imbuf's
|
|
|
|
* for now though this is only used for renders which use scene settings */
|
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
#define TEXT_SIZE_CHECK(str, w, h) \
|
|
|
|
((str[0]) && ((void)(h = h_fixed), (w = BLF_width(mono, str, sizeof(str)))))
|
|
|
|
|
2015-09-18 20:37:53 +10:00
|
|
|
/* must enable BLF_WORD_WRAP before using */
|
|
|
|
#define TEXT_SIZE_CHECK_WORD_WRAP(str, w, h) \
|
|
|
|
((str[0]) && (BLF_boundbox_ex(mono, str, sizeof(str), &wrap.rect, &wrap.info), \
|
|
|
|
(void)(h = h_fixed * wrap.info.lines), (w = BLI_rctf_size_x(&wrap.rect))))
|
|
|
|
|
2011-05-04 15:09:48 +00:00
|
|
|
#define BUFF_MARGIN_X 2
|
|
|
|
#define BUFF_MARGIN_Y 1
|
|
|
|
|
2007-10-28 22:27:07 +00:00
|
|
|
if (!rect && !rectf)
|
|
|
|
return;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
display_device = scene->display_settings.display_device;
|
|
|
|
display = IMB_colormanagement_display_get_named(display_device);
|
|
|
|
|
2011-04-30 05:26:09 +00:00
|
|
|
stampdata(scene, camera, &stamp_data, 1);
|
2009-10-15 19:18:40 +00:00
|
|
|
|
|
|
|
/* TODO, do_versions */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (scene->r.stamp_font_id < 8)
|
2012-05-06 15:15:33 +00:00
|
|
|
scene->r.stamp_font_id = 12;
|
2009-10-15 19:18:40 +00:00
|
|
|
|
2010-11-26 16:33:42 +00:00
|
|
|
/* set before return */
|
|
|
|
BLF_size(mono, scene->r.stamp_font_id, 72);
|
2015-09-18 20:37:53 +10:00
|
|
|
BLF_wordwrap(mono, width - (BUFF_MARGIN_X * 2));
|
2012-06-23 23:22:19 +00:00
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
BLF_buffer(mono, rectf, rect, width, height, channels, display);
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0);
|
2012-05-06 15:15:33 +00:00
|
|
|
pad = BLF_width_max(mono);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
2011-05-28 13:11:24 +00:00
|
|
|
/* use 'h_fixed' rather than 'h', aligns better */
|
2012-05-06 15:15:33 +00:00
|
|
|
h_fixed = BLF_height_max(mono);
|
2011-05-04 15:09:48 +00:00
|
|
|
y_ofs = -BLF_descender(mono);
|
2010-05-25 17:04:32 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
x = 0;
|
|
|
|
y = height;
|
2009-08-18 19:26:53 +00:00
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.file, w, h)) {
|
2007-10-28 22:27:07 +00:00
|
|
|
/* Top left corner */
|
2009-08-18 19:26:53 +00:00
|
|
|
y -= h;
|
|
|
|
|
|
|
|
/* also a little of space to the background. */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
|
2012-11-09 09:33:28 +00:00
|
|
|
x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* and draw the text. */
|
2011-04-30 11:21:46 +00:00
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
2015-09-18 20:10:26 +10:00
|
|
|
BLF_draw_buffer(mono, stamp_data.file, BLF_DRAW_STR_DUMMY_MAX);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* the extra pixel for background. */
|
2011-05-04 15:09:48 +00:00
|
|
|
y -= BUFF_MARGIN_Y * 2;
|
2007-10-28 22:27:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Top left corner, below File */
|
2015-09-18 20:37:53 +10:00
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.date, w, h)) {
|
2009-08-18 19:26:53 +00:00
|
|
|
y -= h;
|
|
|
|
|
|
|
|
/* and space for background. */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
|
2012-11-09 09:33:28 +00:00
|
|
|
0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
2011-04-30 11:21:46 +00:00
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
2015-09-18 20:37:53 +10:00
|
|
|
BLF_draw_buffer(mono, stamp_data.date, BLF_DRAW_STR_DUMMY_MAX);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* the extra pixel for background. */
|
2011-05-04 15:09:48 +00:00
|
|
|
y -= BUFF_MARGIN_Y * 2;
|
2007-10-28 22:27:07 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-09-18 20:37:53 +10:00
|
|
|
/* Top left corner, below File, Date */
|
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.rendertime, w, h)) {
|
2009-08-18 19:26:53 +00:00
|
|
|
y -= h;
|
|
|
|
|
|
|
|
/* and space for background. */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
|
2012-11-09 09:33:28 +00:00
|
|
|
0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
2011-04-30 11:21:46 +00:00
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
2015-09-18 20:37:53 +10:00
|
|
|
BLF_draw_buffer(mono, stamp_data.rendertime, BLF_DRAW_STR_DUMMY_MAX);
|
2009-10-15 19:18:40 +00:00
|
|
|
|
|
|
|
/* the extra pixel for background. */
|
2011-05-04 15:09:48 +00:00
|
|
|
y -= BUFF_MARGIN_Y * 2;
|
2009-10-15 19:18:40 +00:00
|
|
|
}
|
|
|
|
|
2015-09-18 20:37:53 +10:00
|
|
|
/* Top left corner, below File, Date, Rendertime */
|
|
|
|
BLF_enable(mono, BLF_WORD_WRAP);
|
|
|
|
if (TEXT_SIZE_CHECK_WORD_WRAP(stamp_data.note, w, h)) {
|
2009-10-15 19:18:40 +00:00
|
|
|
y -= h;
|
|
|
|
|
|
|
|
/* and space for background. */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
|
2012-11-09 09:33:28 +00:00
|
|
|
0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
|
2009-10-15 19:18:40 +00:00
|
|
|
|
2015-09-18 20:37:53 +10:00
|
|
|
BLF_position(mono, x, y + y_ofs + (h - h_fixed), 0.0);
|
|
|
|
BLF_draw_buffer(mono, stamp_data.note, BLF_DRAW_STR_DUMMY_MAX);
|
2007-10-28 22:27:07 +00:00
|
|
|
}
|
2015-09-18 20:37:53 +10:00
|
|
|
BLF_disable(mono, BLF_WORD_WRAP);
|
2007-10-28 22:27:07 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
x = 0;
|
|
|
|
y = 0;
|
2009-08-18 19:26:53 +00:00
|
|
|
|
2007-10-28 22:27:07 +00:00
|
|
|
/* Bottom left corner, leaving space for timing */
|
2013-12-02 20:33:45 +11:00
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.marker, w, h)) {
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* extra space for background. */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
|
2012-11-09 09:33:28 +00:00
|
|
|
x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* and pad the text. */
|
2011-04-30 11:21:46 +00:00
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
2015-09-18 20:10:26 +10:00
|
|
|
BLF_draw_buffer(mono, stamp_data.marker, BLF_DRAW_STR_DUMMY_MAX);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* space width. */
|
|
|
|
x += w + pad;
|
2007-10-28 22:27:07 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2007-10-28 22:27:07 +00:00
|
|
|
/* Left bottom corner */
|
2013-12-02 20:33:45 +11:00
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.time, w, h)) {
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* extra space for background */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
|
2012-11-09 09:33:28 +00:00
|
|
|
x - BUFF_MARGIN_X, y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* and pad the text. */
|
2011-04-30 11:21:46 +00:00
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
2015-09-18 20:10:26 +10:00
|
|
|
BLF_draw_buffer(mono, stamp_data.time, BLF_DRAW_STR_DUMMY_MAX);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* space width. */
|
|
|
|
x += w + pad;
|
2007-10-28 22:27:07 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.frame, w, h)) {
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* extra space for background. */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
|
2012-11-09 09:33:28 +00:00
|
|
|
x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* and pad the text. */
|
2011-04-30 11:21:46 +00:00
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
2015-09-18 20:10:26 +10:00
|
|
|
BLF_draw_buffer(mono, stamp_data.frame, BLF_DRAW_STR_DUMMY_MAX);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* space width. */
|
|
|
|
x += w + pad;
|
2007-10-28 22:27:07 +00:00
|
|
|
}
|
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.camera, w, h)) {
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* extra space for background. */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
|
2012-11-09 09:33:28 +00:00
|
|
|
x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
|
2011-04-30 11:21:46 +00:00
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
2015-09-18 20:10:26 +10:00
|
|
|
BLF_draw_buffer(mono, stamp_data.camera, BLF_DRAW_STR_DUMMY_MAX);
|
2011-01-13 19:16:35 +00:00
|
|
|
|
|
|
|
/* space width. */
|
|
|
|
x += w + pad;
|
|
|
|
}
|
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.cameralens, w, h)) {
|
2011-01-13 19:16:35 +00:00
|
|
|
|
|
|
|
/* extra space for background. */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
|
2012-11-09 09:33:28 +00:00
|
|
|
x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
|
2011-04-30 11:21:46 +00:00
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
2015-09-18 20:10:26 +10:00
|
|
|
BLF_draw_buffer(mono, stamp_data.cameralens, BLF_DRAW_STR_DUMMY_MAX);
|
2007-10-28 22:27:07 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.scene, w, h)) {
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* Bottom right corner, with an extra space because blenfont is too strict! */
|
2012-05-06 15:15:33 +00:00
|
|
|
x = width - w - 2;
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* extra space for background. */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
|
2012-11-09 09:33:28 +00:00
|
|
|
x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* and pad the text. */
|
2012-05-06 15:15:33 +00:00
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
2015-09-18 20:10:26 +10:00
|
|
|
BLF_draw_buffer(mono, stamp_data.scene, BLF_DRAW_STR_DUMMY_MAX);
|
2007-10-20 16:17:27 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.strip, w, h)) {
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* Top right corner, with an extra space because blenfont is too strict! */
|
2012-05-06 15:15:33 +00:00
|
|
|
x = width - w - pad;
|
|
|
|
y = height - h;
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* extra space for background. */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
|
2012-11-09 09:33:28 +00:00
|
|
|
x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
2011-04-30 11:21:46 +00:00
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
2015-09-18 20:10:26 +10:00
|
|
|
BLF_draw_buffer(mono, stamp_data.strip, BLF_DRAW_STR_DUMMY_MAX);
|
2007-11-08 13:02:59 +00:00
|
|
|
}
|
2009-08-18 19:26:53 +00:00
|
|
|
|
|
|
|
/* cleanup the buffer. */
|
2013-03-22 05:34:10 +00:00
|
|
|
BLF_buffer(mono, NULL, NULL, 0, 0, 0, NULL);
|
2015-09-18 20:37:53 +10:00
|
|
|
BLF_wordwrap(mono, 0);
|
2011-05-04 15:09:48 +00:00
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
#undef TEXT_SIZE_CHECK
|
2015-09-18 20:37:53 +10:00
|
|
|
#undef TEXT_SIZE_CHECK_WORD_WRAP
|
2011-05-04 15:09:48 +00:00
|
|
|
#undef BUFF_MARGIN_X
|
|
|
|
#undef BUFF_MARGIN_Y
|
2007-10-20 16:17:27 +00:00
|
|
|
}
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
|
2015-07-01 15:23:09 +02:00
|
|
|
void BKE_render_result_stamp_info(Scene *scene, Object *camera, struct RenderResult *rr, bool allocate_only)
|
2007-10-28 22:27:07 +00:00
|
|
|
{
|
2015-04-21 18:33:33 +02:00
|
|
|
struct StampData *stamp_data;
|
|
|
|
|
2015-07-01 15:23:09 +02:00
|
|
|
if (!(scene && (scene->r.stamp & R_STAMP_ALL)) && !allocate_only)
|
2015-04-21 18:33:33 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!rr->stamp_data) {
|
|
|
|
stamp_data = MEM_callocN(sizeof(StampData), "RenderResult.stamp_data");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data = rr->stamp_data;
|
|
|
|
}
|
2007-10-28 22:27:07 +00:00
|
|
|
|
2015-07-01 15:23:09 +02:00
|
|
|
if (!allocate_only)
|
|
|
|
stampdata(scene, camera, stamp_data, 0);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-04-21 18:33:33 +02:00
|
|
|
if (!rr->stamp_data) {
|
|
|
|
rr->stamp_data = stamp_data;
|
|
|
|
}
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-07-01 15:23:09 +02:00
|
|
|
void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCallback callback, bool noskip)
|
2015-04-21 18:33:33 +02:00
|
|
|
{
|
2015-12-21 13:00:06 +11:00
|
|
|
if ((callback == NULL) || (stamp_data == NULL)) {
|
2015-06-12 14:34:20 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CALL(member, value_str) \
|
2015-07-01 15:23:09 +02:00
|
|
|
if (noskip || stamp_data->member[0]) { \
|
|
|
|
callback(data, value_str, stamp_data->member, sizeof(stamp_data->member)); \
|
2015-06-12 14:34:20 +02:00
|
|
|
} ((void)0)
|
2015-04-21 18:33:33 +02:00
|
|
|
|
2015-06-12 14:34:20 +02:00
|
|
|
CALL(file, "File");
|
|
|
|
CALL(note, "Note");
|
|
|
|
CALL(date, "Date");
|
|
|
|
CALL(marker, "Marker");
|
|
|
|
CALL(time, "Time");
|
|
|
|
CALL(frame, "Frame");
|
|
|
|
CALL(camera, "Camera");
|
|
|
|
CALL(cameralens, "Lens");
|
|
|
|
CALL(scene, "Scene");
|
|
|
|
CALL(strip, "Strip");
|
|
|
|
CALL(rendertime, "RenderTime");
|
2015-04-21 18:33:33 +02:00
|
|
|
|
2015-06-12 14:34:20 +02:00
|
|
|
#undef CALL
|
2007-10-28 22:27:07 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 14:34:20 +02:00
|
|
|
/* wrap for callback only */
|
2015-07-01 15:23:09 +02:00
|
|
|
static void metadata_change_field(void *data, const char *propname, char *propvalue, int UNUSED(len))
|
2015-05-26 12:02:14 +02:00
|
|
|
{
|
2015-06-12 14:34:20 +02:00
|
|
|
IMB_metadata_change_field(data, propname, propvalue);
|
|
|
|
}
|
|
|
|
|
2015-07-01 15:23:09 +02:00
|
|
|
static void metadata_get_field(void *data, const char *propname, char *propvalue, int len)
|
|
|
|
{
|
|
|
|
IMB_metadata_get_field(data, propname, propvalue, len);
|
|
|
|
}
|
|
|
|
|
2015-06-12 14:34:20 +02:00
|
|
|
void BKE_imbuf_stamp_info(RenderResult *rr, struct ImBuf *ibuf)
|
|
|
|
{
|
|
|
|
struct StampData *stamp_data = rr->stamp_data;
|
|
|
|
|
2015-07-01 15:23:09 +02:00
|
|
|
BKE_stamp_info_callback(ibuf, stamp_data, metadata_change_field, false);
|
2015-05-26 12:02:14 +02:00
|
|
|
}
|
|
|
|
|
2015-07-01 15:23:09 +02:00
|
|
|
void BKE_stamp_info_from_imbuf(RenderResult *rr, struct ImBuf *ibuf)
|
|
|
|
{
|
|
|
|
struct StampData *stamp_data = rr->stamp_data;
|
|
|
|
|
|
|
|
BKE_stamp_info_callback(ibuf, stamp_data, metadata_get_field, true);
|
|
|
|
}
|
2015-05-26 12:02:14 +02:00
|
|
|
|
2014-01-22 02:48:11 +11:00
|
|
|
bool BKE_imbuf_alpha_test(ImBuf *ibuf)
|
2010-11-30 23:38:31 +00:00
|
|
|
{
|
|
|
|
int tot;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ibuf->rect_float) {
|
2014-04-27 00:20:13 +10:00
|
|
|
const float *buf = ibuf->rect_float;
|
2012-05-06 15:15:33 +00:00
|
|
|
for (tot = ibuf->x * ibuf->y; tot--; buf += 4) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (buf[3] < 1.0f) {
|
2014-04-01 11:34:00 +11:00
|
|
|
return true;
|
2010-11-30 23:38:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ibuf->rect) {
|
2012-05-06 15:15:33 +00:00
|
|
|
unsigned char *buf = (unsigned char *)ibuf->rect;
|
|
|
|
for (tot = ibuf->x * ibuf->y; tot--; buf += 4) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (buf[3] != 255) {
|
2014-04-01 11:34:00 +11:00
|
|
|
return true;
|
2010-11-30 23:38:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2010-11-30 23:38:31 +00:00
|
|
|
}
|
|
|
|
|
2011-11-24 06:30:37 +00:00
|
|
|
/* note: imf->planes is ignored here, its assumed the image channels
|
|
|
|
* are already set */
|
2016-01-11 12:01:08 +11:00
|
|
|
void BKE_imbuf_write_prepare(ImBuf *ibuf, const ImageFormatData *imf)
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
char imtype = imf->imtype;
|
|
|
|
char compress = imf->compress;
|
|
|
|
char quality = imf->quality;
|
2011-11-21 20:19:58 +00:00
|
|
|
|
2016-01-14 18:51:48 +11:00
|
|
|
/* initialize all from image format */
|
|
|
|
ibuf->foptions.flag = 0;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (imtype == R_IMF_IMTYPE_IRIS) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_IMAGIC;
|
2010-08-03 11:25:34 +00:00
|
|
|
}
|
|
|
|
#ifdef WITH_HDR
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_RADHDR) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_RADHDR;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2014-07-20 01:30:29 +10:00
|
|
|
else if (ELEM(imtype, R_IMF_IMTYPE_PNG, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID)) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_PNG;
|
2010-07-17 13:29:55 +00:00
|
|
|
|
2012-12-30 13:01:47 +00:00
|
|
|
if (imtype == R_IMF_IMTYPE_PNG) {
|
|
|
|
if (imf->depth == R_IMF_CHAN_DEPTH_16)
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= PNG_16BIT;
|
2012-12-30 13:01:47 +00:00
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.quality = compress;
|
2012-12-30 13:01:47 +00:00
|
|
|
}
|
2010-07-17 13:29:55 +00:00
|
|
|
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
2007-06-25 19:50:25 +00:00
|
|
|
#ifdef WITH_DDS
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_DDS) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_DDS;
|
2007-06-25 19:50:25 +00:00
|
|
|
}
|
|
|
|
#endif
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_BMP) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_BMP;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
2010-05-21 03:25:38 +00:00
|
|
|
#ifdef WITH_TIFF
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_TIFF) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_TIF;
|
2008-03-10 11:39:37 +00:00
|
|
|
|
2016-01-14 15:02:13 +05:00
|
|
|
if (imf->depth == R_IMF_CHAN_DEPTH_16) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= TIF_16BIT;
|
2016-01-14 15:02:13 +05:00
|
|
|
}
|
|
|
|
if (imf->tiff_codec == R_IMF_TIFF_CODEC_NONE) {
|
|
|
|
ibuf->foptions.flag |= TIF_COMPRESS_NONE;
|
|
|
|
}
|
2016-01-16 13:01:10 +11:00
|
|
|
else if (imf->tiff_codec == R_IMF_TIFF_CODEC_DEFLATE) {
|
2016-01-14 15:02:13 +05:00
|
|
|
ibuf->foptions.flag |= TIF_COMPRESS_DEFLATE;
|
|
|
|
}
|
|
|
|
else if (imf->tiff_codec == R_IMF_TIFF_CODEC_LZW) {
|
|
|
|
ibuf->foptions.flag |= TIF_COMPRESS_LZW;
|
|
|
|
}
|
|
|
|
else if (imf->tiff_codec == R_IMF_TIFF_CODEC_PACKBITS) {
|
|
|
|
ibuf->foptions.flag |= TIF_COMPRESS_PACKBITS;
|
|
|
|
}
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
2010-05-21 03:25:38 +00:00
|
|
|
#endif
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
#ifdef WITH_OPENEXR
|
2015-04-06 10:40:12 -03:00
|
|
|
else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_OPENEXR;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (imf->depth == R_IMF_CHAN_DEPTH_16)
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= OPENEXR_HALF;
|
|
|
|
ibuf->foptions.flag |= (imf->exr_codec & OPENEXR_COMPRESS);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!(imf->flag & R_IMF_FLAG_ZBUF))
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->zbuf_float = NULL; /* signal for exr saving */
|
2012-06-23 23:22:19 +00:00
|
|
|
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
|
|
|
#endif
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_CINEON
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_CINEON) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_CINEON;
|
Patch #27397: Improved DPX/Cineon code
Patch by Julien Enche, thanks!
From the patch comment:
It allows Blender to load:
- 1, 8, 10, 12 and 16 bits files. For 10 and 12 bits files, packed or
filled type A/B are supported.
- RGB, Log, Luma and YCbCr colorspaces.
- Big and little endian storage.
- Multi-elements (planar) storage.
It allows Blender to save :
- 8, 10, 12 and 16 bits file. For 10 and 12 bits files, the most used
type A padding is used.
- RGB and Log colorspaces (Cineon can only be saved in Log colorspace).
For Log colorspace, the common default values are used for gamma,
reference black and reference white (respectively 1.7, 95 and 685 for
10 bits files).
- Saved DPX/Cineon files now match the viewer.
Some files won't load (mostly because I haven't seen any of them):
- Compressed files
- 32 and 64 bits files
- Image orientation information are not taken in account. Here too,
I haven't seen any file that was not top-bottom/left-right oriented.
2012-10-22 12:49:00 +00:00
|
|
|
if (imf->cineon_flag & R_IMF_CINEON_FLAG_LOG) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= CINEON_LOG;
|
Patch #27397: Improved DPX/Cineon code
Patch by Julien Enche, thanks!
From the patch comment:
It allows Blender to load:
- 1, 8, 10, 12 and 16 bits files. For 10 and 12 bits files, packed or
filled type A/B are supported.
- RGB, Log, Luma and YCbCr colorspaces.
- Big and little endian storage.
- Multi-elements (planar) storage.
It allows Blender to save :
- 8, 10, 12 and 16 bits file. For 10 and 12 bits files, the most used
type A padding is used.
- RGB and Log colorspaces (Cineon can only be saved in Log colorspace).
For Log colorspace, the common default values are used for gamma,
reference black and reference white (respectively 1.7, 95 and 685 for
10 bits files).
- Saved DPX/Cineon files now match the viewer.
Some files won't load (mostly because I haven't seen any of them):
- Compressed files
- 32 and 64 bits files
- Image orientation information are not taken in account. Here too,
I haven't seen any file that was not top-bottom/left-right oriented.
2012-10-22 12:49:00 +00:00
|
|
|
}
|
|
|
|
if (imf->depth == R_IMF_CHAN_DEPTH_16) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= CINEON_16BIT;
|
2012-10-24 11:31:57 +00:00
|
|
|
}
|
|
|
|
else if (imf->depth == R_IMF_CHAN_DEPTH_12) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= CINEON_12BIT;
|
2012-10-24 11:31:57 +00:00
|
|
|
}
|
|
|
|
else if (imf->depth == R_IMF_CHAN_DEPTH_10) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= CINEON_10BIT;
|
Patch #27397: Improved DPX/Cineon code
Patch by Julien Enche, thanks!
From the patch comment:
It allows Blender to load:
- 1, 8, 10, 12 and 16 bits files. For 10 and 12 bits files, packed or
filled type A/B are supported.
- RGB, Log, Luma and YCbCr colorspaces.
- Big and little endian storage.
- Multi-elements (planar) storage.
It allows Blender to save :
- 8, 10, 12 and 16 bits file. For 10 and 12 bits files, the most used
type A padding is used.
- RGB and Log colorspaces (Cineon can only be saved in Log colorspace).
For Log colorspace, the common default values are used for gamma,
reference black and reference white (respectively 1.7, 95 and 685 for
10 bits files).
- Saved DPX/Cineon files now match the viewer.
Some files won't load (mostly because I haven't seen any of them):
- Compressed files
- 32 and 64 bits files
- Image orientation information are not taken in account. Here too,
I haven't seen any file that was not top-bottom/left-right oriented.
2012-10-22 12:49:00 +00:00
|
|
|
}
|
2006-03-12 14:11:23 +00:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_DPX) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_DPX;
|
Patch #27397: Improved DPX/Cineon code
Patch by Julien Enche, thanks!
From the patch comment:
It allows Blender to load:
- 1, 8, 10, 12 and 16 bits files. For 10 and 12 bits files, packed or
filled type A/B are supported.
- RGB, Log, Luma and YCbCr colorspaces.
- Big and little endian storage.
- Multi-elements (planar) storage.
It allows Blender to save :
- 8, 10, 12 and 16 bits file. For 10 and 12 bits files, the most used
type A padding is used.
- RGB and Log colorspaces (Cineon can only be saved in Log colorspace).
For Log colorspace, the common default values are used for gamma,
reference black and reference white (respectively 1.7, 95 and 685 for
10 bits files).
- Saved DPX/Cineon files now match the viewer.
Some files won't load (mostly because I haven't seen any of them):
- Compressed files
- 32 and 64 bits files
- Image orientation information are not taken in account. Here too,
I haven't seen any file that was not top-bottom/left-right oriented.
2012-10-22 12:49:00 +00:00
|
|
|
if (imf->cineon_flag & R_IMF_CINEON_FLAG_LOG) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= CINEON_LOG;
|
Patch #27397: Improved DPX/Cineon code
Patch by Julien Enche, thanks!
From the patch comment:
It allows Blender to load:
- 1, 8, 10, 12 and 16 bits files. For 10 and 12 bits files, packed or
filled type A/B are supported.
- RGB, Log, Luma and YCbCr colorspaces.
- Big and little endian storage.
- Multi-elements (planar) storage.
It allows Blender to save :
- 8, 10, 12 and 16 bits file. For 10 and 12 bits files, the most used
type A padding is used.
- RGB and Log colorspaces (Cineon can only be saved in Log colorspace).
For Log colorspace, the common default values are used for gamma,
reference black and reference white (respectively 1.7, 95 and 685 for
10 bits files).
- Saved DPX/Cineon files now match the viewer.
Some files won't load (mostly because I haven't seen any of them):
- Compressed files
- 32 and 64 bits files
- Image orientation information are not taken in account. Here too,
I haven't seen any file that was not top-bottom/left-right oriented.
2012-10-22 12:49:00 +00:00
|
|
|
}
|
|
|
|
if (imf->depth == R_IMF_CHAN_DEPTH_16) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= CINEON_16BIT;
|
2012-10-24 11:31:57 +00:00
|
|
|
}
|
|
|
|
else if (imf->depth == R_IMF_CHAN_DEPTH_12) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= CINEON_12BIT;
|
2012-10-24 11:31:57 +00:00
|
|
|
}
|
|
|
|
else if (imf->depth == R_IMF_CHAN_DEPTH_10) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= CINEON_10BIT;
|
Patch #27397: Improved DPX/Cineon code
Patch by Julien Enche, thanks!
From the patch comment:
It allows Blender to load:
- 1, 8, 10, 12 and 16 bits files. For 10 and 12 bits files, packed or
filled type A/B are supported.
- RGB, Log, Luma and YCbCr colorspaces.
- Big and little endian storage.
- Multi-elements (planar) storage.
It allows Blender to save :
- 8, 10, 12 and 16 bits file. For 10 and 12 bits files, the most used
type A padding is used.
- RGB and Log colorspaces (Cineon can only be saved in Log colorspace).
For Log colorspace, the common default values are used for gamma,
reference black and reference white (respectively 1.7, 95 and 685 for
10 bits files).
- Saved DPX/Cineon files now match the viewer.
Some files won't load (mostly because I haven't seen any of them):
- Compressed files
- 32 and 64 bits files
- Image orientation information are not taken in account. Here too,
I haven't seen any file that was not top-bottom/left-right oriented.
2012-10-22 12:49:00 +00:00
|
|
|
}
|
2006-03-12 14:11:23 +00:00
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_TARGA) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_TGA;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_RAWTGA) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_TGA;
|
|
|
|
ibuf->foptions.flag = RAWTGA;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
2009-01-26 08:34:40 +00:00
|
|
|
#ifdef WITH_OPENJPEG
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (imtype == R_IMF_IMTYPE_JP2) {
|
|
|
|
if (quality < 10) quality = 90;
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_JP2;
|
|
|
|
ibuf->foptions.quality = quality;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2011-11-21 20:19:58 +00:00
|
|
|
if (imf->depth == R_IMF_CHAN_DEPTH_16) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= JP2_16BIT;
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else if (imf->depth == R_IMF_CHAN_DEPTH_12) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= JP2_12BIT;
|
2009-01-26 08:34:40 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2011-11-21 20:19:58 +00:00
|
|
|
if (imf->jp2_flag & R_IMF_JP2_FLAG_YCC) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= JP2_YCC;
|
2009-01-26 08:34:40 +00:00
|
|
|
}
|
2011-11-21 20:19:58 +00:00
|
|
|
|
|
|
|
if (imf->jp2_flag & R_IMF_JP2_FLAG_CINE_PRESET) {
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= JP2_CINE;
|
2011-11-21 20:19:58 +00:00
|
|
|
if (imf->jp2_flag & R_IMF_JP2_FLAG_CINE_48)
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= JP2_CINE_48FPS;
|
2009-01-26 08:34:40 +00:00
|
|
|
}
|
2012-12-23 13:57:09 +00:00
|
|
|
|
|
|
|
if (imf->jp2_codec == R_IMF_JP2_CODEC_JP2)
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= JP2_JP2;
|
2012-12-23 13:57:09 +00:00
|
|
|
else if (imf->jp2_codec == R_IMF_JP2_CODEC_J2K)
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions.flag |= JP2_J2K;
|
2012-12-23 13:57:09 +00:00
|
|
|
else
|
|
|
|
BLI_assert(!"Unsupported jp2 codec was specified in im_format->jp2_codec");
|
2009-01-26 08:34:40 +00:00
|
|
|
}
|
|
|
|
#endif
|
2006-07-08 13:18:57 +00:00
|
|
|
else {
|
2011-11-22 00:35:26 +00:00
|
|
|
/* R_IMF_IMTYPE_JPEG90, etc. default we save jpegs */
|
2012-05-06 15:15:33 +00:00
|
|
|
if (quality < 10) quality = 90;
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_JPG;
|
|
|
|
ibuf->foptions.quality = quality;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2016-01-11 12:01:08 +11:00
|
|
|
int BKE_imbuf_write(ImBuf *ibuf, const char *name, const ImageFormatData *imf)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
|
|
|
int ok;
|
|
|
|
|
|
|
|
BKE_imbuf_write_prepare(ibuf, imf);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
BLI_make_existing_file(name);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
|
|
|
|
if (ok == 0) {
|
|
|
|
perror(name);
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
return(ok);
|
|
|
|
}
|
|
|
|
|
2014-06-15 12:15:28 +10:00
|
|
|
/* same as BKE_imbuf_write() but crappy workaround not to permanently modify
|
2011-11-24 06:30:37 +00:00
|
|
|
* _some_, values in the imbuf */
|
2012-05-05 16:03:57 +00:00
|
|
|
int BKE_imbuf_write_as(ImBuf *ibuf, const char *name, ImageFormatData *imf,
|
2014-04-01 11:34:00 +11:00
|
|
|
const bool save_copy)
|
2011-11-24 06:30:37 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
ImBuf ibuf_back = *ibuf;
|
2011-11-24 06:30:37 +00:00
|
|
|
int ok;
|
|
|
|
|
|
|
|
/* all data is rgba anyway,
|
|
|
|
* this just controls how to save for some formats */
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->planes = imf->planes;
|
2011-11-24 06:30:37 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ok = BKE_imbuf_write(ibuf, name, imf);
|
2011-11-24 06:30:37 +00:00
|
|
|
|
|
|
|
if (save_copy) {
|
|
|
|
/* note that we are not restoring _all_ settings */
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->planes = ibuf_back.planes;
|
|
|
|
ibuf->ftype = ibuf_back.ftype;
|
2016-01-14 18:51:48 +11:00
|
|
|
ibuf->foptions = ibuf_back.foptions;
|
2011-11-24 06:30:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2016-01-11 12:01:08 +11:00
|
|
|
int BKE_imbuf_write_stamp(
|
|
|
|
Scene *scene, struct RenderResult *rr, ImBuf *ibuf, const char *name,
|
|
|
|
const struct ImageFormatData *imf)
|
2011-04-30 05:26:09 +00:00
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (scene && scene->r.stamp & R_STAMP_ALL)
|
2015-04-21 18:33:33 +02:00
|
|
|
BKE_imbuf_stamp_info(rr, ibuf);
|
2011-04-30 05:26:09 +00:00
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
return BKE_imbuf_write(ibuf, name, imf);
|
2011-04-30 05:26:09 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void do_makepicstring(
|
2015-01-24 16:48:23 +11:00
|
|
|
char *string, const char *base, const char *relbase, int frame, const char imtype,
|
2015-04-06 10:40:12 -03:00
|
|
|
const ImageFormatData *im_format, const short use_ext, const short use_frames,
|
|
|
|
const char *suffix)
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
if (string == NULL) return;
|
|
|
|
BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */
|
2011-11-20 14:38:11 +00:00
|
|
|
BLI_path_abs(string, relbase);
|
2010-11-16 14:40:46 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (use_frames)
|
2010-11-16 14:40:46 +00:00
|
|
|
BLI_path_frame(string, frame, 4);
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (suffix)
|
|
|
|
BLI_path_suffix(string, FILE_MAX, suffix, "");
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (use_ext)
|
2015-04-06 10:40:12 -03:00
|
|
|
do_add_image_extension(string, imtype, im_format);
|
2012-12-23 13:57:09 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-01-24 16:48:23 +11:00
|
|
|
void BKE_image_path_from_imformat(
|
|
|
|
char *string, const char *base, const char *relbase, int frame,
|
2015-04-06 10:40:12 -03:00
|
|
|
const ImageFormatData *im_format, const bool use_ext, const bool use_frames, const char *suffix)
|
2012-12-23 13:57:09 +00:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
do_makepicstring(string, base, relbase, frame, im_format->imtype, im_format, use_ext, use_frames, suffix);
|
2012-12-23 13:57:09 +00:00
|
|
|
}
|
|
|
|
|
2015-01-24 16:48:23 +11:00
|
|
|
void BKE_image_path_from_imtype(
|
|
|
|
char *string, const char *base, const char *relbase, int frame,
|
2015-04-06 10:40:12 -03:00
|
|
|
const char imtype, const bool use_ext, const bool use_frames, const char *view)
|
2012-12-23 13:57:09 +00:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
do_makepicstring(string, base, relbase, frame, imtype, NULL, use_ext, use_frames, view);
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
|
|
|
|
2015-02-04 18:48:47 +01:00
|
|
|
struct anim *openanim_noload(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE])
|
|
|
|
{
|
|
|
|
struct anim *anim;
|
|
|
|
|
|
|
|
anim = IMB_open_anim(name, flags, streamindex, colorspace);
|
|
|
|
return anim;
|
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* used by sequencer too */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE])
|
2012-05-17 23:21:11 +00:00
|
|
|
{
|
2006-08-20 10:18:01 +00:00
|
|
|
struct anim *anim;
|
|
|
|
struct ImBuf *ibuf;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
anim = IMB_open_anim(name, flags, streamindex, colorspace);
|
2011-02-13 10:52:18 +00:00
|
|
|
if (anim == NULL) return NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
|
2006-02-11 23:17:41 +00:00
|
|
|
if (ibuf == NULL) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (BLI_exists(name))
|
2010-01-18 11:46:19 +00:00
|
|
|
printf("not an anim: %s\n", name);
|
|
|
|
else
|
|
|
|
printf("anim file doesn't exist: %s\n", name);
|
2002-10-12 11:37:38 +00:00
|
|
|
IMB_free_anim(anim);
|
2011-02-13 10:52:18 +00:00
|
|
|
return NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
IMB_freeImBuf(ibuf);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return(anim);
|
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* ************************* New Image API *************** */
|
|
|
|
|
|
|
|
|
2012-06-23 23:22:19 +00:00
|
|
|
/* Notes about Image storage
|
2012-03-03 20:19:11 +00:00
|
|
|
* - packedfile
|
|
|
|
* -> written in .blend
|
|
|
|
* - filename
|
|
|
|
* -> written in .blend
|
|
|
|
* - movie
|
|
|
|
* -> comes from packedfile or filename
|
|
|
|
* - renderresult
|
|
|
|
* -> comes from packedfile or filename
|
|
|
|
* - listbase
|
|
|
|
* -> ibufs from exrhandle
|
|
|
|
* - flipbook array
|
|
|
|
* -> ibufs come from movie, temporary renderresult or sequence
|
|
|
|
* - ibuf
|
|
|
|
* -> comes from packedfile or filename or generated
|
|
|
|
*/
|
2004-01-26 12:37:34 +00:00
|
|
|
|
|
|
|
|
2010-01-14 10:59:42 +00:00
|
|
|
/* forces existence of 1 Image for renderout or nodes, returns Image */
|
2006-12-20 17:57:56 +00:00
|
|
|
/* name is only for default, when making new one */
|
|
|
|
Image *BKE_image_verify_viewer(int type, const char *name)
|
|
|
|
{
|
|
|
|
Image *ima;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (ima = G.main->image.first; ima; ima = ima->id.next)
|
|
|
|
if (ima->source == IMA_SRC_VIEWER)
|
|
|
|
if (ima->type == type)
|
2006-12-20 17:57:56 +00:00
|
|
|
break;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ima == NULL)
|
2013-02-05 12:46:15 +00:00
|
|
|
ima = image_alloc(G.main, name, IMA_SRC_VIEWER, type);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* happens on reload, imagewindow cannot be image user when hidden*/
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ima->id.us == 0)
|
2006-12-20 17:57:56 +00:00
|
|
|
id_us_plus(&ima->id);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
return ima;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void image_viewer_create_views(const RenderData *rd, Image *ima)
|
|
|
|
{
|
2015-04-07 16:56:26 -03:00
|
|
|
if ((rd->scemode & R_MULTIVIEW) == 0) {
|
|
|
|
image_add_view(ima, "", "");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SceneRenderView *srv;
|
|
|
|
for (srv = rd->views.first; srv; srv = srv->next) {
|
|
|
|
if (BKE_scene_multiview_is_render_view_active(rd, srv) == false)
|
|
|
|
continue;
|
|
|
|
image_add_view(ima, srv->name, "");
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset the image cache and views when the Viewer Nodes views don't match the scene views */
|
|
|
|
void BKE_image_verify_viewer_views(const RenderData *rd, Image *ima, ImageUser *iuser)
|
|
|
|
{
|
|
|
|
bool do_reset;
|
2015-05-12 18:18:57 -03:00
|
|
|
const bool is_multiview = (rd->scemode & R_MULTIVIEW) != 0;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
BLI_lock_thread(LOCK_DRAW_IMAGE);
|
|
|
|
|
2015-10-11 01:14:02 +02:00
|
|
|
if (!BKE_scene_multiview_is_stereo3d(rd))
|
2015-04-06 10:40:12 -03:00
|
|
|
iuser->flag &= ~IMA_SHOW_STEREO;
|
|
|
|
|
|
|
|
/* see if all scene render views are in the image view list */
|
|
|
|
do_reset = (BKE_scene_multiview_num_views_get(rd) != BLI_listbase_count(&ima->views));
|
2015-05-12 18:18:57 -03:00
|
|
|
|
|
|
|
/* multiview also needs to be sure all the views are synced */
|
|
|
|
if (is_multiview && !do_reset) {
|
2015-04-06 10:40:12 -03:00
|
|
|
SceneRenderView *srv;
|
|
|
|
ImageView *iv;
|
|
|
|
|
|
|
|
for (iv = ima->views.first; iv; iv = iv->next) {
|
|
|
|
srv = BLI_findstring(&rd->views, iv->name, offsetof(SceneRenderView, name));
|
|
|
|
if ((srv == NULL) || (BKE_scene_multiview_is_render_view_active(rd, srv) == false)) {
|
|
|
|
do_reset = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_reset) {
|
2015-05-10 09:13:16 +02:00
|
|
|
BLI_spin_lock(&image_spin);
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
image_free_cached_frames(ima);
|
|
|
|
BKE_image_free_views(ima);
|
|
|
|
|
|
|
|
/* add new views */
|
|
|
|
image_viewer_create_views(rd, ima);
|
2015-05-10 09:13:16 +02:00
|
|
|
|
|
|
|
BLI_spin_unlock(&image_spin);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
BLI_unlock_thread(LOCK_DRAW_IMAGE);
|
|
|
|
}
|
|
|
|
|
2012-06-04 10:41:18 +00:00
|
|
|
void BKE_image_walk_all_users(const Main *mainp, void *customdata,
|
|
|
|
void callback(Image *ima, ImageUser *iuser, void *customdata))
|
|
|
|
{
|
|
|
|
wmWindowManager *wm;
|
|
|
|
wmWindow *win;
|
|
|
|
Tex *tex;
|
|
|
|
|
|
|
|
/* texture users */
|
|
|
|
for (tex = mainp->tex.first; tex; tex = tex->id.next) {
|
|
|
|
if (tex->type == TEX_IMAGE && tex->ima) {
|
2013-09-02 13:45:57 +00:00
|
|
|
callback(tex->ima, &tex->iuser, customdata);
|
2012-06-04 10:41:18 +00:00
|
|
|
}
|
2015-10-12 02:41:18 +02:00
|
|
|
|
|
|
|
if (tex->nodetree) {
|
|
|
|
bNode *node;
|
|
|
|
for (node = tex->nodetree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->id && node->type == TEX_NODE_IMAGE) {
|
|
|
|
Image *ima = (Image *)node->id;
|
|
|
|
ImageUser *iuser = node->storage;
|
|
|
|
callback(ima, iuser, customdata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-04 10:41:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* image window, compo node users */
|
|
|
|
for (wm = mainp->wm.first; wm; wm = wm->id.next) { /* only 1 wm */
|
|
|
|
for (win = wm->windows.first; win; win = win->next) {
|
|
|
|
ScrArea *sa;
|
|
|
|
for (sa = win->screen->areabase.first; sa; sa = sa->next) {
|
|
|
|
if (sa->spacetype == SPACE_VIEW3D) {
|
|
|
|
View3D *v3d = sa->spacedata.first;
|
|
|
|
BGpic *bgpic;
|
|
|
|
for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
|
|
|
|
callback(bgpic->ima, &bgpic->iuser, customdata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sa->spacetype == SPACE_IMAGE) {
|
|
|
|
SpaceImage *sima = sa->spacedata.first;
|
|
|
|
callback(sima->image, &sima->iuser, customdata);
|
|
|
|
}
|
|
|
|
else if (sa->spacetype == SPACE_NODE) {
|
|
|
|
SpaceNode *snode = sa->spacedata.first;
|
2013-03-18 18:25:05 +00:00
|
|
|
if (snode->nodetree && snode->nodetree->type == NTREE_COMPOSIT) {
|
2012-06-04 10:41:18 +00:00
|
|
|
bNode *node;
|
|
|
|
for (node = snode->nodetree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->id && node->type == CMP_NODE_IMAGE) {
|
|
|
|
Image *ima = (Image *)node->id;
|
|
|
|
ImageUser *iuser = node->storage;
|
|
|
|
callback(ima, iuser, customdata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void image_tag_frame_recalc(Image *ima, ImageUser *iuser, void *customdata)
|
|
|
|
{
|
|
|
|
Image *changed_image = customdata;
|
|
|
|
|
2014-01-14 04:59:58 +11:00
|
|
|
if (ima == changed_image && BKE_image_is_animated(ima)) {
|
2012-06-04 10:41:18 +00:00
|
|
|
iuser->flag |= IMA_NEED_FRAME_RECALC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void image_init_imageuser(Image *ima, ImageUser *iuser)
|
|
|
|
{
|
|
|
|
RenderResult *rr = ima->rr;
|
|
|
|
|
|
|
|
iuser->multi_index = 0;
|
2015-09-09 19:41:46 +05:00
|
|
|
iuser->layer = iuser->pass = iuser->view = 0;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-09-09 19:41:46 +05:00
|
|
|
if (rr)
|
2015-04-06 10:40:12 -03:00
|
|
|
BKE_image_multilayer_index(rr, iuser);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_init_imageuser(Image *ima, ImageUser *iuser)
|
|
|
|
{
|
2015-04-19 22:03:42 +10:00
|
|
|
image_init_imageuser(ima, iuser);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ima == NULL)
|
2006-12-20 17:57:56 +00:00
|
|
|
return;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
BLI_spin_lock(&image_spin);
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (signal) {
|
2012-05-06 15:15:33 +00:00
|
|
|
case IMA_SIGNAL_FREE:
|
2014-10-16 20:33:19 +02:00
|
|
|
BKE_image_free_buffers(ima);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
if (iuser) {
|
2014-10-16 20:33:19 +02:00
|
|
|
iuser->ok = 1;
|
2015-04-06 10:40:12 -03:00
|
|
|
if (iuser->scene) {
|
|
|
|
image_update_views_format(ima, iuser);
|
|
|
|
}
|
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
break;
|
|
|
|
case IMA_SIGNAL_SRC_CHANGE:
|
|
|
|
if (ima->type == IMA_TYPE_UV_TEST)
|
|
|
|
if (ima->source != IMA_SRC_GENERATED)
|
|
|
|
ima->type = IMA_TYPE_IMAGE;
|
|
|
|
|
|
|
|
if (ima->source == IMA_SRC_GENERATED) {
|
|
|
|
if (ima->gen_x == 0 || ima->gen_y == 0) {
|
2013-12-13 16:22:08 +06:00
|
|
|
ImBuf *ibuf = image_get_cached_ibuf_for_index_frame(ima, IMA_NO_INDEX, 0);
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ibuf) {
|
|
|
|
ima->gen_x = ibuf->x;
|
|
|
|
ima->gen_y = ibuf->y;
|
2013-12-13 16:22:08 +06:00
|
|
|
IMB_freeImBuf(ibuf);
|
2012-05-06 15:15:33 +00:00
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2013-12-17 22:16:53 +06:00
|
|
|
|
|
|
|
/* Changing source type to generated will likely change file format
|
|
|
|
* used by generated image buffer. Saving different file format to
|
|
|
|
* the old name might confuse other applications.
|
|
|
|
*
|
|
|
|
* Here we ensure original image path wouldn't be used when saving
|
|
|
|
* generated image.
|
|
|
|
*/
|
|
|
|
ima->name[0] = '\0';
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2009-09-16 19:27:08 +00:00
|
|
|
|
2013-01-24 17:21:22 +00:00
|
|
|
#if 0
|
2012-05-06 15:15:33 +00:00
|
|
|
/* force reload on first use, but not for multilayer, that makes nodes and buttons in ui drawing fail */
|
|
|
|
if (ima->type != IMA_TYPE_MULTILAYER)
|
2014-05-22 17:40:35 +10:00
|
|
|
BKE_image_free_buffers(ima);
|
2013-01-24 17:21:22 +00:00
|
|
|
#else
|
|
|
|
/* image buffers for non-sequence multilayer will share buffers with RenderResult,
|
|
|
|
* however sequence multilayer will own buffers. Such logic makes switching from
|
2013-10-31 14:10:01 +00:00
|
|
|
* single multilayer file to sequence completely unstable
|
2013-01-24 17:21:22 +00:00
|
|
|
* since changes in nodes seems this workaround isn't needed anymore, all sockets
|
|
|
|
* are nicely detecting anyway, but freeing buffers always here makes multilayer
|
|
|
|
* sequences behave stable
|
|
|
|
*/
|
2014-05-22 17:40:35 +10:00
|
|
|
BKE_image_free_buffers(ima);
|
2013-01-24 17:21:22 +00:00
|
|
|
#endif
|
2012-05-06 15:15:33 +00:00
|
|
|
|
|
|
|
ima->ok = 1;
|
|
|
|
if (iuser)
|
|
|
|
iuser->ok = 1;
|
2012-06-04 10:41:18 +00:00
|
|
|
|
|
|
|
BKE_image_walk_all_users(G.main, ima, image_tag_frame_recalc);
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IMA_SIGNAL_RELOAD:
|
|
|
|
/* try to repack file */
|
2015-04-06 10:40:12 -03:00
|
|
|
if (BKE_image_has_packedfile(ima)) {
|
2015-10-24 01:01:10 +11:00
|
|
|
const int totfiles = image_num_files(ima);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
if (totfiles != BLI_listbase_count_ex(&ima->packedfiles, totfiles + 1)) {
|
|
|
|
/* in case there are new available files to be loaded */
|
|
|
|
image_free_packedfiles(ima);
|
|
|
|
BKE_image_packfiles(NULL, ima, ID_BLEND_PATH(G.main, &ima->id));
|
2012-05-06 15:15:33 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-04-06 10:40:12 -03:00
|
|
|
ImagePackedFile *imapf;
|
|
|
|
for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
|
|
|
|
PackedFile *pf;
|
|
|
|
pf = newPackedFile(NULL, imapf->filepath, ID_BLEND_PATH(G.main, &ima->id));
|
|
|
|
if (pf) {
|
|
|
|
freePackedFile(imapf->packedfile);
|
|
|
|
imapf->packedfile = pf;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("ERROR: Image \"%s\" not available. Keeping packed image\n", imapf->filepath);
|
|
|
|
}
|
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
if (BKE_image_has_packedfile(ima))
|
|
|
|
BKE_image_free_buffers(ima);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
2014-10-16 20:33:19 +02:00
|
|
|
else
|
2014-05-22 17:40:35 +10:00
|
|
|
BKE_image_free_buffers(ima);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (iuser) {
|
2012-05-06 15:15:33 +00:00
|
|
|
iuser->ok = 1;
|
2015-04-06 10:40:12 -03:00
|
|
|
if (iuser->scene) {
|
|
|
|
image_update_views_format(ima, iuser);
|
|
|
|
}
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
break;
|
|
|
|
case IMA_SIGNAL_USER_NEW_IMAGE:
|
|
|
|
if (iuser) {
|
|
|
|
iuser->ok = 1;
|
|
|
|
if (ima->source == IMA_SRC_FILE || ima->source == IMA_SRC_SEQUENCE) {
|
|
|
|
if (ima->type == IMA_TYPE_MULTILAYER) {
|
2015-04-06 10:40:12 -03:00
|
|
|
image_init_imageuser(ima, iuser);
|
2012-05-06 15:15:33 +00:00
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
break;
|
2012-10-22 17:34:06 +00:00
|
|
|
case IMA_SIGNAL_COLORMANAGE:
|
2014-10-16 20:33:19 +02:00
|
|
|
BKE_image_free_buffers(ima);
|
2012-10-22 17:34:06 +00:00
|
|
|
|
2014-10-16 20:33:19 +02:00
|
|
|
ima->ok = 1;
|
|
|
|
|
|
|
|
if (iuser)
|
|
|
|
iuser->ok = 1;
|
2012-10-22 17:34:06 +00:00
|
|
|
|
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-11-17 11:07:46 +00:00
|
|
|
BLI_spin_unlock(&image_spin);
|
|
|
|
|
2012-03-18 07:38:51 +00:00
|
|
|
/* don't use notifiers because they are not 100% sure to succeeded
|
2010-09-13 06:08:26 +00:00
|
|
|
* this also makes sure all scenes are accounted for. */
|
|
|
|
{
|
|
|
|
Scene *scene;
|
2012-05-06 15:15:33 +00:00
|
|
|
for (scene = G.main->scene.first; scene; scene = scene->id.next) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (scene->nodetree) {
|
2011-10-19 17:08:35 +00:00
|
|
|
nodeUpdateID(scene->nodetree, &ima->id);
|
2010-09-13 06:08:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2015-09-09 19:41:46 +05:00
|
|
|
#define PASSTYPE_UNSET -1
|
|
|
|
/* return renderpass for a given pass index and active view */
|
|
|
|
/* fallback to available if there are missing passes for active view */
|
|
|
|
static RenderPass *image_render_pass_get(RenderLayer *rl, const int pass, const int view, int *r_passindex)
|
|
|
|
{
|
|
|
|
RenderPass *rpass_ret = NULL;
|
|
|
|
RenderPass *rpass;
|
|
|
|
|
|
|
|
int rp_index = 0;
|
|
|
|
int rp_passtype = PASSTYPE_UNSET;
|
|
|
|
|
|
|
|
for (rpass = rl->passes.first; rpass; rpass = rpass->next, rp_index++) {
|
|
|
|
if (rp_index == pass) {
|
|
|
|
rpass_ret = rpass;
|
|
|
|
if (view == 0) {
|
|
|
|
/* no multiview or left eye */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rp_passtype = rpass->passtype;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* multiview */
|
|
|
|
else if ((rp_passtype != PASSTYPE_UNSET) &&
|
|
|
|
(rpass->passtype == rp_passtype) &&
|
|
|
|
(rpass->view_id == view))
|
|
|
|
{
|
|
|
|
rpass_ret = rpass;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fallback to the first pass in the layer */
|
|
|
|
if (rpass_ret == NULL) {
|
|
|
|
rp_index = 0;
|
|
|
|
rpass_ret = rl->passes.first;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (r_passindex) {
|
|
|
|
*r_passindex = (rpass == rpass_ret ? rp_index : pass);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rpass_ret;
|
|
|
|
}
|
|
|
|
#undef PASSTYPE_UNSET
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* if layer or pass changes, we need an index for the imbufs list */
|
|
|
|
/* note it is called for rendered results, but it doesnt use the index! */
|
|
|
|
/* and because rendered results use fake layer/passes, don't correct for wrong indices here */
|
|
|
|
RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2006-12-20 17:57:56 +00:00
|
|
|
RenderLayer *rl;
|
2012-05-06 15:15:33 +00:00
|
|
|
RenderPass *rpass = NULL;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (rr == NULL)
|
2006-12-20 17:57:56 +00:00
|
|
|
return NULL;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (iuser) {
|
2015-04-17 09:48:31 -03:00
|
|
|
short index = 0, rv_index, rl_index = 0;
|
2015-04-06 10:40:12 -03:00
|
|
|
bool is_stereo = (iuser->flag & IMA_SHOW_STEREO) && RE_RenderResult_is_stereo(rr);
|
|
|
|
|
|
|
|
rv_index = is_stereo ? iuser->multiview_eye : iuser->view;
|
2015-04-17 09:48:31 -03:00
|
|
|
if (RE_HasFakeLayer(rr)) rl_index += 1;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (rl = rr->layers.first; rl; rl = rl->next, rl_index++) {
|
2015-09-09 19:41:46 +05:00
|
|
|
if (iuser->layer == rl_index) {
|
|
|
|
int rp_index;
|
|
|
|
rpass = image_render_pass_get(rl, iuser->pass, rv_index, &rp_index);
|
|
|
|
iuser->multi_index = index + rp_index;
|
2006-12-20 17:57:56 +00:00
|
|
|
break;
|
2015-09-09 19:41:46 +05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
index += BLI_listbase_count(&rl->passes);
|
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
return rpass;
|
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
void BKE_image_multiview_index(Image *ima, ImageUser *iuser)
|
|
|
|
{
|
|
|
|
if (iuser) {
|
2015-10-11 01:14:02 +02:00
|
|
|
bool is_stereo = BKE_image_is_stereo(ima) && (iuser->flag & IMA_SHOW_STEREO);
|
2015-04-06 10:40:12 -03:00
|
|
|
if (is_stereo) {
|
|
|
|
iuser->multi_index = iuser->multiview_eye;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if ((iuser->view < 0) || (iuser->view >= BLI_listbase_count_ex(&ima->views, iuser->view + 1))) {
|
|
|
|
iuser->multi_index = iuser->view = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
iuser->multi_index = iuser->view;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if layer or pass changes, we need an index for the imbufs list */
|
|
|
|
/* note it is called for rendered results, but it doesnt use the index! */
|
|
|
|
/* and because rendered results use fake layer/passes, don't correct for wrong indices here */
|
|
|
|
bool BKE_image_is_multilayer(Image *ima)
|
|
|
|
{
|
|
|
|
if (ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_SEQUENCE)) {
|
|
|
|
if (ima->type == IMA_TYPE_MULTILAYER) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_VIEWER) {
|
|
|
|
if (ima->type == IMA_TYPE_R_RESULT) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-10-11 01:14:02 +02:00
|
|
|
bool BKE_image_is_multiview(Image *ima)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2015-10-11 01:14:02 +02:00
|
|
|
return (BLI_listbase_count_ex(&ima->views, 2) > 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BKE_image_is_stereo(Image *ima)
|
|
|
|
{
|
|
|
|
return BKE_image_is_multiview(ima) &&
|
|
|
|
(BLI_findstring(&ima->views, STEREO_LEFT_NAME, offsetof(ImageView, name)) &&
|
|
|
|
BLI_findstring(&ima->views, STEREO_RIGHT_NAME, offsetof(ImageView, name)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void image_init_multilayer_multiview(Image *ima, RenderResult *rr)
|
|
|
|
{
|
2015-12-29 00:24:41 +01:00
|
|
|
/* update image views from render views, but only if they actually changed,
|
|
|
|
* to avoid invalid memory access during render. ideally these should always
|
|
|
|
* be acquired with a mutex along with the render result, but there are still
|
|
|
|
* some places with just an image pointer that need to access views */
|
|
|
|
if (rr && BLI_listbase_count(&ima->views) == BLI_listbase_count(&rr->views)) {
|
|
|
|
ImageView *iv = ima->views.first;
|
|
|
|
RenderView *rv = rr->views.first;
|
|
|
|
bool modified = false;
|
|
|
|
for (; rv; rv = rv->next, iv = iv->next) {
|
|
|
|
modified |= !STREQ(rv->name, iv->name);
|
|
|
|
}
|
|
|
|
if (!modified)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-11 01:14:02 +02:00
|
|
|
BKE_image_free_views(ima);
|
2015-12-29 00:24:41 +01:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (rr) {
|
2015-12-29 00:24:41 +01:00
|
|
|
for (RenderView *rv = rr->views.first; rv; rv = rv->next) {
|
|
|
|
ImageView *iv = MEM_callocN(sizeof(ImageView), "Viewer Image View");
|
|
|
|
BLI_strncpy(iv->name, rv->name, sizeof(iv->name));
|
|
|
|
BLI_addtail(&ima->views, iv);
|
2015-10-23 17:06:42 +11:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-11 01:14:02 +02:00
|
|
|
|
2010-03-27 15:35:34 +00:00
|
|
|
RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
RenderResult *rr = NULL;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ima->rr) {
|
2015-04-06 10:40:12 -03:00
|
|
|
rr = ima->rr;
|
2010-03-27 15:35:34 +00:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (ima->type == IMA_TYPE_R_RESULT) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ima->render_slot == ima->last_render_slot)
|
2015-04-06 10:40:12 -03:00
|
|
|
rr = RE_AcquireResultRead(RE_GetRender(scene->id.name));
|
2010-03-27 15:35:34 +00:00
|
|
|
else
|
2015-04-06 10:40:12 -03:00
|
|
|
rr = ima->renders[ima->render_slot];
|
|
|
|
|
2015-10-11 01:14:02 +02:00
|
|
|
/* set proper views */
|
|
|
|
image_init_multilayer_multiview(ima, rr);
|
2010-03-27 15:35:34 +00:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
return rr;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
2010-03-27 15:35:34 +00:00
|
|
|
void BKE_image_release_renderresult(Scene *scene, Image *ima)
|
2009-09-30 18:18:32 +00:00
|
|
|
{
|
2012-08-21 11:10:16 +00:00
|
|
|
if (ima->rr) {
|
|
|
|
/* pass */
|
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (ima->type == IMA_TYPE_R_RESULT) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ima->render_slot == ima->last_render_slot)
|
2010-03-27 15:35:34 +00:00
|
|
|
RE_ReleaseResult(RE_GetRender(scene->id.name));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
bool BKE_image_is_openexr(struct Image *ima)
|
|
|
|
{
|
|
|
|
#ifdef WITH_OPENEXR
|
|
|
|
if (ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_SEQUENCE)) {
|
|
|
|
return BLI_testextensie(ima->name, ".exr");
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
UNUSED_VARS(ima);
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-11-30 00:51:30 +01:00
|
|
|
void BKE_image_backup_render(Scene *scene, Image *ima, bool free_current_slot)
|
2010-03-27 15:35:34 +00:00
|
|
|
{
|
|
|
|
/* called right before rendering, ima->renders contains render
|
2012-03-03 20:19:11 +00:00
|
|
|
* result pointers for everything but the current render */
|
2012-05-06 15:15:33 +00:00
|
|
|
Render *re = RE_GetRender(scene->id.name);
|
|
|
|
int slot = ima->render_slot, last = ima->last_render_slot;
|
2010-03-27 15:35:34 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (slot != last) {
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->renders[last] = NULL;
|
2010-03-27 15:35:34 +00:00
|
|
|
RE_SwapResult(re, &ima->renders[last]);
|
2015-11-30 00:51:30 +01:00
|
|
|
|
|
|
|
if (ima->renders[slot]) {
|
|
|
|
if (free_current_slot) {
|
|
|
|
RE_FreeRenderResult(ima->renders[slot]);
|
|
|
|
ima->renders[slot] = NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
RE_SwapResult(re, &ima->renders[slot]);
|
|
|
|
}
|
|
|
|
}
|
2010-03-27 15:35:34 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->last_render_slot = slot;
|
2009-09-30 18:18:32 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/**************************** multiview save openexr *********************************/
|
|
|
|
#ifdef WITH_OPENEXR
|
2015-10-24 01:01:10 +11:00
|
|
|
static const char *image_get_view_cb(void *base, const int view_id)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
|
|
|
Image *ima = base;
|
|
|
|
ImageView *iv = BLI_findlink(&ima->views, view_id);
|
|
|
|
return iv ? iv->name : "";
|
|
|
|
}
|
|
|
|
#endif /* WITH_OPENEXR */
|
|
|
|
|
|
|
|
#ifdef WITH_OPENEXR
|
2015-10-24 01:01:10 +11:00
|
|
|
static ImBuf *image_get_buffer_cb(void *base, const int view_id)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
|
|
|
Image *ima = base;
|
|
|
|
ImageUser iuser = {0};
|
|
|
|
|
|
|
|
iuser.view = view_id;
|
|
|
|
iuser.ok = 1;
|
|
|
|
|
|
|
|
BKE_image_multiview_index(ima, &iuser);
|
|
|
|
|
|
|
|
return image_acquire_ibuf(ima, &iuser, NULL);
|
|
|
|
}
|
|
|
|
#endif /* WITH_OPENEXR */
|
|
|
|
|
|
|
|
bool BKE_image_save_openexr_multiview(Image *ima, ImBuf *ibuf, const char *filepath, const int flags)
|
|
|
|
{
|
|
|
|
#ifdef WITH_OPENEXR
|
|
|
|
char name[FILE_MAX];
|
|
|
|
bool ok;
|
|
|
|
|
|
|
|
BLI_strncpy(name, filepath, sizeof(name));
|
|
|
|
BLI_path_abs(name, G.main->name);
|
|
|
|
|
|
|
|
ibuf->userdata = ima;
|
|
|
|
ok = IMB_exr_multiview_save(ibuf, name, flags, BLI_listbase_count(&ima->views), image_get_view_cb, image_get_buffer_cb);
|
|
|
|
ibuf->userdata = NULL;
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
#else
|
|
|
|
UNUSED_VARS(ima, ibuf, filepath, flags);
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************** multiview load openexr *********************************/
|
|
|
|
|
|
|
|
static void image_add_view(Image *ima, const char *viewname, const char *filepath)
|
|
|
|
{
|
|
|
|
ImageView *iv;
|
|
|
|
|
|
|
|
iv = MEM_mallocN(sizeof(ImageView), "Viewer Image View");
|
|
|
|
BLI_strncpy(iv->name, viewname, sizeof(iv->name));
|
|
|
|
BLI_strncpy(iv->filepath, filepath, sizeof(iv->filepath));
|
|
|
|
|
|
|
|
/* For stereo drawing we need to ensure:
|
|
|
|
* STEREO_LEFT_NAME == STEREO_LEFT_ID and
|
|
|
|
* STEREO_RIGHT_NAME == STEREO_RIGHT_ID */
|
|
|
|
|
|
|
|
if (STREQ(viewname, STEREO_LEFT_NAME)) {
|
|
|
|
BLI_addhead(&ima->views, iv);
|
|
|
|
}
|
|
|
|
else if (STREQ(viewname, STEREO_RIGHT_NAME)) {
|
|
|
|
ImageView *left_iv = BLI_findstring(&ima->views, STEREO_LEFT_NAME, offsetof(ImageView, name));
|
|
|
|
|
|
|
|
if (left_iv == NULL) {
|
|
|
|
BLI_addhead(&ima->views, iv);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_insertlinkafter(&ima->views, left_iv, iv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_addtail(&ima->views, iv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WITH_OPENEXR
|
|
|
|
static void image_add_view_cb(void *base, const char *str)
|
|
|
|
{
|
|
|
|
Image *ima = base;
|
|
|
|
image_add_view(ima, str, ima->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void image_add_buffer_cb(void *base, const char *str, ImBuf *ibuf, const int frame)
|
|
|
|
{
|
|
|
|
Image *ima = base;
|
2015-10-24 01:01:10 +11:00
|
|
|
int id;
|
2015-04-06 10:40:12 -03:00
|
|
|
bool predivide = (ima->alpha_mode == IMA_ALPHA_PREMUL);
|
|
|
|
const char *colorspace = ima->colorspace_settings.name;
|
|
|
|
const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
|
|
|
|
|
|
|
|
if (ibuf == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
id = BLI_findstringindex(&ima->views, str, offsetof(ImageView, name));
|
|
|
|
|
|
|
|
if (id == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ibuf->channels >= 3)
|
|
|
|
IMB_colormanagement_transform(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
|
|
|
|
colorspace, to_colorspace, predivide);
|
|
|
|
|
|
|
|
image_assign_ibuf(ima, ibuf, id, frame);
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
}
|
|
|
|
#endif /* WITH_OPENEXR */
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* after imbuf load, openexr type can return with a exrhandle open */
|
|
|
|
/* in that case we have to build a render-result */
|
2015-04-06 10:40:12 -03:00
|
|
|
#ifdef WITH_OPENEXR
|
|
|
|
static void image_create_multiview(Image *ima, ImBuf *ibuf, const int frame)
|
|
|
|
{
|
2015-10-11 01:14:02 +02:00
|
|
|
BKE_image_free_views(ima);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
IMB_exr_multiview_convert(ibuf->userdata, ima, image_add_view_cb, image_add_buffer_cb, frame);
|
|
|
|
|
|
|
|
IMB_exr_close(ibuf->userdata);
|
|
|
|
}
|
|
|
|
#endif /* WITH_OPENEXR */
|
|
|
|
|
|
|
|
/* after imbuf load, openexr type can return with a exrhandle open */
|
|
|
|
/* in that case we have to build a render-result */
|
|
|
|
#ifdef WITH_OPENEXR
|
2006-12-20 17:57:56 +00:00
|
|
|
static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr)
|
|
|
|
{
|
2012-09-20 10:07:49 +00:00
|
|
|
const char *colorspace = ima->colorspace_settings.name;
|
2014-04-01 11:34:00 +11:00
|
|
|
bool predivide = (ima->alpha_mode == IMA_ALPHA_PREMUL);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-10-11 03:29:28 +02:00
|
|
|
/* only load rr once for multiview */
|
|
|
|
if (!ima->rr)
|
|
|
|
ima->rr = RE_MultilayerConvert(ibuf->userdata, colorspace, predivide, ibuf->x, ibuf->y);
|
2006-12-24 16:03:31 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
IMB_exr_close(ibuf->userdata);
|
2006-12-24 16:03:31 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->userdata = NULL;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ima->rr)
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->rr->framenr = framenr;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-10-11 01:14:02 +02:00
|
|
|
/* set proper views */
|
|
|
|
image_init_multilayer_multiview(ima, ima->rr);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
#endif /* WITH_OPENEXR */
|
2006-12-20 17:57:56 +00:00
|
|
|
|
|
|
|
/* common stuff to do with images after loading */
|
|
|
|
static void image_initialize_after_load(Image *ima, ImBuf *ibuf)
|
|
|
|
{
|
|
|
|
/* preview is NULL when it has never been used as an icon before */
|
2012-05-06 15:15:33 +00:00
|
|
|
if (G.background == 0 && ima->preview == NULL)
|
2015-05-11 16:29:12 +02:00
|
|
|
BKE_icon_changed(BKE_icon_id_ensure(&ima->id));
|
2010-11-05 09:01:00 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* fields */
|
|
|
|
if (ima->flag & IMA_FIELDS) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ima->flag & IMA_STD_FIELD) de_interlace_st(ibuf);
|
2006-12-20 17:57:56 +00:00
|
|
|
else de_interlace_ng(ibuf);
|
|
|
|
}
|
|
|
|
/* timer */
|
2014-05-22 11:58:07 +10:00
|
|
|
BKE_image_tag_time(ima);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->ok = IMA_OK_LOADED;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
2012-12-31 13:52:13 +00:00
|
|
|
static int imbuf_alpha_flags_for_image(Image *ima)
|
|
|
|
{
|
|
|
|
int flag = 0;
|
|
|
|
|
|
|
|
if (ima->flag & IMA_IGNORE_ALPHA)
|
|
|
|
flag |= IB_ignore_alpha;
|
|
|
|
else if (ima->alpha_mode == IMA_ALPHA_PREMUL)
|
|
|
|
flag |= IB_alphamode_premul;
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* the number of files will vary according to the stereo format */
|
2015-10-24 01:01:10 +11:00
|
|
|
static int image_num_files(Image *ima)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2015-10-11 01:14:02 +02:00
|
|
|
const bool is_multiview = BKE_image_is_multiview(ima);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
if (!is_multiview) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (ima->views_format == R_IMF_VIEWS_STEREO_3D) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
/* R_IMF_VIEWS_INDIVIDUAL */
|
|
|
|
else {
|
|
|
|
return BLI_listbase_count(&ima->views);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-24 01:01:10 +11:00
|
|
|
static ImBuf *load_sequence_single(Image *ima, ImageUser *iuser, int frame, const int view_id, bool *r_assign)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
|
|
|
struct ImBuf *ibuf;
|
2012-06-04 19:38:33 +00:00
|
|
|
char name[FILE_MAX];
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
int flag;
|
2015-04-06 10:40:12 -03:00
|
|
|
ImageUser iuser_t;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2010-02-13 13:09:30 +00:00
|
|
|
/* XXX temp stuff? */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ima->lastframe != frame)
|
2010-02-13 13:09:30 +00:00
|
|
|
ima->tpageflag |= IMA_TPAGE_REFRESH;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->lastframe = frame;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
if (iuser)
|
|
|
|
iuser_t = *iuser;
|
|
|
|
|
|
|
|
iuser_t.view = view_id;
|
|
|
|
BKE_image_user_file_path(&iuser_t, ima, name);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
flag = IB_rect | IB_multilayer;
|
2012-12-31 13:52:13 +00:00
|
|
|
flag |= imbuf_alpha_flags_for_image(ima);
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* read ibuf */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
ibuf = IMB_loadiffname(name, flag, ima->colorspace_settings.name);
|
2011-05-01 14:02:40 +00:00
|
|
|
|
|
|
|
#if 0
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ibuf) {
|
2012-05-06 15:15:33 +00:00
|
|
|
printf(AT " loaded %s\n", name);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
printf(AT " missed %s\n", name);
|
2011-05-01 14:02:40 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
if (ibuf) {
|
2006-12-24 20:19:56 +00:00
|
|
|
#ifdef WITH_OPENEXR
|
2012-11-15 15:59:58 +00:00
|
|
|
/* handle multilayer case, don't assign ibuf. will be handled in BKE_image_acquire_ibuf */
|
2015-07-13 13:58:17 +02:00
|
|
|
if (ibuf->ftype == IMB_FTYPE_OPENEXR && ibuf->userdata) {
|
2015-04-06 10:40:12 -03:00
|
|
|
/* handle singlelayer multiview case assign ibuf based on available views */
|
|
|
|
if (IMB_exr_has_singlelayer_multiview(ibuf->userdata)) {
|
|
|
|
image_create_multiview(ima, ibuf, frame);
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
ibuf = NULL;
|
|
|
|
}
|
|
|
|
else if (IMB_exr_has_multilayer(ibuf->userdata)) {
|
|
|
|
/* handle multilayer case, don't assign ibuf. will be handled in BKE_image_acquire_ibuf */
|
|
|
|
image_create_multilayer(ima, ibuf, frame);
|
|
|
|
ima->type = IMA_TYPE_MULTILAYER;
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
ibuf = NULL;
|
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
image_initialize_after_load(ima, ibuf);
|
2015-04-06 10:40:12 -03:00
|
|
|
*r_assign = true;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2006-12-24 20:19:56 +00:00
|
|
|
#else
|
|
|
|
image_initialize_after_load(ima, ibuf);
|
2015-04-06 10:40:12 -03:00
|
|
|
*r_assign = true;
|
2006-12-24 20:19:56 +00:00
|
|
|
#endif
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame)
|
|
|
|
{
|
|
|
|
struct ImBuf *ibuf = NULL;
|
2015-10-11 01:14:02 +02:00
|
|
|
const bool is_multiview = BKE_image_is_multiview(ima);
|
2015-10-24 01:01:10 +11:00
|
|
|
const int totfiles = image_num_files(ima);
|
2015-04-06 10:40:12 -03:00
|
|
|
bool assign = false;
|
|
|
|
|
|
|
|
if (!is_multiview) {
|
|
|
|
ibuf = load_sequence_single(ima, iuser, frame, 0, &assign);
|
|
|
|
if (assign) {
|
|
|
|
image_assign_ibuf(ima, ibuf, 0, frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2015-10-24 01:01:10 +11:00
|
|
|
const int totviews = BLI_listbase_count(&ima->views);
|
|
|
|
int i;
|
2015-04-06 10:40:12 -03:00
|
|
|
struct ImBuf **ibuf_arr;
|
|
|
|
|
|
|
|
ibuf_arr = MEM_mallocN(sizeof(ImBuf *) * totviews, "Image Views Imbufs");
|
|
|
|
|
|
|
|
for (i = 0; i < totfiles; i++)
|
|
|
|
ibuf_arr[i] = load_sequence_single(ima, iuser, frame, i, &assign);
|
|
|
|
|
2015-10-11 01:14:02 +02:00
|
|
|
if (BKE_image_is_stereo(ima) && ima->views_format == R_IMF_VIEWS_STEREO_3D)
|
2015-04-06 10:40:12 -03:00
|
|
|
IMB_ImBufFromStereo3d(ima->stereo3d_format, ibuf_arr[0], &ibuf_arr[0], &ibuf_arr[1]);
|
|
|
|
|
|
|
|
/* return the original requested ImBuf */
|
|
|
|
ibuf = ibuf_arr[(iuser ? iuser->multi_index : 0)];
|
|
|
|
|
|
|
|
if (assign) {
|
|
|
|
for (i = 0; i < totviews; i++) {
|
|
|
|
image_assign_ibuf(ima, ibuf_arr[i], i, frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* "remove" the others (decrease their refcount) */
|
|
|
|
for (i = 0; i < totviews; i++) {
|
|
|
|
if (ibuf_arr[i] != ibuf) {
|
|
|
|
IMB_freeImBuf(ibuf_arr[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
MEM_freeN(ibuf_arr);
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int frame)
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
struct ImBuf *ibuf = NULL;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* either we load from RenderResult, or we have to load a new one */
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* check for new RenderResult */
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ima->rr == NULL || frame != ima->rr->framenr) {
|
2013-10-28 12:16:17 +00:00
|
|
|
if (ima->rr) {
|
|
|
|
/* Cached image buffers shares pointers with render result,
|
|
|
|
* need to ensure there's no image buffers are hanging around
|
|
|
|
* with dead links after freeing the render result.
|
|
|
|
*/
|
2014-10-17 12:37:40 +02:00
|
|
|
image_free_cached_frames(ima);
|
2013-10-28 12:16:17 +00:00
|
|
|
RE_FreeRenderResult(ima->rr);
|
|
|
|
ima->rr = NULL;
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
ibuf = image_load_sequence_file(ima, iuser, frame);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ibuf) { /* actually an error */
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->type = IMA_TYPE_IMAGE;
|
2006-12-20 17:57:56 +00:00
|
|
|
printf("error, multi is normal image\n");
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ima->rr) {
|
2012-05-06 15:15:33 +00:00
|
|
|
RenderPass *rpass = BKE_image_multilayer_index(ima->rr, iuser);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (rpass) {
|
2006-12-20 17:57:56 +00:00
|
|
|
// printf("load from pass %s\n", rpass->name);
|
|
|
|
/* since we free render results, we copy the rect */
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf = IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0);
|
|
|
|
ibuf->rect_float = MEM_dupallocN(rpass->rect);
|
2006-12-20 17:57:56 +00:00
|
|
|
ibuf->flags |= IB_rectfloat;
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->mall = IB_rectfloat;
|
|
|
|
ibuf->channels = rpass->channels;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
image_initialize_after_load(ima, ibuf);
|
2012-05-06 15:15:33 +00:00
|
|
|
image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : 0, frame);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
// else printf("pass not found\n");
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
else
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->ok = 0;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (iuser)
|
2012-05-06 15:15:33 +00:00
|
|
|
iuser->ok = ima->ok;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
return ibuf;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2015-10-24 01:01:10 +11:00
|
|
|
static ImBuf *load_movie_single(Image *ima, ImageUser *iuser, int frame, const int view_id)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
struct ImBuf *ibuf = NULL;
|
2015-04-06 10:40:12 -03:00
|
|
|
ImageAnim *ia;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
ia = BLI_findlink(&ima->anims, view_id);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (ia->anim == NULL) {
|
2006-12-20 17:57:56 +00:00
|
|
|
char str[FILE_MAX];
|
2015-02-03 18:17:12 +05:00
|
|
|
int flags = IB_rect;
|
2015-04-06 10:40:12 -03:00
|
|
|
ImageUser iuser_t;
|
|
|
|
|
2015-02-03 18:17:12 +05:00
|
|
|
if (ima->flag & IMA_DEINTERLACE) {
|
|
|
|
flags |= IB_animdeinterlace;
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (iuser)
|
|
|
|
iuser_t = *iuser;
|
|
|
|
|
|
|
|
iuser_t.view = view_id;
|
|
|
|
|
|
|
|
BKE_image_user_file_path(&iuser_t, ima, str);
|
2011-10-08 11:11:54 +00:00
|
|
|
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
/* FIXME: make several stream accessible in image editor, too*/
|
2015-04-06 10:40:12 -03:00
|
|
|
ia->anim = openanim(str, flags, 0, ima->colorspace_settings.name);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* let's initialize this user */
|
2015-04-06 10:40:12 -03:00
|
|
|
if (ia->anim && iuser && iuser->frames == 0)
|
|
|
|
iuser->frames = IMB_anim_get_duration(ia->anim,
|
2012-05-06 15:15:33 +00:00
|
|
|
IMB_TC_RECORD_RUN);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (ia->anim) {
|
|
|
|
int dur = IMB_anim_get_duration(ia->anim,
|
2012-05-06 15:15:33 +00:00
|
|
|
IMB_TC_RECORD_RUN);
|
|
|
|
int fra = frame - 1;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (fra < 0) fra = 0;
|
|
|
|
if (fra > (dur - 1)) fra = dur - 1;
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
ibuf = IMB_makeSingleUser(
|
2015-04-06 10:40:12 -03:00
|
|
|
IMB_anim_absolute(ia->anim, fra,
|
2012-05-06 15:15:33 +00:00
|
|
|
IMB_TC_RECORD_RUN,
|
|
|
|
IMB_PROXY_NONE));
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ibuf) {
|
2006-12-20 17:57:56 +00:00
|
|
|
image_initialize_after_load(ima, ibuf);
|
|
|
|
}
|
|
|
|
else
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->ok = 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
else
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->ok = 0;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
|
|
|
|
{
|
|
|
|
struct ImBuf *ibuf = NULL;
|
2015-10-11 01:14:02 +02:00
|
|
|
const bool is_multiview = BKE_image_is_multiview(ima);
|
2015-10-24 01:01:10 +11:00
|
|
|
const int totfiles = image_num_files(ima);
|
|
|
|
int i;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
if (totfiles != BLI_listbase_count_ex(&ima->anims, totfiles + 1)) {
|
|
|
|
image_free_anims(ima);
|
|
|
|
|
|
|
|
for (i = 0; i < totfiles; i++) {
|
|
|
|
/* allocate the ImageAnim */
|
|
|
|
ImageAnim *ia = MEM_callocN(sizeof(ImageAnim), "Image Anim");
|
|
|
|
BLI_addtail(&ima->anims, ia);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_multiview) {
|
|
|
|
ibuf = load_movie_single(ima, iuser, frame, 0);
|
|
|
|
image_assign_ibuf(ima, ibuf, 0, frame);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
struct ImBuf **ibuf_arr;
|
2015-10-24 01:01:10 +11:00
|
|
|
const int totviews = BLI_listbase_count(&ima->views);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
ibuf_arr = MEM_mallocN(sizeof(ImBuf *) * totviews, "Image Views (movie) Imbufs");
|
|
|
|
|
|
|
|
for (i = 0; i < totfiles; i++) {
|
|
|
|
ibuf_arr[i] = load_movie_single(ima, iuser, frame, i);
|
|
|
|
}
|
|
|
|
|
2015-10-11 01:14:02 +02:00
|
|
|
if (BKE_image_is_stereo(ima) && ima->views_format == R_IMF_VIEWS_STEREO_3D)
|
2015-04-06 10:40:12 -03:00
|
|
|
IMB_ImBufFromStereo3d(ima->stereo3d_format, ibuf_arr[0], &ibuf_arr[0], &ibuf_arr[1]);
|
|
|
|
|
|
|
|
for (i = 0; i < totviews; i++) {
|
|
|
|
if (ibuf_arr[i]) {
|
|
|
|
image_assign_ibuf(ima, ibuf_arr[i], i, frame);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ima->ok = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return the original requested ImBuf */
|
|
|
|
ibuf = ibuf_arr[(iuser ? iuser->multi_index : 0)];
|
|
|
|
|
|
|
|
/* "remove" the others (decrease their refcount) */
|
|
|
|
for (i = 0; i < totviews; i++) {
|
|
|
|
if (ibuf_arr[i] != ibuf) {
|
|
|
|
IMB_freeImBuf(ibuf_arr[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
MEM_freeN(ibuf_arr);
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (iuser)
|
2012-05-06 15:15:33 +00:00
|
|
|
iuser->ok = ima->ok;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
return ibuf;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static ImBuf *load_image_single(
|
|
|
|
Image *ima, ImageUser *iuser, int cfra,
|
2015-10-24 01:01:10 +11:00
|
|
|
const int view_id,
|
2015-04-06 10:40:12 -03:00
|
|
|
const bool has_packed,
|
|
|
|
bool *r_assign)
|
2006-07-05 17:32:49 +00:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
char filepath[FILE_MAX];
|
|
|
|
struct ImBuf *ibuf = NULL;
|
|
|
|
int flag;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* is there a PackedFile with this image ? */
|
2015-04-06 10:40:12 -03:00
|
|
|
if (has_packed) {
|
|
|
|
ImagePackedFile *imapf;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
flag = IB_rect | IB_multilayer;
|
2012-12-31 13:52:13 +00:00
|
|
|
flag |= imbuf_alpha_flags_for_image(ima);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
imapf = BLI_findlink(&ima->packedfiles, view_id);
|
2015-06-08 18:21:27 +10:00
|
|
|
if (imapf->packedfile) {
|
|
|
|
ibuf = IMB_ibImageFromMemory(
|
|
|
|
(unsigned char *)imapf->packedfile->data, imapf->packedfile->size, flag,
|
|
|
|
ima->colorspace_settings.name, "<packed data>");
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
else {
|
2015-04-06 10:40:12 -03:00
|
|
|
ImageUser iuser_t;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
flag = IB_rect | IB_multilayer | IB_metadata;
|
2012-12-31 13:52:13 +00:00
|
|
|
flag |= imbuf_alpha_flags_for_image(ima);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* get the correct filepath */
|
2012-06-10 07:35:45 +00:00
|
|
|
BKE_image_user_frame_calc(iuser, cfra, 0);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
if (iuser)
|
|
|
|
iuser_t = *iuser;
|
|
|
|
else
|
|
|
|
iuser_t.framenr = ima->lastframe;
|
|
|
|
|
|
|
|
iuser_t.view = view_id;
|
|
|
|
|
|
|
|
BKE_image_user_file_path(&iuser_t, ima, filepath);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* read ibuf */
|
2015-04-06 10:40:12 -03:00
|
|
|
ibuf = IMB_loadiffname(filepath, flag, ima->colorspace_settings.name);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
if (ibuf) {
|
2015-04-06 10:40:12 -03:00
|
|
|
#ifdef WITH_OPENEXR
|
2015-07-13 13:58:17 +02:00
|
|
|
if (ibuf->ftype == IMB_FTYPE_OPENEXR && ibuf->userdata) {
|
2015-04-06 10:40:12 -03:00
|
|
|
if (IMB_exr_has_singlelayer_multiview(ibuf->userdata)) {
|
|
|
|
/* handle singlelayer multiview case assign ibuf based on available views */
|
|
|
|
image_create_multiview(ima, ibuf, cfra);
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
ibuf = NULL;
|
|
|
|
}
|
|
|
|
else if (IMB_exr_has_multilayer(ibuf->userdata)) {
|
|
|
|
/* handle multilayer case, don't assign ibuf. will be handled in BKE_image_acquire_ibuf */
|
|
|
|
image_create_multilayer(ima, ibuf, cfra);
|
|
|
|
ima->type = IMA_TYPE_MULTILAYER;
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
ibuf = NULL;
|
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2015-06-27 09:52:52 +02:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2006-12-20 17:57:56 +00:00
|
|
|
image_initialize_after_load(ima, ibuf);
|
2015-04-06 10:40:12 -03:00
|
|
|
*r_assign = true;
|
2006-12-20 17:57:56 +00:00
|
|
|
|
|
|
|
/* check if the image is a font image... */
|
|
|
|
detectBitmapFont(ibuf);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* make packed file for autopack */
|
2015-04-06 10:40:12 -03:00
|
|
|
if ((has_packed == false) && (G.fileflags & G_AUTOPACK)) {
|
|
|
|
ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image Packefile");
|
|
|
|
BLI_addtail(&ima->packedfiles, imapf);
|
|
|
|
|
|
|
|
BLI_strncpy(imapf->filepath, filepath, sizeof(imapf->filepath));
|
|
|
|
imapf->packedfile = newPackedFile(NULL, filepath, ID_BLEND_PATH(G.main, &ima->id));
|
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->ok = 0;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* warning, 'iuser' can be NULL
|
|
|
|
* note: Image->views was already populated (in image_update_views_format)
|
|
|
|
*/
|
|
|
|
static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
|
|
|
|
{
|
|
|
|
struct ImBuf *ibuf = NULL;
|
|
|
|
bool assign = false;
|
2015-10-11 01:14:02 +02:00
|
|
|
const bool is_multiview = BKE_image_is_multiview(ima);
|
2015-10-24 01:01:10 +11:00
|
|
|
const int totfiles = image_num_files(ima);
|
2015-04-06 10:40:12 -03:00
|
|
|
bool has_packed = BKE_image_has_packedfile(ima);
|
|
|
|
|
|
|
|
/* always ensure clean ima */
|
|
|
|
BKE_image_free_buffers(ima);
|
|
|
|
|
|
|
|
/* this should never happen, but just playing safe */
|
|
|
|
if (has_packed) {
|
|
|
|
if (totfiles != BLI_listbase_count_ex(&ima->packedfiles, totfiles + 1)) {
|
|
|
|
image_free_packedfiles(ima);
|
|
|
|
has_packed = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_multiview) {
|
|
|
|
ibuf = load_image_single(ima, iuser, cfra, 0, has_packed, &assign);
|
|
|
|
if (assign) {
|
|
|
|
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
struct ImBuf **ibuf_arr;
|
2015-10-24 01:01:10 +11:00
|
|
|
const int totviews = BLI_listbase_count(&ima->views);
|
|
|
|
int i;
|
2015-04-06 10:40:12 -03:00
|
|
|
BLI_assert(totviews > 0);
|
|
|
|
|
2015-06-27 09:46:38 +02:00
|
|
|
ibuf_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Image Views Imbufs");
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
for (i = 0; i < totfiles; i++)
|
|
|
|
ibuf_arr[i] = load_image_single(ima, iuser, cfra, i, has_packed, &assign);
|
|
|
|
|
2015-06-27 09:46:38 +02:00
|
|
|
/* multi-views/multi-layers OpenEXR files directly populate ima, and return NULL ibuf... */
|
2015-10-11 01:14:02 +02:00
|
|
|
if (BKE_image_is_stereo(ima) && ima->views_format == R_IMF_VIEWS_STEREO_3D &&
|
2015-06-27 09:46:38 +02:00
|
|
|
ibuf_arr[0] && totfiles == 1 && totviews >= 2)
|
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
IMB_ImBufFromStereo3d(ima->stereo3d_format, ibuf_arr[0], &ibuf_arr[0], &ibuf_arr[1]);
|
2015-06-27 09:46:38 +02:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
/* return the original requested ImBuf */
|
2015-06-27 09:46:38 +02:00
|
|
|
i = (iuser && iuser->multi_index < totviews) ? iuser->multi_index : 0;
|
2015-04-06 10:40:12 -03:00
|
|
|
ibuf = ibuf_arr[i];
|
|
|
|
|
|
|
|
if (assign) {
|
|
|
|
for (i = 0; i < totviews; i++) {
|
|
|
|
image_assign_ibuf(ima, ibuf_arr[i], i, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* "remove" the others (decrease their refcount) */
|
|
|
|
for (i = 0; i < totviews; i++) {
|
|
|
|
if (ibuf_arr[i] != ibuf) {
|
|
|
|
IMB_freeImBuf(ibuf_arr[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
MEM_freeN(ibuf_arr);
|
|
|
|
}
|
2008-04-28 20:57:03 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (iuser)
|
2012-05-06 15:15:33 +00:00
|
|
|
iuser->ok = ima->ok;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
return ibuf;
|
2006-07-05 17:32:49 +00:00
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
ImBuf *ibuf = NULL;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ima->rr == NULL) {
|
2006-12-20 17:57:56 +00:00
|
|
|
ibuf = image_load_image_file(ima, iuser, 0);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ibuf) { /* actually an error */
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->type = IMA_TYPE_IMAGE;
|
2006-12-20 17:57:56 +00:00
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ima->rr) {
|
2012-05-06 15:15:33 +00:00
|
|
|
RenderPass *rpass = BKE_image_multilayer_index(ima->rr, iuser);
|
2006-12-20 17:57:56 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (rpass) {
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf = IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
image_initialize_after_load(ima, ibuf);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->rect_float = rpass->rect;
|
2006-12-20 17:57:56 +00:00
|
|
|
ibuf->flags |= IB_rectfloat;
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->channels = rpass->channels;
|
2008-04-28 20:57:03 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : IMA_NO_INDEX, 0);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ibuf == NULL)
|
|
|
|
ima->ok = 0;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (iuser)
|
2012-05-06 15:15:33 +00:00
|
|
|
iuser->ok = ima->ok;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* showing RGBA result itself (from compo/sequence) or
|
2012-03-03 20:19:11 +00:00
|
|
|
* like exr, using layers etc */
|
2009-02-05 19:28:28 +00:00
|
|
|
/* always returns a single ibuf, also during render progress */
|
2015-05-08 07:25:39 +10:00
|
|
|
static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_lock)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2010-03-16 16:58:45 +00:00
|
|
|
Render *re;
|
|
|
|
RenderResult rres;
|
2015-04-22 18:44:30 -03:00
|
|
|
RenderView *rv;
|
2010-03-16 16:58:45 +00:00
|
|
|
float *rectf, *rectz;
|
|
|
|
unsigned int *rect;
|
|
|
|
float dither;
|
2015-09-09 19:41:46 +05:00
|
|
|
int channels, layer, pass;
|
2010-03-16 16:58:45 +00:00
|
|
|
ImBuf *ibuf;
|
2012-05-06 15:15:33 +00:00
|
|
|
int from_render = (ima->render_slot == ima->last_render_slot);
|
2015-04-06 10:40:12 -03:00
|
|
|
int actview;
|
2014-01-01 16:59:38 +06:00
|
|
|
bool byte_buffer_in_display_space = false;
|
2010-03-16 16:58:45 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!(iuser && iuser->scene))
|
2010-03-16 16:58:45 +00:00
|
|
|
return NULL;
|
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
/* if we the caller is not going to release the lock, don't give the image */
|
2015-05-08 07:25:39 +10:00
|
|
|
if (!r_lock)
|
2009-09-30 18:18:32 +00:00
|
|
|
return NULL;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
re = RE_GetRender(iuser->scene->id.name);
|
2010-03-16 16:58:45 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
channels = 4;
|
2013-07-13 05:53:14 +00:00
|
|
|
layer = iuser->layer;
|
2015-09-09 19:41:46 +05:00
|
|
|
pass = iuser->pass;
|
2015-04-06 10:40:12 -03:00
|
|
|
actview = iuser->view;
|
|
|
|
|
2015-10-11 01:14:02 +02:00
|
|
|
if (BKE_image_is_stereo(ima) && (iuser->flag & IMA_SHOW_STEREO))
|
2015-04-06 10:40:12 -03:00
|
|
|
actview = iuser->multiview_eye;
|
2010-03-27 15:35:34 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (from_render) {
|
2015-04-06 10:40:12 -03:00
|
|
|
RE_AcquireResultImage(re, &rres, actview);
|
2010-07-07 14:28:22 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (ima->renders[ima->render_slot]) {
|
2012-05-06 15:15:33 +00:00
|
|
|
rres = *(ima->renders[ima->render_slot]);
|
2015-04-29 11:26:30 -03:00
|
|
|
rres.have_combined = ((RenderView *)rres.views.first)->rectf != NULL;
|
2010-07-07 14:28:22 +00:00
|
|
|
}
|
2010-03-27 15:35:34 +00:00
|
|
|
else
|
|
|
|
memset(&rres, 0, sizeof(RenderResult));
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!(rres.rectx > 0 && rres.recty > 0)) {
|
|
|
|
if (from_render)
|
2010-04-01 12:51:24 +00:00
|
|
|
RE_ReleaseResultImage(re);
|
2010-03-27 15:35:34 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-05-08 07:25:39 +10:00
|
|
|
/* release is done in BKE_image_release_ibuf using r_lock */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (from_render) {
|
2010-04-01 12:51:24 +00:00
|
|
|
BLI_lock_thread(LOCK_VIEWER);
|
2015-05-08 07:25:39 +10:00
|
|
|
*r_lock = re;
|
2015-04-27 12:09:04 -03:00
|
|
|
rv = NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rv = BLI_findlink(&rres.views, actview);
|
|
|
|
if (rv == NULL)
|
|
|
|
rv = rres.views.first;
|
2010-04-01 12:51:24 +00:00
|
|
|
}
|
2010-03-27 15:35:34 +00:00
|
|
|
|
2015-04-27 12:09:04 -03:00
|
|
|
/* this gives active layer, composite or sequence result */
|
|
|
|
if (rv == NULL) {
|
|
|
|
rect = (unsigned int *)rres.rect32;
|
|
|
|
rectf = rres.rectf;
|
|
|
|
rectz = rres.rectz;
|
|
|
|
}
|
|
|
|
else {
|
2015-04-23 10:59:35 -03:00
|
|
|
rect = (unsigned int *)rv->rect32;
|
|
|
|
rectf = rv->rectf;
|
|
|
|
rectz = rv->rectz;
|
|
|
|
}
|
2015-04-27 12:09:04 -03:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
dither = iuser->scene->r.dither_intensity;
|
2010-03-16 16:58:45 +00:00
|
|
|
|
2010-07-07 14:28:22 +00:00
|
|
|
/* combined layer gets added as first layer */
|
2012-09-04 18:27:47 +00:00
|
|
|
if (rres.have_combined && layer == 0) {
|
|
|
|
/* pass */
|
|
|
|
}
|
2013-02-12 11:45:16 +00:00
|
|
|
else if (rect && layer == 0) {
|
|
|
|
/* rect32 is set when there's a Sequence pass, this pass seems
|
|
|
|
* to have layer=0 (this is from image_buttons.c)
|
|
|
|
* in this case we ignore float buffer, because it could have
|
|
|
|
* hung from previous pass which was float
|
|
|
|
*/
|
|
|
|
rectf = NULL;
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (rres.layers.first) {
|
2012-05-06 15:15:33 +00:00
|
|
|
RenderLayer *rl = BLI_findlink(&rres.layers, layer - (rres.have_combined ? 1 : 0));
|
2012-03-24 06:18:31 +00:00
|
|
|
if (rl) {
|
2015-09-09 19:41:46 +05:00
|
|
|
RenderPass *rpass = image_render_pass_get(rl, pass, actview, NULL);
|
2015-04-06 10:40:12 -03:00
|
|
|
if (rpass) {
|
|
|
|
rectf = rpass->rect;
|
2015-09-09 19:41:46 +05:00
|
|
|
if (pass == 0) {
|
2015-07-06 11:51:40 -03:00
|
|
|
if (rectf == NULL) {
|
|
|
|
/* Happens when Save Buffers is enabled.
|
|
|
|
* Use display buffer stored in the render layer.
|
|
|
|
*/
|
|
|
|
rect = (unsigned int *) rl->display_buffer;
|
|
|
|
byte_buffer_in_display_space = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
channels = rpass->channels;
|
|
|
|
dither = 0.0f; /* don't dither passes */
|
2015-05-04 16:57:17 +02:00
|
|
|
}
|
2010-03-16 16:58:45 +00:00
|
|
|
}
|
2010-02-16 19:24:04 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (rpass = rl->passes.first; rpass; rpass = rpass->next)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (rpass->passtype == SCE_PASS_Z)
|
2012-05-06 15:15:33 +00:00
|
|
|
rectz = rpass->rect;
|
2010-03-16 16:58:45 +00:00
|
|
|
}
|
2009-02-05 19:28:28 +00:00
|
|
|
}
|
2010-02-07 00:28:49 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
ibuf = image_get_cached_ibuf_for_index_frame(ima, IMA_NO_INDEX, 0);
|
2006-12-20 17:57:56 +00:00
|
|
|
|
2010-03-16 16:58:45 +00:00
|
|
|
/* make ibuf if needed, and initialize it */
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ibuf == NULL) {
|
|
|
|
ibuf = IMB_allocImBuf(rres.rectx, rres.recty, 32, 0);
|
2010-03-16 16:58:45 +00:00
|
|
|
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
|
|
|
|
}
|
2010-03-27 15:35:34 +00:00
|
|
|
|
2014-01-01 16:59:38 +06:00
|
|
|
/* Set color space settings for a byte buffer.
|
|
|
|
*
|
|
|
|
* This is mainly to make it so color management treats byte buffer
|
|
|
|
* from render result with Save Buffers enabled as final display buffer
|
|
|
|
* and doesnt' apply any color management on it.
|
|
|
|
*
|
|
|
|
* For other cases we need to be sure it stays to default byte buffer space.
|
|
|
|
*/
|
|
|
|
if (ibuf->rect != rect) {
|
|
|
|
if (byte_buffer_in_display_space) {
|
|
|
|
const char *colorspace =
|
|
|
|
IMB_colormanagement_get_display_colorspace_name(&iuser->scene->view_settings,
|
|
|
|
&iuser->scene->display_settings);
|
|
|
|
IMB_colormanagement_assign_rect_colorspace(ibuf, colorspace);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const char *colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE);
|
|
|
|
IMB_colormanagement_assign_rect_colorspace(ibuf, colorspace);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
/* invalidate color managed buffers if render result changed */
|
|
|
|
BLI_lock_thread(LOCK_COLORMANAGE);
|
2012-09-26 20:26:31 +00:00
|
|
|
if (ibuf->x != rres.rectx || ibuf->y != rres.recty || ibuf->rect_float != rectf) {
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
|
|
|
|
}
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->x = rres.rectx;
|
|
|
|
ibuf->y = rres.recty;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-10-13 12:38:32 +00:00
|
|
|
if (rect) {
|
2013-12-17 23:42:38 +06:00
|
|
|
imb_freerectImBuf(ibuf);
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->rect = rect;
|
2012-10-13 12:38:32 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* byte buffer of render result has been freed, make sure image buffers
|
|
|
|
* does not reference to this buffer anymore
|
|
|
|
* need check for whether byte buffer was allocated and owned by image itself
|
|
|
|
* or if it's reusing buffer from render result
|
|
|
|
*/
|
|
|
|
if ((ibuf->mall & IB_rect) == 0)
|
|
|
|
ibuf->rect = NULL;
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (rectf) {
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->rect_float = rectf;
|
2010-04-23 18:02:50 +00:00
|
|
|
ibuf->flags |= IB_rectfloat;
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->channels = channels;
|
2010-04-23 18:02:50 +00:00
|
|
|
}
|
2010-04-26 12:50:48 +00:00
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->rect_float = NULL;
|
2010-04-26 12:50:48 +00:00
|
|
|
ibuf->flags &= ~IB_rectfloat;
|
|
|
|
}
|
2010-04-23 18:02:50 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (rectz) {
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->zbuf_float = rectz;
|
2010-04-23 18:02:50 +00:00
|
|
|
ibuf->flags |= IB_zbuffloat;
|
|
|
|
}
|
2010-04-26 12:50:48 +00:00
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->zbuf_float = NULL;
|
2010-04-26 12:50:48 +00:00
|
|
|
ibuf->flags &= ~IB_zbuffloat;
|
|
|
|
}
|
2010-04-23 18:02:50 +00:00
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
BLI_unlock_thread(LOCK_COLORMANAGE);
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf->dither = dither;
|
2009-09-30 18:18:32 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ima->ok = IMA_OK_LOADED;
|
2009-09-30 18:18:32 +00:00
|
|
|
|
2010-03-16 16:58:45 +00:00
|
|
|
return ibuf;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
2015-10-24 01:01:10 +11:00
|
|
|
static int image_get_multiview_index(Image *ima, ImageUser *iuser)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
|
|
|
const bool is_multilayer = BKE_image_is_multilayer(ima);
|
|
|
|
const bool is_backdrop = (ima->source == IMA_SRC_VIEWER) && (ima->type == IMA_TYPE_COMPOSITE) && (iuser == NULL);
|
2015-05-10 20:37:38 +02:00
|
|
|
int index = BKE_image_is_animated(ima) ? 0 : IMA_NO_INDEX;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
if (is_multilayer) {
|
2015-05-10 20:37:38 +02:00
|
|
|
return iuser ? iuser->multi_index : index;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
else if (is_backdrop) {
|
2015-10-11 01:14:02 +02:00
|
|
|
if (BKE_image_is_stereo(ima)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
/* backdrop hackaround (since there is no iuser */
|
|
|
|
return ima->eye;
|
|
|
|
}
|
|
|
|
}
|
2015-10-11 01:14:02 +02:00
|
|
|
else if (BKE_image_is_multiview(ima)) {
|
2015-05-10 20:37:38 +02:00
|
|
|
return iuser ? iuser->multi_index : index;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2015-05-10 20:37:38 +02:00
|
|
|
return index;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2014-03-16 03:24:05 +11:00
|
|
|
static void image_get_frame_and_index(Image *ima, ImageUser *iuser, int *r_frame, int *r_index)
|
2013-01-21 08:49:42 +00:00
|
|
|
{
|
2015-05-10 20:37:38 +02:00
|
|
|
int frame = 0, index = image_get_multiview_index(ima, iuser);
|
2013-01-21 08:49:42 +00:00
|
|
|
|
|
|
|
/* see if we already have an appropriate ibuf, with image source and type */
|
|
|
|
if (ima->source == IMA_SRC_MOVIE) {
|
|
|
|
frame = iuser ? iuser->framenr : ima->lastframe;
|
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_SEQUENCE) {
|
|
|
|
if (ima->type == IMA_TYPE_IMAGE) {
|
|
|
|
frame = iuser ? iuser->framenr : ima->lastframe;
|
|
|
|
}
|
|
|
|
else if (ima->type == IMA_TYPE_MULTILAYER) {
|
|
|
|
frame = iuser ? iuser->framenr : ima->lastframe;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-16 03:24:05 +11:00
|
|
|
*r_frame = frame;
|
|
|
|
*r_index = index;
|
2013-01-21 08:49:42 +00:00
|
|
|
}
|
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
/* Get the ibuf from an image cache for a given image user.
|
|
|
|
*
|
|
|
|
* Returns referenced image buffer if it exists, callee is to
|
|
|
|
* call IMB_freeImBuf to de-reference the image buffer after
|
|
|
|
* it's done handling it.
|
|
|
|
*/
|
2014-03-16 03:24:05 +11:00
|
|
|
static ImBuf *image_get_cached_ibuf(Image *ima, ImageUser *iuser, int *r_frame, int *r_index)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2008-04-28 20:57:03 +00:00
|
|
|
ImBuf *ibuf = NULL;
|
2015-05-10 20:37:38 +02:00
|
|
|
int frame = 0, index = image_get_multiview_index(ima, iuser);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2008-04-28 20:57:03 +00:00
|
|
|
/* see if we already have an appropriate ibuf, with image source and type */
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ima->source == IMA_SRC_MOVIE) {
|
|
|
|
frame = iuser ? iuser->framenr : ima->lastframe;
|
2015-04-06 10:40:12 -03:00
|
|
|
ibuf = image_get_cached_ibuf_for_index_frame(ima, index, frame);
|
2010-02-13 21:24:13 +00:00
|
|
|
/* XXX temp stuff? */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ima->lastframe != frame)
|
2010-02-13 21:24:13 +00:00
|
|
|
ima->tpageflag |= IMA_TPAGE_REFRESH;
|
|
|
|
ima->lastframe = frame;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (ima->source == IMA_SRC_SEQUENCE) {
|
|
|
|
if (ima->type == IMA_TYPE_IMAGE) {
|
|
|
|
frame = iuser ? iuser->framenr : ima->lastframe;
|
2015-04-06 10:40:12 -03:00
|
|
|
ibuf = image_get_cached_ibuf_for_index_frame(ima, index, frame);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2010-02-13 13:09:30 +00:00
|
|
|
/* XXX temp stuff? */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ima->lastframe != frame) {
|
2010-02-13 13:09:30 +00:00
|
|
|
ima->tpageflag |= IMA_TPAGE_REFRESH;
|
2010-08-25 02:32:02 +00:00
|
|
|
}
|
2010-02-13 13:09:30 +00:00
|
|
|
ima->lastframe = frame;
|
2015-02-26 15:10:19 +01:00
|
|
|
|
|
|
|
/* counter the fact that image is set as invalid when loading a frame
|
|
|
|
* that is not in the cache (through image_acquire_ibuf for instance),
|
|
|
|
* yet we have valid frames in the cache loaded */
|
|
|
|
if (ibuf) {
|
|
|
|
ima->ok = IMA_OK_LOADED;
|
|
|
|
|
|
|
|
if (iuser)
|
|
|
|
iuser->ok = ima->ok;
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (ima->type == IMA_TYPE_MULTILAYER) {
|
|
|
|
frame = iuser ? iuser->framenr : ima->lastframe;
|
2013-12-13 16:22:08 +06:00
|
|
|
ibuf = image_get_cached_ibuf_for_index_frame(ima, index, frame);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (ima->source == IMA_SRC_FILE) {
|
|
|
|
if (ima->type == IMA_TYPE_IMAGE)
|
2015-04-06 10:40:12 -03:00
|
|
|
ibuf = image_get_cached_ibuf_for_index_frame(ima, index, 0);
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (ima->type == IMA_TYPE_MULTILAYER)
|
2015-04-06 10:40:12 -03:00
|
|
|
ibuf = image_get_cached_ibuf_for_index_frame(ima, index, 0);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (ima->source == IMA_SRC_GENERATED) {
|
2015-04-06 10:40:12 -03:00
|
|
|
ibuf = image_get_cached_ibuf_for_index_frame(ima, index, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (ima->source == IMA_SRC_VIEWER) {
|
2010-09-25 16:35:02 +00:00
|
|
|
/* always verify entirely, not that this shouldn't happen
|
|
|
|
* as part of texture sampling in rendering anyway, so not
|
|
|
|
* a big bottleneck */
|
2008-04-28 20:57:03 +00:00
|
|
|
}
|
|
|
|
|
2014-03-16 03:24:05 +11:00
|
|
|
if (r_frame)
|
|
|
|
*r_frame = frame;
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2014-03-16 03:24:05 +11:00
|
|
|
if (r_index)
|
|
|
|
*r_index = index;
|
2008-04-28 20:57:03 +00:00
|
|
|
|
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
|
2014-01-22 02:48:11 +11:00
|
|
|
BLI_INLINE bool image_quick_test(Image *ima, ImageUser *iuser)
|
2013-01-21 11:38:15 +00:00
|
|
|
{
|
|
|
|
if (ima == NULL)
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2013-01-21 11:38:15 +00:00
|
|
|
|
|
|
|
if (iuser) {
|
|
|
|
if (iuser->ok == 0)
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2013-01-21 11:38:15 +00:00
|
|
|
}
|
|
|
|
else if (ima->ok == 0)
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2013-01-21 11:38:15 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
return true;
|
2013-01-21 11:38:15 +00:00
|
|
|
}
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
/* Checks optional ImageUser and verifies/creates ImBuf.
|
|
|
|
*
|
|
|
|
* not thread-safe, so callee should worry about thread locks
|
|
|
|
*/
|
2015-05-08 07:25:39 +10:00
|
|
|
static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
|
2008-04-28 20:57:03 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
ImBuf *ibuf = NULL;
|
|
|
|
int frame = 0, index = 0;
|
2008-04-28 20:57:03 +00:00
|
|
|
|
2015-05-08 07:25:39 +10:00
|
|
|
if (r_lock)
|
|
|
|
*r_lock = NULL;
|
2008-04-28 20:57:03 +00:00
|
|
|
|
|
|
|
/* quick reject tests */
|
2013-01-21 11:38:15 +00:00
|
|
|
if (!image_quick_test(ima, iuser))
|
2008-04-28 20:57:03 +00:00
|
|
|
return NULL;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
ibuf = image_get_cached_ibuf(ima, iuser, &frame, &index);
|
2008-04-28 20:57:03 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ibuf == NULL) {
|
2012-11-15 15:59:58 +00:00
|
|
|
/* we are sure we have to load the ibuf, using source and type */
|
|
|
|
if (ima->source == IMA_SRC_MOVIE) {
|
|
|
|
/* source is from single file, use flipbook to store ibuf */
|
|
|
|
ibuf = image_load_movie_file(ima, iuser, frame);
|
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_SEQUENCE) {
|
|
|
|
if (ima->type == IMA_TYPE_IMAGE) {
|
|
|
|
/* regular files, ibufs in flipbook, allows saving */
|
|
|
|
ibuf = image_load_sequence_file(ima, iuser, frame);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2012-11-15 15:59:58 +00:00
|
|
|
/* no else; on load the ima type can change */
|
|
|
|
if (ima->type == IMA_TYPE_MULTILAYER) {
|
|
|
|
/* only 1 layer/pass stored in imbufs, no exrhandle anim storage, no saving */
|
|
|
|
ibuf = image_load_sequence_multilayer(ima, iuser, frame);
|
2008-04-28 20:57:03 +00:00
|
|
|
}
|
2012-11-15 15:59:58 +00:00
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_FILE) {
|
|
|
|
|
|
|
|
if (ima->type == IMA_TYPE_IMAGE)
|
|
|
|
ibuf = image_load_image_file(ima, iuser, frame); /* cfra only for '#', this global is OK */
|
|
|
|
/* no else; on load the ima type can change */
|
|
|
|
if (ima->type == IMA_TYPE_MULTILAYER)
|
|
|
|
/* keeps render result, stores ibufs in listbase, allows saving */
|
|
|
|
ibuf = image_get_ibuf_multilayer(ima, iuser);
|
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_GENERATED) {
|
|
|
|
/* generated is: ibuf is allocated dynamically */
|
|
|
|
/* UV testgrid or black or solid etc */
|
|
|
|
if (ima->gen_x == 0) ima->gen_x = 1024;
|
|
|
|
if (ima->gen_y == 0) ima->gen_y = 1024;
|
2013-08-12 07:47:44 +00:00
|
|
|
if (ima->gen_depth == 0) ima->gen_depth = 24;
|
|
|
|
ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, ima->gen_depth, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type,
|
2014-10-02 19:04:38 +06:00
|
|
|
ima->gen_color, &ima->colorspace_settings);
|
2015-04-06 10:40:12 -03:00
|
|
|
image_assign_ibuf(ima, ibuf, index, 0);
|
2012-11-15 15:59:58 +00:00
|
|
|
ima->ok = IMA_OK_LOADED;
|
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_VIEWER) {
|
|
|
|
if (ima->type == IMA_TYPE_R_RESULT) {
|
|
|
|
/* always verify entirely, and potentially
|
|
|
|
* returns pointer to release later */
|
2015-05-08 07:25:39 +10:00
|
|
|
ibuf = image_get_render_result(ima, iuser, r_lock);
|
2008-04-28 20:57:03 +00:00
|
|
|
}
|
2012-11-15 15:59:58 +00:00
|
|
|
else if (ima->type == IMA_TYPE_COMPOSITE) {
|
|
|
|
/* requires lock/unlock, otherwise don't return image */
|
2015-05-08 07:25:39 +10:00
|
|
|
if (r_lock) {
|
2012-11-15 15:59:58 +00:00
|
|
|
/* unlock in BKE_image_release_ibuf */
|
|
|
|
BLI_lock_thread(LOCK_VIEWER);
|
2015-05-08 07:25:39 +10:00
|
|
|
*r_lock = ima;
|
2012-11-15 15:59:58 +00:00
|
|
|
|
|
|
|
/* XXX anim play for viewer nodes not yet supported */
|
2013-03-31 03:28:46 +00:00
|
|
|
frame = 0; // XXX iuser ? iuser->framenr : 0;
|
2015-04-06 10:40:12 -03:00
|
|
|
ibuf = image_get_cached_ibuf_for_index_frame(ima, index, frame);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
|
|
|
if (!ibuf) {
|
|
|
|
/* Composite Viewer, all handled in compositor */
|
|
|
|
/* fake ibuf, will be filled in compositor */
|
2015-04-06 10:40:12 -03:00
|
|
|
ibuf = IMB_allocImBuf(256, 256, 32, IB_rect | IB_rectfloat);
|
|
|
|
image_assign_ibuf(ima, ibuf, index, frame);
|
2010-03-16 16:58:45 +00:00
|
|
|
}
|
2008-04-28 20:57:03 +00:00
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
}
|
2014-03-25 12:30:41 +06:00
|
|
|
|
|
|
|
/* We only want movies and sequences to be memory limited. */
|
|
|
|
if (ibuf != NULL && !ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
|
|
|
|
ibuf->userflags |= IB_PERSISTENT;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_image_tag_time(ima);
|
2006-12-20 17:57:56 +00:00
|
|
|
|
|
|
|
return ibuf;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
/* return image buffer for given image and user
|
|
|
|
*
|
|
|
|
* - will lock render result if image type is render result and lock is not NULL
|
|
|
|
* - will return NULL if image type if render or composite result and lock is NULL
|
|
|
|
*
|
|
|
|
* references the result, BKE_image_release_ibuf should be used to de-reference
|
|
|
|
*/
|
2015-05-08 07:25:39 +10:00
|
|
|
ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
|
2009-09-30 18:18:32 +00:00
|
|
|
{
|
2012-11-15 15:59:58 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
|
|
|
BLI_spin_lock(&image_spin);
|
|
|
|
|
2015-05-08 07:25:39 +10:00
|
|
|
ibuf = image_acquire_ibuf(ima, iuser, r_lock);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
|
|
|
BLI_spin_unlock(&image_spin);
|
|
|
|
|
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
|
|
|
|
{
|
|
|
|
if (lock) {
|
|
|
|
/* for getting image during threaded render / compositing, need to release */
|
|
|
|
if (lock == ima) {
|
|
|
|
BLI_unlock_thread(LOCK_VIEWER); /* viewer image */
|
|
|
|
}
|
|
|
|
else if (lock) {
|
|
|
|
RE_ReleaseResultImage(lock); /* render result */
|
|
|
|
BLI_unlock_thread(LOCK_VIEWER); /* view image imbuf */
|
|
|
|
}
|
2010-04-01 12:51:24 +00:00
|
|
|
}
|
2012-11-15 15:59:58 +00:00
|
|
|
|
|
|
|
if (ibuf) {
|
|
|
|
BLI_spin_lock(&image_spin);
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
BLI_spin_unlock(&image_spin);
|
2010-04-01 12:51:24 +00:00
|
|
|
}
|
2009-09-30 18:18:32 +00:00
|
|
|
}
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
/* checks whether there's an image buffer for given image and user */
|
2014-02-03 18:55:59 +11:00
|
|
|
bool BKE_image_has_ibuf(Image *ima, ImageUser *iuser)
|
2009-09-30 18:18:32 +00:00
|
|
|
{
|
2012-11-19 17:31:31 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
|
|
|
/* quick reject tests */
|
2013-01-21 11:38:15 +00:00
|
|
|
if (!image_quick_test(ima, iuser))
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2012-11-19 17:31:31 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
BLI_spin_lock(&image_spin);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
ibuf = image_get_cached_ibuf(ima, iuser, NULL, NULL);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
if (!ibuf)
|
|
|
|
ibuf = image_acquire_ibuf(ima, iuser, NULL);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
BLI_spin_unlock(&image_spin);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
IMB_freeImBuf(ibuf);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
|
|
|
return ibuf != NULL;
|
2009-09-30 18:18:32 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-01-21 08:49:42 +00:00
|
|
|
/* ******** Pool for image buffers ******** */
|
|
|
|
|
|
|
|
typedef struct ImagePoolEntry {
|
|
|
|
struct ImagePoolEntry *next, *prev;
|
|
|
|
Image *image;
|
|
|
|
ImBuf *ibuf;
|
|
|
|
int index;
|
|
|
|
int frame;
|
|
|
|
} ImagePoolEntry;
|
|
|
|
|
|
|
|
typedef struct ImagePool {
|
|
|
|
ListBase image_buffers;
|
|
|
|
} ImagePool;
|
|
|
|
|
|
|
|
ImagePool *BKE_image_pool_new(void)
|
|
|
|
{
|
|
|
|
ImagePool *pool = MEM_callocN(sizeof(ImagePool), "Image Pool");
|
|
|
|
|
|
|
|
return pool;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_pool_free(ImagePool *pool)
|
|
|
|
{
|
|
|
|
ImagePoolEntry *entry, *next_entry;
|
|
|
|
|
|
|
|
/* use single lock to dereference all the image buffers */
|
|
|
|
BLI_spin_lock(&image_spin);
|
|
|
|
|
|
|
|
for (entry = pool->image_buffers.first; entry; entry = next_entry) {
|
|
|
|
next_entry = entry->next;
|
|
|
|
|
|
|
|
if (entry->ibuf)
|
|
|
|
IMB_freeImBuf(entry->ibuf);
|
|
|
|
|
|
|
|
MEM_freeN(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_spin_unlock(&image_spin);
|
|
|
|
|
|
|
|
MEM_freeN(pool);
|
|
|
|
}
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
BLI_INLINE ImBuf *image_pool_find_entry(ImagePool *pool, Image *image, int frame, int index, bool *found)
|
2013-01-21 08:49:42 +00:00
|
|
|
{
|
|
|
|
ImagePoolEntry *entry;
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
*found = false;
|
2013-01-21 08:49:42 +00:00
|
|
|
|
|
|
|
for (entry = pool->image_buffers.first; entry; entry = entry->next) {
|
|
|
|
if (entry->image == image && entry->frame == frame && entry->index == index) {
|
2014-04-01 11:34:00 +11:00
|
|
|
*found = true;
|
2013-01-21 08:49:42 +00:00
|
|
|
return entry->ibuf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImBuf *BKE_image_pool_acquire_ibuf(Image *ima, ImageUser *iuser, ImagePool *pool)
|
|
|
|
{
|
|
|
|
ImBuf *ibuf;
|
2014-04-01 11:34:00 +11:00
|
|
|
int index, frame;
|
|
|
|
bool found;
|
2013-01-21 08:49:42 +00:00
|
|
|
|
2013-01-21 11:38:15 +00:00
|
|
|
if (!image_quick_test(ima, iuser))
|
|
|
|
return NULL;
|
|
|
|
|
2013-01-21 08:49:42 +00:00
|
|
|
if (pool == NULL) {
|
|
|
|
/* pool could be NULL, in this case use general acquire function */
|
|
|
|
return BKE_image_acquire_ibuf(ima, iuser, NULL);
|
|
|
|
}
|
|
|
|
|
2013-11-26 00:40:53 +01:00
|
|
|
image_get_frame_and_index(ima, iuser, &frame, &index);
|
2013-01-21 08:49:42 +00:00
|
|
|
|
|
|
|
ibuf = image_pool_find_entry(pool, ima, frame, index, &found);
|
|
|
|
if (found)
|
|
|
|
return ibuf;
|
|
|
|
|
|
|
|
BLI_spin_lock(&image_spin);
|
|
|
|
|
|
|
|
ibuf = image_pool_find_entry(pool, ima, frame, index, &found);
|
|
|
|
|
|
|
|
/* will also create entry even in cases image buffer failed to load,
|
|
|
|
* prevents trying to load the same buggy file multiple times
|
|
|
|
*/
|
|
|
|
if (!found) {
|
|
|
|
ImagePoolEntry *entry;
|
|
|
|
|
|
|
|
ibuf = image_acquire_ibuf(ima, iuser, NULL);
|
|
|
|
|
|
|
|
entry = MEM_callocN(sizeof(ImagePoolEntry), "Image Pool Entry");
|
|
|
|
entry->image = ima;
|
|
|
|
entry->frame = frame;
|
|
|
|
entry->index = index;
|
|
|
|
entry->ibuf = ibuf;
|
|
|
|
|
|
|
|
BLI_addtail(&pool->image_buffers, entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_spin_unlock(&image_spin);
|
|
|
|
|
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_pool_release_ibuf(Image *ima, ImBuf *ibuf, ImagePool *pool)
|
|
|
|
{
|
|
|
|
/* if pool wasn't actually used, use general release stuff,
|
|
|
|
* for pools image buffers will be dereferenced on pool free
|
|
|
|
*/
|
|
|
|
if (pool == NULL) {
|
|
|
|
BKE_image_release_ibuf(ima, ibuf, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr, bool *r_is_in_range)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
const int len = (iuser->fie_ima * iuser->frames) / 2;
|
2011-05-01 14:02:40 +00:00
|
|
|
|
2012-07-03 14:04:39 +00:00
|
|
|
if (r_is_in_range) {
|
2014-04-01 11:34:00 +11:00
|
|
|
*r_is_in_range = false;
|
2012-07-03 14:04:39 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (len == 0) {
|
2011-05-01 14:02:40 +00:00
|
|
|
return 0;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-05-01 14:02:40 +00:00
|
|
|
int framenr;
|
2012-05-06 15:15:33 +00:00
|
|
|
cfra = cfra - iuser->sfra + 1;
|
2010-10-05 21:22:33 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* cyclic */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (iuser->cycl) {
|
2012-05-06 15:15:33 +00:00
|
|
|
cfra = ((cfra) % len);
|
|
|
|
if (cfra < 0) cfra += len;
|
|
|
|
if (cfra == 0) cfra = len;
|
2012-07-03 14:04:39 +00:00
|
|
|
|
|
|
|
if (r_is_in_range) {
|
2014-04-01 11:34:00 +11:00
|
|
|
*r_is_in_range = true;
|
2012-07-03 14:04:39 +00:00
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2011-05-01 14:02:40 +00:00
|
|
|
|
2012-07-03 14:04:39 +00:00
|
|
|
if (cfra < 0) {
|
|
|
|
cfra = 0;
|
|
|
|
}
|
|
|
|
else if (cfra > len) {
|
|
|
|
cfra = len;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (r_is_in_range) {
|
2014-04-01 11:34:00 +11:00
|
|
|
*r_is_in_range = true;
|
2012-07-03 14:04:39 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-01 14:02:40 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* convert current frame to current field */
|
2012-05-06 15:15:33 +00:00
|
|
|
cfra = 2 * (cfra);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (fieldnr) cfra++;
|
2011-05-01 14:02:40 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* transform to images space */
|
2012-05-06 15:15:33 +00:00
|
|
|
framenr = (cfra + iuser->fie_ima - 2) / iuser->fie_ima;
|
|
|
|
if (framenr > iuser->frames) framenr = iuser->frames;
|
2011-05-01 14:02:40 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (iuser->cycl) {
|
2012-05-06 15:15:33 +00:00
|
|
|
framenr = ((framenr) % len);
|
|
|
|
while (framenr < 0) framenr += len;
|
|
|
|
if (framenr == 0) framenr = len;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2011-05-01 14:02:40 +00:00
|
|
|
|
2012-07-03 14:25:06 +00:00
|
|
|
/* important to apply after else we cant loop on frames 100 - 110 for eg. */
|
|
|
|
framenr += iuser->offset;
|
|
|
|
|
2011-05-01 14:02:40 +00:00
|
|
|
return framenr;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-01 14:02:40 +00:00
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_image_user_frame_calc(ImageUser *iuser, int cfra, int fieldnr)
|
2011-05-01 14:02:40 +00:00
|
|
|
{
|
2012-06-10 15:07:08 +00:00
|
|
|
if (iuser) {
|
2014-02-03 18:55:59 +11:00
|
|
|
bool is_in_range;
|
2012-07-03 14:04:39 +00:00
|
|
|
const int framenr = BKE_image_user_frame_get(iuser, cfra, fieldnr, &is_in_range);
|
|
|
|
|
|
|
|
if (is_in_range) {
|
|
|
|
iuser->flag |= IMA_USER_FRAME_IN_RANGE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
iuser->flag &= ~IMA_USER_FRAME_IN_RANGE;
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-06-10 15:07:08 +00:00
|
|
|
/* allows image users to handle redraws */
|
|
|
|
if (iuser->flag & IMA_ANIM_ALWAYS)
|
|
|
|
if (framenr != iuser->framenr)
|
|
|
|
iuser->flag |= IMA_ANIM_REFRESHED;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-06-10 15:07:08 +00:00
|
|
|
iuser->framenr = framenr;
|
|
|
|
if (iuser->ok == 0) iuser->ok = 1;
|
|
|
|
}
|
2011-05-01 14:02:40 +00:00
|
|
|
}
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
|
2012-06-04 10:41:18 +00:00
|
|
|
void BKE_image_user_check_frame_calc(ImageUser *iuser, int cfra, int fieldnr)
|
|
|
|
{
|
|
|
|
if ((iuser->flag & IMA_ANIM_ALWAYS) || (iuser->flag & IMA_NEED_FRAME_RECALC)) {
|
|
|
|
BKE_image_user_frame_calc(iuser, cfra, fieldnr);
|
|
|
|
|
|
|
|
iuser->flag &= ~IMA_NEED_FRAME_RECALC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-22 22:17:07 +00:00
|
|
|
/* goes over all ImageUsers, and sets frame numbers if auto-refresh is set */
|
|
|
|
static void image_update_frame(struct Image *UNUSED(ima), struct ImageUser *iuser, void *customdata)
|
|
|
|
{
|
|
|
|
int cfra = *(int *)customdata;
|
|
|
|
|
|
|
|
BKE_image_user_check_frame_calc(iuser, cfra, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_update_frame(const Main *bmain, int cfra)
|
|
|
|
{
|
|
|
|
BKE_image_walk_all_users(bmain, &cfra, image_update_frame);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:35:45 +00:00
|
|
|
void BKE_image_user_file_path(ImageUser *iuser, Image *ima, char *filepath)
|
2012-06-04 19:38:33 +00:00
|
|
|
{
|
2015-10-11 01:14:02 +02:00
|
|
|
if (BKE_image_is_multiview(ima) && (ima->rr == NULL)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
ImageView *iv = BLI_findlink(&ima->views, iuser->view);
|
2015-10-11 01:14:02 +02:00
|
|
|
if (iv->filepath[0])
|
|
|
|
BLI_strncpy(filepath, iv->filepath, FILE_MAX);
|
|
|
|
else
|
|
|
|
BLI_strncpy(filepath, ima->name, FILE_MAX);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_strncpy(filepath, ima->name, FILE_MAX);
|
|
|
|
}
|
2012-06-04 19:38:33 +00:00
|
|
|
|
|
|
|
if (ima->source == IMA_SRC_SEQUENCE) {
|
|
|
|
char head[FILE_MAX], tail[FILE_MAX];
|
|
|
|
unsigned short numlen;
|
2012-06-28 15:34:21 +00:00
|
|
|
int frame = iuser ? iuser->framenr : ima->lastframe;
|
2012-06-04 19:38:33 +00:00
|
|
|
|
|
|
|
BLI_stringdec(filepath, head, tail, &numlen);
|
|
|
|
BLI_stringenc(filepath, head, tail, numlen, frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_path_abs(filepath, ID_BLEND_PATH(G.main, &ima->id));
|
|
|
|
}
|
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
bool BKE_image_has_alpha(struct Image *image)
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
{
|
|
|
|
ImBuf *ibuf;
|
|
|
|
void *lock;
|
2011-11-21 20:47:19 +00:00
|
|
|
int planes;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
|
|
|
|
planes = (ibuf ? ibuf->planes : 0);
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(image, ibuf, lock);
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
|
2011-11-21 20:47:19 +00:00
|
|
|
if (planes == 32)
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
else
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
}
|
2012-09-13 05:29:38 +00:00
|
|
|
|
|
|
|
void BKE_image_get_size(Image *image, ImageUser *iuser, int *width, int *height)
|
|
|
|
{
|
|
|
|
ImBuf *ibuf = NULL;
|
|
|
|
void *lock;
|
|
|
|
|
|
|
|
ibuf = BKE_image_acquire_ibuf(image, iuser, &lock);
|
|
|
|
|
|
|
|
if (ibuf && ibuf->x > 0 && ibuf->y > 0) {
|
|
|
|
*width = ibuf->x;
|
|
|
|
*height = ibuf->y;
|
|
|
|
}
|
2016-01-25 12:04:50 +01:00
|
|
|
else if (image->type == IMA_TYPE_R_RESULT && iuser != NULL && iuser->scene != NULL) {
|
|
|
|
Scene *scene = iuser->scene;
|
|
|
|
*width = (scene->r.xsch * scene->r.size) / 100;
|
|
|
|
*height = (scene->r.ysch * scene->r.size) / 100;
|
|
|
|
if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) {
|
|
|
|
*width *= BLI_rctf_size_x(&scene->r.border);
|
|
|
|
*height *= BLI_rctf_size_y(&scene->r.border);
|
|
|
|
}
|
|
|
|
}
|
2012-09-13 05:29:38 +00:00
|
|
|
else {
|
|
|
|
*width = IMG_SIZE_FALLBACK;
|
|
|
|
*height = IMG_SIZE_FALLBACK;
|
|
|
|
}
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(image, ibuf, lock);
|
2012-09-13 05:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_get_size_fl(Image *image, ImageUser *iuser, float size[2])
|
|
|
|
{
|
|
|
|
int width, height;
|
|
|
|
BKE_image_get_size(image, iuser, &width, &height);
|
|
|
|
|
|
|
|
size[0] = (float)width;
|
|
|
|
size[1] = (float)height;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_get_aspect(Image *image, float *aspx, float *aspy)
|
|
|
|
{
|
|
|
|
*aspx = 1.0;
|
|
|
|
|
|
|
|
/* x is always 1 */
|
2012-09-18 19:20:21 +00:00
|
|
|
if (image)
|
|
|
|
*aspy = image->aspy / image->aspx;
|
|
|
|
else
|
|
|
|
*aspy = 1.0f;
|
2012-09-13 05:29:38 +00:00
|
|
|
}
|
Movies support for Cycles
This adds support of movie textures for Cycles rendering.
Uses the same builtin images routines as packed/generated images,
but with some extra non-rna hookups from blender_session side.
Basically, it's not so clear how to give access to video frames
via C++ RNA -- it'll require exposing ImBuf to API, doing some
threading locks and so. Ended up adding two more functions which
are actually bad level call, but don't consider it's so much bad
-- we have few bad calls already, which are actually related.
Changed a bit how builtin images names are passing to image
manager. Now it's not just an ID datablock name, but also a frame
number concatenated via '@' character, which makes itpossible to
easily know frame number to be used for movie images, without
adding extra descriptors to image manager.
Decoding of builtin name is a bit slower now, but it should be
still nothing in comparison with rendering complexity.
Also exposed image user's frame_current to python API, which
is needed to get absolute frame number of movie from node's
image user.
P.S. Generated/packed images are also using bad level call but
only does it to make things more clear here. Either all images
are using C++ RNA here or no images does. That's the most clear
for now.
2013-01-16 17:07:25 +00:00
|
|
|
|
|
|
|
unsigned char *BKE_image_get_pixels_for_frame(struct Image *image, int frame)
|
|
|
|
{
|
2013-03-22 05:34:10 +00:00
|
|
|
ImageUser iuser = {NULL};
|
Movies support for Cycles
This adds support of movie textures for Cycles rendering.
Uses the same builtin images routines as packed/generated images,
but with some extra non-rna hookups from blender_session side.
Basically, it's not so clear how to give access to video frames
via C++ RNA -- it'll require exposing ImBuf to API, doing some
threading locks and so. Ended up adding two more functions which
are actually bad level call, but don't consider it's so much bad
-- we have few bad calls already, which are actually related.
Changed a bit how builtin images names are passing to image
manager. Now it's not just an ID datablock name, but also a frame
number concatenated via '@' character, which makes itpossible to
easily know frame number to be used for movie images, without
adding extra descriptors to image manager.
Decoding of builtin name is a bit slower now, but it should be
still nothing in comparison with rendering complexity.
Also exposed image user's frame_current to python API, which
is needed to get absolute frame number of movie from node's
image user.
P.S. Generated/packed images are also using bad level call but
only does it to make things more clear here. Either all images
are using C++ RNA here or no images does. That's the most clear
for now.
2013-01-16 17:07:25 +00:00
|
|
|
void *lock;
|
|
|
|
ImBuf *ibuf;
|
|
|
|
unsigned char *pixels = NULL;
|
|
|
|
|
|
|
|
iuser.framenr = frame;
|
2014-04-01 11:34:00 +11:00
|
|
|
iuser.ok = true;
|
Movies support for Cycles
This adds support of movie textures for Cycles rendering.
Uses the same builtin images routines as packed/generated images,
but with some extra non-rna hookups from blender_session side.
Basically, it's not so clear how to give access to video frames
via C++ RNA -- it'll require exposing ImBuf to API, doing some
threading locks and so. Ended up adding two more functions which
are actually bad level call, but don't consider it's so much bad
-- we have few bad calls already, which are actually related.
Changed a bit how builtin images names are passing to image
manager. Now it's not just an ID datablock name, but also a frame
number concatenated via '@' character, which makes itpossible to
easily know frame number to be used for movie images, without
adding extra descriptors to image manager.
Decoding of builtin name is a bit slower now, but it should be
still nothing in comparison with rendering complexity.
Also exposed image user's frame_current to python API, which
is needed to get absolute frame number of movie from node's
image user.
P.S. Generated/packed images are also using bad level call but
only does it to make things more clear here. Either all images
are using C++ RNA here or no images does. That's the most clear
for now.
2013-01-16 17:07:25 +00:00
|
|
|
|
|
|
|
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
|
|
|
|
|
|
|
|
if (ibuf) {
|
|
|
|
pixels = (unsigned char *) ibuf->rect;
|
|
|
|
|
|
|
|
if (pixels)
|
|
|
|
pixels = MEM_dupallocN(pixels);
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(image, ibuf, lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pixels)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return pixels;
|
|
|
|
}
|
|
|
|
|
|
|
|
float *BKE_image_get_float_pixels_for_frame(struct Image *image, int frame)
|
|
|
|
{
|
2013-03-22 05:34:10 +00:00
|
|
|
ImageUser iuser = {NULL};
|
Movies support for Cycles
This adds support of movie textures for Cycles rendering.
Uses the same builtin images routines as packed/generated images,
but with some extra non-rna hookups from blender_session side.
Basically, it's not so clear how to give access to video frames
via C++ RNA -- it'll require exposing ImBuf to API, doing some
threading locks and so. Ended up adding two more functions which
are actually bad level call, but don't consider it's so much bad
-- we have few bad calls already, which are actually related.
Changed a bit how builtin images names are passing to image
manager. Now it's not just an ID datablock name, but also a frame
number concatenated via '@' character, which makes itpossible to
easily know frame number to be used for movie images, without
adding extra descriptors to image manager.
Decoding of builtin name is a bit slower now, but it should be
still nothing in comparison with rendering complexity.
Also exposed image user's frame_current to python API, which
is needed to get absolute frame number of movie from node's
image user.
P.S. Generated/packed images are also using bad level call but
only does it to make things more clear here. Either all images
are using C++ RNA here or no images does. That's the most clear
for now.
2013-01-16 17:07:25 +00:00
|
|
|
void *lock;
|
|
|
|
ImBuf *ibuf;
|
|
|
|
float *pixels = NULL;
|
|
|
|
|
|
|
|
iuser.framenr = frame;
|
2014-04-01 11:34:00 +11:00
|
|
|
iuser.ok = true;
|
Movies support for Cycles
This adds support of movie textures for Cycles rendering.
Uses the same builtin images routines as packed/generated images,
but with some extra non-rna hookups from blender_session side.
Basically, it's not so clear how to give access to video frames
via C++ RNA -- it'll require exposing ImBuf to API, doing some
threading locks and so. Ended up adding two more functions which
are actually bad level call, but don't consider it's so much bad
-- we have few bad calls already, which are actually related.
Changed a bit how builtin images names are passing to image
manager. Now it's not just an ID datablock name, but also a frame
number concatenated via '@' character, which makes itpossible to
easily know frame number to be used for movie images, without
adding extra descriptors to image manager.
Decoding of builtin name is a bit slower now, but it should be
still nothing in comparison with rendering complexity.
Also exposed image user's frame_current to python API, which
is needed to get absolute frame number of movie from node's
image user.
P.S. Generated/packed images are also using bad level call but
only does it to make things more clear here. Either all images
are using C++ RNA here or no images does. That's the most clear
for now.
2013-01-16 17:07:25 +00:00
|
|
|
|
|
|
|
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
|
|
|
|
|
|
|
|
if (ibuf) {
|
|
|
|
pixels = ibuf->rect_float;
|
|
|
|
|
|
|
|
if (pixels)
|
|
|
|
pixels = MEM_dupallocN(pixels);
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(image, ibuf, lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pixels)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return pixels;
|
|
|
|
}
|
2013-03-27 11:26:10 +00:00
|
|
|
|
|
|
|
int BKE_image_sequence_guess_offset(Image *image)
|
|
|
|
{
|
2015-10-16 15:17:54 +11:00
|
|
|
return BLI_stringdec(image->name, NULL, NULL, NULL);
|
2013-03-27 11:26:10 +00:00
|
|
|
}
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
bool BKE_image_has_anim(Image *ima)
|
|
|
|
{
|
|
|
|
return (BLI_listbase_is_empty(&ima->anims) == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BKE_image_has_packedfile(Image *ima)
|
|
|
|
{
|
|
|
|
return (BLI_listbase_is_empty(&ima->packedfiles) == false);
|
|
|
|
}
|
|
|
|
|
2014-01-14 04:59:58 +11:00
|
|
|
/**
|
|
|
|
* Checks the image buffer changes (not keyframed values)
|
|
|
|
*
|
|
|
|
* to see if we need to call #BKE_image_user_check_frame_calc
|
|
|
|
*/
|
|
|
|
bool BKE_image_is_animated(Image *image)
|
|
|
|
{
|
|
|
|
return ELEM(image->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE);
|
|
|
|
}
|
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
bool BKE_image_is_dirty(Image *image)
|
|
|
|
{
|
|
|
|
bool is_dirty = false;
|
|
|
|
|
|
|
|
BLI_spin_lock(&image_spin);
|
|
|
|
if (image->cache != NULL) {
|
|
|
|
struct MovieCacheIter *iter = IMB_moviecacheIter_new(image->cache);
|
|
|
|
|
|
|
|
while (!IMB_moviecacheIter_done(iter)) {
|
|
|
|
ImBuf *ibuf = IMB_moviecacheIter_getImBuf(iter);
|
|
|
|
if (ibuf->userflags & IB_BITMAPDIRTY) {
|
|
|
|
is_dirty = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_step(iter);
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_free(iter);
|
|
|
|
}
|
|
|
|
BLI_spin_unlock(&image_spin);
|
|
|
|
|
|
|
|
return is_dirty;
|
|
|
|
}
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
void BKE_image_file_format_set(Image *image, int ftype, const ImbFormatOptions *options)
|
2013-12-13 16:22:08 +06:00
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);
|
|
|
|
if (ibuf) {
|
|
|
|
ibuf->ftype = ftype;
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions = options;
|
2013-12-13 16:22:08 +06:00
|
|
|
}
|
|
|
|
BKE_image_release_ibuf(image, ibuf, NULL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BLI_spin_lock(&image_spin);
|
|
|
|
if (image->cache != NULL) {
|
|
|
|
struct MovieCacheIter *iter = IMB_moviecacheIter_new(image->cache);
|
|
|
|
|
|
|
|
while (!IMB_moviecacheIter_done(iter)) {
|
|
|
|
ImBuf *ibuf = IMB_moviecacheIter_getImBuf(iter);
|
|
|
|
ibuf->ftype = ftype;
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->foptions = *options;
|
2013-12-13 16:22:08 +06:00
|
|
|
IMB_moviecacheIter_step(iter);
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_free(iter);
|
|
|
|
}
|
|
|
|
BLI_spin_unlock(&image_spin);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BKE_image_has_loaded_ibuf(Image *image)
|
|
|
|
{
|
|
|
|
bool has_loaded_ibuf = false;
|
|
|
|
|
|
|
|
BLI_spin_lock(&image_spin);
|
|
|
|
if (image->cache != NULL) {
|
|
|
|
struct MovieCacheIter *iter = IMB_moviecacheIter_new(image->cache);
|
|
|
|
|
|
|
|
while (!IMB_moviecacheIter_done(iter)) {
|
|
|
|
has_loaded_ibuf = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_free(iter);
|
|
|
|
}
|
|
|
|
BLI_spin_unlock(&image_spin);
|
|
|
|
|
|
|
|
return has_loaded_ibuf;
|
|
|
|
}
|
|
|
|
|
2014-01-03 23:00:53 +06:00
|
|
|
/* References the result, BKE_image_release_ibuf is to be called to de-reference.
|
|
|
|
* Use lock=NULL when calling BKE_image_release_ibuf().
|
|
|
|
*/
|
2013-12-13 16:22:08 +06:00
|
|
|
ImBuf *BKE_image_get_ibuf_with_name(Image *image, const char *name)
|
|
|
|
{
|
|
|
|
ImBuf *ibuf = NULL;
|
|
|
|
|
|
|
|
BLI_spin_lock(&image_spin);
|
|
|
|
if (image->cache != NULL) {
|
|
|
|
struct MovieCacheIter *iter = IMB_moviecacheIter_new(image->cache);
|
|
|
|
|
|
|
|
while (!IMB_moviecacheIter_done(iter)) {
|
|
|
|
ImBuf *current_ibuf = IMB_moviecacheIter_getImBuf(iter);
|
|
|
|
if (STREQ(current_ibuf->name, name)) {
|
|
|
|
ibuf = current_ibuf;
|
|
|
|
IMB_refImBuf(ibuf);
|
|
|
|
break;
|
|
|
|
}
|
2014-03-13 19:55:19 +02:00
|
|
|
IMB_moviecacheIter_step(iter);
|
2013-12-13 16:22:08 +06:00
|
|
|
}
|
|
|
|
IMB_moviecacheIter_free(iter);
|
|
|
|
}
|
|
|
|
BLI_spin_unlock(&image_spin);
|
|
|
|
|
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
|
2014-01-03 23:00:53 +06:00
|
|
|
/* References the result, BKE_image_release_ibuf is to be called to de-reference.
|
|
|
|
* Use lock=NULL when calling BKE_image_release_ibuf().
|
2013-12-13 16:22:08 +06:00
|
|
|
*
|
|
|
|
* TODO(sergey): This is actually "get first entry from the cache", which is
|
|
|
|
* not so much predictable. But using first loaded image buffer
|
|
|
|
* was also malicious logic and all the areas which uses this
|
|
|
|
* function are to be re-considered.
|
|
|
|
*/
|
|
|
|
ImBuf *BKE_image_get_first_ibuf(Image *image)
|
|
|
|
{
|
|
|
|
ImBuf *ibuf = NULL;
|
|
|
|
|
|
|
|
BLI_spin_lock(&image_spin);
|
|
|
|
if (image->cache != NULL) {
|
|
|
|
struct MovieCacheIter *iter = IMB_moviecacheIter_new(image->cache);
|
|
|
|
|
|
|
|
while (!IMB_moviecacheIter_done(iter)) {
|
|
|
|
ibuf = IMB_moviecacheIter_getImBuf(iter);
|
|
|
|
IMB_refImBuf(ibuf);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_free(iter);
|
|
|
|
}
|
|
|
|
BLI_spin_unlock(&image_spin);
|
|
|
|
|
|
|
|
return ibuf;
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
static void image_update_views_format(Image *ima, ImageUser *iuser)
|
|
|
|
{
|
|
|
|
SceneRenderView *srv;
|
|
|
|
ImageView *iv;
|
|
|
|
Scene *scene = iuser->scene;
|
|
|
|
const bool is_multiview = ((scene->r.scemode & R_MULTIVIEW) != 0) &&
|
|
|
|
((ima->flag & IMA_USE_VIEWS) != 0);
|
|
|
|
|
|
|
|
/* reset the image views */
|
|
|
|
BKE_image_free_views(ima);
|
|
|
|
|
|
|
|
if (!is_multiview) {
|
2015-10-11 01:14:02 +02:00
|
|
|
/* nothing to do */
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
else if (ima->views_format == R_IMF_VIEWS_STEREO_3D) {
|
2015-10-24 01:01:10 +11:00
|
|
|
int i;
|
2015-04-06 10:40:12 -03:00
|
|
|
const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
image_add_view(ima, names[i], ima->name);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* R_IMF_VIEWS_INDIVIDUAL */
|
|
|
|
char prefix[FILE_MAX] = {'\0'};
|
|
|
|
char *name = ima->name;
|
2015-06-27 11:00:47 +02:00
|
|
|
const char *ext = NULL;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
BKE_scene_multiview_view_prefix_get(scene, name, prefix, &ext);
|
|
|
|
|
|
|
|
if (prefix[0] == '\0') {
|
2015-10-11 01:14:02 +02:00
|
|
|
BKE_image_free_views(ima);
|
|
|
|
return;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* create all the image views */
|
|
|
|
for (srv = scene->r.views.first; srv; srv = srv->next) {
|
|
|
|
if (BKE_scene_multiview_is_render_view_active(&scene->r, srv)) {
|
|
|
|
char filepath[FILE_MAX];
|
|
|
|
BLI_snprintf(filepath, sizeof(filepath), "%s%s%s", prefix, srv->suffix, ext);
|
|
|
|
image_add_view(ima, srv->name, filepath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if the files are all available */
|
|
|
|
iv = ima->views.last;
|
|
|
|
while (iv) {
|
|
|
|
int file;
|
|
|
|
char str[FILE_MAX];
|
|
|
|
|
|
|
|
BLI_strncpy(str, iv->filepath, sizeof(str));
|
|
|
|
BLI_path_abs(str, G.main->name);
|
|
|
|
|
|
|
|
/* exists? */
|
|
|
|
file = BLI_open(str, O_BINARY | O_RDONLY, 0);
|
|
|
|
if (file == -1) {
|
|
|
|
ImageView *iv_del = iv;
|
|
|
|
iv = iv->prev;
|
|
|
|
BLI_remlink(&ima->views, iv_del);
|
|
|
|
MEM_freeN(iv_del);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
iv = iv->prev;
|
2015-04-09 17:21:17 +10:00
|
|
|
close(file);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* all good */
|
2015-10-11 01:14:02 +02:00
|
|
|
if (!BKE_image_is_multiview(ima)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
BKE_image_free_views(ima);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|