gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/styles.cpp server/styles...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/styles.cpp server/styles...
Date: Mon, 19 Jun 2006 00:05:16 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/06/19 00:05:16

Modified files:
        .              : ChangeLog 
        server         : styles.cpp styles.h swf.h 

Log message:
                * server/swf.h: added symbolic names for fill_style types.
                * server/styles.h: some indentation and doxygen comments.
                * server/styles.cpp: use symbolic names for fill_style types,
                stricter checks on them, accept hard-edges versions of
                CLIPPED and TILED bitmap fills.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.410&r2=1.411
http://cvs.savannah.gnu.org/viewcvs/gnash/server/styles.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/styles.h?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf.h?cvsroot=gnash&r1=1.14&r2=1.15

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.410
retrieving revision 1.411
diff -u -b -r1.410 -r1.411
--- ChangeLog   16 Jun 2006 01:51:43 -0000      1.410
+++ ChangeLog   19 Jun 2006 00:05:16 -0000      1.411
@@ -1,3 +1,11 @@
+2006-06-19 Sandro Santilli <address@hidden>
+
+       * server/swf.h: added symbolic names for fill_style types.
+       * server/styles.h: some indentation and doxygen comments.
+       * server/styles.cpp: use symbolic names for fill_style types,
+       stricter checks on them, accept hard-edges versions of
+       CLIPPED and TILED bitmap fills.
+
 2006-06-15 Sandro Santilli <address@hidden>
 
        * server/action.cpp (call_method): include method name in 

Index: server/styles.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/styles.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/styles.cpp   7 Jun 2006 03:03:21 -0000       1.11
+++ server/styles.cpp   19 Jun 2006 00:05:16 -0000      1.12
@@ -12,8 +12,10 @@
 #include "render.h"
 #include "stream.h"
 #include "movie_definition.h"
+#include "swf.h"
 
 namespace gnash {
+
 //
 // gradient_record
 //
@@ -59,43 +61,55 @@
 
     log_parse("  fill_style read type = 0x%X\n", m_type);
 
-    if (m_type == 0x00) {
+    if (m_type == SWF::FILL_SOLID)
+    {
         // 0x00: solid fill
-        if (tag_type <= 22) {
+        if (tag_type == SWF::DEFINESHAPE2)
+        {
             m_color.read_rgb(in);
-        } else {
+        }
+        else
+        {
+            // For DefineMorphShape tags we should use morph_fill_style 
+            assert( tag_type != SWF::DEFINEMORPHSHAPE );
             m_color.read_rgba(in);
         }
 
         log_parse("  color: ");
         m_color.print();
-    } else if (m_type == 0x10 || m_type == 0x12) {
+    }
+    else if (m_type == SWF::FILL_LINEAR_GRADIENT
+            || m_type == SWF::FILL_RADIAL_GRADIENT)
+    {
         // 0x10: linear gradient fill
         // 0x12: radial gradient fill
 
         matrix input_matrix;
         input_matrix.read(in);
 
-        if (m_type == 0x10) {
+        // shouldn't this be in initializer's list ?
             m_gradient_matrix.set_identity();
+        if (m_type == SWF::FILL_LINEAR_GRADIENT)
+        {
             m_gradient_matrix.concatenate_translation(128.f, 0.f);
             m_gradient_matrix.concatenate_scale(1.0f / 128.0f);
-        } else {
-            m_gradient_matrix.set_identity();
+        }
+        else
+        {
             m_gradient_matrix.concatenate_translation(32.f, 32.f);
             m_gradient_matrix.concatenate_scale(1.0f / 512.0f);
         }
 
-
         matrix m;
         m.set_inverse(input_matrix);
         m_gradient_matrix.concatenate(m);
                                
         // GRADIENT
         int    num_gradients = in->read_u8();
-        if (num_gradients < 1 || num_gradients > 8) {
-            fprintf(stderr, "WARNING: %s (%d): %d read bad gradient value!\n",
-                    __PRETTY_FUNCTION__, __LINE__,
+        if (num_gradients < 1 || num_gradients > 8)
+        {
+            // see: http://sswf.sourceforge.net/SWFalexref.html#swf_gradient
+            log_warning("Unexpected num gradients (%d), expected 1 to 8",
                     num_gradients);
         }                      
         m_gradients.resize(num_gradients);
@@ -118,9 +132,16 @@
 
         // Make sure our movie_def_impl knows about this bitmap.
         md->add_bitmap_info(m_gradient_bitmap_info.get_ptr());
-    } else if (m_type == 0x40 || m_type == 0x41) {
+    }
+    else if (m_type == SWF::FILL_TILED_BITMAP
+          || m_type == SWF::FILL_CLIPPED_BITMAP
+          || m_type == SWF::FILL_TILED_BITMAP_HARD
+          || m_type == SWF::FILL_CLIPPED_BITMAP_HARD)
+    {
         // 0x40: tiled bitmap fill
         // 0x41: clipped bitmap fill
+        // 0x42: tiled bitmap fill with hard edges
+        // 0x43: clipped bitmap fill with hard edges
 
         int    bitmap_char_id = in->read_u16();
         log_parse("  bitmap_char = %d\n", bitmap_char_id);
@@ -139,6 +160,13 @@
             m_bitmap_matrix.print();
         }
     }
+    else
+    {
+        log_error("Unsupported fill style type: 0x%X", m_type);
+        // This is a fatal error, we'll be leaving the stream
+        // read pointer in an unknown position.
+        assert(0);
+    }
 }
 
 
@@ -148,7 +176,8 @@
     // Ratio is in [0, 255].
 {
     assert(ratio >= 0 && ratio <= 255);
-    assert(m_type == 0x10 || m_type == 0x12);
+    assert(m_type == SWF::FILL_LINEAR_GRADIENT
+        || m_type == SWF::FILL_RADIAL_GRADIENT);
     assert(m_gradients.size() > 0);
 
     if (ratio < m_gradients[0].m_ratio) {
@@ -156,7 +185,8 @@
     }
                 
                
-    for (unsigned int i = 1; i < m_gradients.size(); i++) {
+    for (size_t i = 1, n = m_gradients.size(); i < n; ++i)
+    {
         if (m_gradients[i].m_ratio >= ratio) {
             const gradient_record& gr0 = m_gradients[i - 1];
             const gradient_record& gr1 = m_gradients[i];
@@ -175,14 +205,14 @@
 
 gnash::bitmap_info*
 fill_style::create_gradient_bitmap() const
-    // Make a bitmap_info* corresponding to our gradient.
-    // We can use this to set the gradient fill style.
 {
-    assert(m_type == 0x10 || m_type == 0x12);
+    assert(m_type == SWF::FILL_LINEAR_GRADIENT
+        || m_type == SWF::FILL_RADIAL_GRADIENT);
 
     image::rgba*       im = NULL;
 
-    if (m_type == 0x10) {
+    if (m_type == SWF::FILL_LINEAR_GRADIENT)
+    {
         // Linear gradient.
         im = image::create_rgba(256, 1);
 
@@ -190,7 +220,9 @@
             rgba       sample = sample_gradient(i);
             im->set_pixel(i, 0, sample.m_r, sample.m_g, sample.m_b, 
sample.m_a);
         }
-    } else if (m_type == 0x12) {
+    }
+    else if (m_type == SWF::FILL_RADIAL_GRADIENT)
+    {
         // Radial gradient.
         im = image::create_rgba(64, 64);
 
@@ -218,15 +250,18 @@
 
 void
 fill_style::apply(int fill_side, float ratio) const
-    // Push our style parameters into the renderer.
 {
 //            GNASH_REPORT_FUNCTION;
             
     UNUSED(ratio);
-    if (m_type == 0x00) {
+    if (m_type == SWF::FILL_SOLID)
+    {
         // 0x00: solid fill
         gnash::render::fill_style_color(fill_side, m_color);
-    } else if (m_type == 0x10 || m_type == 0x12) {
+    }
+    else if (m_type == SWF::FILL_LINEAR_GRADIENT
+          || m_type == SWF::FILL_RADIAL_GRADIENT)
+    {
         // 0x10: linear gradient fill
         // 0x12: radial gradient fill
 
@@ -245,14 +280,21 @@
                 m_gradient_matrix,
                 gnash::render_handler::WRAP_CLAMP);
         }
-    } else if (m_type == 0x40 || m_type == 0x41) {
+    }
+    else if (m_type == SWF::FILL_TILED_BITMAP
+          || m_type == SWF::FILL_CLIPPED_BITMAP
+          || m_type == SWF::FILL_TILED_BITMAP_HARD
+          || m_type == SWF::FILL_CLIPPED_BITMAP_HARD)
+    {
         // bitmap fill (either tiled or clipped)
         gnash::bitmap_info*    bi = NULL;
         if (m_bitmap_character != NULL)        {
             bi = m_bitmap_character->get_bitmap_info();
             if (bi != NULL)    {
                 gnash::render_handler::bitmap_wrap_mode        wmode = 
gnash::render_handler::WRAP_REPEAT;
-                if (m_type == 0x41) {
+                if (m_type == SWF::FILL_CLIPPED_BITMAP
+                    || m_type == SWF::FILL_CLIPPED_BITMAP_HARD)
+                {
                     wmode = gnash::render_handler::WRAP_CLAMP;
                 }
                 gnash::render::fill_style_bitmap(
@@ -289,7 +331,8 @@
     // fill style gradients
     assert(m_gradients.size() == a.m_gradients.size());
     assert(m_gradients.size() == b.m_gradients.size());
-    for (unsigned int j=0; j < m_gradients.size(); j++) {
+    for (size_t j=0, nj=m_gradients.size(); j<nj; ++j)
+    {
         m_gradients[j].m_ratio =
             (uint8_t) frnd(
                 flerp(a.m_gradients[j].m_ratio, b.m_gradients[j].m_ratio, t)

Index: server/styles.h
===================================================================
RCS file: /sources/gnash/gnash/server/styles.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/styles.h     25 May 2006 11:58:09 -0000      1.9
+++ server/styles.h     19 Jun 2006 00:05:16 -0000      1.10
@@ -14,8 +14,8 @@
 #include "bitmap_character_def.h"
 
 namespace gnash {
-struct stream;
 
+struct stream;
 
 struct gradient_record
 {
@@ -30,26 +30,41 @@
 struct base_fill_style
 {
        virtual ~base_fill_style() {};
+
+    /// Push our style parameters into the renderer.
        virtual void apply(int fill_side, float ratio) const = 0;
 };
 
+/// For the interior of outline shapes.
 class fill_style : public base_fill_style
-// For the interior of outline shapes.
 {
 public:
+
        fill_style();
+
        virtual ~fill_style();
        
        void    read(stream* in, int tag_type, movie_definition* m);
+
+    /// \brief
+    /// Return the color at the specified ratio into our gradient.
+    /// Ratio is in [0, 255].
        rgba    sample_gradient(int ratio) const;
+
+    /// \brief
+    /// Make a bitmap_info* corresponding to our gradient.
+    /// We can use this to set the gradient fill style.
        gnash::bitmap_info*     create_gradient_bitmap() const;
+
        virtual void    apply(int fill_side, float ratio) const;
        
        rgba    get_color() const { return m_color; }
+
        void    set_color(rgba new_color) { m_color = new_color; }
+
        int     get_type() const { return m_type; }
        
-       // For shape morphing
+    /// Sets this style to a blend of a and b.  t = [0,1] (for shape morphing)
        void    set_lerp(const fill_style& a, const fill_style& b, float t);
        
 private:
@@ -67,14 +82,21 @@
 
 class morph_fill_style : public base_fill_style
 {
+
 public:
+
        morph_fill_style();
+
        morph_fill_style(stream* in, movie_definition* m);
+
        virtual ~morph_fill_style();
        
        void read(stream* in, movie_definition* m);
+
        rgba sample_gradient(int ratio, float morph);
+
        bitmap_info* create_gradient_bitmap(float morph) const;
+
        virtual void apply(int fill_side, float morph) const;
        rgba get_color(float morph) const;
        void set_colors(rgba new_color_orig, rgba new_color_target);
@@ -94,8 +116,8 @@
        virtual void apply(float ratio) const = 0;
 };
 
+/// For the outside of outline shapes, or just bare lines.
 class line_style : public base_line_style
-// For the outside of outline shapes, or just bare lines.
 {
 public:
        line_style();
@@ -125,7 +147,8 @@
        uint16_t m_width[2];
        rgba   m_color[2];
 };
-}
+
+} // namespace gnash
 
 
 #endif // GNASH_STYLES_H

Index: server/swf.h
===================================================================
RCS file: /sources/gnash/gnash/server/swf.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- server/swf.h        9 May 2006 15:34:16 -0000       1.14
+++ server/swf.h        19 Jun 2006 00:05:16 -0000      1.15
@@ -111,7 +111,7 @@
     DEFINEBITSPTR         = 1023
 } tag_type;
 
-/// SWF action ids. Symbolc names copied from Ming.
+/// SWF action ids. Symbolic names copied from Ming.
 //
 /// For semantic of each action see:
 /// http://sswf.sourceforge.net/SWFalexref.html
@@ -378,6 +378,26 @@
     ACTION_SETREGISTER             = 0x87
 } action_type;
 
+/// SWF fill style types. Symbolic names copied from Ming.
+//
+/// For more info see:
+/// http://sswf.sourceforge.net/SWFalexref.html#swf_fill_style
+///
+typedef enum {
+       FILL_SOLID                   = 0x00,
+       FILL_LINEAR_GRADIENT         = 0x10,
+       FILL_RADIAL_GRADIENT         = 0x12,
+       FILL_TILED_BITMAP            = 0x40,
+       FILL_CLIPPED_BITMAP          = 0x41,
+
+       /// swf7, hard edges
+       FILL_TILED_BITMAP_HARD       = 0x42, 
+
+       /// swf7, hard edges
+       FILL_CLIPPED_BITMAP_HARD     = 0x43
+
+} fill_style_type;
+
 
 } // namespace gnash::SWF
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]