summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Staudinger <robsta@gnome.org>2009-08-07 18:58:11 +0200
committerRobert Staudinger <robsta@gnome.org>2009-08-07 18:58:11 +0200
commitb0566f2c127ab54cd3096fc67fd85b449ce7e2ff (patch)
tree77311c91761af5414c9812cd8fd2c435fb3f8fc6
parent8861d7990f9bf5818db62f5129b44859d652978c (diff)
[cairo-style] Consolidate drawing functions.
Do away with 'outline' and 'line'. functions. Move do double precision coordinates.
-rw-r--r--NEWS3
-rw-r--r--TODO2
-rw-r--r--ccss-cairo-doc/tmpl/ccss-cairo-unused.sgml24
-rw-r--r--ccss-cairo-doc/tmpl/style.sgml26
-rw-r--r--ccss-cairo/ccss-cairo-appearance-parser.c1
-rw-r--r--ccss-cairo/ccss-cairo-background.c28
-rw-r--r--ccss-cairo/ccss-cairo-background.h10
-rw-r--r--ccss-cairo/ccss-cairo-style.c110
-rw-r--r--ccss-cairo/ccss-cairo-style.h36
-rw-r--r--ccss/ccss-node-priv.h8
-rw-r--r--ccss/ccss-node.c18
-rw-r--r--ccss/ccss-node.h8
-rw-r--r--ccss/ccss-selector.c14
-rw-r--r--ccss/ccss-style-priv.h8
14 files changed, 99 insertions, 197 deletions
diff --git a/NEWS b/NEWS
index 6cf464e..fb26816 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,9 @@ Core
Cairo
* Support for loadable modules to hook in custom CSS3 "appearance" renderers.
* Draw background with alpha channel.
+* Move to double precision coordinates.
+* Consolidate drawing functions (no more "outline", "line"), use double precision
+ coordinates.
Gtk
* Improvements to gtk[rc] compatibility.
diff --git a/TODO b/TODO
index b54fea9..c65cf0b 100644
--- a/TODO
+++ b/TODO
@@ -7,8 +7,6 @@ Also see gtk-css-engine's TODO for now.
0.5
---
-* Move to double coordinates.
-* Get rid of draw_line() functions?
* Implement gaps by passing a custom property "-gce-gap" with a ccss_property_t
that contains a cairo_rectangle_t? Or -gce-gap-side, -gce-gap-start, -gce-gap-width?
* Improve test suite. Libxml backend for cascading tests?
diff --git a/ccss-cairo-doc/tmpl/ccss-cairo-unused.sgml b/ccss-cairo-doc/tmpl/ccss-cairo-unused.sgml
index 7726ec8..df7e4b1 100644
--- a/ccss-cairo-doc/tmpl/ccss-cairo-unused.sgml
+++ b/ccss-cairo-doc/tmpl/ccss-cairo-unused.sgml
@@ -22,3 +22,27 @@
Initialization
+<!-- ##### FUNCTION ccss_cairo_style_draw_line ##### -->
+<para>
+
+</para>
+
+@self:
+@cr:
+@x1:
+@x2:
+@y1:
+@y2:
+
+<!-- ##### FUNCTION ccss_cairo_style_draw_outline ##### -->
+<para>
+
+</para>
+
+@self:
+@cr:
+@x:
+@y:
+@width:
+@height:
+
diff --git a/ccss-cairo-doc/tmpl/style.sgml b/ccss-cairo-doc/tmpl/style.sgml
index f9333c1..e154e16 100644
--- a/ccss-cairo-doc/tmpl/style.sgml
+++ b/ccss-cairo-doc/tmpl/style.sgml
@@ -27,32 +27,6 @@ ccss_style_t
@CCSS_CAIRO_GAP_SIDE_TOP:
@CCSS_CAIRO_GAP_SIDE_BOTTOM:
-<!-- ##### FUNCTION ccss_cairo_style_draw_line ##### -->
-<para>
-
-</para>
-
-@self:
-@cr:
-@x1:
-@x2:
-@y1:
-@y2:
-
-
-<!-- ##### FUNCTION ccss_cairo_style_draw_outline ##### -->
-<para>
-
-</para>
-
-@self:
-@cr:
-@x:
-@y:
-@width:
-@height:
-
-
<!-- ##### FUNCTION ccss_cairo_style_draw_rectangle ##### -->
<para>
diff --git a/ccss-cairo/ccss-cairo-appearance-parser.c b/ccss-cairo/ccss-cairo-appearance-parser.c
index 9ad3405..6f99976 100644
--- a/ccss-cairo/ccss-cairo-appearance-parser.c
+++ b/ccss-cairo/ccss-cairo-appearance-parser.c
@@ -22,7 +22,6 @@
#include <gmodule.h>
#include "ccss-cairo-appearance.h"
#include "ccss-cairo-appearance-parser.h"
-#include "ccss-cairo-style.h"
#include "config.h"
typedef char const *
diff --git a/ccss-cairo/ccss-cairo-background.c b/ccss-cairo/ccss-cairo-background.c
index 35271fc..80bc281 100644
--- a/ccss-cairo/ccss-cairo-background.c
+++ b/ccss-cairo/ccss-cairo-background.c
@@ -28,10 +28,8 @@
static cairo_pattern_t *
create_pattern (ccss_cairo_image_t const *image,
- double width,
- double height,
- double tile_width,
- double tile_height)
+ int width,
+ int height)
{
cairo_t *cr;
cairo_surface_t *surface;
@@ -79,8 +77,8 @@ repeat (ccss_cairo_image_t const *image,
/* Create pattern for (width + tile_width, height + tile_height)
* so we can account for `background-position'. */
pattern = create_pattern (image,
- width + tile_width, height + tile_height,
- tile_width, tile_height);
+ width + tile_width,
+ height + tile_height);
g_return_if_fail (pattern);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_NONE);
@@ -102,8 +100,8 @@ repeat_x (ccss_cairo_image_t const *image,
/* Create pattern for (width + tile_width, tile_height)
* so we can account for `background-position'. */
pattern = create_pattern (image,
- width + tile_width, tile_height,
- tile_width, tile_height);
+ width + tile_width,
+ tile_height);
g_return_if_fail (pattern);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_NONE);
@@ -125,8 +123,8 @@ repeat_y (ccss_cairo_image_t const *image,
/* Create pattern for (tile_width, height + tile_height)
* so we can account for `background-position'. */
pattern = create_pattern (image,
- tile_width, height + tile_height,
- tile_width, tile_height);
+ tile_width,
+ height + tile_height);
g_return_if_fail (pattern);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_NONE);
@@ -153,17 +151,17 @@ no_repeat (ccss_cairo_image_t const *image,
* the background. The path is not modified.
**/
void
-ccss_cairo_background_fill (ccss_background_attachment_t const *bg_attachment,
+ccss_cairo_background_fill (ccss_background_attachment_t const *bg_attachment,
ccss_color_t const *bg_color,
ccss_background_image_t const *bg_image,
ccss_background_position_t const *bg_position,
ccss_background_repeat_t const *bg_repeat,
ccss_background_size_t const *bg_size,
cairo_t *cr,
- int32_t x,
- int32_t y,
- int32_t width,
- int32_t height)
+ double x,
+ double y,
+ double width,
+ double height)
{
cairo_status_t status;
double dx;
diff --git a/ccss-cairo/ccss-cairo-background.h b/ccss-cairo/ccss-cairo-background.h
index bdeb4df..6982e02 100644
--- a/ccss-cairo/ccss-cairo-background.h
+++ b/ccss-cairo/ccss-cairo-background.h
@@ -36,17 +36,17 @@
CCSS_BEGIN_DECLS
void
-ccss_cairo_background_fill (ccss_background_attachment_t const *bg_attachment,
+ccss_cairo_background_fill (ccss_background_attachment_t const *bg_attachment,
ccss_color_t const *bg_color,
ccss_background_image_t const *bg_image,
ccss_background_position_t const *bg_position,
ccss_background_repeat_t const *bg_repeat,
ccss_background_size_t const *bg_size,
cairo_t *cr,
- int32_t x,
- int32_t y,
- int32_t width,
- int32_t height);
+ double x,
+ double y,
+ double width,
+ double height);
CCSS_END_DECLS
diff --git a/ccss-cairo/ccss-cairo-style.c b/ccss-cairo/ccss-cairo-style.c
index e176a3c..2517e9d 100644
--- a/ccss-cairo/ccss-cairo-style.c
+++ b/ccss-cairo/ccss-cairo-style.c
@@ -87,54 +87,6 @@ lookup_property_r (ccss_style_t const *self,
return NULL;
}
-/**
- * ccss_cairo_style_draw_line:
- * @self: a #ccss_style_t.
- * @cr: the target to draw onto.
- * @x1: the starting x coordinate.
- * @x2: the ending x coordinate.
- * @y1: the starting y coordinate.
- * @y2: the ending y coordinate.
- *
- * Draw a line using the given style instance.
- **/
-void
-ccss_cairo_style_draw_line (ccss_style_t const *self,
- cairo_t *cr,
- int x1,
- int x2,
- int y1,
- int y2)
-{
- ccss_border_stroke_t stroke;
- double off;
-
- stroke.color = (ccss_color_t *) lookup_property_r (self,
- "border-color");
- stroke.style = (ccss_border_style_t *) lookup_property_r (self,
- "border-style");
- stroke.width = (ccss_border_width_t *) lookup_property_r (self,
- "border-width");
- if (NULL == stroke.width) {
- /* No width, short-cut. */
- return;
- }
-
- off = stroke.width->width / 2.;
-
- if (y1 == y2) {
- ccss_cairo_border_draw (NULL, NULL, &stroke, NULL,
- NULL, NULL, NULL, NULL,
- CCSS_BORDER_VISIBILITY_SHOW_ALL,
- cr, x1, y1 - off, x2 - x1, 0);
- } else {
- ccss_cairo_border_draw (&stroke, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- CCSS_BORDER_VISIBILITY_SHOW_ALL,
- cr, x1 - off, y1, 0, y2 - y1);
- }
-}
-
static void
gather_stroke (ccss_style_t const *self,
char const *color_prop,
@@ -274,43 +226,6 @@ gather_background (ccss_style_t const *self,
}
/**
- * ccss_cairo_style_draw_outline:
- * @self: a #ccss_style_t.
- * @cr: the target to draw onto.
- * @x: the starting x coordinate.
- * @y: the starting y coordinate.
- * @width: width of the outline to draw.
- * @height: height of the outline to draw.
- *
- * Draw an outline using this style instance. Information about how to draw
- * this style's background is diregarded.
- **/
-void
-ccss_cairo_style_draw_outline (ccss_style_t const *self,
- cairo_t *cr,
- int x,
- int y,
- int width,
- int height)
-{
- ccss_border_stroke_t bottom, left, right, top;
- ccss_border_join_t const *bottom_left;
- ccss_border_join_t const *bottom_right;
- ccss_border_join_t const *top_left;
- ccss_border_join_t const *top_right;
-
- gather_outline (self, &bottom, &left, &right, &top,
- &bottom_left, &bottom_right, &top_left, &top_right);
-
- ccss_cairo_border_draw (&left, top_left,
- &top, top_right,
- &right, bottom_right,
- &bottom, bottom_left,
- CCSS_BORDER_VISIBILITY_SHOW_ALL,
- cr, x, y, width, height);
-}
-
-/**
* ccss_cairo_style_draw_rectangle:
* @self: a #ccss_style_t.
* @cr: the target to draw onto.
@@ -324,10 +239,10 @@ ccss_cairo_style_draw_outline (ccss_style_t const *self,
void
ccss_cairo_style_draw_rectangle (ccss_style_t const *self,
cairo_t *cr,
- int x,
- int y,
- int width,
- int height)
+ double x,
+ double y,
+ double width,
+ double height)
{
ccss_border_stroke_t bottom, left, right, top;
ccss_border_join_t const *bottom_left;
@@ -343,7 +258,7 @@ ccss_cairo_style_draw_rectangle (ccss_style_t const *self,
ccss_background_repeat_t const *bg_repeat;
ccss_background_size_t const *bg_size;
- int32_t l, t, w, h;
+ double l, t, w, h;
ccss_cairo_appearance_t *appearance = NULL;
if (ccss_style_get_property (self,
@@ -428,13 +343,13 @@ ccss_cairo_style_draw_rectangle (ccss_style_t const *self,
void
ccss_cairo_style_draw_rectangle_with_gap (ccss_style_t const *self,
cairo_t *cr,
- int x,
- int y,
- int width,
- int height,
+ double x,
+ double y,
+ double width,
+ double height,
ccss_cairo_gap_side_t gap_side,
- int gap_start,
- int gap_width)
+ double gap_start,
+ double gap_width)
{
ccss_border_stroke_t bottom, left, right, top;
ccss_border_join_t const *bl;
@@ -453,7 +368,8 @@ ccss_cairo_style_draw_rectangle_with_gap (ccss_style_t const *self,
ccss_border_join_t bottom_right = { .base.state = CCSS_PROPERTY_STATE_SET, .radius = 0 };
ccss_border_join_t top_left = { .base.state = CCSS_PROPERTY_STATE_SET, .radius = 0 };
ccss_border_join_t top_right = { .base.state = CCSS_PROPERTY_STATE_SET, .radius = 0 };
- int32_t l, t, w, h;
+
+ double l, t, w, h;
gather_outline (self, &bottom, &left, &right, &top,
&bl, &br, &tl, &tr);
diff --git a/ccss-cairo/ccss-cairo-style.h b/ccss-cairo/ccss-cairo-style.h
index 1336704..84ae228 100644
--- a/ccss-cairo/ccss-cairo-style.h
+++ b/ccss-cairo/ccss-cairo-style.h
@@ -50,39 +50,23 @@ typedef enum {
} ccss_cairo_gap_side_t;
void
-ccss_cairo_style_draw_line (ccss_style_t const *self,
- cairo_t *cr,
- int x1,
- int x2,
- int y1,
- int y2);
-
-void
-ccss_cairo_style_draw_outline (ccss_style_t const *self,
- cairo_t *cr,
- int x,
- int y,
- int width,
- int height);
-
-void
ccss_cairo_style_draw_rectangle (ccss_style_t const *self,
cairo_t *cr,
- int x,
- int y,
- int width,
- int height);
+ double x,
+ double y,
+ double width,
+ double height);
void
ccss_cairo_style_draw_rectangle_with_gap (ccss_style_t const *self,
cairo_t *cr,
- int x,
- int y,
- int width,
- int height,
+ double x,
+ double y,
+ double width,
+ double height,
ccss_cairo_gap_side_t gap_side,
- int gap_start,
- int gap_width);
+ double gap_start,
+ double gap_width);
bool
ccss_cairo_style_get_double (ccss_style_t const *self,
diff --git a/ccss/ccss-node-priv.h b/ccss/ccss-node-priv.h
index 791fb88..0fdbbe6 100644
--- a/ccss/ccss-node-priv.h
+++ b/ccss/ccss-node-priv.h
@@ -64,10 +64,10 @@ ccss_node_get_style (ccss_node_t *self,
bool
ccss_node_get_viewport (ccss_node_t const *self,
- uint32_t *x,
- uint32_t *y,
- uint32_t *width,
- uint32_t *height);
+ double *x,
+ double *y,
+ double *width,
+ double *height);
void
ccss_node_release (ccss_node_t *self);
diff --git a/ccss/ccss-node.c b/ccss/ccss-node.c
index b69f80b..6de1e7e 100644
--- a/ccss/ccss-node.c
+++ b/ccss/ccss-node.c
@@ -75,7 +75,7 @@ get_pseudo_classes (ccss_node_t const *self)
static char *
get_attribute (ccss_node_t const *self,
- char const *name)
+ char const *name)
{
return NULL;
}
@@ -89,10 +89,10 @@ get_style (ccss_node_t const *self,
static bool
get_viewport (ccss_node_t const *self,
- uint32_t *x,
- uint32_t *y,
- uint32_t *width,
- uint32_t *height)
+ double *x,
+ double *y,
+ double *width,
+ double *height)
{
return false;
}
@@ -292,10 +292,10 @@ ccss_node_get_style (ccss_node_t *self,
bool
ccss_node_get_viewport (ccss_node_t const *self,
- uint32_t *x,
- uint32_t *y,
- uint32_t *width,
- uint32_t *height)
+ double *x,
+ double *y,
+ double *width,
+ double *height)
{
g_return_val_if_fail (self, false);
g_return_val_if_fail (self->node_class, false);
diff --git a/ccss/ccss-node.h b/ccss/ccss-node.h
index 409d273..d18b96f 100644
--- a/ccss/ccss-node.h
+++ b/ccss/ccss-node.h
@@ -157,9 +157,11 @@ typedef const char * (*ccss_node_get_style_f) (ccss_node_t const *self,
*
* Returns: %TRUE if a valid viewport position has been assigned to the out parameters.
**/
-typedef bool (*ccss_node_get_viewport_f) (ccss_node_t const *self,
- uint32_t *x, uint32_t *y,
- uint32_t *width, uint32_t *height);
+typedef bool (*ccss_node_get_viewport_f) (ccss_node_t const *self,
+ double *x,
+ double *y,
+ double *width,
+ double *height);
/**
* ccss_node_release_f:
diff --git a/ccss/ccss-selector.c b/ccss/ccss-selector.c
index 7cd400f..92e5b97 100644
--- a/ccss/ccss-selector.c
+++ b/ccss/ccss-selector.c
@@ -61,9 +61,9 @@ struct ccss_selector_ {
unsigned int c : 5;
unsigned int d : 5;
unsigned int e : 5;
- struct ccss_selector_ *refinement;
- struct ccss_selector_ *container;
- struct ccss_selector_ *antecessor;
+ struct ccss_selector_ *refinement;
+ struct ccss_selector_ *container;
+ struct ccss_selector_ *antecessor;
ccss_block_t *block;
};
@@ -85,7 +85,11 @@ selector_sync (ccss_selector_t const *self,
to->refinement = NULL;
to->container = NULL;
to->antecessor = NULL;
- to->block = ccss_block_reference (self->block);
+ if (self->block) {
+ to->block = ccss_block_reference (self->block);
+ } else {
+ to->block = NULL;
+ }
}
/*
@@ -1037,7 +1041,7 @@ ccss_selector_apply (ccss_selector_t const *self,
GHashTableIter iter;
gpointer key;
gpointer value;
- uint32_t x, y, width, height;
+ double x, y, width, height;
bool ret;
g_return_val_if_fail (self && self->block && style, false);
diff --git a/ccss/ccss-style-priv.h b/ccss/ccss-style-priv.h
index bd98fe6..8784258 100644
--- a/ccss/ccss-style-priv.h
+++ b/ccss/ccss-style-priv.h
@@ -37,10 +37,10 @@ struct ccss_style_ {
/*< private >*/
ccss_stylesheet_t *stylesheet;
GHashTable *properties;
- int32_t viewport_x;
- int32_t viewport_y;
- int32_t viewport_width;
- int32_t viewport_height;
+ double viewport_x;
+ double viewport_y;
+ double viewport_width;
+ double viewport_height;
#ifdef CCSS_DEBUG
GHashTable *selectors; /* Property pointers to string */
#endif