index d429cbee3cd69a49f2fc263ec829e4dc171798c7..bc3c6c4848b6c9fbd795e4e8cb9c2a5baae0af89 100644 (file)
-#define __SP_CAIRO_RENDERER_C__
-
/** \file
* Rendering with Cairo.
*/
/*
* Author:
* Miklos Erdelyi <erdelyim@gmail.com>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2006 Miklos Erdelyi
*
if (!shape->curve) return;
- sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE);
+ item->invoke_bbox( &pbox, Geom::identity(), TRUE);
SPStyle* style = SP_OBJECT_STYLE (item);
// Get the bounding box of the selection in document coordinates.
Geom::OptRect bbox =
- item->getBounds(sp_item_i2d_affine(item), SPItem::RENDERING_BBOX);
+ item->getBounds(item->i2d_affine(), SPItem::RENDERING_BBOX);
- if (!bbox) // no bbox, e.g. empty group
+ // no bbox, e.g. empty group
+ if (!bbox) {
return;
+ }
+
+ Geom::Rect docrect(Geom::Rect(Geom::Point(0, 0), SP_OBJECT(item)->document->getDimensions()));
+ Geom::Rect bboxrect(Geom::Rect(Geom::Point(bbox->min()[Geom::X], bbox->min()[Geom::Y]), Geom::Point(bbox->max()[Geom::X], bbox->max()[Geom::Y])));
+
+ Geom::OptRect _bbox = Geom::intersect(docrect, bboxrect);
+
+ // assign the object dimension clipped on the document, no need to draw on area not on canvas
+ bbox = _bbox;
+
+ // no bbox, e.g. empty group
+ if (!bbox) {
+ return;
+ }
// The width and height of the bitmap in pixels
unsigned width = (unsigned) floor ((bbox->max()[Geom::X] - bbox->min()[Geom::X]) * (res / PX_PER_IN));
(Geom::Matrix)(Geom::Translate (shift_x, shift_y));
// ctx matrix already includes item transformation. We must substract.
- Geom::Matrix t_item = sp_item_i2d_affine (item);
+ Geom::Matrix t_item = item->i2d_affine ();
Geom::Matrix t = t_on_document * t_item.inverse();
// Do the export
@@ -603,16 +618,17 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
g_assert( ctx != NULL );
- if (!base)
- base = SP_ITEM(sp_document_root(doc));
+ if (!base) {
+ base = SP_ITEM(doc->getRoot());
+ }
NRRect d;
if (pageBoundingBox) {
d.x0 = d.y0 = 0;
- d.x1 = sp_document_width(doc);
- d.y1 = sp_document_height(doc);
+ d.x1 = doc->getWidth();
+ d.y1 = doc->getHeight();
} else {
- sp_item_invoke_bbox(base, &d, sp_item_i2d_affine(base), TRUE, SPItem::RENDERING_BBOX);
+ base->invoke_bbox( &d, base->i2d_affine(), TRUE, SPItem::RENDERING_BBOX);
}
if (ctx->_vector_based_target) {
@@ -632,7 +648,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
if (ret && !pageBoundingBox)
{
- double high = sp_document_height(doc);
+ double high = doc->getHeight();
if (ctx->_vector_based_target)
high *= PT_PER_PX;
TRACE(("BEGIN clip\n"));
SPObject *co = SP_OBJECT(cp);
- for (SPObject *child = sp_object_first_child(co) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ for ( SPObject *child = co->firstChild() ; child; child = child->getNext() ) {
if (SP_IS_ITEM(child)) {
SPItem *item = SP_ITEM(child);
TRACE(("BEGIN mask\n"));
SPObject *co = SP_OBJECT(mask);
- for (SPObject *child = sp_object_first_child(co) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ for ( SPObject *child = co->firstChild() ; child; child = child->getNext() ) {
if (SP_IS_ITEM(child)) {
SPItem *item = SP_ITEM(child);
renderItem(ctx, item);
@@ -813,4 +829,4 @@ calculatePreserveAspectRatio(unsigned int aspect_align, unsigned int aspect_clip
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :