Author: lewing
Date: 2007-10-10 12:24:00 -0400 (Wed, 10 Oct 2007)
New Revision: 87279

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/control.cpp
   trunk/moon/src/media.cpp
   trunk/moon/src/panel.cpp
   trunk/moon/src/shape.cpp
   trunk/moon/src/text.cpp
   trunk/moon/src/uielement.cpp
   trunk/moon/src/uielement.h
Log:
    2007-10-10 Larry Ewing <[EMAIL PROTECTED]>

        * src/control.cpp, src/media.cpp, src/panel.cpp, src/shape.cpp,
        src/text.cpp src/uielement.cpp src/uielement.h shape.cpp: Rework
        IntersectBoundsWithClipPath to return a modified rect then use it
        in all the ComputeBounds methods.


Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-10-10 16:09:43 UTC (rev 87278)
+++ trunk/moon/src/ChangeLog    2007-10-10 16:24:00 UTC (rev 87279)
@@ -138,6 +138,15 @@
 
 2007-10-08  Larry Ewing  <[EMAIL PROTECTED]>
 
+       * media.cpp:
+       * panel.cpp: intersect the bounds with the clip path to
+       optimize the invalidated region.
+
+       * shape.cpp: return 0.0 when shape_get_stroke_thickness is called
+       with a NULL.
+
+2007-10-08  Larry Ewing  <[EMAIL PROTECTED]>
+
        * runtime.cpp: change previous logic to drop the alpha
        completely here until more testing can be done.
 

Modified: trunk/moon/src/control.cpp
===================================================================
--- trunk/moon/src/control.cpp  2007-10-10 16:09:43 UTC (rev 87278)
+++ trunk/moon/src/control.cpp  2007-10-10 16:24:00 UTC (rev 87279)
@@ -48,8 +48,8 @@
        if (x2 != 0.0 && y2 != 0.0) {
 
                Rect fw_rect = bounding_rect_for_transformed_rect 
(&absolute_xform,
-                                                                  Rect 
(x1,y1,x2,y2));
-
+                                                                  
IntersectBoundsWithClipPath (Rect (x1,y1,x2,y2), false));
+               
                if (real_object)
                        bounds = bounds.Union (fw_rect);
                else

Modified: trunk/moon/src/media.cpp
===================================================================
--- trunk/moon/src/media.cpp    2007-10-10 16:09:43 UTC (rev 87278)
+++ trunk/moon/src/media.cpp    2007-10-10 16:24:00 UTC (rev 87279)
@@ -320,9 +320,8 @@
 
        Rect box = Rect (0, 0, w, h);
        
-       bounds = bounding_rect_for_transformed_rect (&absolute_xform, box);
-
-       IntersectBoundsWithClipPath ();
+       bounds = bounding_rect_for_transformed_rect (&absolute_xform,
+                                                    
IntersectBoundsWithClipPath (box, false));
 }
 
 Point
@@ -1351,9 +1350,8 @@
                         framework_element_get_width (this),
                         framework_element_get_height (this));
                                                                   
-       bounds = bounding_rect_for_transformed_rect (&absolute_xform, box);
-
-       IntersectBoundsWithClipPath ();
+       bounds = bounding_rect_for_transformed_rect (&absolute_xform,
+                                                    
IntersectBoundsWithClipPath (box, false));
 // no-op       bounds.GrowBy (1);
 }
 

Modified: trunk/moon/src/panel.cpp
===================================================================
--- trunk/moon/src/panel.cpp    2007-10-10 16:09:43 UTC (rev 87278)
+++ trunk/moon/src/panel.cpp    2007-10-10 16:24:00 UTC (rev 87279)
@@ -105,7 +105,7 @@
                                continue;
 
                        Rect r = item->GetBounds ();
-
+                       r = IntersectBoundsWithClipPath (r, true);
 #if DEBUG_BOUNDS
                        space (levelb + 4);
                        printf ("Item (%s, 5s) bounds %g %g %g %g\n", 
@@ -129,18 +129,16 @@
        y2 = framework_element_get_height (this);
 
        if (x2 != 0.0 && y2 != 0.0) {
-
                Rect fw_rect = bounding_rect_for_transformed_rect 
(&absolute_xform,
-                                                                  Rect 
(x1,y1,x2,y2));
+                                                                  
IntersectBoundsWithClipPath (Rect (x1,y1,x2,y2), false));
 
+
                if (first)
                        bounds = fw_rect;
                else
                        bounds = bounds.Union (fw_rect);
        }
 
-       IntersectBoundsWithClipPath ();
-
        /* standard "grow the rectangle by enough to cover our
           asses because of cairo's floating point rendering"
           thing */
@@ -230,7 +228,6 @@
        cairo_save (cr);  // for UIElement::ClipProperty
 
        cairo_set_matrix (cr, &absolute_xform);
-
        RenderClipPath (cr);
 
        Value *value = GetValue (Panel::BackgroundProperty);
@@ -239,6 +236,8 @@
                double fheight = framework_element_get_height (this);
 
                if (fwidth > 0 && fheight > 0){
+
+
                        Brush *background = value->AsBrush ();
                        background->SetupBrush (cr, this);
 

Modified: trunk/moon/src/shape.cpp
===================================================================
--- trunk/moon/src/shape.cpp    2007-10-10 16:09:43 UTC (rev 87278)
+++ trunk/moon/src/shape.cpp    2007-10-10 16:24:00 UTC (rev 87279)
@@ -280,15 +280,12 @@
                w = h = shape_get_stroke_thickness (this);
 
        if (w != 0.0 && h != 0.0) {
-
                bounds = bounding_rect_for_transformed_rect (&absolute_xform,
-                                                            Rect (0,0,w,h));
+                      IntersectBoundsWithClipPath (Rect (0, 0, w, h), false));
 
                //printf ("%f,%f,%f,%f\n", bounds.x, bounds.y, bounds.w, 
bounds.h);
        }
 
-       IntersectBoundsWithClipPath ();
-
        /* standard "grow the rectangle by enough to cover our
           asses because of cairo's floating point rendering"
           thing */
@@ -978,9 +975,9 @@
        }
 
        calc_line_bounds (line_get_x1 (this), line_get_x2 (this), line_get_y1 
(this), line_get_y2 (this), thickness, &bounds);
-       bounds = bounding_rect_for_transformed_rect (&absolute_xform, bounds);
-
-       IntersectBoundsWithClipPath ();
+       
+       bounds = bounding_rect_for_transformed_rect (&absolute_xform, 
+                                                    
IntersectBoundsWithClipPath (bounds, false));
 }
 
 void
@@ -1265,9 +1262,8 @@
                bounds.y -= y0;
        }
 
-       bounds = bounding_rect_for_transformed_rect (&absolute_xform, bounds);
-
-       IntersectBoundsWithClipPath ();
+       bounds = bounding_rect_for_transformed_rect (&absolute_xform, 
+                                                    
IntersectBoundsWithClipPath (bounds, false));
 }
 
 void
@@ -1470,9 +1466,8 @@
                bounds.y -= points [0].y;
        }
 
-       bounds = bounding_rect_for_transformed_rect (&absolute_xform, bounds);
-
-       IntersectBoundsWithClipPath ();
+       bounds = bounding_rect_for_transformed_rect (&absolute_xform, 
+                                                    
IntersectBoundsWithClipPath (bounds, false));
 }
 
 void
@@ -1646,9 +1641,9 @@
                bounds.h += t;
        }
 
-       bounds = bounding_rect_for_transformed_rect (&absolute_xform, bounds);
+       bounds = bounding_rect_for_transformed_rect (&absolute_xform,
+                                                    
IntersectBoundsWithClipPath (bounds, false));
 
-       IntersectBoundsWithClipPath ();
 }
 
 void

Modified: trunk/moon/src/text.cpp
===================================================================
--- trunk/moon/src/text.cpp     2007-10-10 16:09:43 UTC (rev 87278)
+++ trunk/moon/src/text.cpp     2007-10-10 16:24:00 UTC (rev 87279)
@@ -461,6 +461,7 @@
 {
        cairo_save (cr);
        cairo_set_matrix (cr, &absolute_xform);
+       RenderClipPath (cr);
        Paint (cr);
        cairo_restore (cr);
 }
@@ -468,7 +469,8 @@
 void 
 TextBlock::ComputeBounds ()
 {
-       bounds = bounding_rect_for_transformed_rect (&absolute_xform, Rect (0, 
0, GetBoundingWidth (), GetBoundingHeight ()));
+       bounds = bounding_rect_for_transformed_rect (&absolute_xform, 
+                                                    
IntersectBoundsWithClipPath (Rect (0, 0, GetBoundingWidth (), GetBoundingHeight 
()), false));
 }
 
 bool
@@ -866,6 +868,7 @@
                dirty = true;
        } else if (prop == TextBlock::TextProperty) {
                // handled elsewhere
+
                dirty = true;
        } else if (prop == TextBlock::InlinesProperty) {
                Inlines *newcol = GetValue (prop)->AsInlines ();
@@ -984,10 +987,13 @@
                else if (property == TextBlock::ActualWidthProperty)
                        actual_width = value->AsDouble ();
        }
-       
        if (property == TextBlock::TextProperty) {
                // Text is a virtual property and setting it deletes all 
current runs,
                // creating a new run
+               //Value *old = GetValue (TextBlock::TextProperty);
+               //if (value && old->AsString () == value->AsString ())
+               //      return;
+
                Run *run = new Run ();
                if (value)
                        run_set_text (run, value->AsString ());
@@ -1421,15 +1427,20 @@
        TextFont *font;
        double x0, y0;
        double y1;
-       
+
        if ((width == 0.0 && height == 0.0) || invalid)
                return;
        
+       cairo_save (cr);
+       cairo_set_matrix (cr, &absolute_xform);
+       RenderClipPath (cr);
+
        fill->SetupBrush (cr, this);
        
        if (path) {
                cairo_append_path (cr, path);
                cairo_fill (cr);
+               cairo_restore (cr);
                return;
        }
        
@@ -1516,6 +1527,7 @@
        }
        
        font->unref ();
+       cairo_restore (cr);
 }
 
 void 
@@ -1524,7 +1536,8 @@
        if (dirty)
                Layout ();
        
-       bounds = bounding_rect_for_transformed_rect (&absolute_xform, Rect (0, 
0, width, height));
+       bounds = bounding_rect_for_transformed_rect (&absolute_xform, 
+                                                    
IntersectBoundsWithClipPath (Rect (0, 0, width, height), false));
 }
 
 Point

Modified: trunk/moon/src/uielement.cpp
===================================================================
--- trunk/moon/src/uielement.cpp        2007-10-10 16:09:43 UTC (rev 87278)
+++ trunk/moon/src/uielement.cpp        2007-10-10 16:24:00 UTC (rev 87279)
@@ -76,17 +76,21 @@
        remove_dirty_element (this);
 }
 
-void
-UIElement::IntersectBoundsWithClipPath ()
+Rect
+UIElement::IntersectBoundsWithClipPath (Rect unclipped, bool transform)
 {
        Value *value = GetValue (UIElement::ClipProperty);
        if (!value)
-               return;
+               return unclipped;
 
        Geometry *geometry = value->AsGeometry ();
        Rect box = geometry->ComputeBounds (NULL);
-       box = bounding_rect_for_transformed_rect (&absolute_xform, box);
-       bounds = box.Intersection (bounds);
+
+       if (transform)
+               box = bounding_rect_for_transformed_rect (&absolute_xform,
+                                                         box);
+
+       return box.Intersection (unclipped);
 }
 
 void
@@ -488,13 +492,17 @@
                mask = cairo_get_source (cr);
                cairo_pattern_reference (mask);
                cairo_push_group (cr);
+
        }
        
        Render (cr, x, y, width, height);
 
        if (opacityMask != NULL) {
                cairo_pop_group_to_source (cr);
-               cairo_rectangle (cr, bounds.x + 1, bounds.y + 1, bounds.w - 2, 
bounds.h - 2);
+               cairo_set_matrix (cr, &absolute_xform);
+               RenderClipPath (cr);
+               cairo_identity_matrix (cr);
+               cairo_rectangle (cr, bounds.x, bounds.y, bounds.w, bounds.h);
                cairo_clip (cr);
                cairo_mask (cr, mask);
                cairo_pattern_destroy (mask);

Modified: trunk/moon/src/uielement.h
===================================================================
--- trunk/moon/src/uielement.h  2007-10-10 16:09:43 UTC (rev 87278)
+++ trunk/moon/src/uielement.h  2007-10-10 16:24:00 UTC (rev 87279)
@@ -36,7 +36,7 @@
 
        double total_opacity;
 protected:
-       void IntersectBoundsWithClipPath ();
+       Rect IntersectBoundsWithClipPath (Rect bounds, bool transform);
        void RenderClipPath (cairo_t *cr);
 public:
        UIElement ();

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

Reply via email to