Author: toshok
Date: 2007-08-21 15:07:27 -0400 (Tue, 21 Aug 2007)
New Revision: 84581
Modified:
branches/moon-delayed-rendering/src/ChangeLog
branches/moon-delayed-rendering/src/shape.cpp
branches/moon-delayed-rendering/src/shape.h
Log:
2007-08-21 Chris Toshok <[EMAIL PROTECTED]>
* shape.h: add Shape::ComputeBoundsSlow, which uses the slow
(cairo_*_extents) codepath for computing bounds. Use this path
for polygons, polylines, and paths. Implement a Line-specific
fast ComputeBounds.
Modified: branches/moon-delayed-rendering/src/ChangeLog
===================================================================
--- branches/moon-delayed-rendering/src/ChangeLog 2007-08-21 19:07:24 UTC
(rev 84580)
+++ branches/moon-delayed-rendering/src/ChangeLog 2007-08-21 19:07:27 UTC
(rev 84581)
@@ -1,3 +1,10 @@
+2007-08-21 Chris Toshok <[EMAIL PROTECTED]>
+
+ * shape.h: add Shape::ComputeBoundsSlow, which uses the slow
+ (cairo_*_extents) codepath for computing bounds. Use this path
+ for polygons, polylines, and paths. Implement a Line-specific
+ fast ComputeBounds.
+
2007-08-20 Chris Toshok <[EMAIL PROTECTED]>
* media.cpp (MediaElement::ComputeBounds): GrowBy(1).
Modified: branches/moon-delayed-rendering/src/shape.cpp
===================================================================
--- branches/moon-delayed-rendering/src/shape.cpp 2007-08-21 19:07:24 UTC
(rev 84580)
+++ branches/moon-delayed-rendering/src/shape.cpp 2007-08-21 19:07:27 UTC
(rev 84581)
@@ -298,6 +298,32 @@
}
void
+Shape::ComputeBoundsSlow ()
+{
+ double x1, y1, x2, y2;
+ cairo_t* cr = measuring_context_create ();
+
+ cairo_save (cr);
+ // dont do the operation
+ DoDraw (cr, false, true);
+
+ // XXX this next call will hopefully become unnecessary in a
+ // later version of cairo.
+ cairo_identity_matrix (cr);
+ if (stroke)
+ cairo_stroke_extents (cr, &x1, &y1, &x2, &y2);
+ else
+ cairo_fill_extents (cr, &x1, &y1, &x2, &y2);
+
+ cairo_new_path (cr);
+ cairo_restore (cr);
+
+ bounds = Rect (x1-1, y1-1, x2-x1 + 2, y2-y1 + 2);
+
+ measuring_context_destroy (cr);
+}
+
+void
Shape::GetSizeForBrush (cairo_t *cr, double *width, double *height)
{
double x1, y1, x2, y2;
@@ -720,6 +746,21 @@
DependencyProperty* Line::Y2Property;
void
+Line::ComputeBounds ()
+{
+ double x1 = line_get_x1 (this);
+ double y1 = line_get_y1 (this);
+ double x2 = line_get_x2 (this);
+ double y2 = line_get_y2 (this);
+
+ bounds = bounding_rect_for_transformed_rect (&absolute_xform,
+ Rect (MIN(x1,x2),
MIN(y1,y2),
+ fabs (x2-x1), fabs
(y2-y1)));
+
+ bounds.GrowBy (shape_get_stroke_thickness (this) + 1);
+}
+
+void
Line::Draw (cairo_t *cr)
{
// Note: Shape::StretchProperty has no effect on lines
@@ -804,6 +845,12 @@
DependencyProperty* Polygon::PointsProperty;
void
+Polygon::ComputeBounds ()
+{
+ Shape::ComputeBoundsSlow ();
+}
+
+void
Polygon::Draw (cairo_t *cr)
{
int i, count = 0;
@@ -919,6 +966,12 @@
DependencyProperty* Polyline::PointsProperty;
void
+Polyline::ComputeBounds ()
+{
+ Shape::ComputeBoundsSlow ();
+}
+
+void
Polyline::Draw (cairo_t *cr)
{
int i, count = 0;
@@ -1028,6 +1081,12 @@
}
void
+Path::ComputeBounds()
+{
+ Shape::ComputeBoundsSlow ();
+}
+
+void
Path::Draw (cairo_t *cr)
{
Geometry* data = path_get_data (this);
Modified: branches/moon-delayed-rendering/src/shape.h
===================================================================
--- branches/moon-delayed-rendering/src/shape.h 2007-08-21 19:07:24 UTC (rev
84580)
+++ branches/moon-delayed-rendering/src/shape.h 2007-08-21 19:07:27 UTC (rev
84581)
@@ -37,8 +37,10 @@
// Shape class
//
class Shape : public FrameworkElement {
+ private:
void DoDraw (cairo_t *cr, bool do_op, bool consider_fill);
Brush *stroke, *fill;
+
public:
static DependencyProperty* FillProperty;
static DependencyProperty* StretchProperty;
@@ -62,6 +64,7 @@
virtual void Render (cairo_t *cr, int x, int y, int width, int height);
virtual void GetSizeForBrush (cairo_t *cr, double *width, double
*height);
virtual void ComputeBounds ();
+ void ComputeBoundsSlow (); /* uses the cairo_*_extents calls */
virtual bool InsideObject (cairo_t *cr, double x, double y);
//
@@ -161,6 +164,8 @@
Line () { };
virtual Type::Kind GetObjectType () { return Type::LINE; };
+ virtual void ComputeBounds ();
+
void Draw (cairo_t *cr);
// Line has no center to compute, it's always 0,0 because it provides
it's own start and end
@@ -195,6 +200,8 @@
// Polygon has no center to compute, it's always 0,0 because it
provides it's own start and end
// virtual Point GetTransformOrigin ();
+ virtual void ComputeBounds ();
+
void Draw (cairo_t *cr);
virtual void OnPropertyChanged (DependencyProperty *prop);
virtual void OnCollectionChanged (Collection *col, CollectionChangeType
type, DependencyObject *obj, DependencyProperty *prop);
@@ -221,6 +228,8 @@
// Polyline has no center to compute, it's always 0,0 because it
provides it's own start and end
// virtual Point GetTransformOrigin ();
+ virtual void ComputeBounds ();
+
void Draw (cairo_t *cr);
virtual void OnPropertyChanged (DependencyProperty *prop);
@@ -253,6 +262,8 @@
// Path has no center to compute, it's always 0,0 because it provides
it's own start and end
// virtual Point GetTransformOrigin ();
+ virtual void ComputeBounds ();
+
void Draw (cairo_t *cr);
virtual bool CanFill ();
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches