CVSROOT: /sources/gnash Module name: gnash Changes by: Chad Musick <cmusick> 07/09/03 05:55:39
Modified files: . : ChangeLog backend : render_handler_agg_style.h server : fill_style.cpp Log message: Improved handling of focal gradient fills. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4192&r2=1.4193 http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_agg_style.h?cvsroot=gnash&r1=1.22&r2=1.23 http://cvs.savannah.gnu.org/viewcvs/gnash/server/fill_style.cpp?cvsroot=gnash&r1=1.9&r2=1.10 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.4192 retrieving revision 1.4193 diff -u -b -r1.4192 -r1.4193 --- ChangeLog 2 Sep 2007 23:43:23 -0000 1.4192 +++ ChangeLog 3 Sep 2007 05:55:38 -0000 1.4193 @@ -1,3 +1,11 @@ +2007-09-03 Chad Musick <[EMAIL PROTECTED]> + + * backend/render_handler_agg_style.h Correct(maybe) the placement of the + focal point for focal gradient fills. + * server/fill_style.cpp Read focal gradient fills in the right place + (after gradient records, not before), also added focal gradients to + known bitmap transforms. + 2007-09-03 Markus Gothe <[EMAIL PROTECTED]> * macros/boost.m4: Commented out bogus check and improved the Index: backend/render_handler_agg_style.h =================================================================== RCS file: /sources/gnash/gnash/backend/render_handler_agg_style.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -b -r1.22 -r1.23 --- backend/render_handler_agg_style.h 2 Sep 2007 17:01:59 -0000 1.22 +++ backend/render_handler_agg_style.h 3 Sep 2007 05:55:39 -0000 1.23 @@ -646,7 +646,7 @@ // move the focal fill to where it should be. gnash::matrix transl; // TODO: Is this right? - transl.concatenate_translation(fs.get_focal_point() * 32.0f, 0.0f); + transl.concatenate_translation(fs.get_focal_point() * 32.0f - 32.0f, -32.0f); transl.concatenate(mat); st_type* st = new st_type(fs, transl, cx, 64/2); Index: server/fill_style.cpp =================================================================== RCS file: /sources/gnash/gnash/server/fill_style.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -b -r1.9 -r1.10 --- server/fill_style.cpp 2 Sep 2007 17:01:59 -0000 1.9 +++ server/fill_style.cpp 3 Sep 2007 05:55:39 -0000 1.10 @@ -120,19 +120,10 @@ m_gradient_matrix.concatenate_translation(128.f, 0.f); m_gradient_matrix.concatenate_scale(1.0f / 128.0f); } - else + else // FILL_RADIAL_GRADIENT or FILL_FOCAL_GRADIENT { m_gradient_matrix.concatenate_translation(32.f, 32.f); m_gradient_matrix.concatenate_scale(1.0f / 512.0f); - // A focal gradient also has a focal point. - if (m_type == SWF::FILL_FOCAL_GRADIENT) - { - m_focal_point = in->read_short_sfixed(); - if (m_focal_point < -1.0f) - m_focal_point = -1.0f; - else if (m_focal_point > 1.0f) - m_focal_point = 1.0f; - } } matrix m; @@ -141,7 +132,10 @@ // GRADIENT in->ensureBytes(1); - uint8_t num_gradients = in->read_u8(); + // num_gradients is not 8 bits, it is only the last 4. + // at the moment, the first four are unused, so we may + // mask, but this needs to be changed. + uint8_t num_gradients = in->read_u8() & 15; if ( ! num_gradients ) { IF_VERBOSE_MALFORMED_SWF( @@ -150,8 +144,8 @@ return; } - if ( num_gradients > 8 + (tag_type == SWF::DEFINESHAPE4 || - tag_type == SWF::DEFINESHAPE4_) ? 7 : 0) + if ( num_gradients > 8 + ((tag_type == SWF::DEFINESHAPE4 || + tag_type == SWF::DEFINESHAPE4_) ? 7 : 0)) { // see: http://sswf.sourceforge.net/SWFalexref.html#swf_gradient log_error(_("Unexpected num gradients (%d), expected 1 to 8"), @@ -163,6 +157,16 @@ m_gradients[i].read(in, tag_type); } + // A focal gradient also has a focal point. + if (m_type == SWF::FILL_FOCAL_GRADIENT) + { + m_focal_point = in->read_short_sfixed(); + if (m_focal_point < -1.0f) + m_focal_point = -1.0f; + else if (m_focal_point > 1.0f) + m_focal_point = 1.0f; + } + IF_VERBOSE_PARSE ( log_parse(" gradients: num_gradients = %d", num_gradients); @@ -285,7 +289,8 @@ fill_style::sample_gradient(uint8_t ratio) const { assert(m_type == SWF::FILL_LINEAR_GRADIENT - || m_type == SWF::FILL_RADIAL_GRADIENT); + || m_type == SWF::FILL_RADIAL_GRADIENT + || m_type == SWF::FILL_FOCAL_GRADIENT); assert(m_gradients.size()); @@ -353,7 +358,8 @@ fill_style::create_gradient_bitmap() const { assert(m_type == SWF::FILL_LINEAR_GRADIENT - || m_type == SWF::FILL_RADIAL_GRADIENT); + || m_type == SWF::FILL_RADIAL_GRADIENT + || m_type == SWF::FILL_FOCAL_GRADIENT); image::rgba* im = NULL; @@ -386,6 +392,30 @@ } } } + else if (m_type == SWF::FILL_FOCAL_GRADIENT) + { + // Focal gradient. + im = image::create_rgba(64, 64); + + for (int j = 0; j < im->m_height; j++) + { + for (int i = 0; i < im->m_width; i++) + { + float radiusy = (im->m_height - 1) / 2.0f; + float radiusx = radiusy + abs(radiusy * m_focal_point); + float y = (j - radiusy) / radiusy; + float x = (i - radiusx) / radiusx; + int ratio = (int) floorf(255.5f * sqrt(x*x + y*y)); + if (ratio > 255) + { + ratio = 255; + } + rgba sample = sample_gradient(ratio); + im->set_pixel(i, j, sample.m_r, sample.m_g, sample.m_b, sample.m_a); + } + } + } + gnash::bitmap_info* bi = gnash::render::create_bitmap_info_rgba(im); delete im; _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit