19 #ifndef BACKEND_RENDER_HANDLER_AGG_STYLE_H 20 #define BACKEND_RENDER_HANDLER_AGG_STYLE_H 27 #include <boost/ptr_container/ptr_vector.hpp> 28 #pragma GCC diagnostic push 29 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" 30 #include <agg_gradient_lut.h> 31 #include <agg_color_rgba.h> 32 #include <agg_color_gray.h> 33 #include <agg_image_accessors.h> 34 #include <agg_span_allocator.h> 35 #include <agg_span_gradient.h> 36 #include <agg_span_interpolator_linear.h> 37 #include <agg_image_filters.h> 38 #include <agg_span_image_filter_rgb.h> 39 #include <agg_span_image_filter_rgba.h> 40 #include <agg_pixfmt_rgb.h> 41 #include <agg_pixfmt_rgba.h> 42 #pragma GCC diagnostic pop 59 template<
typename FillMode,
typename Pixel>
60 void storeBitmap(
StyleHandler& st,
const agg_bitmap_info* bi,
61 const SWFMatrix& mat,
const SWFCxForm& cx,
63 template<
typename FillMode>
void storeBitmap(
StyleHandler& st,
64 const agg_bitmap_info* bi,
const SWFMatrix& mat,
const SWFCxForm& cx,
68 void storeGradient(
StyleHandler& st,
const GradientFill& fs,
69 const SWFMatrix& mat,
const SWFCxForm& cx);
70 template<
typename Spread>
void storeGradient(
StyleHandler& st,
71 const GradientFill& fs,
const SWFMatrix& mat,
const SWFCxForm& cx);
72 template<
typename Spread,
typename Interpolation>
73 void storeGradient(
StyleHandler& st,
const GradientFill& fs,
74 const SWFMatrix& mat,
const SWFCxForm& cx);
96 bool solid()
const {
return _solid; }
97 agg::rgba8
color()
const {
return _color; }
106 const agg::rgba8 _color;
114 template<
typename P>
struct Type {
115 typedef agg::wrap_mode_repeat Wrap;
116 typedef agg::image_accessor_wrap<P, Wrap, Wrap>
type;
123 template<
typename P>
struct Type {
124 typedef agg::image_accessor_clone<P>
type;
129 template<
typename P,
typename W>
132 typedef typename P::PixelFormat PixelFormat;
134 typedef agg::span_allocator<PixelFormat> Allocator;
135 typedef agg::span_interpolator_linear<agg::trans_affine>
142 typedef agg::pixfmt_rgba32_pre PixelFormat;
144 template<
typename SourceType,
typename Interpolator>
146 typedef agg::span_image_filter_rgba_nn<SourceType, Interpolator>
type;
149 template<
typename SourceType,
typename Interpolator>
151 typedef agg::span_image_filter_rgba_bilinear<SourceType, Interpolator>
159 typedef agg::pixfmt_rgb24_pre PixelFormat;
161 template<
typename SourceType,
typename Interpolator>
163 typedef agg::span_image_filter_rgb_nn<SourceType, Interpolator>
type;
166 template<
typename SourceType,
typename Interpolator>
168 typedef agg::span_image_filter_rgb_bilinear<SourceType, Interpolator>
174 template<
typename P,
typename W>
175 struct NN :
public FilterType<P, W>
177 typedef FilterType<P, W> BaseType;
178 typedef typename P::template Simple<
179 typename BaseType::SourceType,
180 typename BaseType::Interpolator>
::type Generator;
184 template<
typename P,
typename W>
185 struct AA :
public FilterType<P, W>
187 typedef FilterType<P, W> BaseType;
188 typedef typename P::template AntiAlias<
189 typename BaseType::SourceType,
190 typename BaseType::Interpolator>
::type Generator;
196 template<
typename T>
struct Type {
197 typedef agg::gradient_reflect_adaptor<T>
type;
204 template<
typename T>
struct Type {
205 typedef agg::gradient_repeat_adaptor<T>
type;
212 template<
typename T>
struct Type {
218 struct InterpolatorLinearRGB
220 template<
typename Pixel>
struct Type {
221 typedef agg::gradient_lut<linear_rgb_interpolator<Pixel>, 256>
type;
226 struct InterpolatorRGB
228 template<
typename Pixel>
struct Type {
229 typedef agg::gradient_lut<agg::color_interpolator<Pixel>, 256>
type;
238 template <
class Color,
class Allocator,
class Interpolator,
class GradientType,
239 class Adaptor,
class ColorInterpolator,
class SpanGenerator>
240 class GradientStyle :
public AggStyle 245 SWFCxForm cx,
int norm_size, GradientType gr = GradientType())
249 m_tr(mat.
a() / 65536.0, mat.
b() / 65536.0, mat.
c() / 65536.0,
250 mat.
d() / 65536.0, mat.
tx(), mat.
ty()),
266 for (
size_t i = 0;
i != size; ++
i) {
277 virtual ~GradientStyle() { }
280 m_sg.generate(span, x, y, len);
321 template<
typename G,
typename A,
typename I>
324 typedef agg::rgba8 Color;
325 typedef G GradientType;
328 typedef agg::span_allocator<Color> Allocator;
329 typedef agg::span_interpolator_linear<agg::trans_affine> Interpolator;
330 typedef agg::span_gradient<Color, Interpolator, Adaptor,
331 ColorInterpolator> Generator;
332 typedef GradientStyle<Color, Allocator, Interpolator, GradientType,
333 Adaptor, ColorInterpolator, Generator>
Type;
339 class SolidStyle :
public AggStyle
343 SolidStyle(
const agg::rgba8&
color)
345 AggStyle(
true, color)
361 template <
class PixelFormat,
class Allocator,
class SourceType,
362 class Interpolator,
class Generator>
363 class BitmapStyle :
public AggStyle
368 const SWFMatrix& mat, SWFCxForm cx)
372 m_rbuf(data, width, height, rowlen),
375 m_tr(mat.a() / 65535.0, mat.b() / 65535.0, mat.c() / 65535.0,
376 mat.d() / 65535.0, mat.tx(), mat.ty()),
377 m_interpolator(
m_tr),
378 m_sg(m_img_src, m_interpolator)
382 virtual ~BitmapStyle() {
387 m_sg.generate(span, x, y, len);
389 const bool transform = (
m_cx != SWFCxForm());
391 for (
size_t i = 0;
i < len; ++
i) {
394 span->r = std::min(span->r, span->a);
395 span->g = std::min(span->g, span->a);
396 span->b = std::min(span->b, span->a);
398 m_cx.transform(span->r, span->g, span->b, span->a);
411 agg::rendering_buffer m_rbuf;
418 SourceType m_img_src;
421 agg::trans_affine
m_tr;
424 Interpolator m_interpolator;
451 assert(style <
_styles.size());
457 SolidStyle *st =
new SolidStyle(color);
463 const SWFCxForm& cx,
bool repeat,
bool smooth) {
469 storeBitmap<Tile>(*
this, bi, mat, cx, smooth);
473 storeBitmap<Clip>(*
this, bi, mat, cx, smooth);
490 typename T::GradientType gr;
494 typename T::Type* st =
new typename T::Type(fs, mat, cx, 32.0, gr);
515 agg::rgba8
color(
unsigned style)
const 525 unsigned len,
unsigned style)
527 _styles[style].generate_span(span,x,y,len);
535 template<
typename Filter>
void 539 typedef typename Filter::PixelFormat PixelFormat;
540 typedef typename Filter::Generator Generator;
541 typedef typename Filter::Allocator Allocator;
542 typedef typename Filter::SourceType SourceType;
543 typedef typename Filter::Interpolator Interpolator;
545 typedef BitmapStyle<PixelFormat, Allocator,
546 SourceType, Interpolator, Generator> Style;
573 const agg::gray8&
color(
unsigned )
const 597 _stageMatrix(stage.invert()),
598 _fillMatrix(fill.invert()),
609 storeGradient(_sh, f, m, _cx);
617 _sh.add_color(agg::rgba8_pre(color.
m_r, color.
m_g, color.
m_b,
655 _sh.add_color(agg::rgba8_pre(255,0,0,255));
659 _sh.add_color(agg::rgba8_pre(0,0,0,0));
662 _sh.add_bitmap(dynamic_cast<const agg_bitmap_info*>(bm),
663 m, _cx, tiled, smooth);
681 template<
typename FillMode,
typename Pixel>
687 st.addBitmap<AA<Pixel, FillMode> >(bi, mat, cx);
690 st.addBitmap<NN<Pixel, FillMode> >(bi, mat, cx);
693 template<
typename FillMode>
700 storeBitmap<FillMode, RGB>(st, bi, mat, cx, smooth);
703 storeBitmap<FillMode, RGBA>(st, bi, mat, cx, smooth);
706 template<
typename Spread,
typename Interpolation>
712 typedef agg::gradient_x Linear;
713 typedef agg::gradient_radial Radial;
714 typedef agg::gradient_radial_focus Focal;
716 typedef Gradient<Linear, Spread, Interpolation> LinearGradient;
717 typedef Gradient<Focal, Spread, Interpolation> FocalGradient;
718 typedef Gradient<Radial, Spread, Interpolation> RadialGradient;
722 st.addLinearGradient<LinearGradient>(fs, mat, cx);
726 if (fs.focalPoint()) {
727 st.addFocalGradient<FocalGradient>(fs, mat, cx);
730 st.addRadialGradient<RadialGradient>(fs, mat, cx);
734 template<
typename Spread>
741 storeGradient<Spread, InterpolatorRGB>(st, fs, mat, cx);
744 storeGradient<Spread, InterpolatorLinearRGB>(st, fs, mat, cx);
757 storeGradient<Pad>(st, fs, mat, cx);
760 storeGradient<Reflect>(st, fs, mat, cx);
763 storeGradient<Repeat>(st, fs, mat, cx);
772 #endif // BACKEND_RENDER_HANDLER_AGG_STYLE_H void operator()(const SolidFill &f) const
Definition: Renderer_agg_style.h:612
const CachedBitmap * bitmap() const
Get the actual Bitmap data.
Definition: FillStyle.cpp:182
SpanGenerator m_sg
Definition: Renderer_agg_style.h:310
int get_bpp() const
Definition: Renderer_agg_bitmap.h:57
agg::rgba8 m_transparent
Definition: Renderer_agg_style.h:555
bool m_need_premultiply
Definition: Renderer_agg_style.h:313
Definition: Renderer_agg_bitmap.h:31
const GradientRecord & record(size_t i) const
Query the GradientRecord at the specified index.
Definition: FillStyle.h:215
Definition: FillStyle.h:76
std::uint8_t m_b
Definition: RGBA.h:113
Definition: FillStyle.h:162
VGPaint fill
Definition: testr_gtk.cpp:86
~StyleHandler()
Definition: Renderer_agg_style.h:446
SmoothingPolicy smoothingPolicy() const
Get the smoothing policy of this BitmapFill.
Definition: FillStyle.h:122
Definition: Renderer_agg_style.h:438
virtual bool disposed() const =0
Whether the CachedBitmap has been disposed.
Definition: SWFMatrix.h:53
SWFCxForm m_cx
Definition: Renderer_agg_style.h:292
Definition: Renderer_agg_style.h:559
std::int32_t d() const
Definition: SWFMatrix.h:91
A SolidFill containing one color.
Definition: FillStyle.h:246
StyleHandler()
Definition: Renderer_agg_style.h:442
AggStyle(bool solid, agg::rgba8 color=agg::rgba8(0, 0, 0, 0))
Definition: Renderer_agg_style.h:84
Definition: GnashKey.h:163
Definition: GnashKey.h:119
const agg::gray8 & color(unsigned) const
Definition: Renderer_agg_style.h:573
SimpleBuffer data
Definition: LocalConnection_as.cpp:151
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
Quality
Definition: GnashEnums.h:34
Style handler.
Definition: Renderer_agg_style.h:592
type
Definition: GnashKey.h:329
const SWFMatrix & matrix() const
Get the matrix of this BitmapFill.
Definition: FillStyle.h:130
ColorInterpolator m_gradient_lut
Definition: Renderer_agg_style.h:307
agg_mask_style_handler()
Definition: Renderer_agg_style.h:563
Definition: klash_part.cpp:329
std::uint8_t ratio
Definition: FillStyle.h:50
Definition: GnashKey.h:149
Definition: GnashKey.h:152
agg::trans_affine m_tr
Definition: Renderer_agg_style.h:298
void addRadialGradient(const GradientFill &fs, const SWFMatrix &mat, const SWFCxForm &cx)
Definition: Renderer_agg_style.h:502
void operator()(const GradientFill &f) const
Definition: Renderer_agg_style.h:605
Definition: FillStyle.h:161
void operator()(const BitmapFill &f) const
Definition: Renderer_agg_style.h:621
rgba color
Definition: FillStyle.h:51
double focalPoint() const
Get the focal point of this GradientFill.
Definition: FillStyle.h:228
std::uint8_t m_g
Definition: RGBA.h:113
int get_width() const
Definition: Renderer_agg_bitmap.h:55
Definition: FillStyle.h:167
int get_height() const
Definition: Renderer_agg_bitmap.h:56
A GradientFill.
Definition: FillStyle.h:153
SpreadMode spreadMode
Definition: FillStyle.h:232
Type type() const
Get the Type of this BitmapFill.
Definition: FillStyle.h:117
void generate_span(agg::rgba8 *span, int x, int y, unsigned len, unsigned style)
Called by AGG to generate a scanline span for non-solid fills.
Definition: Renderer_agg_style.h:524
Definition: FillStyle.h:166
void addBitmap(const agg_bitmap_info *bi, const SWFMatrix &mat, const SWFCxForm &cx)
Add a bitmap with the specified filter.
Definition: Renderer_agg_style.h:536
Definition: klash_part.cpp:329
Definition: FillStyle.h:168
std::int32_t ty() const
Definition: SWFMatrix.h:99
Definition: FillStyle.h:40
void addFocalGradient(const GradientFill &fs, const SWFMatrix &mat, const SWFCxForm &cx)
Definition: Renderer_agg_style.h:487
std::uint8_t * get_data() const
Definition: Renderer_agg_bitmap.h:59
void generate_span(agg::gray8 *, int, int, int, unsigned)
Definition: Renderer_agg_style.h:578
bool is_solid(unsigned style) const
Called by AGG to ask if a certain style is a solid color.
Definition: Renderer_agg_style.h:450
std::int32_t c() const
Definition: SWFMatrix.h:87
size_t recordCount() const
Get the number of records in this GradientFill.
Definition: FillStyle.h:208
std::int32_t x
Definition: BitmapData_as.cpp:434
bool solid() const
Definition: Renderer_agg_style.h:96
boost::ptr_vector< AggStyle > _styles
Definition: Renderer_agg_style.h:554
void add_color(const agg::rgba8 &color)
Adds a new solid fill color style.
Definition: Renderer_agg_style.h:456
Definition: GnashEnums.h:36
Adaptor m_gradient_adaptor
Definition: Renderer_agg_style.h:304
std::int32_t b() const
Definition: SWFMatrix.h:83
InterpolationMode interpolation
Definition: FillStyle.h:233
const SWFMatrix & matrix() const
Definition: FillStyle.h:191
std::uint8_t m_a
Definition: RGBA.h:113
Definition: GnashKey.h:132
Definition: FillStyle.h:77
std::int32_t y
Definition: BitmapData_as.cpp:435
int get_rowlen() const
Definition: Renderer_agg_bitmap.h:58
void add_bitmap(const agg_bitmap_info *bi, const SWFMatrix &mat, const SWFCxForm &cx, bool repeat, bool smooth)
Adds a new bitmap fill style.
Definition: Renderer_agg_style.h:462
Definition: GnashKey.h:155
Definition: GnashEnums.h:39
agg::rgba8 color(unsigned style) const
Returns the color of a certain fill style (solid)
Definition: Renderer_agg_style.h:515
Allocator m_sa
Definition: Renderer_agg_style.h:295
Definition: GnashKey.h:159
Type type() const
Definition: FillStyle.h:187
void concatenate(const SWFMatrix &m)
Concatenate m's transform onto ours.
Definition: SWFMatrix.cpp:148
std::uint8_t m_r
Definition: RGBA.h:113
A CachedBitmap is created by the renderer in a format of its choosing.
Definition: CachedBitmap.h:37
virtual ~AggStyle()
Definition: Renderer_agg_style.h:95
std::int32_t a() const
Definition: SWFMatrix.h:79
std::int32_t tx() const
Definition: SWFMatrix.h:95
rgba color() const
Get the color of the fill.
Definition: FillStyle.h:268
agg::rgba8 color() const
Definition: Renderer_agg_style.h:97
A BitmapFill.
Definition: FillStyle.h:70
AddStyles(SWFMatrix stage, SWFMatrix fill, const SWFCxForm &c, StyleHandler &sh, Quality q)
Definition: Renderer_agg_style.h:594
Definition: Renderer_agg_style.h:81
Definition: FillStyle.h:87
bool is_solid(unsigned) const
Definition: Renderer_agg_style.h:568
Interpolator m_span_interpolator
Definition: Renderer_agg_style.h:301
void addLinearGradient(const GradientFill &fs, const SWFMatrix &mat, const SWFCxForm &cx)
Definition: Renderer_agg_style.h:477
A basic RGBA type.
Definition: RGBA.h:35