Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vectorscope: add RYB option #9904

Merged
merged 6 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 39 additions & 3 deletions src/common/colorspaces_inline_conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,15 +481,23 @@ static inline void dt_Rec709_to_XYZ_D50(const dt_aligned_pixel_t sRGB, dt_aligne
}


#ifdef _OPENMP
#pragma omp declare simd aligned(sRGB, RGB)
#endif
static inline void dt_sRGB_to_linear_sRGB(const dt_aligned_pixel_t sRGB, dt_aligned_pixel_t RGB)
{
// gamma corrected sRGB -> linear sRGB
for(int c = 0; c < 3; c++)
RGB[c] = sRGB[c] <= 0.04045f ? sRGB[c] / 12.92f : powf((sRGB[c] + 0.055f) / (1.0f + 0.055f), 2.4f);
}

#ifdef _OPENMP
#pragma omp declare simd aligned(sRGB, XYZ)
#endif
static inline void dt_sRGB_to_XYZ(const dt_aligned_pixel_t sRGB, dt_aligned_pixel_t XYZ)
{
dt_aligned_pixel_t rgb = { 0 };
// gamma corrected sRGB -> linear sRGB
for(int c = 0; c < 3; c++)
rgb[c] = sRGB[c] <= 0.04045f ? sRGB[c] / 12.92f : powf((sRGB[c] + 0.055f) / (1.0f + 0.055f), 2.4f);
dt_sRGB_to_linear_sRGB(sRGB, rgb);
// linear sRGB -> XYZ
dt_Rec709_to_XYZ_D50(rgb, XYZ);
}
Expand Down Expand Up @@ -771,6 +779,34 @@ static inline void dt_HSV_2_RGB(const dt_aligned_pixel_t HSV, dt_aligned_pixel_t
}


#ifdef _OPENMP
#pragma omp declare simd aligned(RGB, HCV: 16)
#endif
static inline void dt_RGB_2_HCV(const dt_aligned_pixel_t RGB, dt_aligned_pixel_t HCV)
{
const float min = fminf(RGB[0], fminf(RGB[1], RGB[2]));
const float max = fmaxf(RGB[0], fmaxf(RGB[1], RGB[2]));
const float delta = max - min;

const float V = max;
float C, H;

if(fabsf(max) > 1e-6f && fabsf(delta) > 1e-6f)
{
C = delta;
H = _dt_RGB_2_Hue(RGB, max, delta);
}
else
{
C = 0.0f;
H = 0.0f;
}

HCV[0] = H;
HCV[1] = C;
HCV[2] = V;
}

#ifdef _OPENMP
#pragma omp declare simd
#endif
Expand Down
27 changes: 27 additions & 0 deletions src/dtgtk/paint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,33 @@ void dtgtk_cairo_paint_jzazbz(cairo_t *cr, gint x, gint y, gint w, gint h, gint
FINISH
}

void dtgtk_cairo_paint_ryb(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data)
{
PREAMBLE(1, 0, 0)

// FIXME: change icon to "RYB"

cairo_move_to(cr, 0.0, 0.7);
cairo_line_to(cr, 0.0, 0.2);
cairo_curve_to(cr, 0.5, 0.25, -0.2, 0.45, 0.45, 0.7);
cairo_stroke(cr);

cairo_move_to(cr, 0.5, 0.5);
cairo_line_to(cr, 1.0, 0.0);
cairo_stroke(cr);
cairo_move_to(cr, 0.75, 0.25);
cairo_line_to(cr, 0.4, 0.0);
cairo_stroke(cr);

cairo_move_to(cr, 0.55, 1.0);
cairo_line_to(cr, 0.55, 0.5);
cairo_curve_to(cr, 1.0, 0.55, 1.0, 0.7, 0.55, 0.75);
cairo_curve_to(cr, 1.3, 0.8, 1.3, 0.95, 0.4, 1.0);
cairo_stroke(cr);

FINISH
}

void dtgtk_cairo_paint_filmstrip(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data)
{
gdouble sw = 0.6;
Expand Down
2 changes: 2 additions & 0 deletions src/dtgtk/paint.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ void dtgtk_cairo_paint_rgb_parade(cairo_t *cr, gint x, gint y, gint w, gint h, g
void dtgtk_cairo_paint_luv(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data);
/** paint JzAzBz icon */
void dtgtk_cairo_paint_jzazbz(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data);
/** paint RYB icon */
void dtgtk_cairo_paint_ryb(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data);

/** paint active modulegroup icon */
void dtgtk_cairo_paint_modulegroup_active(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data);
Expand Down