Skip to content

Commit

Permalink
Fix linear light blend mode in text recordings
Browse files Browse the repository at this point in the history
The name contains a space, which is not allowed for draw dabs messages.
We now use an alternate name that doesn't contain a space in those
cases, ORA export still uses the Krita-compatible name.
  • Loading branch information
askmeaboutlo0m committed Aug 7, 2023
1 parent b777acf commit 2ffa977
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
22 changes: 21 additions & 1 deletion src/drawdance/libmsg/dpmsg/blend_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
#define INCREASE_OPACITY (1 << 3)
#define BLEND_BLANK (1 << 4)

// The Krita name for the linear light blend mode contains a space, which isn't
// supported in draw dabs messages, since they already use the curly brace body
// for the dab data. So we have to use this alternate, spaceless name instead.
#define LINEAR_LIGHT_TEXT_NAME "-dp-linear-light"

typedef struct DP_BlendModeAttributes {
int flags;
const char *enum_name;
Expand Down Expand Up @@ -280,6 +285,16 @@ const char *DP_blend_mode_svg_name(int blend_mode)
return get_attributes(blend_mode)->svg_name;
}

const char *DP_blend_mode_text_name(int blend_mode)
{
if (blend_mode == DP_BLEND_MODE_LINEAR_LIGHT) {
return LINEAR_LIGHT_TEXT_NAME;
}
else {
return DP_blend_mode_svg_name(blend_mode);
}
}

bool DP_blend_mode_can_increase_opacity(int blend_mode)
{
return get_attributes(blend_mode)->flags & INCREASE_OPACITY;
Expand Down Expand Up @@ -307,5 +322,10 @@ DP_BlendMode DP_blend_mode_by_svg_name(const char *svg_name,
mode_attributes[DP_BLEND_MODE_REPLACE].svg_name)) {
return DP_BLEND_MODE_REPLACE;
}
return not_found_value;
else if (DP_str_equal(svg_name, LINEAR_LIGHT_TEXT_NAME)) {
return DP_BLEND_MODE_LINEAR_LIGHT;
}
else {
return not_found_value;
}
}
2 changes: 2 additions & 0 deletions src/drawdance/libmsg/dpmsg/blend_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ const char *DP_blend_mode_enum_name_unprefixed(int blend_mode);

const char *DP_blend_mode_svg_name(int blend_mode);

const char *DP_blend_mode_text_name(int blend_mode);

bool DP_blend_mode_can_increase_opacity(int blend_mode);

bool DP_blend_mode_can_decrease_opacity(int blend_mode);
Expand Down
2 changes: 1 addition & 1 deletion src/drawdance/libmsg/dpmsg/text_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ bool DP_text_writer_write_blend_mode(DP_TextWriter *writer, const char *key,
DP_ASSERT(writer);
DP_ASSERT(key);
return DP_text_writer_write_string(writer, key,
DP_blend_mode_svg_name(blend_mode));
DP_blend_mode_text_name(blend_mode));
}

static bool buffer_wrapped_argument(DP_TextWriter *writer, const char *key,
Expand Down

0 comments on commit 2ffa977

Please sign in to comment.