[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash/backend render_handler_agg.cpp
From: |
Udo Giacomozzi |
Subject: |
[Gnash-commit] gnash/backend render_handler_agg.cpp |
Date: |
Fri, 27 Oct 2006 17:56:50 +0000 |
CVSROOT: /cvsroot/gnash
Module name: gnash
Changes by: Udo Giacomozzi <udog> 06/10/27 17:56:50
Modified files:
backend : render_handler_agg.cpp
Log message:
Fixed sub-shapes (bug #18095)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_agg.cpp?cvsroot=gnash&r1=1.29&r2=1.30
Patches:
Index: render_handler_agg.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/backend/render_handler_agg.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- render_handler_agg.cpp 26 Oct 2006 13:15:46 -0000 1.29
+++ render_handler_agg.cpp 27 Oct 2006 17:56:49 -0000 1.30
@@ -34,7 +34,7 @@
// forward this exception.
-/* $Id: render_handler_agg.cpp,v 1.29 2006/10/26 13:15:46 udog Exp $ */
+/* $Id: render_handler_agg.cpp,v 1.30 2006/10/27 17:56:49 udog Exp $ */
// Original version by Udo Giacomozzi and Hannes Mayr,
// INDUNET GmbH (www.indunet.it)
@@ -53,7 +53,7 @@
outlines:
solid COMPLETE
- patterns NOT IMPLEMENTED (seems like Gnash does not support them
yet)
+ patterns don't exist (they're converted at compile time by Flash!)
widths COMPLETE
colors, alpha COMPLETE
@@ -116,6 +116,7 @@
#include <agg_conv_transform.h>
#include <agg_trans_affine.h>
#include <agg_scanline_u.h>
+#include <agg_scanline_bin.h>
#include <agg_scanline_p.h>
#include <agg_renderer_scanline.h>
// must only include if render_scanlines_compound_layered is not defined
@@ -717,7 +718,7 @@
need_single_fill_style(color);
// draw the shape
- draw_shape(paths, m_single_fill_styles, m_neutral_cxform, mat, false);
+ draw_shape(-1, paths, m_single_fill_styles, m_neutral_cxform, mat, false);
// NOTE: Do not use even-odd filling rule for glyphs!
}
@@ -734,9 +735,16 @@
apply_matrix_to_path(def->get_paths(), paths, mat);
- draw_shape(paths, fill_styles, cx, mat, true);
-
- draw_outlines(paths, line_styles, cx);
+ // We need to separate sub-shapes during rendering. The current
+ // implementation is a bit sub-optimal because the fill styles get
+ // re-initialized for each sub-shape. Maybe this will be no more a problem
+ // once fill styles get cached, anyway.
+ const int subshape_count=count_sub_shapes(paths);
+
+ for (int subshape=0; subshape<subshape_count; subshape++) {
+ draw_shape(subshape, paths, fill_styles, cx, mat, true);
+ draw_outlines(subshape, paths, line_styles, cx);
+ }
}
@@ -787,15 +795,41 @@
} // apply_matrix
+
+ /// A shape can have sub-shapes. This can happen when there are multiple
+ /// layers of the same frame count. Flash combines them to one single shape.
+ /// The problem with sub-shapes is, that outlines can be hidden by other
+ /// layers so they must be rendered separately.
+ unsigned int count_sub_shapes(const std::vector<path> &paths) {
+
+ int sscount=1;
+
+ int pcount = paths.size();
+
+ for (int pno=0; pno<pcount; pno++) { // skip first path!
+ const path &this_path = paths[pno];
+
+ if (pno==0)
+ assert(!this_path.m_new_shape); // this would break draw_XXX
+
+ if (this_path.m_new_shape)
+ sscount++;
+ }
+
+ return sscount;
+ }
+
+
/// 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,
+ /// 'subshape_id' defines which sub-shape should be drawn (-1 means all
+ /// subshapes)
+ void draw_shape(int subshape_id, const std::vector<path> &paths,
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
data model. So we just have to feed AGG with all data and we're done. :-)
@@ -836,7 +870,6 @@
// tell AGG what styles are used
fcount = fill_styles.size();
- //log_msg("%d fill styles\n", fcount);
for (fno=0; fno<fcount; fno++) {
bool smooth=false;
@@ -903,6 +936,7 @@
// push paths to AGG
pcount = paths.size();
+ int current_subshape = 0;
for (pno=0; pno<pcount; pno++) {
@@ -910,6 +944,14 @@
agg::path_storage path;
agg::conv_curve< agg::path_storage > curve(path);
+ if (this_path.m_new_shape)
+ current_subshape++;
+
+ if ((subshape_id>=0) && (current_subshape!=subshape_id)) {
+ // Skip this path as it is not part of the requested sub-shape.
+ continue;
+ }
+
// Tell the rasterizer which styles the following path will use.
// The good thing is, that it already supports two fill styles out of
// the box.
@@ -947,7 +989,7 @@
/// Just like draw_shapes() except that it draws an outline.
- void draw_outlines(const std::vector<path> &paths,
+ void draw_outlines(int subshape_id, const std::vector<path> &paths,
const std::vector<line_style> &line_styles, const cxform& cx) {
assert(m_pixf != NULL);
@@ -976,14 +1018,24 @@
stroke(curve); // to get an outline
+ int current_subshape = 0;
pcount = paths.size();
for (pno=0; pno<pcount; pno++) {
const path &this_path = paths[pno];
+ if (this_path.m_new_shape)
+ current_subshape++;
+
+ if ((subshape_id>=0) && (current_subshape!=subshape_id)) {
+ // Skip this path as it is not part of the requested sub-shape.
+ continue;
+ }
+
if (!this_path.m_line)
continue; // invisible line
+
const line_style &lstyle = line_styles[this_path.m_line-1];
rgba color = cx.transform(lstyle.get_color());
int width = lstyle.get_width();
- [Gnash-commit] gnash/backend render_handler_agg.cpp, Sandro Santilli, 2006/10/07
- [Gnash-commit] gnash/backend render_handler_agg.cpp, Udo Giacomozzi, 2006/10/09
- [Gnash-commit] gnash/backend render_handler_agg.cpp, Udo Giacomozzi, 2006/10/09
- [Gnash-commit] gnash/backend render_handler_agg.cpp, Sandro Santilli, 2006/10/09
- [Gnash-commit] gnash/backend render_handler_agg.cpp, Udo Giacomozzi, 2006/10/09
- [Gnash-commit] gnash/backend render_handler_agg.cpp, Udo Giacomozzi, 2006/10/13
- [Gnash-commit] gnash/backend render_handler_agg.cpp,
Udo Giacomozzi <=