Fixed issue #1247. Problem was missing cache clean on assignment of stipple pattern and line styles

This commit is contained in:
Matthias Koefferlein 2023-01-12 00:11:36 +01:00
parent 5952974095
commit 12e34f9282
4 changed files with 51 additions and 39 deletions

View File

@ -462,6 +462,8 @@ static const char *dither_strings [] = {
// ---------------------------------------------------------------------
// DitherPatternInfo implementation
static tl::Mutex s_mutex;
DitherPatternInfo::DitherPatternInfo ()
: m_width (1), m_height (1), m_order_index (0)
{
@ -482,23 +484,31 @@ DitherPatternInfo &
DitherPatternInfo::operator= (const DitherPatternInfo &d)
{
if (&d != this) {
m_order_index = d.m_order_index;
m_name = d.m_name;
m_width = d.m_width;
m_pattern_stride = d.m_pattern_stride;
m_height = d.m_height;
for (size_t i = 0; i < sizeof (m_pattern) / sizeof (m_pattern [0]); ++i) {
m_pattern [i] = &m_buffer [0] + (d.m_pattern [i] - d.m_buffer);
}
memcpy (m_buffer, d.m_buffer, sizeof (m_buffer));
tl::MutexLocker locker (& s_mutex);
assign_no_lock (d);
}
return *this;
}
bool
void
DitherPatternInfo::assign_no_lock (const DitherPatternInfo &d)
{
m_scaled_pattern.reset ();
m_order_index = d.m_order_index;
m_name = d.m_name;
m_width = d.m_width;
m_pattern_stride = d.m_pattern_stride;
m_height = d.m_height;
for (size_t i = 0; i < sizeof (m_pattern) / sizeof (m_pattern [0]); ++i) {
m_pattern [i] = &m_buffer [0] + (d.m_pattern [i] - d.m_buffer);
}
memcpy (m_buffer, d.m_buffer, sizeof (m_buffer));
}
bool
DitherPatternInfo::same_bitmap (const DitherPatternInfo &d) const
{
if (m_width != d.m_width || m_height != d.m_height) {
@ -597,15 +607,11 @@ DitherPatternInfo::get_bitmap (int width, int height, int frame_width) const
#endif
static tl::Mutex s_mutex;
void
DitherPatternInfo::set_pattern (const uint32_t *pt, unsigned int w, unsigned int h)
{
{
tl::MutexLocker locker (& s_mutex);
m_scaled_pattern.reset (0);
}
tl::MutexLocker locker (& s_mutex);
m_scaled_pattern.reset (0);
set_pattern_impl (pt, w, h);
}
@ -669,10 +675,8 @@ DitherPatternInfo::set_pattern_impl (const uint32_t *pt, unsigned int w, unsigne
void
DitherPatternInfo::set_pattern (const uint64_t *pt, unsigned int w, unsigned int h)
{
{
tl::MutexLocker locker (& s_mutex);
m_scaled_pattern.reset (0);
}
tl::MutexLocker locker (& s_mutex);
m_scaled_pattern.reset (0);
set_pattern_impl (pt, w, h);
}
@ -752,7 +756,7 @@ DitherPatternInfo::scaled (unsigned int n) const
}
DitherPatternInfo &sp = (*m_scaled_pattern) [n];
sp = *this;
sp.assign_no_lock (*this);
sp.scale_pattern (n);
return sp;
}

View File

@ -243,6 +243,7 @@ private:
void set_pattern_impl (const uint32_t *pattern, unsigned int w, unsigned int h);
void set_pattern_impl (const uint64_t *pattern, unsigned int w, unsigned int h);
void assign_no_lock (const DitherPatternInfo &other);
};
/**

View File

@ -75,6 +75,8 @@ static const char *style_strings [] = {
// ---------------------------------------------------------------------
// LineStyleInfo implementation
static tl::Mutex s_mutex;
LineStyleInfo::LineStyleInfo ()
: m_width (0), m_order_index (0)
{
@ -92,19 +94,26 @@ LineStyleInfo &
LineStyleInfo::operator= (const LineStyleInfo &d)
{
if (&d != this) {
m_order_index = d.m_order_index;
m_name = d.m_name;
m_width = d.m_width;
m_pattern_stride = d.m_pattern_stride;
memcpy (m_pattern, d.m_pattern, sizeof (m_pattern));
tl::MutexLocker locker (& s_mutex);
assign_no_lock (d);
}
return *this;
}
bool
void
LineStyleInfo::assign_no_lock (const LineStyleInfo &d)
{
m_scaled_pattern.reset (0);
m_order_index = d.m_order_index;
m_name = d.m_name;
m_width = d.m_width;
m_pattern_stride = d.m_pattern_stride;
memcpy (m_pattern, d.m_pattern, sizeof (m_pattern));
}
bool
LineStyleInfo::same_bits (const LineStyleInfo &d) const
{
if (m_width != d.m_width) {
@ -201,15 +210,11 @@ LineStyleInfo::get_bitmap (int width, int height) const
}
#endif
static tl::Mutex s_mutex;
void
LineStyleInfo::set_pattern (uint32_t pt, unsigned int w)
{
{
tl::MutexLocker locker (& s_mutex);
m_scaled_pattern.reset (0);
}
tl::MutexLocker locker (& s_mutex);
m_scaled_pattern.reset (0);
memset (m_pattern, 0, sizeof (m_pattern));
@ -271,7 +276,7 @@ LineStyleInfo::scaled (unsigned int n) const
}
LineStyleInfo &sp = (*m_scaled_pattern) [n];
sp = *this;
sp.assign_no_lock (*this);
sp.scale_pattern (n);
return sp;
}

View File

@ -216,6 +216,8 @@ private:
unsigned int m_order_index;
std::string m_name;
mutable std::unique_ptr<std::map<unsigned int, LineStyleInfo> > m_scaled_pattern;
void assign_no_lock (const LineStyleInfo &other);
};
/**