2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup spimage
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2023-07-22 11:27:25 +10:00
|
|
|
#include <cmath>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <cstring>
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_brush_types.h"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
#include "DNA_camera_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_mask_types.h"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_space_types.h"
|
2021-09-29 17:47:32 +10:00
|
|
|
#include "DNA_view2d_types.h"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
Add support for tiled images and the UDIM naming scheme
This patch contains the work that I did during my week at the Code Quest - adding support for tiled images to Blender.
With this patch, images now contain a list of tiles. By default, this just contains one tile, but if the source type is set to Tiled, the user can add additional tiles. When acquiring an ImBuf, the tile to be loaded is specified in the ImageUser.
Therefore, code that is not yet aware of tiles will just access the default tile as usual.
The filenames of the additional tiles are derived from the original filename according to the UDIM naming scheme - the filename contains an index that is calculated as (1001 + 10*<y coordinate of the tile> + <x coordinate of the tile>), where the x coordinate never goes above 9.
Internally, the various tiles are stored in a cache just like sequences. When acquired for the first time, the code will try to load the corresponding file from disk. Alternatively, a new operator can be used to initialize the tile similar to the New Image operator.
The following features are supported so far:
- Automatic detection and loading of all tiles when opening the first tile (1001)
- Saving all tiles
- Adding and removing tiles
- Filling tiles with generated images
- Drawing all tiles in the Image Editor
- Viewing a tiled grid even if no image is selected
- Rendering tiled images in Eevee
- Rendering tiled images in Cycles (in SVM mode)
- Automatically skipping loading of unused tiles in Cycles
- 2D texture painting (also across tiles)
- 3D texture painting (also across tiles, only limitation: individual faces can not cross tile borders)
- Assigning custom labels to individual tiles (drawn in the Image Editor instead of the ID)
- Different resolutions between tiles
There still are some missing features that will be added later (see T72390):
- Workbench engine support
- Packing/Unpacking support
- Baking support
- Cycles OSL support
- many other Blender features that rely on images
Thanks to Brecht for the review and to all who tested the intermediate versions!
Differential Revision: https://developer.blender.org/D3509
2019-12-12 16:06:08 +01:00
|
|
|
#include "BLI_listbase.h"
|
2012-08-20 23:06:17 +00:00
|
|
|
#include "BLI_rect.h"
|
2011-02-12 16:54:24 +00:00
|
|
|
#include "BLI_string.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_threads.h"
|
2024-01-19 14:32:28 +01:00
|
|
|
#include "BLI_time.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2024-01-18 22:50:23 +02:00
|
|
|
#include "IMB_colormanagement.hh"
|
|
|
|
|
#include "IMB_imbuf.hh"
|
|
|
|
|
#include "IMB_imbuf_types.hh"
|
|
|
|
|
#include "IMB_moviecache.hh"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2023-11-16 11:41:55 +01:00
|
|
|
#include "BKE_context.hh"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
#include "BKE_image.h"
|
2023-08-02 22:14:18 +02:00
|
|
|
#include "BKE_paint.hh"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "BIF_glutil.hh"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2024-03-23 01:24:18 +01:00
|
|
|
#include "GPU_framebuffer.hh"
|
|
|
|
|
#include "GPU_immediate.hh"
|
|
|
|
|
#include "GPU_immediate_util.hh"
|
|
|
|
|
#include "GPU_matrix.hh"
|
|
|
|
|
#include "GPU_state.hh"
|
2017-03-03 13:12:29 -05:00
|
|
|
|
2024-01-31 14:04:56 -05:00
|
|
|
#include "BLF_api.hh"
|
2010-12-02 04:23:56 +00:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_gpencil_legacy.hh"
|
|
|
|
|
#include "ED_image.hh"
|
|
|
|
|
#include "ED_mask.hh"
|
|
|
|
|
#include "ED_render.hh"
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "ED_screen.hh"
|
|
|
|
|
#include "ED_util.hh"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "UI_interface.hh"
|
|
|
|
|
#include "UI_resources.hh"
|
|
|
|
|
#include "UI_view2d.hh"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2013-01-01 16:15:13 +00:00
|
|
|
#include "RE_engine.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "RE_pipeline.h"
|
2010-03-27 15:35:34 +00:00
|
|
|
|
2023-12-20 13:17:39 +02:00
|
|
|
#include "image_intern.hh"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2015-03-11 00:01:53 +05:00
|
|
|
static void draw_render_info(
|
2020-03-06 16:56:42 +01:00
|
|
|
const bContext *C, Scene *scene, Image *ima, ARegion *region, float zoomx, float zoomy)
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
{
|
2017-09-12 11:27:22 +05:00
|
|
|
Render *re = RE_GetSceneRender(scene);
|
2015-03-11 00:01:53 +05:00
|
|
|
Scene *stats_scene = ED_render_job_get_scene(C);
|
2023-07-12 13:43:00 +02:00
|
|
|
if (stats_scene == nullptr) {
|
2015-03-11 00:01:53 +05:00
|
|
|
stats_scene = CTX_data_scene(C);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-03 17:53:53 -05:00
|
|
|
RenderResult *rr = BKE_image_acquire_renderresult(stats_scene, ima);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (rr && rr->text) {
|
2013-04-14 21:42:58 +00:00
|
|
|
float fill_color[4] = {0.0f, 0.0f, 0.0f, 0.25f};
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_info_draw(region, rr->text, fill_color, true);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-03-11 00:01:53 +05:00
|
|
|
BKE_image_release_renderresult(stats_scene, ima);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-01 16:15:13 +00:00
|
|
|
if (re) {
|
|
|
|
|
int total_tiles;
|
2023-07-20 11:21:23 +02:00
|
|
|
const rcti *tiles = RE_engine_get_current_tiles(re, &total_tiles);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-01 16:15:13 +00:00
|
|
|
if (total_tiles) {
|
|
|
|
|
/* find window pixel coordinates of origin */
|
2017-03-03 17:53:53 -05:00
|
|
|
int x, y;
|
2020-03-06 16:56:42 +01:00
|
|
|
UI_view2d_view_to_region(®ion->v2d, 0.0f, 0.0f, &x, &y);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push();
|
|
|
|
|
GPU_matrix_translate_2f(x, y);
|
|
|
|
|
GPU_matrix_scale_2f(zoomx, zoomy);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
uint pos = GPU_vertformat_attr_add(
|
|
|
|
|
immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2022-09-01 09:31:07 -03:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
2017-03-03 17:53:53 -05:00
|
|
|
immUniformThemeColor(TH_FACE_SELECT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_width(1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-20 11:16:04 +02:00
|
|
|
const rcti *tile = tiles;
|
2017-03-03 17:53:53 -05:00
|
|
|
for (int i = 0; i < total_tiles; i++, tile++) {
|
|
|
|
|
immDrawBorderCorners(pos, tile, zoomx, zoomy);
|
2013-01-01 16:15:13 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-03 17:53:53 -05:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop();
|
2013-01-01 16:15:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-31 23:39:08 +11:00
|
|
|
void ED_image_draw_info(Scene *scene,
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region,
|
2014-03-31 23:39:08 +11:00
|
|
|
bool color_manage,
|
|
|
|
|
bool use_default_view,
|
|
|
|
|
int channels,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
2020-02-08 01:02:18 +11:00
|
|
|
const uchar cp[4],
|
2013-03-18 11:34:05 +00:00
|
|
|
const float fp[4],
|
2023-07-04 17:03:02 +02:00
|
|
|
const float linearcol[4])
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
{
|
2013-12-24 17:20:37 +11:00
|
|
|
rcti color_rect;
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
char str[256];
|
2013-12-24 15:06:38 +11:00
|
|
|
int dx = 6;
|
2019-03-05 10:39:42 +01:00
|
|
|
/* local coordinate visible rect inside region, to accommodate overlapping ui */
|
2020-03-06 16:56:42 +01:00
|
|
|
const rcti *rect = ED_region_visible_rect(region);
|
2019-08-16 05:41:43 +10:00
|
|
|
const int ymin = rect->ymin;
|
2019-03-05 10:39:42 +01:00
|
|
|
const int dy = ymin + 0.3f * UI_UNIT_Y;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
/* text colors */
|
|
|
|
|
/* XXX colored text not allowed in Blender UI */
|
2013-12-22 14:11:10 +11:00
|
|
|
#if 0
|
2020-02-08 01:02:18 +11:00
|
|
|
uchar red[3] = {255, 50, 50};
|
|
|
|
|
uchar green[3] = {0, 255, 0};
|
|
|
|
|
uchar blue[3] = {100, 100, 255};
|
2013-12-22 14:11:10 +11:00
|
|
|
#else
|
2020-08-07 22:36:11 +10:00
|
|
|
const uchar red[3] = {255, 255, 255};
|
|
|
|
|
const uchar green[3] = {255, 255, 255};
|
|
|
|
|
const uchar blue[3] = {255, 255, 255};
|
2013-12-22 14:11:10 +11:00
|
|
|
#endif
|
2012-03-28 11:53:18 +00:00
|
|
|
float hue = 0, sat = 0, val = 0, lum = 0, u = 0, v = 0;
|
2011-04-23 08:30:28 +00:00
|
|
|
float col[4], finalcol[4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
uint pos = GPU_vertformat_attr_add(
|
|
|
|
|
immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
|
2022-09-01 09:31:07 -03:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-04 04:14:25 +00:00
|
|
|
/* noisy, high contrast make impossible to read if lower alpha is used. */
|
2017-03-15 16:49:26 -04:00
|
|
|
immUniformColor4ub(0, 0, 0, 190);
|
2020-03-06 16:56:42 +01:00
|
|
|
immRecti(pos, 0, ymin, BLI_rcti_size_x(®ion->winrct) + 1, ymin + UI_UNIT_Y);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-16 01:13:18 -03:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-03-17 04:19:05 +01:00
|
|
|
BLF_size(blf_mono_font, 11.0f * UI_SCALE_FAC);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-15 15:04:41 +01:00
|
|
|
BLF_color3ub(blf_mono_font, 255, 255, 255);
|
2019-03-07 14:18:13 +11:00
|
|
|
SNPRINTF(str, "X:%-4d Y:%-4d |", x, y);
|
2013-12-24 15:06:38 +11:00
|
|
|
BLF_position(blf_mono_font, dx, dy, 0);
|
2021-08-25 13:30:00 -07:00
|
|
|
BLF_draw(blf_mono_font, str, sizeof(str));
|
2013-12-02 20:33:45 +11:00
|
|
|
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
if (channels == 1 && (cp != nullptr || fp != nullptr)) {
|
|
|
|
|
if (fp != nullptr) {
|
2019-03-07 14:18:13 +11:00
|
|
|
SNPRINTF(str, " Val:%-.3f |", fp[0]);
|
2016-05-13 11:19:32 +02:00
|
|
|
}
|
2023-07-12 13:43:00 +02:00
|
|
|
else if (cp != nullptr) {
|
2019-03-07 14:18:13 +11:00
|
|
|
SNPRINTF(str, " Val:%-.3f |", cp[0] / 255.0f);
|
2016-05-13 11:19:32 +02:00
|
|
|
}
|
2017-03-15 15:04:41 +01:00
|
|
|
BLF_color3ub(blf_mono_font, 255, 255, 255);
|
2016-05-13 11:19:32 +02:00
|
|
|
BLF_position(blf_mono_font, dx, dy, 0);
|
2021-08-25 13:30:00 -07:00
|
|
|
BLF_draw(blf_mono_font, str, sizeof(str));
|
2016-05-13 11:19:32 +02:00
|
|
|
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (channels >= 3) {
|
2017-03-15 15:04:41 +01:00
|
|
|
BLF_color3ubv(blf_mono_font, red);
|
2019-03-07 14:18:13 +11:00
|
|
|
if (fp) {
|
|
|
|
|
SNPRINTF(str, " R:%-.5f", fp[0]);
|
|
|
|
|
}
|
|
|
|
|
else if (cp) {
|
|
|
|
|
SNPRINTF(str, " R:%-3d", cp[0]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
STRNCPY(str, " R:-");
|
|
|
|
|
}
|
2013-12-24 15:06:38 +11:00
|
|
|
BLF_position(blf_mono_font, dx, dy, 0);
|
2021-08-25 13:30:00 -07:00
|
|
|
BLF_draw(blf_mono_font, str, sizeof(str));
|
2013-12-02 20:33:45 +11:00
|
|
|
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-15 15:04:41 +01:00
|
|
|
BLF_color3ubv(blf_mono_font, green);
|
2019-03-07 14:18:13 +11:00
|
|
|
if (fp) {
|
|
|
|
|
SNPRINTF(str, " G:%-.5f", fp[1]);
|
|
|
|
|
}
|
|
|
|
|
else if (cp) {
|
|
|
|
|
SNPRINTF(str, " G:%-3d", cp[1]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
STRNCPY(str, " G:-");
|
|
|
|
|
}
|
2013-12-24 15:06:38 +11:00
|
|
|
BLF_position(blf_mono_font, dx, dy, 0);
|
2021-08-25 13:30:00 -07:00
|
|
|
BLF_draw(blf_mono_font, str, sizeof(str));
|
2013-12-02 20:33:45 +11:00
|
|
|
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-15 15:04:41 +01:00
|
|
|
BLF_color3ubv(blf_mono_font, blue);
|
2019-03-07 14:18:13 +11:00
|
|
|
if (fp) {
|
|
|
|
|
SNPRINTF(str, " B:%-.5f", fp[2]);
|
|
|
|
|
}
|
|
|
|
|
else if (cp) {
|
|
|
|
|
SNPRINTF(str, " B:%-3d", cp[2]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
STRNCPY(str, " B:-");
|
|
|
|
|
}
|
2013-12-24 15:06:38 +11:00
|
|
|
BLF_position(blf_mono_font, dx, dy, 0);
|
2021-08-25 13:30:00 -07:00
|
|
|
BLF_draw(blf_mono_font, str, sizeof(str));
|
2013-12-02 20:33:45 +11:00
|
|
|
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (channels == 4) {
|
2017-03-15 15:04:41 +01:00
|
|
|
BLF_color3ub(blf_mono_font, 255, 255, 255);
|
2019-03-07 14:18:13 +11:00
|
|
|
if (fp) {
|
|
|
|
|
SNPRINTF(str, " A:%-.4f", fp[3]);
|
|
|
|
|
}
|
|
|
|
|
else if (cp) {
|
|
|
|
|
SNPRINTF(str, " A:%-3d", cp[3]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
STRNCPY(str, "- ");
|
|
|
|
|
}
|
2013-12-24 15:06:38 +11:00
|
|
|
BLF_position(blf_mono_font, dx, dy, 0);
|
2021-08-25 13:30:00 -07:00
|
|
|
BLF_draw(blf_mono_font, str, sizeof(str));
|
2013-12-02 20:33:45 +11:00
|
|
|
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
2011-04-20 09:49:32 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 11:34:05 +00:00
|
|
|
if (color_manage) {
|
|
|
|
|
float rgba[4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 11:34:05 +00:00
|
|
|
copy_v3_v3(rgba, linearcol);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (channels == 3) {
|
2013-03-18 11:34:05 +00:00
|
|
|
rgba[3] = 1.0f;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
|
else {
|
2013-03-18 11:34:05 +00:00
|
|
|
rgba[3] = linearcol[3];
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (use_default_view) {
|
2023-07-12 13:43:00 +02:00
|
|
|
IMB_colormanagement_pixel_to_display_space_v4(
|
|
|
|
|
rgba, rgba, nullptr, &scene->display_settings);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
|
else {
|
2017-03-15 16:49:26 -04:00
|
|
|
IMB_colormanagement_pixel_to_display_space_v4(
|
|
|
|
|
rgba, rgba, &scene->view_settings, &scene->display_settings);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-07 14:18:13 +11:00
|
|
|
SNPRINTF(str, " | CM R:%-.4f G:%-.4f B:%-.4f", rgba[0], rgba[1], rgba[2]);
|
2013-12-24 15:06:38 +11:00
|
|
|
BLF_position(blf_mono_font, dx, dy, 0);
|
2021-08-25 13:30:00 -07:00
|
|
|
BLF_draw(blf_mono_font, str, sizeof(str));
|
2013-12-02 20:33:45 +11:00
|
|
|
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
2019-04-17 06:17:24 +02: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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-23 08:30:28 +00:00
|
|
|
/* color rectangle */
|
2012-03-28 11:53:18 +00:00
|
|
|
if (channels == 1) {
|
2012-01-20 14:33:03 +00:00
|
|
|
if (fp) {
|
2011-04-23 08:30:28 +00:00
|
|
|
col[0] = col[1] = col[2] = fp[0];
|
2012-01-20 14:33:03 +00:00
|
|
|
}
|
|
|
|
|
else if (cp) {
|
2023-07-14 12:23:37 +10:00
|
|
|
col[0] = col[1] = col[2] = float(cp[0]) / 255.0f;
|
2012-01-20 14:33:03 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2011-04-23 08:30:28 +00:00
|
|
|
col[0] = col[1] = col[2] = 0.0f;
|
2012-01-20 14:33:03 +00:00
|
|
|
}
|
|
|
|
|
col[3] = 1.0f;
|
2011-04-20 09:49:32 +00:00
|
|
|
}
|
2012-03-28 11:53:18 +00:00
|
|
|
else if (channels == 3) {
|
2013-03-18 11:34:05 +00:00
|
|
|
copy_v3_v3(col, linearcol);
|
2012-01-20 14:33:03 +00:00
|
|
|
col[3] = 1.0f;
|
2011-04-20 09:49:32 +00:00
|
|
|
}
|
2012-03-28 11:53:18 +00:00
|
|
|
else if (channels == 4) {
|
2013-03-18 11:34:05 +00:00
|
|
|
copy_v4_v4(col, linearcol);
|
2012-01-20 14:33:03 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_assert(0);
|
|
|
|
|
zero_v4(col);
|
2011-04-23 08:30:28 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-23 08:30:28 +00:00
|
|
|
if (color_manage) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (use_default_view) {
|
2023-07-12 13:43:00 +02:00
|
|
|
IMB_colormanagement_pixel_to_display_space_v4(
|
|
|
|
|
finalcol, col, nullptr, &scene->display_settings);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
|
else {
|
2017-03-15 16:49:26 -04:00
|
|
|
IMB_colormanagement_pixel_to_display_space_v4(
|
|
|
|
|
finalcol, col, &scene->view_settings, &scene->display_settings);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2011-04-23 08:30:28 +00:00
|
|
|
else {
|
|
|
|
|
copy_v4_v4(finalcol, col);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2013-02-13 19:01:33 +00:00
|
|
|
dx += 0.25f * UI_UNIT_X;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-05 10:39:42 +01:00
|
|
|
BLI_rcti_init(&color_rect,
|
|
|
|
|
dx,
|
|
|
|
|
dx + (1.5f * UI_UNIT_X),
|
|
|
|
|
ymin + 0.15f * UI_UNIT_Y,
|
|
|
|
|
ymin + 0.85f * UI_UNIT_Y);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-15 16:49:26 -04:00
|
|
|
/* BLF uses immediate mode too, so we must reset our vertex format */
|
2018-07-18 00:12:21 +02:00
|
|
|
pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
|
2022-09-01 09:31:07 -03:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-12-24 17:20:37 +11:00
|
|
|
if (channels == 4) {
|
|
|
|
|
rcti color_rect_half;
|
|
|
|
|
int color_quater_x, color_quater_y;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-12-24 17:20:37 +11:00
|
|
|
color_rect_half = color_rect;
|
|
|
|
|
color_rect_half.xmax = BLI_rcti_cent_x(&color_rect);
|
2017-03-15 16:49:26 -04:00
|
|
|
/* what color ??? */
|
|
|
|
|
immRecti(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-12-24 17:20:37 +11:00
|
|
|
color_rect_half = color_rect;
|
|
|
|
|
color_rect_half.xmin = BLI_rcti_cent_x(&color_rect);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-12-24 17:20:37 +11:00
|
|
|
color_quater_x = BLI_rcti_cent_x(&color_rect_half);
|
|
|
|
|
color_quater_y = BLI_rcti_cent_y(&color_rect_half);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-15 16:49:26 -04:00
|
|
|
immUniformColor3ub(UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK);
|
|
|
|
|
immRecti(pos,
|
|
|
|
|
color_rect_half.xmin,
|
|
|
|
|
color_rect_half.ymin,
|
|
|
|
|
color_rect_half.xmax,
|
|
|
|
|
color_rect_half.ymax);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-15 16:49:26 -04:00
|
|
|
immUniformColor3ub(UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT);
|
|
|
|
|
immRecti(pos, color_quater_x, color_quater_y, color_rect_half.xmax, color_rect_half.ymax);
|
|
|
|
|
immRecti(pos, color_rect_half.xmin, color_rect_half.ymin, color_quater_x, color_quater_y);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
if (fp != nullptr || cp != nullptr) {
|
2021-08-27 15:07:26 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
|
|
|
|
immUniformColor3fvAlpha(finalcol, fp ? fp[3] : (cp[3] / 255.0f));
|
|
|
|
|
immRecti(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
|
|
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
|
|
|
|
}
|
2013-12-24 17:20:37 +11:00
|
|
|
}
|
|
|
|
|
else {
|
2017-03-15 16:49:26 -04:00
|
|
|
immUniformColor3fv(finalcol);
|
|
|
|
|
immRecti(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
|
2013-12-24 17:20:37 +11:00
|
|
|
}
|
2017-03-16 01:13:18 -03:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-16 23:44:08 +00:00
|
|
|
/* draw outline */
|
2018-07-18 00:12:21 +02:00
|
|
|
pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2022-09-01 09:31:07 -03:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
2017-03-03 13:12:29 -05:00
|
|
|
immUniformColor3ub(128, 128, 128);
|
2017-09-26 15:21:01 +10:00
|
|
|
imm_draw_box_wire_2d(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
|
2017-03-03 13:12:29 -05:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-02-13 19:01:33 +00:00
|
|
|
dx += 1.75f * UI_UNIT_X;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-15 15:04:41 +01:00
|
|
|
BLF_color3ub(blf_mono_font, 255, 255, 255);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (channels == 1) {
|
2011-04-20 09:49:32 +00:00
|
|
|
if (fp) {
|
|
|
|
|
rgb_to_hsv(fp[0], fp[0], fp[0], &hue, &sat, &val);
|
2018-04-29 18:00:45 -04:00
|
|
|
rgb_to_yuv(fp[0], fp[0], fp[0], &lum, &u, &v, BLI_YUV_ITU_BT709);
|
2011-04-20 09:49:32 +00:00
|
|
|
}
|
|
|
|
|
else if (cp) {
|
2012-03-28 11:53:18 +00:00
|
|
|
rgb_to_hsv(
|
2023-07-14 12:23:37 +10:00
|
|
|
float(cp[0]) / 255.0f, float(cp[0]) / 255.0f, float(cp[0]) / 255.0f, &hue, &sat, &val);
|
|
|
|
|
rgb_to_yuv(float(cp[0]) / 255.0f,
|
|
|
|
|
float(cp[0]) / 255.0f,
|
|
|
|
|
float(cp[0]) / 255.0f,
|
2018-04-29 18:00:45 -04:00
|
|
|
&lum,
|
|
|
|
|
&u,
|
|
|
|
|
&v,
|
|
|
|
|
BLI_YUV_ITU_BT709);
|
2011-04-20 09:49:32 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-07 14:18:13 +11:00
|
|
|
SNPRINTF(str, "V:%-.4f", val);
|
2013-12-24 15:06:38 +11:00
|
|
|
BLF_position(blf_mono_font, dx, dy, 0);
|
2021-08-25 13:30:00 -07:00
|
|
|
BLF_draw(blf_mono_font, str, sizeof(str));
|
2013-12-02 20:33:45 +11:00
|
|
|
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-07 14:18:13 +11:00
|
|
|
SNPRINTF(str, " L:%-.4f", lum);
|
2013-12-24 15:06:38 +11:00
|
|
|
BLF_position(blf_mono_font, dx, dy, 0);
|
2021-08-25 13:30:00 -07:00
|
|
|
BLF_draw(blf_mono_font, str, sizeof(str));
|
2011-04-20 09:49:32 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (channels >= 3) {
|
2013-10-07 08:06:19 +00:00
|
|
|
rgb_to_hsv(finalcol[0], finalcol[1], finalcol[2], &hue, &sat, &val);
|
2018-04-29 18:00:45 -04:00
|
|
|
rgb_to_yuv(finalcol[0], finalcol[1], finalcol[2], &lum, &u, &v, BLI_YUV_ITU_BT709);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-07 14:18:13 +11:00
|
|
|
SNPRINTF(str, "H:%-.4f", hue);
|
2013-12-24 15:06:38 +11:00
|
|
|
BLF_position(blf_mono_font, dx, dy, 0);
|
2021-08-25 13:30:00 -07:00
|
|
|
BLF_draw(blf_mono_font, str, sizeof(str));
|
2013-12-02 20:33:45 +11:00
|
|
|
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-07 14:18:13 +11:00
|
|
|
SNPRINTF(str, " S:%-.4f", sat);
|
2013-12-24 15:06:38 +11:00
|
|
|
BLF_position(blf_mono_font, dx, dy, 0);
|
2021-08-25 13:30:00 -07:00
|
|
|
BLF_draw(blf_mono_font, str, sizeof(str));
|
2013-12-02 20:33:45 +11:00
|
|
|
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-07 14:18:13 +11:00
|
|
|
SNPRINTF(str, " V:%-.4f", val);
|
2013-12-24 15:06:38 +11:00
|
|
|
BLF_position(blf_mono_font, dx, dy, 0);
|
2021-08-25 13:30:00 -07:00
|
|
|
BLF_draw(blf_mono_font, str, sizeof(str));
|
2013-12-02 20:33:45 +11:00
|
|
|
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-07 14:18:13 +11:00
|
|
|
SNPRINTF(str, " L:%-.4f", lum);
|
2013-12-24 15:06:38 +11:00
|
|
|
BLF_position(blf_mono_font, dx, dy, 0);
|
2021-08-25 13:30:00 -07:00
|
|
|
BLF_draw(blf_mono_font, str, sizeof(str));
|
2011-04-20 09:49:32 +00:00
|
|
|
}
|
2009-02-10 23:17:58 +00:00
|
|
|
}
|
2012-06-10 12:09:25 +00:00
|
|
|
void draw_image_sample_line(SpaceImage *sima)
|
|
|
|
|
{
|
|
|
|
|
if (sima->sample_line_hist.flag & HISTO_FLAG_SAMPLELINE) {
|
|
|
|
|
Histogram *hist = &sima->sample_line_hist;
|
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
|
uint shdr_dashed_pos = GPU_vertformat_attr_add(
|
|
|
|
|
format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2017-03-16 10:15:01 -03:00
|
|
|
|
2022-09-05 19:01:02 -03:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
|
2017-04-29 20:41:57 +02:00
|
|
|
|
|
|
|
|
float viewport_size[4];
|
2018-07-02 18:27:05 +02:00
|
|
|
GPU_viewport_size_get_f(viewport_size);
|
2023-03-17 04:19:05 +01:00
|
|
|
immUniform2f(
|
|
|
|
|
"viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC);
|
2017-04-29 20:41:57 +02:00
|
|
|
|
2018-07-01 08:42:16 +02:00
|
|
|
immUniform1i("colors_len", 2); /* Advanced dashes. */
|
2022-05-02 00:35:49 +02:00
|
|
|
immUniform4f("color", 1.0f, 1.0f, 1.0f, 1.0f);
|
|
|
|
|
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 1.0f);
|
2017-04-29 20:41:57 +02:00
|
|
|
immUniform1f("dash_width", 2.0f);
|
2022-12-08 21:07:28 +01:00
|
|
|
immUniform1f("udash_factor", 0.5f);
|
2012-06-10 12:09:25 +00:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 2);
|
2017-04-29 20:41:57 +02:00
|
|
|
immVertex2fv(shdr_dashed_pos, hist->co[0]);
|
|
|
|
|
immVertex2fv(shdr_dashed_pos, hist->co[1]);
|
2017-03-16 10:15:01 -03:00
|
|
|
immEnd();
|
2012-06-10 12:09:25 +00:00
|
|
|
|
2017-03-16 10:15:01 -03:00
|
|
|
immUnbindProgram();
|
2012-06-10 12:09:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-11 07:59:48 +02:00
|
|
|
void draw_image_main_helpers(const bContext *C, ARegion *region)
|
|
|
|
|
{
|
|
|
|
|
SpaceImage *sima = CTX_wm_space_image(C);
|
2020-10-26 15:54:00 +01:00
|
|
|
Image *ima = ED_space_image(sima);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-26 15:54:00 +01:00
|
|
|
const bool show_viewer = (ima && ima->source == IMA_SRC_VIEWER) != 0;
|
|
|
|
|
const bool show_render = (show_viewer && ima->type == IMA_TYPE_R_RESULT) != 0;
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ima && show_render) {
|
2020-10-26 15:54:00 +01:00
|
|
|
float zoomx, zoomy;
|
|
|
|
|
ED_space_image_get_zoom(sima, region, &zoomx, &zoomy);
|
2020-03-06 16:56:42 +01:00
|
|
|
draw_render_info(C, sima->iuser.scene, ima, region, zoomx, zoomy);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-07-13 13:47:13 +00:00
|
|
|
}
|
2014-04-02 16:50:06 +06:00
|
|
|
|
2021-10-19 12:22:06 +11:00
|
|
|
bool ED_space_image_show_cache(const SpaceImage *sima)
|
2014-04-30 17:39:14 +06:00
|
|
|
{
|
2014-12-09 20:33:19 +05:00
|
|
|
Image *image = ED_space_image(sima);
|
2023-07-12 13:43:00 +02:00
|
|
|
Mask *mask = nullptr;
|
2014-12-09 20:33:19 +05:00
|
|
|
if (sima->mode == SI_MODE_MASK) {
|
|
|
|
|
mask = ED_space_image_get_mask(sima);
|
|
|
|
|
}
|
2023-07-12 13:43:00 +02:00
|
|
|
if (image == nullptr && mask == nullptr) {
|
2014-04-30 17:39:14 +06:00
|
|
|
return false;
|
|
|
|
|
}
|
2023-07-12 13:43:00 +02:00
|
|
|
if (mask == nullptr) {
|
2014-04-30 17:39:14 +06:00
|
|
|
return ELEM(image->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-19 12:22:06 +11:00
|
|
|
bool ED_space_image_show_cache_and_mval_over(const SpaceImage *sima,
|
|
|
|
|
ARegion *region,
|
|
|
|
|
const int mval[2])
|
|
|
|
|
{
|
|
|
|
|
const rcti *rect_visible = ED_region_visible_rect(region);
|
2023-03-17 04:19:05 +01:00
|
|
|
if (mval[1] > rect_visible->ymin + (16 * UI_SCALE_FAC)) {
|
2021-10-19 12:22:06 +11:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return ED_space_image_show_cache(sima);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
void draw_image_cache(const bContext *C, ARegion *region)
|
2014-04-02 16:50:06 +06:00
|
|
|
{
|
|
|
|
|
SpaceImage *sima = CTX_wm_space_image(C);
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
Image *image = ED_space_image(sima);
|
2022-06-30 18:36:42 +02:00
|
|
|
float x, cfra = scene->r.cfra, sfra = scene->r.sfra, efra = scene->r.efra,
|
|
|
|
|
framelen = region->winx / (efra - sfra + 1);
|
2023-07-12 13:43:00 +02:00
|
|
|
Mask *mask = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-12-09 20:33:19 +05:00
|
|
|
if (!ED_space_image_show_cache(sima)) {
|
|
|
|
|
return;
|
2014-04-02 16:50:06 +06:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-12-09 20:33:19 +05:00
|
|
|
if (sima->mode == SI_MODE_MASK) {
|
|
|
|
|
mask = ED_space_image_get_mask(sima);
|
2014-04-02 16:50:06 +06:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-10-29 16:49:27 +01:00
|
|
|
/* Local coordinate visible rect inside region, to accommodate overlapping ui. */
|
2020-03-06 16:56:42 +01:00
|
|
|
const rcti *rect_visible = ED_region_visible_rect(region);
|
2019-10-29 16:49:27 +01:00
|
|
|
const int region_bottom = rect_visible->ymin;
|
|
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-04-02 16:50:06 +06:00
|
|
|
/* Draw cache background. */
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_cache_draw_background(region);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-04-02 16:50:06 +06:00
|
|
|
/* Draw cached segments. */
|
2023-07-12 13:43:00 +02:00
|
|
|
if (image != nullptr && image->cache != nullptr &&
|
|
|
|
|
ELEM(image->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE))
|
|
|
|
|
{
|
2014-04-02 16:50:06 +06:00
|
|
|
int num_segments = 0;
|
2023-07-12 13:43:00 +02:00
|
|
|
int *points = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
BLI_mutex_lock(static_cast<ThreadMutex *>(image->runtime.cache_mutex));
|
2014-04-02 16:50:06 +06:00
|
|
|
IMB_moviecache_get_cache_segments(image->cache, IMB_PROXY_NONE, 0, &num_segments, &points);
|
2023-07-12 13:43:00 +02:00
|
|
|
BLI_mutex_unlock(static_cast<ThreadMutex *>(image->runtime.cache_mutex));
|
2022-03-11 12:32:30 +01:00
|
|
|
|
2014-04-02 16:50:06 +06:00
|
|
|
ED_region_cache_draw_cached_segments(
|
2020-03-06 16:56:42 +01:00
|
|
|
region, num_segments, points, sfra + sima->iuser.offset, efra + sima->iuser.offset);
|
2014-04-02 16:50:06 +06:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-04-02 16:50:06 +06:00
|
|
|
/* Draw current frame. */
|
2020-03-06 16:56:42 +01:00
|
|
|
x = (cfra - sfra) / (efra - sfra + 1) * region->winx;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
uint pos = GPU_vertformat_attr_add(
|
|
|
|
|
immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
|
2022-09-01 09:31:07 -03:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
2017-03-23 14:56:42 -03:00
|
|
|
immUniformThemeColor(TH_CFRAME);
|
2023-03-17 04:19:05 +01:00
|
|
|
immRecti(pos, x, region_bottom, x + ceilf(framelen), region_bottom + 8 * UI_SCALE_FAC);
|
2017-03-23 14:56:42 -03:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-03-17 04:19:05 +01:00
|
|
|
ED_region_cache_draw_curfra_label(cfra, x, region_bottom + 8.0f * UI_SCALE_FAC);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
if (mask != nullptr) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_mask_draw_frames(mask, region, cfra, sfra, efra);
|
2014-04-02 16:50:06 +06:00
|
|
|
}
|
|
|
|
|
}
|
2021-09-29 17:47:32 +10:00
|
|
|
|
|
|
|
|
float ED_space_image_zoom_level(const View2D *v2d, const int grid_dimension)
|
|
|
|
|
{
|
|
|
|
|
/* UV-space length per pixel */
|
2023-07-14 12:23:37 +10:00
|
|
|
float xzoom = (v2d->cur.xmax - v2d->cur.xmin) / float(v2d->mask.xmax - v2d->mask.xmin);
|
|
|
|
|
float yzoom = (v2d->cur.ymax - v2d->cur.ymin) / float(v2d->mask.ymax - v2d->mask.ymin);
|
2021-09-29 17:47:32 +10:00
|
|
|
|
|
|
|
|
/* Zoom_factor for UV/Image editor is calculated based on:
|
|
|
|
|
* - Default grid size on startup, which is 256x256 pixels
|
|
|
|
|
* - How blend factor for grid lines is set up in the fragment shader `grid_frag.glsl`. */
|
|
|
|
|
float zoom_factor;
|
2022-01-24 14:29:19 +11:00
|
|
|
zoom_factor = (xzoom + yzoom) / 2.0f; /* Average for accuracy. */
|
2022-10-07 22:52:53 +11:00
|
|
|
zoom_factor *= 256.0f / powf(grid_dimension, 2);
|
2021-09-29 17:47:32 +10:00
|
|
|
return zoom_factor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ED_space_image_grid_steps(SpaceImage *sima,
|
2022-09-18 17:03:40 +12:00
|
|
|
float grid_steps_x[SI_GRID_STEPS_LEN],
|
|
|
|
|
float grid_steps_y[SI_GRID_STEPS_LEN],
|
2021-09-29 17:47:32 +10:00
|
|
|
const int grid_dimension)
|
|
|
|
|
{
|
2023-07-12 13:43:00 +02:00
|
|
|
const eSpaceImage_GridShapeSource grid_shape_source = eSpaceImage_GridShapeSource(
|
|
|
|
|
sima->grid_shape_source);
|
2022-09-18 17:03:40 +12:00
|
|
|
for (int step = 0; step < SI_GRID_STEPS_LEN; step++) {
|
2022-10-12 11:26:14 +13:00
|
|
|
switch (grid_shape_source) {
|
|
|
|
|
case SI_GRID_SHAPE_DYNAMIC:
|
|
|
|
|
grid_steps_x[step] = powf(grid_dimension, step - SI_GRID_STEPS_LEN);
|
|
|
|
|
grid_steps_y[step] = powf(grid_dimension, step - SI_GRID_STEPS_LEN);
|
|
|
|
|
break;
|
|
|
|
|
case SI_GRID_SHAPE_FIXED:
|
|
|
|
|
grid_steps_x[step] = 1.0f / sima->custom_grid_subdiv[0];
|
|
|
|
|
grid_steps_y[step] = 1.0f / sima->custom_grid_subdiv[1];
|
|
|
|
|
break;
|
|
|
|
|
case SI_GRID_SHAPE_PIXEL: {
|
|
|
|
|
int pixel_width = IMG_SIZE_FALLBACK;
|
|
|
|
|
int pixel_height = IMG_SIZE_FALLBACK;
|
|
|
|
|
ED_space_image_get_size(sima, &pixel_width, &pixel_height);
|
|
|
|
|
BLI_assert(pixel_width > 0 && pixel_height > 0);
|
|
|
|
|
grid_steps_x[step] = 1.0f / pixel_width;
|
|
|
|
|
grid_steps_y[step] = 1.0f / pixel_height;
|
2023-09-23 21:10:22 +10:00
|
|
|
break;
|
|
|
|
|
}
|
2022-10-12 11:26:14 +13:00
|
|
|
default:
|
|
|
|
|
BLI_assert_unreachable();
|
2021-09-29 17:47:32 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-20 09:20:55 +12:00
|
|
|
float ED_space_image_increment_snap_value(const int grid_dimensions,
|
2021-09-29 17:47:32 +10:00
|
|
|
const float grid_steps[SI_GRID_STEPS_LEN],
|
|
|
|
|
const float zoom_factor)
|
|
|
|
|
{
|
|
|
|
|
/* Small offset on each grid_steps[] so that snapping value doesn't change until grid lines are
|
|
|
|
|
* significantly visible.
|
2022-09-20 09:20:55 +12:00
|
|
|
* `Offset = 3/4 * (grid_steps[i] - (grid_steps[i] / grid_dimensions))`
|
2021-09-29 17:47:32 +10:00
|
|
|
*
|
|
|
|
|
* Refer `grid_frag.glsl` to find out when grid lines actually start appearing */
|
|
|
|
|
|
|
|
|
|
for (int step = 0; step < SI_GRID_STEPS_LEN; step++) {
|
2022-09-20 09:20:55 +12:00
|
|
|
float offset = (3.0f / 4.0f) * (grid_steps[step] - (grid_steps[step] / grid_dimensions));
|
2021-09-29 17:47:32 +10:00
|
|
|
|
|
|
|
|
if ((grid_steps[step] - offset) > zoom_factor) {
|
|
|
|
|
return grid_steps[step];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Fallback */
|
|
|
|
|
return grid_steps[0];
|
|
|
|
|
}
|