[Bf-blender-cvs] [86cb87c0fad] greasepencil-object: Chnages to use OCIO
Antonio Vazquez
noreply at git.blender.org
Tue Feb 13 17:35:05 CET 2018
Commit: 86cb87c0fadea9b1c0d7b2e0080ed0f66c2c4bfc
Author: Antonio Vazquez
Date: Tue Feb 13 13:22:34 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB86cb87c0fadea9b1c0d7b2e0080ed0f66c2c4bfc
Chnages to use OCIO
===================================================================
M source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M source/blender/draw/engines/gpencil/gpencil_engine.c
M source/blender/draw/engines/gpencil/gpencil_engine.h
M source/blender/draw/engines/gpencil/gpencil_geom.c
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 2579b71a58b..57e1e1665bd 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -47,6 +47,7 @@
#include "DEG_depsgraph.h"
#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
#include "draw_cache_impl.h"
#include "gpencil_engine.h"
@@ -523,7 +524,7 @@ DRWShadingGroup *DRW_gpencil_shgroup_point_create(GPENCIL_e_data *e_data, GPENCI
/* add fill shading group to pass */
static void gpencil_add_fill_shgroup(GpencilBatchCache *cache, DRWShadingGroup *fillgrp,
Object *ob, bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps,
- const float tintcolor[4], const bool onion, const bool custonion)
+ const float tintcolor[4], const bool onion, const bool custonion, ColorSpace *colorspace)
{
if (gps->totpoints >= 3) {
float tfill[4];
@@ -546,7 +547,7 @@ static void gpencil_add_fill_shgroup(GpencilBatchCache *cache, DRWShadingGroup *
}
if (cache->is_dirty) {
gpencil_batch_cache_check_free_slots(ob);
- cache->batch_fill[cache->cache_idx] = DRW_gpencil_get_fill_geom(gps, color);
+ cache->batch_fill[cache->cache_idx] = DRW_gpencil_get_fill_geom(gps, color, colorspace);
}
DRW_shgroup_call_add(fillgrp, cache->batch_fill[cache->cache_idx], gpf->viewmatrix);
}
@@ -556,7 +557,8 @@ static void gpencil_add_fill_shgroup(GpencilBatchCache *cache, DRWShadingGroup *
/* add stroke shading group to pass */
static void gpencil_add_stroke_shgroup(GpencilBatchCache *cache, DRWShadingGroup *strokegrp,
Object *ob, bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps,
- const float opacity, const float tintcolor[4], const bool onion, const bool custonion)
+ const float opacity, const float tintcolor[4], const bool onion, const bool custonion,
+ ColorSpace *colorspace)
{
float tcolor[4];
float ink[4];
@@ -590,10 +592,10 @@ static void gpencil_add_stroke_shgroup(GpencilBatchCache *cache, DRWShadingGroup
if (cache->is_dirty) {
gpencil_batch_cache_check_free_slots(ob);
if ((gps->totpoints > 1) && ((gps->palcolor->flag & PAC_COLOR_DOT) == 0)) {
- cache->batch_stroke[cache->cache_idx] = DRW_gpencil_get_stroke_geom(gpf, gps, sthickness, ink);
+ cache->batch_stroke[cache->cache_idx] = DRW_gpencil_get_stroke_geom(gpf, gps, sthickness, ink, colorspace);
}
else {
- cache->batch_stroke[cache->cache_idx] = DRW_gpencil_get_point_geom(gps, sthickness, ink);
+ cache->batch_stroke[cache->cache_idx] = DRW_gpencil_get_point_geom(gps, sthickness, ink, colorspace);
}
}
DRW_shgroup_call_add(strokegrp, cache->batch_stroke[cache->cache_idx], gpf->viewmatrix);
@@ -672,7 +674,7 @@ static void gpencil_draw_onion_strokes(GpencilBatchCache *cache, GPENCIL_e_data
}
/* stroke */
- gpencil_add_stroke_shgroup(cache, stl->shgroups[id].shgrps_stroke, ob, gpd, gpl, gpf, gps, opacity, tintcolor, true, custonion);
+ gpencil_add_stroke_shgroup(cache, stl->shgroups[id].shgrps_stroke, ob, gpd, gpl, gpf, gps, opacity, tintcolor, true, custonion, NULL);
stl->storage->shgroup_id++;
cache->cache_idx++;
@@ -696,7 +698,8 @@ static void gpencil_init_evalctx_from_drawctx(const DRWContextState *draw_ctx, E
/* main function to draw strokes */
static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_data, void *vedata, ToolSettings *ts, Object *ob,
bGPdata *gpd, bGPDlayer *gpl, bGPDframe *src_gpf, bGPDframe *derived_gpf,
- const float opacity, const float tintcolor[4], const bool custonion)
+ const float opacity, const float tintcolor[4], const bool custonion,
+ ColorSpace *colorspace)
{
GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
@@ -807,11 +810,11 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
}
/* fill */
if ((fillgrp) && (!GP_SIMPLIFY_FILL(ts, playing))) {
- gpencil_add_fill_shgroup(cache, fillgrp, ob, gpd, gpl, derived_gpf, gps, tintcolor, false, custonion);
+ gpencil_add_fill_shgroup(cache, fillgrp, ob, gpd, gpl, derived_gpf, gps, tintcolor, false, custonion, colorspace);
}
/* stroke */
if (strokegrp) {
- gpencil_add_stroke_shgroup(cache, strokegrp, ob, gpd, gpl, derived_gpf, gps, opacity, tintcolor, false, custonion);
+ gpencil_add_stroke_shgroup(cache, strokegrp, ob, gpd, gpl, derived_gpf, gps, opacity, tintcolor, false, custonion, colorspace);
}
}
@@ -1104,7 +1107,7 @@ void DRW_gpencil_populate_multiedit(GPENCIL_e_data *e_data, void *vedata, Scene
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || (gpf->flag & GP_FRAME_SELECT)) {
gpencil_draw_strokes(cache, e_data, vedata, ts, ob, gpd, gpl, gpf, gpf,
- gpl->opacity, gpl->tintcolor, false);
+ gpl->opacity, gpl->tintcolor, false, NULL);
}
}
}
@@ -1112,7 +1115,7 @@ void DRW_gpencil_populate_multiedit(GPENCIL_e_data *e_data, void *vedata, Scene
gpf = BKE_gpencil_layer_getframe(gpl, CFRA, 0);
if (gpf) {
gpencil_draw_strokes(cache, e_data, vedata, ts, ob, gpd, gpl, gpf, gpf,
- gpl->opacity, gpl->tintcolor, false);
+ gpl->opacity, gpl->tintcolor, false, NULL);
}
}
@@ -1186,7 +1189,7 @@ void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data, void *vedata, Scene
/* draw normal strokes */
gpencil_draw_strokes(cache, e_data, vedata, ts, ob, gpd, gpl, gpf, derived_gpf,
- gpl->opacity, gpl->tintcolor, false);
+ gpl->opacity, gpl->tintcolor, false, stl->storage->colorspace);
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index d63b1a99723..933259442bf 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -41,6 +41,8 @@
#include "UI_resources.h"
+#include "IMB_colormanagement.h"
+
#include "RE_pipeline.h"
#include "gpencil_engine.h"
@@ -302,6 +304,9 @@ static void GPENCIL_cache_init(void *vedata)
stl->storage->pixsize = &stl->storage->render_pixsize;
}
+ /* save color space */
+ stl->storage->colorspace = colormanage_colorspace_get_named(colormanage_display_get_default_name());
+
/* detect if painting session */
bGPdata *obact_gpd = NULL;
if ((obact) && (obact->type == OB_GPENCIL) && (obact->data))
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 332105d8515..ddab26c8e95 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -31,6 +31,7 @@
struct tGPspoint;
struct ModifierData;
struct GPENCIL_StorageList;
+struct ColorSpace;
/* TODO: these could be system parameter in userprefs screen */
#define GPENCIL_MAX_GP_OBJ 256
@@ -175,6 +176,7 @@ typedef struct GPENCIL_Storage {
float viewmat[4][4], viewinv[4][4];
float winmat[4][4], wininv[4][4];
float view_vecs[2][4]; /* vec4[2] */
+ struct ColorSpace *colorspace;
} GPENCIL_Storage;
typedef struct GPENCIL_StorageList {
@@ -328,9 +330,9 @@ void DRW_gpencil_populate_datablock(struct GPENCIL_e_data *e_data, void *vedata,
void DRW_gpencil_populate_buffer_strokes(struct GPENCIL_e_data *e_data, void *vedata, struct ToolSettings *ts, struct Object *ob);
void DRW_gpencil_populate_multiedit(struct GPENCIL_e_data *e_data, void *vedata, struct Scene *scene, struct Object *ob, struct ToolSettings *ts, struct bGPdata *gpd);
-struct Gwn_Batch *DRW_gpencil_get_point_geom(struct bGPDstroke *gps, short thickness, const float ink[4]);
-struct Gwn_Batch *DRW_gpencil_get_stroke_geom(struct bGPDframe *gpf, struct bGPDstroke *gps, short thickness, const float ink[4]);
-struct Gwn_Batch *DRW_gpencil_get_fill_geom(struct bGPDstroke *gps, const float color[4]);
+struct Gwn_Batch *DRW_gpencil_get_point_geom(struct bGPDstroke *gps, short thickness, const float ink[4], struct ColorSpace *colorspace);
+struct Gwn_Batch *DRW_gpencil_get_stroke_geom(struct bGPDframe *gpf, struct bGPDstroke *gps, short thickness, const float ink[4], struct ColorSpace *colorspace);
+struct Gwn_Batch *DRW_gpencil_get_fill_geom(struct bGPDstroke *gps, const float color[4], struct ColorSpace *colorspace);
struct Gwn_Batch *DRW_gpencil_get_edit_geom(struct bGPDstroke *gps, float alpha, short dflag);
struct Gwn_Batch *DRW_gpencil_get_edlin_geom(struct bGPDstroke *gps, float alpha, short dflag);
struct Gwn_Batch *DRW_gpencil_get_buffer_stroke_geom(struct bGPdata *gpd, float matrix[4][4], short thickness);
diff --git a/source/blender/draw/engines/gpencil/gpencil_geom.c b/source/blender/draw/engines/gpencil/gpencil_geom.c
index da0694b4812..727c347850d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_geom.c
+++ b/source/blender/draw/engines/gpencil/gpencil_geom.c
@@ -48,17 +48,16 @@
#include "UI_resources.h"
+#include "IMB_colormanagement.h"
+
#include "gpencil_engine.h"
/* helper to convert color space to linear */
-static void gpencil_linear_colorspace(const float color[4], float r_color[4])
+static void gpencil_linear_colorspace(const float color[4], ColorSpace *colorspace, float r_color[4])
{
- const char *display_device;
- const DRWContextState *draw_ctx = DRW_context_state_get();
- Scene *scene = draw_ctx->scene;
-
- display_device = scene->display_settings.display_device;
- if ((DRW_state_is_image_render()) && (STREQ(display_device, "sRGB"))) {
+ if ((DRW_state_is_image_render()) && (colorspace != NULL)) {
+ copy_v4_v4(r_color, color);
+ IMB_colormanagement_colorspace_to_scene_linear_v4(r_color, false, colorspace);
srgb_to_linearrgb_v4(r_color, color);
}
else {
@@ -71,7 +70,7 @@ static void gpencil_set_stroke_point(
Gwn_VertBuf *vbo, float matrix[4][4], const bGPDspoint *pt, int idx,
uint pos_id, uint color_id,
uint thickness_id, short thickness,
- const float ink[4])
+ const float ink[4], ColorSpace *colorspace)
{
float viewfpt[3];
float space_color[4];
@@ -81,7 +80,7 @@ static void gpencil_set_stroke_point(
flo
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list