CVSROOT: /sources/gnash Module name: gnash Changes by: Bastiaan Jacques <bjacques> 07/12/01 22:49:19
Modified files: . : ChangeLog backend : render_handler_agg.cpp Removed files: backend : render_handler_tri.cpp render_handler_tri.h Log message: * backend/render_handler_tri.{cpp,h}: Remove these unused files. * backend/render_handler_agg.cpp: Minor cleanups: Avoid calling default constructors (they are called anyway). Switch m_pixf to std::auto_ptr. Remove the unused stubs apply_color and apply_matrix. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5047&r2=1.5048 http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_agg.cpp?cvsroot=gnash&r1=1.118&r2=1.119 http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_tri.cpp?cvsroot=gnash&r1=1.23&r2=0 http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_tri.h?cvsroot=gnash&r1=1.16&r2=0 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.5047 retrieving revision 1.5048 diff -u -b -r1.5047 -r1.5048 --- ChangeLog 1 Dec 2007 22:11:23 -0000 1.5047 +++ ChangeLog 1 Dec 2007 22:49:17 -0000 1.5048 @@ -1,3 +1,11 @@ +2007-12-01 Bastiaan Jacques <[EMAIL PROTECTED]> + + * backend/render_handler_tri.{cpp,h}: Remove these unused + files. + * backend/render_handler_agg.cpp: Minor cleanups: Avoid calling + default constructors (they are called anyway). Switch m_pixf to + std::auto_ptr. Remove the unused stubs apply_color and apply_matrix. + 2007-12-01 Sandro Santilli <[EMAIL PROTECTED]> * testsuite/swfdec/PASSING: sync to master. Index: backend/render_handler_agg.cpp =================================================================== RCS file: /sources/gnash/gnash/backend/render_handler_agg.cpp,v retrieving revision 1.118 retrieving revision 1.119 diff -u -b -r1.118 -r1.119 --- backend/render_handler_agg.cpp 30 Nov 2007 23:11:10 -0000 1.118 +++ backend/render_handler_agg.cpp 1 Dec 2007 22:49:18 -0000 1.119 @@ -17,7 +17,7 @@ -/* $Id: render_handler_agg.cpp,v 1.118 2007/11/30 23:11:10 bjacques Exp $ */ +/* $Id: render_handler_agg.cpp,v 1.119 2007/12/01 22:49:18 bjacques Exp $ */ // Original version by Udo Giacomozzi and Hannes Mayr, // INDUNET GmbH (www.indunet.it) @@ -590,17 +590,11 @@ bpp(bits_per_pixel), /*xscale(1.0/20.0), yscale(1.0/20.0),*/ - stage_matrix(), scale_set(false), m_enable_antialias(true), m_display_width(0.0), m_display_height(0.0), - m_rbuf(), - m_pixf(NULL), // TODO: use an auto_ptr - _clipbounds(), - _clipbounds_selected(), - m_drawing_mask(false), - m_alpha_mask() + m_drawing_mask(false) { // TODO: we really don't want to set the scale here as the core should // tell us the right values before rendering anything. However this is @@ -613,7 +607,6 @@ // Destructor ~render_handler_agg() { - delete m_pixf; } /// Initializes the rendering buffer. The memory pointed by "mem" is not @@ -632,12 +625,10 @@ xres = x; yres = y; - delete m_pixf; - m_rbuf.attach(memaddr, xres, yres, rowstride); // allocate pixel format accessor - m_pixf = new PixelFormat(m_rbuf); + m_pixf.reset(new PixelFormat(m_rbuf)); //m_rbase = new renderer_base(*m_pixf); --> does not work!!?? // by default allow drawing everywhere @@ -666,7 +657,7 @@ // coordinates of the movie that correspond to the viewport // bounds. { - assert(m_pixf != NULL); + assert(m_pixf.get()); assert(scale_set); // clear the stage using the background color @@ -728,21 +719,6 @@ // nothing to do } - static void apply_matrix(const gnash::matrix& /*m*/) - // add user space transformation - { - // TODO: what's the use for this, anyway?? - log_msg("apply_matrix(); called - NOT IMPLEMENTED"); - } - - static void apply_color(const gnash::rgba& /*c*/) - // Set the given color. - { - // TODO: what's the use for this, anyway?? - log_msg("apply_color(); called - NOT IMPLEMENTED"); - } - - template <class ras_type> void apply_clip_box(ras_type& ras, const geometry::Range2d<int>& bounds) @@ -762,7 +738,7 @@ // Draw the line strip formed by the sequence of points. { - assert(m_pixf != NULL); + assert(m_pixf.get()); matrix mat = stage_matrix; mat.concatenate(line_mat); @@ -1544,7 +1520,7 @@ Thank to Maxim Shemanarev for providing us such a great tool with AGG... */ - assert(m_pixf != NULL); + assert(m_pixf.get()); assert(!m_drawing_mask); @@ -1771,7 +1747,7 @@ const std::vector<line_style> &line_styles, const cxform& cx, const matrix& linestyle_matrix, scanline_type& sl) { - assert(m_pixf != NULL); + assert(m_pixf.get()); if (m_drawing_mask) // Flash ignores lines in mask /definitions/ return; @@ -1862,7 +1838,7 @@ void draw_poly_impl(const point* corners, size_t corner_count, const rgba& fill, const rgba& outline, scanline_type& sl, const matrix& poly_mat) { - assert(m_pixf != NULL); + assert(m_pixf.get()); if (corner_count<1) return; @@ -2129,8 +2105,7 @@ agg::rendering_buffer m_rbuf; - // TODO: use an auto_ptr, since we're deleting in the destructor... - PixelFormat *m_pixf; + std::auto_ptr<PixelFormat> m_pixf; /// clipping rectangle std::vector< geometry::Range2d<int> > _clipbounds; Index: backend/render_handler_tri.cpp =================================================================== RCS file: backend/render_handler_tri.cpp diff -N backend/render_handler_tri.cpp --- backend/render_handler_tri.cpp 10 Nov 2007 11:51:42 -0000 1.23 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,381 +0,0 @@ -// -// Copyright (C) 2005, 2006, 2007 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 3 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 - -// -// - -/* $Id: render_handler_tri.cpp,v 1.23 2007/11/10 11:51:42 strk Exp $ */ - -#include "render_handler_tri.h" - -#ifndef RENDER_HANDLER_H -#error missing includes! -#endif - -#ifndef GNASH_RENDER_HANDLER_TRI_H -#error missing includes! -#endif - -#include "log.h" - -#include <boost/scoped_array.hpp> - -namespace gnash { - -bool SortByDecreasingError(const mesh_set& lhs, const mesh_set& rhs) -{ - float ltol = lhs.get_error_tolerance(); - float rtol = rhs.get_error_tolerance(); - - return ltol < rtol; -} - -/// Takes a vector and copies all the values into an array. The array's memory -/// is guaranteed to be contiguous, unlike the vector's. -template <typename T> -void vector_to_array(const std::vector<T>& vec, boost::scoped_array<T>& array) -{ - using namespace boost; - size_t vec_size = vec.size(); - - array.reset(new T[vec_size]); - - for (size_t i = 0; i < vec_size; i++) { - array[i] = vec[i]; - } -} - - -//------------------------------------------------------------------------------ - -mesh_set* tri_cache_manager::search_candidate(float max_error) { - - for (unsigned int i=0,n=m_cached_meshes.size(); i<n; i++) { - - mesh_set& candidate = m_cached_meshes[i]; - float candidate_etol = candidate.get_error_tolerance(); - - if (max_error > candidate_etol * 3.0f) { - // Mesh is too high-res; the remaining meshes are higher res, - // so stop searching and build an appropriately scaled mesg. - break; - } - - if (max_error > candidate_etol) { - // found it! - return &candidate; - } - - } // for - - // when we come here it means that no candidate could be found... :-( - return NULL; - -} // search_candidate - - -/// Adds a mesh set to the cache. -void tri_cache_manager::add(mesh_set* m) { - m_cached_meshes.push_back(*m); - sort_and_clean_meshes(); -} // add - - -/// Maintain cached meshes. Clean out mesh_sets that haven't been used -/// recently, and make sure they're sorted from high error to low error. -void tri_cache_manager::sort_and_clean_meshes() { - - // Re-sort. - if (!m_cached_meshes.size()) { - return; - } - - std::sort(m_cached_meshes.begin(), m_cached_meshes.end(), - SortByDecreasingError); - - // TODO: The cache will grow forever, without any limit. Add code that - // limits the vector to a certain size. The older Gnash implementation - // appears to never have removed unused cache objects! - - // Sort check omitted! - -} // sort_and_clean_meshes - - - -//------------------------------------------------------------------------------ - -// Can't initialize this in header, for ISO C++ conformance: -// error: ISO C++ forbids initialization of member constant `s_curve_max_pixel_error' -// of non-integral type `const float' -const float triangulating_render_handler::s_curve_max_pixel_error = 1.0f; - - -void triangulating_render_handler::draw_glyph(shape_character_def *def, - const matrix& mat, const rgba& color, float pixel_scale) { - - // Make sure m_single_fill_styles contains the desired color - need_single_fill_style(color); - - // A glyph is a notmal character, so draw it normally - draw_shape_character(def, mat, m_neutral_cxform, pixel_scale, - m_single_fill_styles, m_dummy_line_styles); -} - - - - -void triangulating_render_handler::draw_shape_character(shape_character_def *def, - const matrix& mat, - const cxform& cx, - float pixel_scale, - const std::vector<fill_style>& fill_styles, - const std::vector<line_style>& line_styles) { - tri_cache_manager* cman = get_cache_of(def); - - // Compute the error tolerance in object-space. - float max_scale = mat.get_max_scale(); - - if (fabsf(max_scale) < 1e-6f) { - // Scale is essentially zero. - return; - } - - float object_space_max_error = - 20.0f / max_scale / pixel_scale * s_curve_max_pixel_error; - - - // NOTE: gnash_debug_show_paths ommitted - - // Try to find a usable mesh set in the cache - mesh_set *m = cman->search_candidate(object_space_max_error); - int from_cache = m != NULL; - - if (!from_cache) { - // no cache hit, construct a new mesh to handle this error tolerance. - m = new mesh_set(def, object_space_max_error * 0.75f); - }; - - // draw the mesh set - draw_mesh_set(*m, mat, cx, fill_styles, line_styles, 1.0); - - - if (!from_cache) { - // add to cache (do this after drawing the mesh!) - cman->add(m); - } - -} // draw_shape_character - - - -void triangulating_render_handler::draw_mesh_set(const mesh_set& m, - const matrix& mat, const cxform& cx, - const std::vector<fill_style> &fill_styles, - const std::vector<line_style> &line_styles, float ratio) { - - set_matrix(mat); - set_cxform(cx); - - // draw fills - for (unsigned int i = 0; i < m.m_meshes.size(); i++) { - const mesh& the_mesh = m.m_meshes[i]; - const fill_style& the_style = fill_styles[i]; - - if (!the_mesh.m_triangle_strip.size()) continue; // nothing to draw - - apply_fill_style(the_style, 0, ratio); - - boost::scoped_array<int16_t> coords; - vector_to_array(the_mesh.m_triangle_strip, coords); - - draw_mesh_strip(coords.get(), the_mesh.m_triangle_strip.size() / 2); - } - - // draw outlines - for (unsigned int i = 0; i < m.m_line_strips.size(); i++) - { - int style = m.m_line_strips[i].get_style(); - const line_strip& strip = m.m_line_strips[i]; - - assert(strip.m_coords.size() > 1); - assert((strip.m_coords.size() & 1) == 0); - apply_line_style(line_styles[style], ratio); - - boost::scoped_array<int16_t> coords; - vector_to_array(strip.m_coords, coords); - - draw_line_strip(coords.get(), strip.m_coords.size() / 2); - } - - -} // draw_mesh_set - - -void triangulating_render_handler::apply_fill_style(const fill_style& style, - int fill_side, float ratio) { - - UNUSED(ratio); - - if (style.m_type == SWF::FILL_SOLID) - { - // 0x00: solid fill - fill_style_color(fill_side, style.m_color); - } - else if (style.m_type == SWF::FILL_LINEAR_GRADIENT - || style.m_type == SWF::FILL_RADIAL_GRADIENT - || style.m_type == SWF::FILL_FOCAL_GRADIENT) - { - // 0x10: linear gradient fill - // 0x12: radial gradient fill - - style.need_gradient_bitmap(); - - if (style.m_gradient_bitmap_info != NULL) { - fill_style_bitmap( - fill_side, - style.m_gradient_bitmap_info.get(), - style.m_gradient_matrix, - gnash::render_handler::WRAP_CLAMP); - } - } - else if (style.m_type == SWF::FILL_TILED_BITMAP - || style.m_type == SWF::FILL_CLIPPED_BITMAP - || style.m_type == SWF::FILL_TILED_BITMAP_HARD - || style.m_type == SWF::FILL_CLIPPED_BITMAP_HARD) - { - - // bitmap fill (either tiled or clipped) - - gnash::bitmap_info* bi = NULL; - - if (style.m_bitmap_character != NULL) { - - bi = style.m_bitmap_character->get_bitmap_info(); - - if (bi != NULL) { - - gnash::render_handler::bitmap_wrap_mode - wmode = gnash::render_handler::WRAP_REPEAT; - - if (style.m_type == SWF::FILL_CLIPPED_BITMAP - || style.m_type == SWF::FILL_CLIPPED_BITMAP_HARD) - { - wmode = gnash::render_handler::WRAP_CLAMP; - } - fill_style_bitmap( - fill_side, - bi, - style.m_bitmap_matrix, - wmode); - } - } - } - -} // apply_fill_stype - - -void triangulating_render_handler::apply_line_style(const line_style& style, - float ratio) { - - UNUSED(ratio); - line_style_color(style.m_color); - line_style_width(style.m_width); -} // apply_line_style - - - -void triangulating_render_handler::draw_line_strip(const void* coords, - int vertex_count, const rgba& color) { - - line_style_color(color); - line_style_width(1); - draw_line_strip(coords, vertex_count); - -} - -void triangulating_render_handler::draw_poly(const point* corners, - size_t corner_count, const rgba& fill, const rgba& outline, bool /*masked*/) { - - // TODO: The current implementation is only correct when masked==true, - // ie. it will always be masked. - - unsigned int vno=0; - // Create points array to vertex array - int16_t *vertex = new int16_t[(corner_count+1)*2]; - for (unsigned int cno=0; cno<corner_count; cno++) { - vertex[vno ] = static_cast<int16_t>(corners[cno].x); - vertex[vno+1] = static_cast<int16_t>(corners[cno].y); - vno+=2; - } - // add one more point to close the polygon - vertex[vno ] = vertex[0]; - vertex[vno+1] = vertex[1]; - - // fill the polygon - if (fill.m_a>0) { - fill_style_color(0, fill); - draw_mesh_strip(vertex, corner_count+1); - } - - // draw the polygon outline - if (outline.m_a>0) { - line_style_color(outline); - line_style_width(1.0f); - draw_line_strip(vertex, corner_count+1); - } - - delete[] vertex; - -} // draw_poly - - - - -tri_cache_manager* triangulating_render_handler::get_cache_of(character_def* def) { - - if (def->m_render_cache == NULL) { - def->m_render_cache = new tri_cache_manager; - } - - return static_cast<tri_cache_manager*> (def->m_render_cache); - -} // get_cache_of - - -geometry::Range2d<int> -triangulating_render_handler::world_to_pixel(const rect& worldbounds) -{ - // TODO: verify this is correct - geometry::Range2d<int> ret(worldbounds.getRange()); - ret.scale(1.0/20.0); // twips to pixels - return ret; -} - -point -triangulating_render_handler::pixel_to_world(int x, int y) -{ - // TODO: verify this is correct - return point(PIXELS_TO_TWIPS(x), PIXELS_TO_TWIPS(y)); -} - -tri_cache_manager::~tri_cache_manager() -{ -} - - -} // namespace gnash Index: backend/render_handler_tri.h =================================================================== RCS file: backend/render_handler_tri.h diff -N backend/render_handler_tri.h --- backend/render_handler_tri.h 21 Sep 2007 20:18:41 -0000 1.16 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,211 +0,0 @@ -// -// Copyright (C) 2005, 2006, 2007 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 3 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 - -// -// - -/* $Id: render_handler_tri.h,v 1.16 2007/09/21 20:18:41 bjacques Exp $ */ - -#ifndef GNASH_RENDER_HANDLER_TRI_H -#define GNASH_RENDER_HANDLER_TRI_H - - -// Original version by Udo Giacomozzi, Indunet GmbH (www.indunet.it) - - -#include "gnash.h" -#include "types.h" -#include "image.h" -#include "utility.h" -#include "log.h" - -#include "render_handler.h" - -#ifndef RENDER_HANDLER_H -#error missing includes! -#endif - -namespace gnash -{ - -class DSOEXPORT tri_cache_manager : public render_cache_manager -{ -private: - /// A list of pre-computed meshes. Each mesh set was computed with a certain - /// error tolerance. The error tolerance defines the number of straight lines - /// that are used to reconstruct a curve. As this approximation becomes - /// visible when magnifing a character, different mesh sets are cached. - /// Of course, more edge lines produce more triangles which slows down - /// rendering. So we try to use a mesh set with the minimal triangle amount - /// that's still acceptable when viewed. - /// To draw these meshes they still have to be transformed using the desired - /// matrix! - /// - /// This instance owns the mesh_sets - /// - typedef std::vector <mesh_set> MeshSetList; - MeshSetList m_cached_meshes; - -public: - - /// Searches a mesh set with a error tolerance below max_error. - /// Returns NULL when no candidate could be found. - /// Ownership is NOT transferred - mesh_set* search_candidate(float max_error); - - /// Adds a mesh set to the cache. - // - /// Transfer ownerhips of the mesh_set. - /// TODO: take an auto_ptr - /// - void add(mesh_set* m); - - /// Maintain cached meshes. Clean out mesh_sets that haven't been used - /// recently, and make sure they're sorted from high error to low error. - void sort_and_clean_meshes(); - - /// Drop all cached meshes - virtual ~tri_cache_manager(); - -}; // class tri_cache_manager - - - - -/// \brief -/// This is the base class for all triangle-based renderers (hardware -/// accelerated ones, for example). -// -/// It shields the renderer from the special -/// Flash edges that have two fill styles - one for each side. Also, Flash -/// shapes do not contain single, closed polygons. -/// The triangulating_render_handler contains algorithms that transform the -/// shapes to simplified triangle sets ("mesh sets") that are relatively easy -/// to render. -/// -class triangulating_render_handler : public render_handler -{ -public: - - // --- reimplemented methods ------------------------------------------------- - // The implementation of this virtual method takes care that the shape is - // translated to a mesh set. Triangulating backends do not need to declare - // their own draw_shape_character. - - /// This method is required by all render handlers. The triangulating render - /// handler has already a common implementation that uses a tesselator and - /// generates mesh sets that can be used by simpler handlers. - /*void draw_shape_character(shape_character_def *def, - character *inst);*/ - - /// Alterante version of draw_shape_character() which does not depend on any - /// character instance and accepts arbitrary line and fill styles. - void draw_shape_character(shape_character_def *def, - const matrix& mat, - const cxform& cx, - float pixel_scale, - const std::vector<fill_style>& fill_styles, - const std::vector<line_style>& line_styles); - - /// Triangulating render handlers do not need to support this special version - /// of draw_line_strip(). - void draw_line_strip(const void* coords, int vertex_count, const rgba& color); - - /// The given polygon is translated to a mesh strip by this class. - void draw_poly(const point* corners, size_t corner_count, const rgba& fill, - const rgba& outline, bool masked); - - /// The glyph is drawn just like a normal shape character. - virtual void draw_glyph(shape_character_def *def, - const matrix& mat, const rgba& color, float pixel_scale); - - /// Older backends always used glyph textures, so any triangulating render - /// handler activates glyph textures by default. - bool allow_glyph_textures() { return true; } - - /// Translates world coordinates to pixel coordinates - geometry::Range2d<int> world_to_pixel(const rect& worldbounds); - - point pixel_to_world(int x, int y); - - // --- helper methods -------------------------------------------------------- - // These methods are called by draw_shape_character() and normally don't need - // to be accessed by other classes. They are here to make the class more - // readable and flexible. - // Note: The old methods mesh_set::display(), fill_style::apply() etc. have - // been removed to disallow them completely since these methods rely on - // triangular renderers which may not be available. This is the reason why - // the methods have been re-implemented inside triangulating_render_handler. - - void draw_mesh_set(const mesh_set& m, const matrix& mat, const cxform& cx, - const std::vector<fill_style> &fill_styles, - const std::vector<line_style> &line_styles, float ratio); - - void apply_fill_style(const fill_style& style, int fill_side, float ratio); - void apply_line_style(const line_style& style, float ratio); - - - - // --- low level graphic methods --------------------------------------------- - // These methods were defined in the older render_handler design. They must be - // implemented by the real handlers as they are defined abstract. - - /// Disables the current fill style (so that it is transparent) for the - /// given fill side (which is always zero?). - virtual void fill_style_disable(int fill_side) = 0; - - /// Sets the fill style to the given solid color. - virtual void fill_style_color(int fill_side, const rgba& color) = 0; - - /// Sets the fill style to the given bitmap. This is also used for gradients - /// which are transformed to a bitmap prior to this call. - virtual void fill_style_bitmap(int fill_side, const bitmap_info* bi, - const matrix& m, bitmap_wrap_mode wm) = 0; - - /// Disables the current line style - virtual void line_style_disable() = 0; - - /// Sets the stroke color for subsequent draw_line_strip() calls - virtual void line_style_color(const rgba& color) = 0; - - /// Sets the stroke width for subsequent draw_line_strip() calls. When - /// width==1.0 a "hairline" should be drawn. - virtual void line_style_width(float width) = 0; - - /// Draws the given line strip using the current transformation matrix. - virtual void draw_line_strip(const void* coords, int vertex_count) = 0; - - /// Draws the given mesh strip (trianges) using the current transformation - /// matrix. - virtual void draw_mesh_strip(const void* coords, int vertex_count) = 0; - - - -protected: - static const float s_curve_max_pixel_error; // = 1.0f; - - - /// Returns the cache manager instance of the given character definition. - /// Allocates a new manager if necessary. - tri_cache_manager* get_cache_of(character_def* def); - - -}; // class render_handler_impl - -} // namespace gnash - -#endif // GNASH_RENDER_HANDLER_IMPL_H _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit