8000 Use Agg workarounds in image module as well · matplotlib/matplotlib@14448fa · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 14448fa

Browse files
committed
Use Agg workarounds in image module as well
1 parent 86c4436 commit 14448fa

File tree

2 files changed

+6
-41
lines changed

2 files changed

+6
-41
lines changed

src/_backend_agg.h

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,45 +37,7 @@
3737
#include "_backend_agg_basic_types.h"
3838
#include "path_converters.h"
3939
#include "array.h"
40-
41-
/**********************************************************************
42-
WORKAROUND: This class is to workaround a bug in Agg SVN where the
43-
blending of RGBA32 pixels does not preserve enough precision
44-
*/
45-
46-
template<class ColorT, class Order>
47-
struct fixed_blender_rgba_plain : agg::conv_rgba_plain<ColorT, Order>
48-
{
49-
typedef ColorT color_type;
50-
typedef Order order_type;
51-
typedef typename color_type::value_type value_type;
52-
typedef typename color_type::calc_type calc_type;
53-
typedef typename color_type::long_type long_type;
54-
enum base_scale_e { base_shift = color_type::base_shift };
55-
56-
//--------------------------------------------------------------------
57-
static AGG_INLINE void blend_pix(value_type* p,
58-
value_type cr, value_type cg, value_type cb, value_type alpha, agg::cover_type cover)
59-
{
60-
blend_pix(p, cr, cg, cb, color_type::mult_cover(alpha, cover));
61-
}
62-
63-
//--------------------------------------------------------------------
64-
static AGG_INLINE void blend_pix(value_type* p,
65-
value_type cr, value_type cg, value_type cb, value_type alpha)
66-
{
67-
if(alpha == 0) return;
68-
calc_type a = p[Order::A];
69-
calc_type r = p[Order::R] * a;
70-
calc_type g = p[Order::G] * a;
71-
calc_type b = p[Order::B] * a;
72-
a = ((alpha + a) << base_shift) - alpha * a;
73-
p[Order::A] = (value_type)(a >> base_shift);
74-
p[Order::R] = (value_type)((((cr << base_shift) - r) * alpha + (r << base_shift)) / a);
75-
p[Order::G] = (value_type)((((cg << base_shift) - g) * alpha + (g << base_shift)) / a);
76-
p[Order::B] = (value_type)((((cb << base_shift) - b) * alpha + (b << base_shift)) / a);
77-
}
78-
};
40+
#include "agg_workaround.h"
7941

8042
/**********************************************************************/
8143

src/_image.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@
2525

2626
#include "_image.h"
2727
#include "mplutils.h"
28+
#include "agg_workaround.h"
2829

29-
typedef agg::pixfmt_rgba32_plain pixfmt;
30-
typedef agg::pixfmt_rgba32_pre pixfmt_pre;
30+
typedef fixed_blender_rgba_plain<agg::rgba8, agg::order_rgba> fixed_blender_rgba32_plain;
31+
typedef agg::pixfmt_alpha_blend_rgba<fixed_blender_rgba32_plain, agg::rendering_buffer> pixfmt;
32+
typedef fixed_blender_rgba_pre<agg::rgba8, agg::order_rgba> fixed_blender_rgba32_pre;
33+
typedef agg::pixfmt_alpha_blend_rgba<fixed_blender_rgba32_pre, agg::rendering_buffer> pixfmt_pre;
3134
typedef agg::renderer_base<pixfmt> renderer_base;
3235
typedef agg::span_interpolator_linear<> interpolator_type;
3336
typedef agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_dbl> rasterizer;

0 commit comments

Comments
 (0)
0