Author: miguel
Date: 2007-06-05 19:42:32 -0400 (Tue, 05 Jun 2007)
New Revision: 78689

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/demo.cpp
   trunk/moon/src/ffvideo.cpp
   trunk/moon/src/runtime.cpp
   trunk/moon/src/runtime.h
   trunk/moon/src/shape.cpp
   trunk/moon/src/shape.h
   trunk/moon/src/video.cpp
Log:
2007-06-05  Miguel de Icaza  <[EMAIL PROTECTED]>

        * shape.cpp, ffvideo.cpp, video.cpp: Do not use x, y anymore, we
        now have an absolute affine set for us beforehand.

        * runtim.cpp: on update_xform call the parent ::get_xform_for to
        obtain the base affine transform to use.



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-06-05 23:41:43 UTC (rev 78688)
+++ trunk/moon/src/ChangeLog    2007-06-05 23:42:32 UTC (rev 78689)
@@ -1,3 +1,11 @@
+2007-06-05  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * shape.cpp, ffvideo.cpp, video.cpp: Do not use x, y anymore, we
+       now have an absolute affine set for us beforehand.
+
+       * runtim.cpp: on update_xform call the parent ::get_xform_for to
+       obtain the base affine transform to use.
+
 2007-06-05  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * geometry.cpp|h: Use DependencyProperty for properties.
@@ -13,6 +21,9 @@
 
 2007-06-05  Miguel de Icaza  <[EMAIL PROTECTED]>
 
+       * ffvideo.cpp (VideoFfmpeg): Initialize audio_frames_size, caught
+       by valgrind
+
        * runtime.cpp (item_set_transform): This routine was doing nothing
        but doing an invalidate of the region, updating the transform,
        updating the bounding box and re-invalidating the new area.   Move

Modified: trunk/moon/src/demo.cpp
===================================================================
--- trunk/moon/src/demo.cpp     2007-06-05 23:41:43 UTC (rev 78688)
+++ trunk/moon/src/demo.cpp     2007-06-05 23:42:32 UTC (rev 78689)
@@ -17,6 +17,7 @@
 static RotateTransform *r_trans;
 static RotateTransform *v_trans;
 static ScaleTransform *s_trans;
+static TranslateTransform *t_trans;
 
 static gboolean
 animate (gpointer data)
@@ -26,7 +27,6 @@
 
        rotate_transform_set_angle (r_trans,
                                    rotate_transform_get_angle (r_trans) - 3);
-
        static double scale_change = -0.02;
 
        scale_transform_set_scale_x (s_trans,
@@ -38,7 +38,7 @@
            || (scale_change > 0 && scale_transform_get_scale_x (s_trans) > 
0.75)) {
            scale_change = -scale_change;
        }
-       
+
        return TRUE;
 }
 
@@ -67,18 +67,24 @@
        r_trans = new RotateTransform ();
        v_trans = new RotateTransform ();
        s_trans = new ScaleTransform ();
+       t_trans = new TranslateTransform ();
 
        Surface *t = surface_new (600, 600);
        gtk_container_add (GTK_CONTAINER(w), t->drawing_area);
 
-       r = rectangle_new (50, 50, 50, 50);
+       r = rectangle_new (50, 50);
+       r->SetValue (Canvas::LeftProperty, Value (50.0));
+       r->SetValue (Canvas::TopProperty, Value (50.0));
+
        rectangle_set_radius_x (r, 10);
        rectangle_set_radius_y (r, 20);
        item_set_render_transform (r, s_trans);
        Color c = Color (1.0, 0.0, 0.5, 0.5);
        shape_set_stroke (r, new SolidColorBrush (c));
 
-       Rectangle *r2 = rectangle_new (50, 50, 50, 50);
+       Rectangle *r2 = rectangle_new (50, 50);
+       r2->SetValue (Canvas::LeftProperty, Value (50.0));
+       r2->SetValue (Canvas::TopProperty, Value (50.0));
        item_set_render_transform (r2, r_trans);
        shape_set_stroke (r2, new SolidColorBrush (c));
        panel_child_add (t, r2);
@@ -88,7 +94,7 @@
 #endif
 
 #ifdef VIDEO_DEMO
-       v = video_new ("file:///tmp/BoxerSmacksdownInhoffe.wmv", 0, 0);
+       v = video_new ("file:///tmp/BoxerSmacksdownInhoffe.wmv");
        item_set_render_transform (v, v_trans);
        item_set_transform_origin (v, Point (1, 1));
        printf ("Got %d\n", v);
@@ -100,7 +106,9 @@
 #ifdef VIDEO_DEMO
        //UIElement *v2 = video_new 
("file:///tmp/Countdown-Colbert-BestNailings.wmv", 100, 100);
        //UIElement *v2 = video_new ("file:///tmp/red.wmv", 100, 100);
-       UIElement *v2 = video_new ("file:///tmp/BoxerSmacksdownInhoffe.wmv", 
100, 100);
+       UIElement *v2 = video_new ("file:///tmp/BoxerSmacksdownInhoffe.wmv");
+       v2->SetValue (Canvas::LeftProperty, Value (100.0));
+       v2->SetValue (Canvas::TopProperty, Value (100.0));
        item_set_render_transform (v2, s_trans);
        panel_child_add (t, v2);
 #endif

Modified: trunk/moon/src/ffvideo.cpp
===================================================================
--- trunk/moon/src/ffvideo.cpp  2007-06-05 23:41:43 UTC (rev 78688)
+++ trunk/moon/src/ffvideo.cpp  2007-06-05 23:42:32 UTC (rev 78689)
@@ -56,7 +56,7 @@
 public:
        int w, h;
 
-       VideoFfmpeg (const char *filename, double x, double y);
+       VideoFfmpeg (const char *filename);
        ~VideoFfmpeg ();
 
        // Virtual method overrides
@@ -143,7 +143,7 @@
        cairo_save (s->cairo);
        cairo_set_matrix (s->cairo, &absolute_xform);
 
-       cairo_rectangle (s->cairo, x, y, cc->width, cc->height);
+       cairo_rectangle (s->cairo, 0, 0, cc->width, cc->height);
        cairo_fill_extents (s->cairo, &x1, &y1, &x2, &y2);
 
        cairo_restore (s->cairo);
@@ -552,9 +552,9 @@
        cairo_save (s->cairo);
        cairo_set_matrix (s->cairo, &absolute_xform);
    
-       cairo_set_source_surface (s->cairo, video_cairo_surface, this->x, 
this->y);
+       cairo_set_source_surface (s->cairo, video_cairo_surface, 0, 0);
 
-       cairo_rectangle (s->cairo, this->x, this->y, this->w, this->h);
+       cairo_rectangle (s->cairo, 0, 0, this->w, this->h);
 
        cairo_fill (s->cairo);
 
@@ -576,18 +576,18 @@
        }
 }
 Video *
-video_ffmpeg_new (const char *filename, double x, double y)
+video_ffmpeg_new (const char *filename)
 {
        VideoFfmpeg *video;
 
        ffmpeg_init ();
 
-       video = new VideoFfmpeg (filename, x, y);
+       video = new VideoFfmpeg (filename);
 
        return (Video *) video;
 }
 
-VideoFfmpeg::VideoFfmpeg (const char *filename, double x, double y) : Video 
(filename, x, y)
+VideoFfmpeg::VideoFfmpeg (const char *filename) : Video (filename)
 {
        printf ("VideoFfmpeg .ctor. filename = %s\n", filename);
        
@@ -608,6 +608,7 @@
        frame_size = 0;
        micro_to_pts = 0;
        video_frames_size = 0;
+       audio_frames_size = 0;
 
        pipe (pipes);
        fcntl (pipes [0], F_SETFL, O_NONBLOCK);
@@ -623,7 +624,7 @@
 Point
 VideoFfmpeg::getxformorigin ()
 {
-       return Point (x + user_xform_origin.x * w, y + user_xform_origin.y * h);
+       return Point (user_xform_origin.x * w, user_xform_origin.y * h);
 }
 
 VideoFfmpeg::~VideoFfmpeg ()
@@ -650,8 +651,8 @@
  *
  */
 Video *
-video_new (const char *filename, double x, double y)
+video_new (const char *filename)
 {
-       return video_ffmpeg_new (filename, x, y);
+       return video_ffmpeg_new (filename);
 }
 

Modified: trunk/moon/src/runtime.cpp
===================================================================
--- trunk/moon/src/runtime.cpp  2007-06-05 23:41:43 UTC (rev 78688)
+++ trunk/moon/src/runtime.cpp  2007-06-05 23:42:32 UTC (rev 78689)
@@ -97,6 +97,13 @@
        printf ("FIXME: We should go through all of the attached properties and 
unref them\n");
 }
 
+void
+UIElement::get_xform_for (UIElement *item, cairo_matrix_t *result)
+{
+       printf ("get_xform_for called on a non-container, you must implement 
this in your container\n");
+       exit (1);
+}
+
 void 
 item_invalidate (UIElement *item)
 {
@@ -150,8 +157,18 @@
 {
        cairo_matrix_t user_transform;
 
+       //
+       // What is more important, the space used by 6 doubles,
+       // or the time spent calling the parent (that will call
+       // DependencyObject->GetProperty to get the positions?
+       //
+       // Currently we go for thiner, but if we decide to go
+       // for reduced computation, we should introduce the 
+       // base transform in UIElement that will be updated by the
+       // container on demand
+       //
        if (parent != NULL)
-               absolute_xform = parent->absolute_xform;
+               parent->get_xform_for (this, &absolute_xform);
        else
                cairo_matrix_init_identity (&absolute_xform);
 
@@ -213,26 +230,34 @@
        panel->getbounds ();
 }
 
+void 
+panel_child_add (Panel *panel, UIElement *item)
+{
+       collection_add (&panel->children, item);
+}
+
 Panel::Panel ()
 {
        children.Setup (panel_child_add, panel_child_remove, this);
 }
 
 void
-Panel::render (Surface *s, int x, int y, int width, int height)
+Canvas::get_xform_for (UIElement *item, cairo_matrix_t *result)
 {
-       GSList *il;
-       double actual [6];
-       
-       for (il = children.list; il != NULL; il = il->next){
-               UIElement *item = (UIElement *) il->data;
+       *result = absolute_xform;
 
-               item->render (s, x, y, width, height);
-       }
+       // Compute left/top if its attached to the item
+       Value *val_top = item->GetValue (Canvas::TopProperty);
+       double top = val_top == NULL ? 0.0 : val_top->u.d;
+
+       Value *val_left = item->GetValue (Canvas::LeftProperty);
+       double left = val_left == NULL ? 0.0 : val_left->u.d;
+               
+       cairo_matrix_translate (result, left, top);
 }
 
 void
-Panel::update_xform ()
+Canvas::update_xform ()
 {
        UIElement::update_xform ();
        GSList *il;
@@ -245,7 +270,7 @@
 }
 
 void
-Panel::getbounds ()
+Canvas::getbounds ()
 {
        bool first = TRUE;
        GSList *il;
@@ -280,12 +305,6 @@
 }
 
 void 
-panel_child_add (Panel *panel, UIElement *item)
-{
-       collection_add (&panel->children, item);
-}
-
-void 
 surface_clear (Surface *s, int x, int y, int width, int height)
 {
        static unsigned char n;
@@ -406,12 +425,6 @@
        }
 }
 
-void 
-Canvas::getbounds ()
-{
-       Panel::getbounds ();
-}
-
 Surface *
 surface_new (int width, int height)
 {
@@ -452,8 +465,8 @@
 GHashTable *DependencyObject::default_values = NULL;
 
 typedef struct {
-  DependencyObject *dob;
-  DependencyProperty *prop;
+       DependencyObject *dob;
+       DependencyProperty *prop;
 } Attachee;
 
 void

Modified: trunk/moon/src/runtime.h
===================================================================
--- trunk/moon/src/runtime.h    2007-06-05 23:41:43 UTC (rev 78688)
+++ trunk/moon/src/runtime.h    2007-06-05 23:42:32 UTC (rev 78689)
@@ -387,7 +387,7 @@
        // 
        Point   user_xform_origin;      // transformation origin, user set
 
-       // Absolute affine transform
+       // Absolute affine transform, precomputed with all of its data
        cairo_matrix_t absolute_xform;
 
        //
@@ -420,6 +420,13 @@
        virtual void set_prop_from_str (const char *pname, const char *vname);
 
        //
+       // get_xform_for
+       //   Obtains the affine transform for the given child, this is
+       //   implemented by containers
+
+       virtual void get_xform_for (UIElement *item, cairo_matrix_t *result);
+       
+       //
        // gencenter:
        //   Returns the transformation origin based on  of the item and the
        //   xform_origin
@@ -451,10 +458,6 @@
        Collection children;
 
        Panel ();
-
-       virtual void render (Surface *s, int x, int y, int width, int height);
-       virtual void getbounds ();
-       virtual void update_xform ();
 };
 
 // panel_get_collection, exposed to the managed world so it can manipulate the 
collection
@@ -475,6 +478,8 @@
 
        virtual void render (Surface *s, int x, int y, int width, int height);
        virtual void getbounds ();
+       virtual void update_xform ();
+       virtual void get_xform_for (UIElement *item, cairo_matrix_t *result);
 
        static DependencyProperty* TopProperty;
        static DependencyProperty* LeftProperty;
@@ -485,7 +490,6 @@
 //
 class FrameworkElement : public UIElement {
  public:
-       double x, y;            // Canvas.TopProperty, Canvas.LeftProperty
        double w, h;
 
        FrameworkElement () : w(0), h(0) {} 
@@ -497,18 +501,17 @@
 class Video : public UIElement {
        enum { VIDEO_OK, VIDEO_ERROR_OPEN, VIDEO_ERROR_STREAM_INFO } VideoError;
  public:
-       double x, y;
        char  *filename;
        int    error;
 
        virtual Point getxformorigin () = 0;
        
-       Video (const char *filename, double x, double y);
+       Video (const char *filename);
        ~Video ();
 };
 
-Video *video_new     (const char *filename, double x, double y);
-void  video_destroy  (Video *video);
+Video *video_new     (const char *filename);
+void   video_destroy (Video *video);
 
 typedef struct _SurfacePrivate SurfacePrivate;
 

Modified: trunk/moon/src/shape.cpp
===================================================================
--- trunk/moon/src/shape.cpp    2007-06-05 23:41:43 UTC (rev 78688)
+++ trunk/moon/src/shape.cpp    2007-06-05 23:42:32 UTC (rev 78689)
@@ -21,11 +21,7 @@
 void
 FrameworkElement::set_prop_from_str (const char *prop, const char *value)
 {
-       if (!g_strcasecmp (prop, "canvas.left"))
-               x = strtod (value, NULL);
-       else if (!g_strcasecmp (prop, "canvas.top"))
-               y = strtod (value, NULL);
-       else if (!g_strcasecmp (prop, "width"))
+       if (!g_strcasecmp (prop, "width"))
                w = strtod (value, NULL);
        else if (!g_strcasecmp (prop, "height"))
                h = strtod (value, NULL);
@@ -198,8 +194,8 @@
 
        rx = w / 2;
        ry = h / 2;
-       cx = x + rx;
-       cy = y + ry;
+       cx = rx;
+       cy = ry;
 
        cairo_move_to (s->cairo, cx + rx, cy);
 
@@ -251,7 +247,7 @@
                        // approximate (quite close) the arc using a bezier 
curve
                        double c1 = ARC_TO_BEZIER * radius_x;
                        double c2 = ARC_TO_BEZIER * radius_y;
-                       cairo_move_to (s->cairo, x + radius_x, y);
+                       cairo_move_to (s->cairo, radius_x, 0);
                        cairo_rel_line_to (s->cairo, w - 2 * radius_x, 0.0);
                        cairo_rel_curve_to (s->cairo, c1, 0.0, radius_x, c2, 
radius_x, radius_y);
                        cairo_rel_line_to (s->cairo, 0, h - 2 * radius_y);
@@ -266,7 +262,7 @@
        }
 
        // normal rectangle
-       cairo_rectangle (s->cairo, x, y, w, h);
+       cairo_rectangle (s->cairo, 0, 0, w, h);
 }
 
 void
@@ -283,7 +279,7 @@
 Point
 Rectangle::getxformorigin ()
 {
-       return Point (x + w * user_xform_origin.x, y + h * user_xform_origin.y);
+       return Point (w * user_xform_origin.x, h * user_xform_origin.y);
 }
 
 double
@@ -311,11 +307,9 @@
 }
 
 Rectangle *
-rectangle_new (double x, double y, double w, double h)
+rectangle_new (double w, double h)
 {
        Rectangle *rect = new Rectangle ();
-       rect->x = x;
-       rect->y = y;
        rect->w = w;
        rect->h = h;
        return rect;

Modified: trunk/moon/src/shape.h
===================================================================
--- trunk/moon/src/shape.h      2007-06-05 23:41:43 UTC (rev 78688)
+++ trunk/moon/src/shape.h      2007-06-05 23:42:32 UTC (rev 78689)
@@ -103,11 +103,11 @@
 
        virtual Point getxformorigin ();
 };
-Rectangle *rectangle_new  (double x, double y, double w, double h);
-double rectangle_get_radius_x (Rectangle *rectangle);
-void rectangle_set_radius_x (Rectangle *rectangle, double value);
-double rectangle_get_radius_y (Rectangle *rectangle);
-void rectangle_set_radius_y (Rectangle *rectangle, double value);
+Rectangle *rectangle_new          (double w, double h);
+double     rectangle_get_radius_x (Rectangle *rectangle);
+void       rectangle_set_radius_x (Rectangle *rectangle, double value);
+double     rectangle_get_radius_y (Rectangle *rectangle);
+void       rectangle_set_radius_y (Rectangle *rectangle, double value);
 
 //
 // Line class 

Modified: trunk/moon/src/video.cpp
===================================================================
--- trunk/moon/src/video.cpp    2007-06-05 23:41:43 UTC (rev 78688)
+++ trunk/moon/src/video.cpp    2007-06-05 23:42:32 UTC (rev 78689)
@@ -17,11 +17,9 @@
 #include <stdlib.h>
 #include "runtime.h"
 
-Video::Video (const char *filename, double x, double y)
+Video::Video (const char *filename)
 {
        this->filename = g_strdup (filename);
-       this->x = x;
-       this->y = y;
 }
 
 Video::~Video ()

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to