gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10714: Add a bitmap smoothing polic


From: Sandro Santilli
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10714: Add a bitmap smoothing policy member to fill_style class, taking no additional space (fills some padding space). The policy is based on SWF version and tag type
Date: Wed, 18 Mar 2009 16:28:18 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10714
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Wed 2009-03-18 16:28:18 +0100
message:
  Add a bitmap smoothing policy member to fill_style class, taking no 
additional space (fills some padding space). The policy is based on SWF version 
and tag type
   (UNSPECIFIED, ON, OFF).
modified:
  libcore/fill_style.cpp
  libcore/fill_style.h
=== modified file 'libcore/fill_style.cpp'
--- a/libcore/fill_style.cpp    2009-03-18 13:47:58 +0000
+++ b/libcore/fill_style.cpp    2009-03-18 15:28:18 +0000
@@ -28,7 +28,9 @@
 #include "movie_definition.h"
 #include "swf.h"
 #include "GnashException.h"
+
 #include <cmath> // sqrt, floor
+#include <iostream> // for output operator
 
 namespace gnash {
 
@@ -49,11 +51,12 @@
 //
 fill_style::fill_style()
     :
-    m_type(SWF::FILL_SOLID),
+    _bitmapInfo(0),
     m_color(), // FF.FF.FF.FF
-    _bitmapInfo(0),
     m_spread_mode(SWF::GRADIENT_SPREAD_PAD),
-    m_interpolation(SWF::GRADIENT_INTERPOL_NORMAL)
+    m_interpolation(SWF::GRADIENT_INTERPOL_NORMAL),
+    m_type(SWF::FILL_SOLID),
+    _bitmapSmoothingPolicy(BITMAP_SMOOTHING_UNSPECIFIED)
 {
 }
 
@@ -250,11 +253,26 @@
         // 0x42: tiled bitmap fill with hard edges
         // 0x43: clipped bitmap fill with hard edges
 
+        if ( m_type == SWF::FILL_TILED_BITMAP_HARD ||
+             m_type == SWF::FILL_CLIPPED_BITMAP_HARD )
+        {
+            _bitmapSmoothingPolicy = BITMAP_SMOOTHING_OFF;
+        }
+        else if ( md.get_version() >= 8 )
+        {
+            _bitmapSmoothingPolicy = BITMAP_SMOOTHING_ON;
+        }
+        else
+        {
+            _bitmapSmoothingPolicy = BITMAP_SMOOTHING_UNSPECIFIED;
+        }
+
         in.ensureBytes(2);
         int bitmap_char_id = in.read_u16();
         IF_VERBOSE_PARSE
         (
-            log_parse("  bitmap_char = %d", bitmap_char_id);
+            log_parse("  bitmap_char = %d, smoothing_policy = %s",
+                bitmap_char_id, _bitmapSmoothingPolicy);
         );
 
         // Look up the bitmap character.
@@ -560,9 +578,10 @@
 
 fill_style::fill_style(BitmapInfo* bitmap, const SWFMatrix& mat)
     :
+    _matrix(mat),
+    _bitmapInfo(bitmap),
     m_type(SWF::FILL_CLIPPED_BITMAP),
-    _bitmapInfo(bitmap),
-    _matrix(mat)
+    _bitmapSmoothingPolicy(BITMAP_SMOOTHING_UNSPECIFIED)
 {
 }
 
@@ -593,6 +612,28 @@
     _bitmapInfo = 0;
 }
 
+std::ostream& operator << (std::ostream& os,
+        const fill_style::BitmapSmoothingPolicy& p)
+{
+    switch (p)
+    {
+        case fill_style::BITMAP_SMOOTHING_UNSPECIFIED:
+            os << "unspecified";
+            break;
+        case fill_style::BITMAP_SMOOTHING_ON:
+            os << "on";
+            break;
+        case fill_style::BITMAP_SMOOTHING_OFF:
+            os << "off";
+            break;
+        default:
+            // cast to int required to avoid infinite recursion
+            os << "unknown " << (int)p;
+            break;
+    }
+    return os;
+}
+
 
 #ifdef GNASH_USE_GC
 void

=== modified file 'libcore/fill_style.h'
--- a/libcore/fill_style.h      2009-03-18 13:47:58 +0000
+++ b/libcore/fill_style.h      2009-03-18 15:28:18 +0000
@@ -28,6 +28,7 @@
 #include "RGBA.h" // for rgba type
 
 #include <vector> // for composition
+#include <iosfwd> // for output operator forward declarations
 
 namespace gnash {
 
@@ -63,6 +64,42 @@
 {
 public:
 
+    /// Bitmap smoothing policy
+    enum BitmapSmoothingPolicy {
+
+        /// Only smooth when _quality >= BEST
+        //
+        /// This is the policy for bitmap fills
+        /// defined by SWF up to version 7:
+        ///  - SWF::FILL_CLIPPED_BITMAP
+        ///  - SWF::FILL_TILED_BITMAP
+        ///
+        BITMAP_SMOOTHING_UNSPECIFIED,
+
+        /// Always smooth if _quality > LOW
+        //
+        /// This is the policy for non-hard bitmap fills
+        /// defined by SWF 8 and higher:
+        ///  - SWF::FILL_CLIPPED_BITMAP
+        ///  - SWF::FILL_TILED_BITMAP
+        ///
+        BITMAP_SMOOTHING_ON,
+
+        /// Never smooth
+        ///
+        /// MovieClip.forceSmoothing can force this to
+        /// behave like BITMAP_SMOOTHING_ON 
+        ///
+        /// This is the policy for hard bitmap fills
+        /// introduced in SWF 8:
+        ///  - SWF::FILL_CLIPPED_BITMAP_HARD
+        ///  - SWF::FILL_TILED_BITMAP_HARD
+        ///
+        ///
+        BITMAP_SMOOTHING_OFF
+    };
+    
+
        /// Create a solid opaque white fill.
        fill_style();
 
@@ -173,6 +210,10 @@
        ///        (it happens..)
        ///
        BitmapInfo* get_bitmap_info() const;
+
+    BitmapSmoothingPolicy getBitmapSmoothingPolicy() const {
+        return _bitmapSmoothingPolicy;
+    }
        
        /// Returns the bitmap transformation SWFMatrix
        const SWFMatrix& getBitmapMatrix() const; 
@@ -214,9 +255,6 @@
 
        friend class morph2_character_def;
 
-       /// Fill type, see SWF::fill_style_type
-       uint8_t m_type;
-       
        // For BITMAP or GRADIENT types 
        SWFMatrix       _matrix;
 
@@ -232,8 +270,20 @@
        SWF::gradient_spread_mode m_spread_mode;
        SWF::gradient_interpolation_mode m_interpolation;
 
+       /// Fill type, see SWF::fill_style_type
+       uint8_t m_type;
+
+       // Only for BITMAP type
+    //
+    // 0: unspecified (smooth with _quality >= BEST)
+    // 1: smooth (smooth with _quality >= MEDIUM)
+    // 2: don't smooth, can be forced with .forceSmoothing, in
+    //    which case it becomes as policy 1
+    BitmapSmoothingPolicy _bitmapSmoothingPolicy;
 };
 
+DSOEXPORT std::ostream& operator << (std::ostream& os,
+    const fill_style::BitmapSmoothingPolicy& p);
 
 } // namespace gnash
 


reply via email to

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