[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash backend/render_handler_agg.cpp ChangeLog ...
From: |
Udo Giacomozzi |
Subject: |
[Gnash-commit] gnash backend/render_handler_agg.cpp ChangeLog ... |
Date: |
Thu, 26 Oct 2006 08:22:18 +0000 |
CVSROOT: /cvsroot/gnash
Module name: gnash
Changes by: Udo Giacomozzi <udog> 06/10/26 08:22:18
Modified files:
backend : render_handler_agg.cpp
. : ChangeLog
Added files:
backend : render_handler_agg_style.h
Log message:
Fully implemented bitmap and gradient fill styles and split
render_handler_agg.cpp file for better readability
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_agg.cpp?cvsroot=gnash&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_agg_style.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1393&r2=1.1394
Patches:
Index: backend/render_handler_agg.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/backend/render_handler_agg.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- backend/render_handler_agg.cpp 24 Oct 2006 12:59:00 -0000 1.27
+++ backend/render_handler_agg.cpp 26 Oct 2006 08:22:18 -0000 1.28
@@ -34,7 +34,7 @@
// forward this exception.
-/* $Id: render_handler_agg.cpp,v 1.27 2006/10/24 12:59:00 bjacques Exp $ */
+/* $Id: render_handler_agg.cpp,v 1.28 2006/10/26 08:22:18 udog Exp $ */
// Original version by Udo Giacomozzi and Hannes Mayr,
// INDUNET GmbH (www.indunet.it)
@@ -59,17 +59,33 @@
fills:
solid fills COMPLETE
- gradients NOT IMPLEMENTED
- bitmaps NOT IMPLEMENTED
+ linear gradients COMPLETE
+ radial gradients COMPLETE
+ focal gradients NOT IMPLEMENTED *
+ bitmaps, tiled COMPLETE
+ bitmaps, clipped COMPLETE
+ bitmaps, smooth COMPLETE
+ bitmaps, hard COMPLETE
+ color xform COMPLETE
+
+ * focal gradients (introduced in Flash 7, I think) are not yet supported
+ by Gnash itself AFAIK, but AGG supports them and it should be easy to add
+ them.
fonts COMPLETE
masks NOT IMPLEMENTED (masks are drawn as shapes)
- caching currently working on it...
+ caching NONE IMPLEMENTED
video don't know how that works
+
+
+AGG ressources:
+ http://www.antigrain.com/
+ http://haiku-os.org/node/86
+
*/
#ifdef HAVE_CONFIG_H
@@ -118,7 +134,16 @@
#include <agg_renderer_primitives.h>
#include <agg_gamma_functions.h>
#include <agg_math_stroke.h>
+#include <agg_image_filters.h>
+#include <agg_image_accessors.h>
+#include <agg_span_image_filter_rgb.h>
+#include <agg_span_image_filter_rgba.h>
+#include <agg_span_interpolator_linear.h>
+#include <agg_span_gradient.h>
+#include <agg_gradient_lut.h>
+#include "render_handler_agg_bitmap.h"
+#include "render_handler_agg_style.h"
using namespace gnash;
@@ -126,18 +151,6 @@
-class bitmap_info_agg : public gnash::bitmap_info
-{
-public:
-
- bitmap_info_agg() {
- //log_msg("bitmap_info_agg instance");
- // dummy
- }
-
-};
-
-
namespace gnash {
// --- CACHE
-------------------------------------------------------------------
@@ -175,46 +188,6 @@
};
-// --- AGG HELPER CLASSES
------------------------------------------------------
-
-// Style handler for AGG's compound rasterizer.
-class agg_style_handler
-{
-public:
- agg_style_handler() :
- m_transparent(0, 0, 0, 0)
- {}
-
- /// Called by AGG to ask if a certain style is a solid color
- bool is_solid(unsigned style) const {
- return true; // The backend currently only supports solid fills
- }
-
- /// Adds a new solid fill color style
- void add(const agg::rgba8 color) {
- m_colors.push_back(color);
- }
-
- /// Returns the color of a certain fill style (solid)
- const agg::rgba8& color(unsigned style) const
- {
- if (style < m_colors.size())
- return m_colors[style];
-
- return m_transparent;
- }
-
- /// Called by AGG to generate a scanline span for non-solid fills
- void generate_span(agg::rgba8* span, int x, int y, unsigned len, unsigned
style)
- {
- // non-solid fills currently not supported
- }
-
-
-private:
- std::vector<agg::rgba8> m_colors;
- agg::rgba8 m_transparent;
-}; // class agg_style_handler
@@ -253,8 +226,9 @@
gnash::matrix m_current_matrix;
gnash::cxform m_current_cxform;
- void set_antialiased(bool /*enable*/) {
- // dummy
+ void set_antialiased(bool enable) {
+ // enable=false *forces* all bitmaps to be rendered in low quality
+ m_enable_antialias = enable;
}
// Style state.
@@ -272,10 +246,9 @@
// that can later be passed to fill_styleX_bitmap(), to set a
// bitmap fill style.
{
- UNUSED(im);
- // bitmaps currently not supported! - return dummy for fontlib
- return new bitmap_info_agg();
- return NULL;
+ return new agg_bitmap_info<agg::pixfmt_rgb24> (im->m_width,
im->m_height,
+ im->m_pitch, im->m_data, 24);
+ assert(0);
}
@@ -286,10 +259,8 @@
//
// This version takes an image with an alpha channel.
{
- UNUSED(im);
- // bitmaps currently not supported! - return dummy for fontlib
- return new bitmap_info_agg();
- return NULL;
+ return new agg_bitmap_info<agg::pixfmt_rgba32> (im->m_width,
im->m_height,
+ im->m_pitch, im->m_data, 32);
}
@@ -301,20 +272,20 @@
// textures into these bitmap infos.
{
// bitmaps currently not supported! - return dummy for fontlib
- return new bitmap_info_agg();
- return NULL;
+ unsigned char dummy=0;
+ return new agg_bitmap_info<agg::pixfmt_rgb24> (0, 0, 0, &dummy, 24);
}
- gnash::bitmap_info* create_bitmap_info_alpha(int w, int h, uint8_t* data)
+ gnash::bitmap_info* create_bitmap_info_alpha(int /*w*/, int /*h*/, uint8_t*
/*data*/)
// Create a bitmap_info so that it contains an alpha texture
// with the given data (1 byte per texel).
{
- UNUSED(w);
- UNUSED(h);
- UNUSED(data);
- // bitmaps currently not supported! - return dummy for fontlib
- return new bitmap_info_agg();
- return NULL;
+ //return new agg_bitmap_info<agg::pixfmt_gray8> (w, h, w, data, 8);
+
+ // where is this used, anyway??
+ log_msg("create_bitmap_info_alpha() currently not supported");
+
+ return new bitmap_info();
}
@@ -333,6 +304,8 @@
bpp = bits_per_pixel;
m_pixf = NULL;
+ m_enable_antialias = true;
+
}
// Destructor
@@ -506,6 +479,7 @@
// Intended for textured glyph rendering.
{
log_msg(" draw_bitmap NOT IMPLEMENTED\n");
+ // could be implemented, but is not used
}
void begin_submit_mask()
@@ -743,7 +717,7 @@
need_single_fill_style(color);
// draw the shape
- draw_shape(paths, m_single_fill_styles, m_neutral_cxform, false);
+ draw_shape(paths, m_single_fill_styles, m_neutral_cxform, mat, false);
// NOTE: Do not use even-odd filling rule for glyphs!
}
@@ -760,7 +734,7 @@
apply_matrix_to_path(def->get_paths(), paths, mat);
- draw_shape(paths, fill_styles, cx, true);
+ draw_shape(paths, fill_styles, cx, mat, true);
draw_outlines(paths, line_styles, cx);
}
@@ -816,8 +790,11 @@
/// Draws the given path using the given fill style and color transform.
/// Normally, Flash shapes are drawn using even-odd filling rule. However,
/// for glyphs non-zero filling rule should be used (even_odd=0).
+ /// Note the paths have already been transformed by the matrix and
+ /// 'fillstyle_matrix' is only provided for bitmap transformations.
void draw_shape(const std::vector<path> &paths,
- const std::vector<fill_style> &fill_styles, const cxform& cx, int
even_odd) {
+ const std::vector<fill_style> &fill_styles, const cxform& cx,
+ const matrix& fillstyle_matrix, int even_odd) {
/*
Fortunately, AGG provides a rasterizer that fits perfectly to the flash
@@ -861,16 +838,72 @@
fcount = fill_styles.size();
//log_msg("%d fill styles\n", fcount);
for (fno=0; fno<fcount; fno++) {
+
+ bool smooth=false;
+ int fill_type = fill_styles[fno].get_type();
+
+ switch (fill_type) {
+
+ case SWF::FILL_LINEAR_GRADIENT:
+ {
+ matrix m = fill_styles[fno].get_gradient_matrix();
+ matrix cm;
+ cm.set_inverse(fillstyle_matrix);
+ m.concatenate(cm);
+ m.concatenate_scale(20.0f);
+
+ sh.add_gradient_linear(fill_styles[fno], m, cx);
+ break;
+ }
+
+ case SWF::FILL_RADIAL_GRADIENT:
+ {
+ matrix m = fill_styles[fno].get_gradient_matrix();
+ matrix cm;
+ cm.set_inverse(fillstyle_matrix);
+ m.concatenate(cm);
+ m.concatenate_scale(20.0f);
+
+ sh.add_gradient_radial(fill_styles[fno], m, cx);
+ break;
+ }
+
+ case SWF::FILL_TILED_BITMAP:
+ case SWF::FILL_CLIPPED_BITMAP:
+ smooth=true; // continue with next case!
+
+ case SWF::FILL_TILED_BITMAP_HARD:
+ case SWF::FILL_CLIPPED_BITMAP_HARD:
+ {
+ matrix m = fill_styles[fno].get_bitmap_matrix();
+ matrix cm;
+ cm.set_inverse(fillstyle_matrix);
+ m.concatenate(cm);
+ m.concatenate_scale(20.0f);
+
+ sh.add_bitmap(dynamic_cast<agg_bitmap_info_base*>
+ (fill_styles[fno].get_bitmap_info()), m, cx,
+ (fill_type==SWF::FILL_TILED_BITMAP) ||
(fill_type==SWF::FILL_TILED_BITMAP_HARD),
+ smooth && m_enable_antialias);
+ break;
+ }
+
+ case SWF::FILL_SOLID:
+ default:
+ {
rgba color = cx.transform(fill_styles[fno].get_color());
// add the color to our self-made style handler (basically just a list)
- sh.add(agg::rgba8(color.m_r, color.m_g, color.m_b, color.m_a));
+ sh.add_color(agg::rgba8(color.m_r, color.m_g, color.m_b, color.m_a));
}
+ } // switch
+ } // for
+
// push paths to AGG
pcount = paths.size();
- //log_msg("%d paths\n", pcount);
+
for (pno=0; pno<pcount; pno++) {
const path &this_path = paths[pno];
Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnash/gnash/ChangeLog,v
retrieving revision 1.1393
retrieving revision 1.1394
diff -u -b -r1.1393 -r1.1394
--- ChangeLog 25 Oct 2006 19:21:35 -0000 1.1393
+++ ChangeLog 26 Oct 2006 08:22:18 -0000 1.1394
@@ -1,3 +1,14 @@
+2006-10-26 Udo Giacomozzi <address@hidden>
+
+ * server/gnash.h, server/styles.cpp, server/styles.h,
+ server/types.cpp: Added new methods for read access to
+ some members and for faster color transform.
+ * backend/render_handler_agg.cpp,
+ backend/render_handler_agg_bitmap.h,
+ backend/render_handler_agg_style.h: Fully implemented
+ bitmap and gradient fill styles and split main AGG
+ renderer file for better readability.
+
2006-10-25 Sandro Santilli <address@hidden>
* server/as_object.h: get_member() method taking
Index: backend/render_handler_agg_style.h
===================================================================
RCS file: backend/render_handler_agg_style.h
diff -N backend/render_handler_agg_style.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ backend/render_handler_agg_style.h 26 Oct 2006 08:22:18 -0000 1.1
@@ -0,0 +1,619 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+// Linking Gnash statically or dynamically with other modules is making a
+// combined work based on Gnash. Thus, the terms and conditions of the GNU
+// General Public License cover the whole combination.
+//
+// As a special exception, the copyright holders of Gnash give you
+// permission to combine Gnash with free software programs or libraries
+// that are released under the GNU LGPL and with code included in any
+// release of Talkback distributed by the Mozilla Foundation. You may
+// copy and distribute such a system following the terms of the GNU GPL
+// for all but the LGPL-covered parts and Talkback, and following the
+// LGPL for the LGPL-covered parts.
+//
+// Note that people who make modified versions of Gnash are not obligated
+// to grant this special exception for their modified versions; it is their
+// choice whether to do so. The GNU General Public License gives permission
+// to release a modified version without this exception; this exception
+// also makes it possible to release a modified version which carries
+// forward this exception.
+//
+//
+
+#ifndef BACKEND_RENDER_HANDLER_AGG_STYLE_H
+#define BACKEND_RENDER_HANDLER_AGG_STYLE_H
+
+// This include file used only to make render_handler_agg more readable.
+
+
+// TODO: Instead of re-creating AGG fill styles again and again, they should
+// be cached somewhere.
+
+
+using namespace gnash;
+
+namespace gnash {
+
+/// Internal style class that represents a fill style. Roughly speaking, AGG
+/// computes the fill areas of a flash composite shape and calls generate_span
+/// to generate small horizontal pixel rows. generate_span provides whatever
+/// fill pattern for that coordinate.
+class agg_style_base
+{
+public:
+ // for solid styles:
+ bool m_is_solid;
+ agg::rgba8 m_color; // defined here for easy access
+
+ // for non-solid styles:
+ virtual void generate_span(agg::rgba8* span, int x, int y, unsigned len)=0;
+};
+
+
+/// Solid AGG fill style. generate_span is not used in this case as AGG does
+/// solid fill styles internally.
+class agg_style_solid : public agg_style_base
+{
+public:
+
+ agg_style_solid(const agg::rgba8 color) {
+ m_is_solid = true;
+ m_color = color;
+ }
+
+ void generate_span(agg::rgba8* /*span*/, int /*x*/, int /*y*/, unsigned
/*len*/)
+ {
+ assert(0); // never call generate_span for solid fill styles
+ }
+};
+
+
+// Simple hack to get rid of that additional parameter for the
+// image_accessor_clip constructor which breaks template usage.
+template <class PixelFormat>
+class image_accessor_clip_transp : public agg::image_accessor_clip<PixelFormat>
+{
+public:
+ image_accessor_clip_transp(const PixelFormat& pixf) :
+ agg::image_accessor_clip<PixelFormat>::image_accessor_clip(pixf,
+ agg::rgba_pre(0, 0, 0, 0))
+ {
+ }
+};
+
+
+/// AGG bitmap fill style. There are quite a few combinations possible and so
+/// the class types are defined outside. The bitmap can be tiled or clipped.
+/// It can have any transformation matrix and color transform. Any pixel format
+/// can be used, too.
+template <class PixelFormat, class span_allocator_type, class img_source_type,
+ class interpolator_type, class sg_type>
+class agg_style_bitmap : public agg_style_base
+{
+public:
+
+ agg_style_bitmap(int width, int height, int rowlen, uint8_t* data,
+ gnash::matrix mat, gnash::cxform cx) :
+
+ m_rbuf(data, width, height, rowlen),
+ m_pixf(m_rbuf),
+ m_img_src(m_pixf),
+ m_tr(), // initialize later
+ m_interpolator(m_tr),
+ m_sg(m_img_src, m_interpolator)
+ {
+
+ m_is_solid = false;
+
+ // Convert the transformation matrix to AGG's class. It's basically the
+ // same and we could even use gnash::matrix since AGG does not require
+ // a real AGG descendant (templates!). However, it's better to use AGG's
+ // class as this should be faster (avoid type conversion).
+ m_tr=agg::trans_affine(
+ mat.m_[0][0], mat.m_[1][0],
+ mat.m_[0][1], mat.m_[1][1],
+ mat.m_[0][2], mat.m_[1][2]);
+
+ m_cx = cx;
+
+ }
+
+ virtual ~agg_style_bitmap() {
+ }
+
+ void generate_span(agg::rgba8* span, int x, int y, unsigned len)
+ {
+ m_sg.generate(span, x, y, len);
+
+ // Apply color transform
+ // TODO: Check if this can be optimized
+ if (!m_cx.is_identity())
+ for (unsigned int i=0; i<len; i++) {
+ m_cx.transform(span->r, span->g, span->b, span->a);
+ ++span;
+ }
+ }
+
+
+
+private:
+
+ // Color transform
+ gnash::cxform m_cx;
+
+ // Pixel access
+ agg::rendering_buffer m_rbuf;
+ PixelFormat m_pixf;
+
+ // Span allocator
+ span_allocator_type m_sa;
+
+ // Image accessor
+ img_source_type m_img_src;
+
+ // Transformer
+ agg::trans_affine m_tr;
+
+ // Interpolator
+ interpolator_type m_interpolator;
+
+ // Span generator
+ sg_type m_sg;
+};
+
+
+/// AGG gradient fill style. Don't use Gnash texture bitmaps as this is slower
+/// and less accurate. Even worse, the bitmap fill would need to be tweaked
+/// to have non-repeating gradients (first and last color stops continue
+/// forever on each side). This class can be used for any kind of gradient, so
+/// even focal gradients should be possible.
+template <class color_type, class span_allocator_type, class
interpolator_type,
+ class gradient_func_type, class gradient_adaptor_type, class
color_func_type,
+ class sg_type>
+class agg_style_gradient : public agg_style_base {
+public:
+
+ agg_style_gradient(const gnash::fill_style& fs, gnash::matrix mat,
gnash::cxform cx, int norm_size) :
+ m_tr(),
+ m_span_interpolator(m_tr),
+ m_gradient_func(),
+ m_gradient_adaptor(m_gradient_func),
+ m_sg(m_span_interpolator, m_gradient_adaptor, m_gradient_lut, 0,
norm_size)
+ {
+
+ m_is_solid = false;
+
+ m_tr=agg::trans_affine(
+ mat.m_[0][0], mat.m_[1][0],
+ mat.m_[0][1], mat.m_[1][1],
+ mat.m_[0][2], mat.m_[1][2]);
+
+
+ // Built gradient lookup table
+ m_gradient_lut.remove_all();
+
+ for (int i=0; i<fs.get_color_stop_count(); i++) {
+
+ const gradient_record gr = fs.get_color_stop(i);
+
+ m_gradient_lut.add_color(gr.m_ratio/255.0, agg::rgba8(gr.m_color.m_r,
+ gr.m_color.m_g, gr.m_color.m_b, gr.m_color.m_a));
+
+ } // for
+
+ m_gradient_lut.build_lut();
+
+ m_cx = cx;
+
+ } // agg_style_gradient constructor
+
+
+ void generate_span(color_type* span, int x, int y, unsigned len)
+ {
+ m_sg.generate(span, x, y, len);
+
+ // Apply color transform
+ // TODO: Check if this can be optimized
+ if (!m_cx.is_identity())
+ for (unsigned int i=0; i<len; i++) {
+ m_cx.transform(span->r, span->g, span->b, span->a);
+ ++span;
+ }
+ }
+
+private:
+
+
+ // Color transform
+ gnash::cxform m_cx;
+
+ // Span allocator
+ span_allocator_type m_sa;
+
+ // Span interpolator
+ interpolator_type m_span_interpolator;
+
+ gradient_func_type m_gradient_func;
+
+ // Gradient adaptor
+ gradient_adaptor_type m_gradient_adaptor;
+
+ // Gradient LUT
+ color_func_type m_gradient_lut;
+
+ // Transformer
+ agg::trans_affine m_tr;
+
+ // Span generator
+ sg_type m_sg;
+
+}; // agg_style_gradient
+
+
+
+// --- AGG HELPER CLASSES
------------------------------------------------------
+
+/// Style handler for AGG's compound rasterizer. This is the class which is
+/// called by AGG itself. It provides an interface to the various fill style
+/// classes defined above.
+class agg_style_handler
+{
+public:
+
+ agg_style_handler() :
+ m_transparent(0, 0, 0, 0)
+ {}
+
+ /// Called by AGG to ask if a certain style is a solid color
+ bool is_solid(unsigned style) const {
+
+ return m_styles[style]->m_is_solid;
+ }
+
+ /// Adds a new solid fill color style
+ void add_color(const agg::rgba8 color) {
+ agg_style_solid *st = new agg_style_solid(color);
+ m_styles.push_back(st);
+ }
+
+ /// Adds a new bitmap fill style
+ void add_bitmap(agg_bitmap_info_base* bi, gnash::matrix mat, gnash::cxform
cx,
+ bool repeat, bool smooth) {
+
+ if (bi==NULL) {
+ // NOTE: Apparently "bi" can be NULL in some cases and this should not
+ // be treated as an error.
+ log_msg("WARNING: add_bitmap called with bi=NULL");
+ add_color(agg::rgba8(0,0,0,0));
+ return;
+ }
+
+ // Whew! There are 8 bitmap combinations (bpp, smooth, repeat) possible
+ // and AGG uses templates, so...
+ // I'd need to pass "span_image_filter_rgba_nn" (because span_image_xxx
+ // dependends on the pixel format) without passing the template
+ // parameters, but AFAIK this can't be done. But hey, this is my first
+ // C++ code (the whole AGG backend) and I immediately had to start with
+ // templates. I'm giving up and write eight versions of add_bitmap_xxx.
+ // So, if anyone has a better solution, for heaven's sake, implement
it!!
+
+ if (repeat) {
+ if (smooth) {
+
+ if (bi->get_bpp()==24)
+ add_bitmap_repeat_aa_rgb24 (bi, mat, cx);
+ else
+ if (bi->get_bpp()==32)
+ add_bitmap_repeat_aa_rgba32 (bi, mat, cx);
+ else
+ assert(0);
+
+ } else {
+
+ if (bi->get_bpp()==24)
+ add_bitmap_repeat_nn_rgb24 (bi, mat, cx);
+ else
+ if (bi->get_bpp()==32)
+ add_bitmap_repeat_nn_rgba32 (bi, mat, cx);
+ else
+ assert(0);
+
+ } // if smooth
+ } else {
+ if (smooth) {
+
+ if (bi->get_bpp()==24)
+ add_bitmap_clip_aa_rgb24 (bi, mat, cx);
+ else
+ if (bi->get_bpp()==32)
+ add_bitmap_clip_aa_rgba32 (bi, mat, cx);
+ else
+ assert(0);
+
+ } else {
+
+ if (bi->get_bpp()==24)
+ add_bitmap_clip_nn_rgb24 (bi, mat, cx);
+ else
+ if (bi->get_bpp()==32)
+ add_bitmap_clip_nn_rgba32 (bi, mat, cx);
+ else
+ assert(0);
+
+ } // if smooth
+ } // if repeat
+
+ } // add_bitmap
+
+
+ // === RGB24 ===
+
+
+ void add_bitmap_repeat_nn_rgb24(agg_bitmap_info_base* bi, gnash::matrix
mat, gnash::cxform cx) {
+
+ // tiled, nearest neighbor method (faster)
+
+ typedef agg::pixfmt_rgb24 PixelFormat;
+ typedef agg::span_allocator<PixelFormat> span_allocator_type;
+ typedef agg::wrap_mode_repeat wrap_type;
+ typedef agg::image_accessor_wrap<PixelFormat, wrap_type, wrap_type>
img_source_type;
+ typedef agg::span_interpolator_linear_subdiv<agg::trans_affine>
interpolator_type;
+ typedef agg::span_image_filter_rgb_nn<img_source_type,
interpolator_type> sg_type;
+
+ typedef agg_style_bitmap<PixelFormat, span_allocator_type,
img_source_type,
+ interpolator_type, sg_type> st_type;
+
+ st_type* st = new st_type(bi->get_width(), bi->get_height(),
+ bi->get_rowlen(), bi->get_data(), mat, cx);
+
+ m_styles.push_back(st);
+ }
+
+
+
+
+ void add_bitmap_clip_nn_rgb24(agg_bitmap_info_base* bi, gnash::matrix mat,
gnash::cxform cx) {
+
+ // clipped, nearest neighbor method (faster)
+
+ typedef agg::pixfmt_rgb24 PixelFormat;
+ typedef agg::span_allocator<PixelFormat> span_allocator_type;
+ typedef image_accessor_clip_transp<PixelFormat> img_source_type;
+ typedef agg::span_interpolator_linear_subdiv<agg::trans_affine>
interpolator_type;
+ typedef agg::span_image_filter_rgb_nn<img_source_type,
interpolator_type> sg_type;
+
+ typedef agg_style_bitmap<PixelFormat, span_allocator_type,
img_source_type,
+ interpolator_type, sg_type> st_type;
+
+ st_type* st = new st_type(bi->get_width(), bi->get_height(),
+ bi->get_rowlen(), bi->get_data(), mat, cx);
+
+ m_styles.push_back(st);
+ }
+
+
+
+ void add_bitmap_repeat_aa_rgb24(agg_bitmap_info_base* bi, gnash::matrix
mat, gnash::cxform cx) {
+
+ // tiled, bilinear method (better quality)
+
+ typedef agg::pixfmt_rgb24 PixelFormat;
+ typedef agg::span_allocator<PixelFormat> span_allocator_type;
+ typedef agg::wrap_mode_repeat wrap_type;
+ typedef agg::image_accessor_wrap<PixelFormat, wrap_type, wrap_type>
img_source_type;
+ typedef agg::span_interpolator_linear_subdiv<agg::trans_affine>
interpolator_type;
+ typedef agg::span_image_filter_rgb_bilinear<img_source_type,
interpolator_type> sg_type;
+
+ typedef agg_style_bitmap<PixelFormat, span_allocator_type,
img_source_type,
+ interpolator_type, sg_type> st_type;
+
+ st_type* st = new st_type(bi->get_width(), bi->get_height(),
+ bi->get_rowlen(), bi->get_data(), mat, cx);
+
+ m_styles.push_back(st);
+ }
+
+
+ void add_bitmap_clip_aa_rgb24(agg_bitmap_info_base* bi, gnash::matrix mat,
gnash::cxform cx) {
+
+ // clipped, bilinear method (better quality)
+
+ typedef agg::pixfmt_rgb24 PixelFormat;
+ typedef agg::span_allocator<PixelFormat> span_allocator_type;
+ typedef image_accessor_clip_transp<PixelFormat> img_source_type;
+ typedef agg::span_interpolator_linear_subdiv<agg::trans_affine>
interpolator_type;
+ typedef agg::span_image_filter_rgb_bilinear<img_source_type,
interpolator_type> sg_type;
+
+ typedef agg_style_bitmap<PixelFormat, span_allocator_type,
img_source_type,
+ interpolator_type, sg_type> st_type;
+
+ st_type* st = new st_type(bi->get_width(), bi->get_height(),
+ bi->get_rowlen(), bi->get_data(), mat, cx);
+
+ m_styles.push_back(st);
+ }
+
+
+
+ // === RGBA32 ===
+
+ void add_bitmap_repeat_nn_rgba32(agg_bitmap_info_base* bi, gnash::matrix
mat, gnash::cxform cx) {
+
+ // tiled, nearest neighbor method (faster)
+
+ typedef agg::pixfmt_rgba32 PixelFormat;
+ typedef agg::span_allocator<PixelFormat> span_allocator_type;
+ typedef agg::wrap_mode_repeat wrap_type;
+ typedef agg::image_accessor_wrap<PixelFormat, wrap_type, wrap_type>
img_source_type;
+ typedef agg::span_interpolator_linear_subdiv<agg::trans_affine>
interpolator_type;
+ typedef agg::span_image_filter_rgba_nn<img_source_type,
interpolator_type> sg_type;
+
+ typedef agg_style_bitmap<PixelFormat, span_allocator_type,
img_source_type,
+ interpolator_type, sg_type> st_type;
+
+ st_type* st = new st_type(bi->get_width(), bi->get_height(),
+ bi->get_rowlen(), bi->get_data(), mat, cx);
+
+ m_styles.push_back(st);
+ }
+
+
+
+
+ void add_bitmap_clip_nn_rgba32(agg_bitmap_info_base* bi, gnash::matrix
mat, gnash::cxform cx) {
+
+ // clipped, nearest neighbor method (faster)
+
+ typedef agg::pixfmt_rgba32 PixelFormat;
+ typedef agg::span_allocator<PixelFormat> span_allocator_type;
+ typedef image_accessor_clip_transp<PixelFormat> img_source_type;
+ typedef agg::span_interpolator_linear_subdiv<agg::trans_affine>
interpolator_type;
+ typedef agg::span_image_filter_rgba_nn<img_source_type,
interpolator_type> sg_type;
+
+ typedef agg_style_bitmap<PixelFormat, span_allocator_type,
img_source_type,
+ interpolator_type, sg_type> st_type;
+
+ st_type* st = new st_type(bi->get_width(), bi->get_height(),
+ bi->get_rowlen(), bi->get_data(), mat, cx);
+
+ m_styles.push_back(st);
+ }
+
+
+
+ void add_bitmap_repeat_aa_rgba32(agg_bitmap_info_base* bi, gnash::matrix
mat, gnash::cxform cx) {
+
+ // tiled, bilinear method (better quality)
+
+ typedef agg::pixfmt_rgba32 PixelFormat;
+ typedef agg::span_allocator<PixelFormat> span_allocator_type;
+ typedef agg::wrap_mode_repeat wrap_type;
+ typedef agg::image_accessor_wrap<PixelFormat, wrap_type, wrap_type>
img_source_type;
+ typedef agg::span_interpolator_linear_subdiv<agg::trans_affine>
interpolator_type;
+ typedef agg::span_image_filter_rgba_bilinear<img_source_type,
interpolator_type> sg_type;
+
+ typedef agg_style_bitmap<PixelFormat, span_allocator_type,
img_source_type,
+ interpolator_type, sg_type> st_type;
+
+ st_type* st = new st_type(bi->get_width(), bi->get_height(),
+ bi->get_rowlen(), bi->get_data(), mat, cx);
+
+ m_styles.push_back(st);
+ }
+
+
+ void add_bitmap_clip_aa_rgba32(agg_bitmap_info_base* bi, gnash::matrix
mat, gnash::cxform cx) {
+
+ // clipped, bilinear method (better quality)
+
+ typedef agg::pixfmt_rgba32 PixelFormat;
+ typedef agg::span_allocator<PixelFormat> span_allocator_type;
+ typedef image_accessor_clip_transp<PixelFormat> img_source_type;
+ typedef agg::span_interpolator_linear_subdiv<agg::trans_affine>
interpolator_type;
+ typedef agg::span_image_filter_rgba_bilinear<img_source_type,
interpolator_type> sg_type;
+
+ typedef agg_style_bitmap<PixelFormat, span_allocator_type,
img_source_type,
+ interpolator_type, sg_type> st_type;
+
+ st_type* st = new st_type(bi->get_width(), bi->get_height(),
+ bi->get_rowlen(), bi->get_data(), mat, cx);
+
+ m_styles.push_back(st);
+ }
+
+
+ // === GRADIENT ===
+
+ void add_gradient_linear(const gnash::fill_style& fs, gnash::matrix mat,
gnash::cxform cx) {
+
+ typedef agg::rgba8 color_type;
+ typedef agg::span_allocator<color_type> span_allocator_type;
+ typedef agg::span_interpolator_linear<agg::trans_affine>
interpolator_type;
+ typedef agg::gradient_x gradient_func_type;
+ //typedef agg::gradient_repeat_adaptor<gradient_func_type>
gradient_adaptor_type;
+ typedef gradient_func_type gradient_adaptor_type;
+ typedef agg::gradient_lut<agg::color_interpolator<agg::rgba8>, 256>
color_func_type;
+ typedef agg::span_gradient<color_type,
+ interpolator_type,
+ gradient_adaptor_type,
+ color_func_type> sg_type;
+
+ typedef agg_style_gradient<color_type, span_allocator_type,
+ interpolator_type, gradient_func_type, gradient_adaptor_type,
+ color_func_type, sg_type> st_type;
+
+ st_type* st = new st_type(fs, mat, cx, 256);
+
+ // NOTE: The value 256 is based on the bitmap texture used by other
+ // Gnash renderers which is normally 256x1 pixels for linear gradients.
+
+ m_styles.push_back(st);
+ }
+
+
+ void add_gradient_radial(const gnash::fill_style& fs, gnash::matrix mat,
gnash::cxform cx) {
+
+ typedef agg::rgba8 color_type;
+ typedef agg::span_allocator<color_type> span_allocator_type;
+ typedef agg::span_interpolator_linear<agg::trans_affine>
interpolator_type;
+ typedef agg::gradient_radial gradient_func_type;
+ typedef gradient_func_type gradient_adaptor_type;
+ typedef agg::gradient_lut<agg::color_interpolator<agg::rgba8>, 256>
color_func_type;
+ typedef agg::span_gradient<color_type,
+ interpolator_type,
+ gradient_adaptor_type,
+ color_func_type> sg_type;
+
+ typedef agg_style_gradient<color_type, span_allocator_type,
+ interpolator_type, gradient_func_type, gradient_adaptor_type,
+ color_func_type, sg_type> st_type;
+
+ st_type* st = new st_type(fs, mat, cx, 64);
+
+ // NOTE: The value 64 is based on the bitmap texture used by other
+ // Gnash renderers which is normally 64x64 pixels for linear gradients.
+
+ m_styles.push_back(st);
+ }
+
+
+ /// Returns the color of a certain fill style (solid)
+ const agg::rgba8& color(unsigned style) const
+ {
+ if (style < m_styles.size())
+ return m_styles[style]->m_color;
+
+ return m_transparent;
+ }
+
+ /// Called by AGG to generate a scanline span for non-solid fills
+ void generate_span(agg::rgba8* span, int x, int y, unsigned len, unsigned
style)
+ {
+ m_styles[style]->generate_span(span,x,y,len);
+ }
+
+
+private:
+ std::vector<agg_style_base*> m_styles;
+ agg::rgba8 m_transparent;
+}; // class agg_style_handler
+
+
+} // namespace gnash
+
+#endif // BACKEND_RENDER_HANDLER_AGG_STYLE_H
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash backend/render_handler_agg.cpp ChangeLog ...,
Udo Giacomozzi <=