gnash-commit
[Top][All Lists]
Advanced

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

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


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/DynamicShape.cpp server/...
Date: Mon, 19 Feb 2007 21:40:32 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/02/19 21:40:32

Modified files:
        .              : ChangeLog 
        server         : DynamicShape.cpp DynamicShape.h 
                         sprite_instance.cpp sprite_instance.h 
Added files:
        testsuite/misc-ming.all: DrawingApi.as 

Log message:
                * server/: DynamicShape.{cpp,h}, sprite_instance.{cpp,h}:
                  Implement beginFill() and endFill()
                * testsuite/misc-ming.all/DrawingApi.as: non-automatic
                  source for testing the drawing api. Feel free to add
                  calls there :)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2396&r2=1.2397
http://cvs.savannah.gnu.org/viewcvs/gnash/server/DynamicShape.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/DynamicShape.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.173&r2=1.174
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.69&r2=1.70
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/DrawingApi.as?cvsroot=gnash&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2396
retrieving revision 1.2397
diff -u -b -r1.2396 -r1.2397
--- ChangeLog   19 Feb 2007 18:14:03 -0000      1.2396
+++ ChangeLog   19 Feb 2007 21:40:32 -0000      1.2397
@@ -1,8 +1,16 @@
+2007-02-19 Sandro Santilli <address@hidden>
+
+       * server/: DynamicShape.{cpp,h}, sprite_instance.{cpp,h}:
+         Implement beginFill() and endFill()
+       * testsuite/misc-ming.all/DrawingApi.as: non-automatic
+         source for testing the drawing api. Feel free to add
+         calls there :)
+
 2007-02-19 Udo Giacomozzi <address@hidden>
 
   * server/fill_style.h: add missing return type
-  * gui/fb.cpp: add support for eGalax/eTurbotouch touchscreens; use persistent
-    buffer for PS/2 mice also     
+       * gui/fb.cpp: add support for eGalax/eTurbotouch touchscreens;
+         use persistent buffer for PS/2 mice also     
 
 2007-02-19 Sandro Santilli <address@hidden>
 

Index: server/DynamicShape.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/DynamicShape.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/DynamicShape.cpp     19 Feb 2007 11:21:58 -0000      1.2
+++ server/DynamicShape.cpp     19 Feb 2007 21:40:32 -0000      1.3
@@ -16,9 +16,10 @@
 
 
 
-/* $Id: DynamicShape.cpp,v 1.2 2007/02/19 11:21:58 strk Exp $ */
+/* $Id: DynamicShape.cpp,v 1.3 2007/02/19 21:40:32 strk Exp $ */
 
 #include "DynamicShape.h"
+#include "log.h"
 
 #include <cfloat>
 #include <algorithm>
@@ -49,6 +50,8 @@
 void
 DynamicShape::add_path(const path& pth)
 {
+       log_msg("Adding path with origin(%f,%f), lefFill(%u), rightFill(%u), 
lineStyle(%u)",
+                       pth.m_ax, pth.m_ay, pth.m_fill0, pth.m_fill1, 
pth.m_line);
        m_paths.push_back(pth);
        _currpath = &(m_paths.back());
        compute_bound(&m_bound);
@@ -57,18 +60,8 @@
 void
 DynamicShape::endFill()
 {
-       // Nothing to do if path is already filled
-       if ( _filledpath.empty() ) return;
-
        // Close the path
-       _filledpath.close();
-
-       // Add this path to the drawed ones
-       add_path(_filledpath);
-
-       // Reset filled path, so next path will be drawn from scratch
-       _filledpath.clear(); 
-       assert(_filledpath.empty());
+       if ( _currpath ) _currpath->close();
 
        // Remove reference to the "current" path, as
        // next drawing will happen on a different one
@@ -78,10 +71,22 @@
        _currfill = 0;
 
        // TODO: should I also clear _currline ?
+}
 
-       // Mark as changed
-       changed();
+void
+DynamicShape::beginFill(const rgba& color)
+{
+       // Add the new fill style and set as current
+       fill_style style; style.setSolid(color);
 
+       endFill();
+
+       _currfill = add_fill_style(style);
+       // TODO: how to know wheter the fill should be set
+       //       as *left* or *right* fill ?
+       //       A quick test shows that *left* always work fine !
+       path newPath(_x, _y, _currfill, 0, _currline);
+       add_path(newPath);
 }
 
 void

Index: server/DynamicShape.h
===================================================================
RCS file: /sources/gnash/gnash/server/DynamicShape.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/DynamicShape.h       19 Feb 2007 11:08:22 -0000      1.1
+++ server/DynamicShape.h       19 Feb 2007 21:40:32 -0000      1.2
@@ -15,7 +15,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 
-/* $Id: DynamicShape.h,v 1.1 2007/02/19 11:08:22 strk Exp $ */
+/* $Id: DynamicShape.h,v 1.2 2007/02/19 21:40:32 strk Exp $ */
 
 #ifndef GNASH_DYNAMIC_SHAPE_H
 #define GNASH_DYNAMIC_SHAPE_H
@@ -51,6 +51,9 @@
        /// using given control points.
        void curveTo(float cx, float cy, float ax, float ay);
 
+       /// Start drawing with a solid fill
+       void beginFill(const rgba& color);
+
        /// Close an existing filled path, if any.
        void endFill();
 
@@ -103,8 +106,6 @@
        //
        void startNewPath();
 
-       path _filledpath;
-
        path* _currpath;
 
        size_t _currfill;

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -b -r1.173 -r1.174
--- server/sprite_instance.cpp  19 Feb 2007 11:21:58 -0000      1.173
+++ server/sprite_instance.cpp  19 Feb 2007 21:40:32 -0000      1.174
@@ -858,12 +858,12 @@
 sprite_endFill(const fn_call& fn)
 {
        sprite_instance* sprite = ensure_sprite(fn.this_ptr);
-       UNUSED(sprite);
+       sprite->endFill();
 
        static bool warned = false;
        if ( ! warned )
        {
-               log_error("FIXME: MovieClip.endFill() not implemented yet");
+               log_warning("MovieClip.endFill() TESTING");
                warned=true;
        }
 }
@@ -1014,12 +1014,30 @@
 sprite_beginFill(const fn_call& fn)
 {
        sprite_instance* sprite = ensure_sprite(fn.this_ptr);
-       UNUSED(sprite);
+
+       uint8_t r = 0;
+       uint8_t g = 0;
+       uint8_t b = 0;
+       uint8_t a = 255;
+
+       if ( fn.nargs > 0 )
+       {
+               // 2^24 is the max here
+               uint32_t rgbval = uint32_t(fclamp(fn.arg(0).to_number(), 0, 
16777216));
+               r = uint8_t( (rgbval&0xFF0000) >> 16);
+               g = uint8_t( (rgbval&0x00FF00) >> 8);
+               b = uint8_t( (rgbval&0x0000FF) );
+
+       }
+
+       rgba color(r, g, b, a);
+
+       sprite->beginFill(color);
 
        static bool warned = false;
        if ( ! warned )
        {
-               log_error("FIXME: MovieClip.beginFill() not implemented yet");
+               log_warning("MovieClip.beginFill() TESTING");
                warned=true;
        }
 }

Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- server/sprite_instance.h    19 Feb 2007 11:08:22 -0000      1.69
+++ server/sprite_instance.h    19 Feb 2007 21:40:32 -0000      1.70
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: sprite_instance.h,v 1.69 2007/02/19 11:08:22 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.70 2007/02/19 21:40:32 strk Exp $ */
 
 // Stateful live Sprite instance
 
@@ -601,6 +601,16 @@
                _drawable->lineStyle(thickness, color);
        }
 
+       void beginFill(const rgba& color)
+       {
+               _drawable->beginFill(color);
+       }
+
+       void endFill()
+       {
+               _drawable->endFill();
+       }
+
        void moveTo(float x, float y)
        {
                _drawable->moveTo(x, y);

Index: testsuite/misc-ming.all/DrawingApi.as
===================================================================
RCS file: testsuite/misc-ming.all/DrawingApi.as
diff -N testsuite/misc-ming.all/DrawingApi.as
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/DrawingApi.as       19 Feb 2007 21:40:32 -0000      
1.1
@@ -0,0 +1,64 @@
+//
+// Some tests for the Drawing API
+// Build with:
+//     makeswf -o DrawingApi.swf DrawingApi.as
+// Run with:
+//     firefox DrawingApi.swf
+// Or:
+//     gnash DrawingApi.swf
+//
+
+// Can draw both on a dynamically-created movie...
+//createEmptyMovieClip("a", 10);
+// ... or on a statically-created one
+a = _root;
+
+with (a)
+{
+       clear();
+       lineStyle(20, 0xFF0000, 100);
+       moveTo(100, 100);
+       lineTo(200, 200);
+       moveTo(100, 200);
+       lineStyle(5, 0xFF00FF, 50);
+       lineTo(200, 250);
+       lineStyle(10, 0xFFFF00, 100);
+       lineTo(400, 200);
+       lineStyle(8, 0x00FF00, 100);
+       curveTo(400, 120, 300, 100);
+       lineStyle();
+       lineTo(80, 100);
+       lineStyle(20);
+       lineTo(80, 150);
+
+       moveTo(80, 180);
+       lineStyle(2, 0xFF0000);
+       beginFill(0x0000FF, 100);
+       lineTo(50, 180);
+       curveTo(20, 200, 50, 250);
+       lineTo(100, 250);
+       lineTo(80, 180);
+       endFill();
+       lineTo(50, 150);
+
+       // clockwise
+       moveTo(200, 100);
+       lineStyle(1, 0x00FF00);
+       beginFill(0x00FFFF, 100);
+       lineTo(200, 120);
+       lineTo(180, 120);
+       lineTo(180, 100);
+       lineTo(200, 100);
+       endFill();
+
+       // counter-clockwise
+       moveTo(230, 100);
+       lineStyle(1, 0x00FFFF);
+       beginFill(0x00FF00, 50);
+       lineTo(210, 100);
+       lineTo(210, 120);
+       lineTo(230, 120);
+       lineTo(230, 100);
+       endFill();
+}
+




reply via email to

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