gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash/server gnash.h styles.cpp styles.h types.cpp


From: Udo Giacomozzi
Subject: [Gnash-commit] gnash/server gnash.h styles.cpp styles.h types.cpp
Date: Thu, 26 Oct 2006 08:20:10 +0000

CVSROOT:        /cvsroot/gnash
Module name:    gnash
Changes by:     Udo Giacomozzi <udog>   06/10/26 08:20:10

Modified files:
        server         : gnash.h styles.cpp styles.h types.cpp 

Log message:
        Additional access methods

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/gnash.h?cvsroot=gnash&r1=1.67&r2=1.68
http://cvs.savannah.gnu.org/viewcvs/gnash/server/styles.cpp?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/server/styles.h?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/server/types.cpp?cvsroot=gnash&r1=1.15&r2=1.16

Patches:
Index: gnash.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/gnash.h,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- gnash.h     21 Oct 2006 09:54:44 -0000      1.67
+++ gnash.h     26 Oct 2006 08:20:09 -0000      1.68
@@ -35,7 +35,7 @@
 // 
 //
 
-/* $Id: gnash.h,v 1.67 2006/10/21 09:54:44 bjacques Exp $ */
+/* $Id: gnash.h,v 1.68 2006/10/26 08:20:09 udog Exp $ */
 
 /// \mainpage
 ///
@@ -542,6 +542,9 @@
     /// Apply our transform to the given color; return the result.
     rgba transform(const rgba in) const;
     
+    /// Faster transform() method for loops (avoids creation of rgba object)
+    void transform(uint8_t& r, uint8_t& g, uint8_t& b, uint8_t& a) const;    
+    
     /// Read RGB from the SWF input stream.
     void read_rgb(stream* in);
     
@@ -554,6 +557,9 @@
     /// Debug log.
     void print() const;
     
+    /// Returns true when the cxform equals identity (no transform)
+    bool is_identity() const;
+    
     /// The identity color transform (no transform)
     static cxform      identity;
 };

Index: styles.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/server/styles.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- styles.cpp  7 Oct 2006 15:08:26 -0000       1.21
+++ styles.cpp  26 Oct 2006 08:20:09 -0000      1.22
@@ -180,6 +180,47 @@
 }
 
 
+bitmap_info* 
+fill_style::get_bitmap_info() const 
+{    
+  assert(m_type != SWF::FILL_SOLID);
+  
+  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) {
+
+   if (m_bitmap_character!=NULL)
+     return m_bitmap_character->get_bitmap_info();
+   else
+     return NULL;
+   
+  } else
+  if (m_type == SWF::FILL_LINEAR_GRADIENT
+   || m_type == SWF::FILL_RADIAL_GRADIENT) {
+   
+   return need_gradient_bitmap();
+   
+  } else {
+    log_msg("Unknown fill style");
+    assert(0);
+  }  
+}
+
+matrix
+fill_style::get_bitmap_matrix() const 
+{
+  assert(m_type != SWF::FILL_SOLID);
+  return m_bitmap_matrix;
+}
+
+matrix
+fill_style::get_gradient_matrix() const 
+{
+  // TODO: Why do we separate bitmap and gradient matrices? 
+  return m_gradient_matrix;
+}
+
 rgba
 fill_style::sample_gradient(int ratio) const
     // Return the color at the specified ratio into our gradient.
@@ -313,6 +354,18 @@
 }
 
 
+int 
+fill_style::get_color_stop_count() const 
+{
+  return m_gradients.size();
+}
+
+const gradient_record& 
+fill_style::get_color_stop(int index) const
+{
+  return m_gradients[index];
+}
+
 //
 // line_style
 //

Index: styles.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/styles.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- styles.h    14 Oct 2006 03:22:52 -0000      1.13
+++ styles.h    26 Oct 2006 08:20:09 -0000      1.14
@@ -5,7 +5,7 @@
 
 // Fill and line style types.
 
-/* $Id: styles.h,v 1.13 2006/10/14 03:22:52 nihilus Exp $ */
+/* $Id: styles.h,v 1.14 2006/10/26 08:20:09 udog Exp $ */
 
 #ifndef GNASH_STYLES_H
 #define GNASH_STYLES_H
@@ -70,6 +70,21 @@
     /// 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);
        
+       /// Returns the bitmap info for all styles except solid fills
+       bitmap_info* get_bitmap_info() const;
+       
+       /// Returns the bitmap transformation matrix
+       matrix get_bitmap_matrix() const; 
+       
+       /// Returns the gradient transformation matrix
+       matrix get_gradient_matrix() const; 
+       
+       /// Returns the number of color stops in the gradient
+       int get_color_stop_count() const;
+       
+       /// Returns the color stop value at a specified index
+       const gradient_record& get_color_stop(int index) const;
+       
 private:
        friend class morph2_character_def;
        friend class triangulating_render_handler;

Index: types.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/server/types.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- types.cpp   17 Oct 2006 15:32:48 -0000      1.15
+++ types.cpp   26 Oct 2006 08:20:09 -0000      1.16
@@ -76,16 +76,21 @@
        rgba    cxform::transform(const rgba in) const
        // Apply our transform to the given color; return the result.
        {
-               rgba    result;
+               rgba    result(in.m_r, in.m_g, in.m_b, in.m_a);
 
-               result.m_r = (uint8_t) fclamp(in.m_r * m_[0][0] + m_[0][1], 0, 
255);
-               result.m_g = (uint8_t) fclamp(in.m_g * m_[1][0] + m_[1][1], 0, 
255);
-               result.m_b = (uint8_t) fclamp(in.m_b * m_[2][0] + m_[2][1], 0, 
255);
-               result.m_a = (uint8_t) fclamp(in.m_a * m_[3][0] + m_[3][1], 0, 
255);
+               transform(result.m_r, result.m_g, result.m_b, result.m_a);
 
                return result;
        }
 
+  void cxform::transform(uint8_t& r, uint8_t& g, uint8_t& b, uint8_t& a) const
+  // Faster transform() method for loops (avoids creation of rgba object)
+  {
+               r = (uint8_t) fclamp(r * m_[0][0] + m_[0][1], 0, 255);
+               g = (uint8_t) fclamp(g * m_[1][0] + m_[1][1], 0, 255);
+               b = (uint8_t) fclamp(b * m_[2][0] + m_[2][1], 0, 255);
+               a = (uint8_t) fclamp(a * m_[3][0] + m_[3][1], 0, 255);
+  }
 
        void    cxform::read_rgb(stream* in)
        {
@@ -167,6 +172,17 @@
                log_parse("| %4.4f %4.4f|", m_[3][0], m_[3][1]);
        }
 
+       bool    cxform::is_identity() const
+       // Returns true when the cxform equals identity (no transform)
+       {          
+         for (int a=0; a<4; a++)
+          for (int b=0; b<2; b++)
+           if (m_[a][b] != identity.m_[a][b])
+            return false;
+         
+         return true;
+  }
+
 
        //
        // rgba




reply via email to

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