~7-eric/inkscape/boolop-fix

« back to all changes in this revision

Viewing changes to src/extension/internal/cairo-renderer.cpp

Merge Google Summer of Code unit refactor.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
#include "sp-mask.h"
56
56
#include "sp-clippath.h"
57
57
 
58
 
#include <unit-constants.h>
 
58
#include "util/units.h"
59
59
#include "helper/png-write.h"
60
60
#include "helper/pixbuf-ops.h"
61
61
 
442
442
    */
443
443
    res = ctx->getBitmapResolution();
444
444
    if(res == 0) {
445
 
        res = PX_PER_IN;
 
445
        res = Inkscape::Util::Quantity::convert(1, "in", "px");
446
446
    }
447
447
    TRACE(("sp_asbitmap_render: resolution: %f\n", res ));
448
448
 
463
463
    }
464
464
 
465
465
    // The width and height of the bitmap in pixels
466
 
    unsigned width =  ceil(bbox->width() * (res / PX_PER_IN));
467
 
    unsigned height = ceil(bbox->height() * (res / PX_PER_IN));
 
466
    unsigned width =  ceil(bbox->width() * (res / Inkscape::Util::Quantity::convert(1, "in", "px")));
 
467
    unsigned height = ceil(bbox->height() * (res / Inkscape::Util::Quantity::convert(1, "in", "px")));
468
468
 
469
469
    if (width == 0 || height == 0) return;
470
470
 
477
477
    double shift_y = bbox->max()[Geom::Y];
478
478
 
479
479
    // For default 90 dpi, snap bitmap to pixel grid
480
 
    if (res == PX_PER_IN) { 
 
480
    if (res == Inkscape::Util::Quantity::convert(1, "in", "px")) { 
481
481
        shift_x = round (shift_x);
482
482
        shift_y = -round (-shift_y); // Correct rounding despite coordinate inversion.
483
483
                                     // Remove the negations when the inversion is gone.
629
629
 
630
630
    if (ctx->_vector_based_target) {
631
631
        // convert from px to pt
632
 
        d *= Geom::Scale(PT_PER_PX);
 
632
        d *= Geom::Scale(Inkscape::Util::Quantity::convert(1, "px", "pt"));
633
633
    }
634
634
 
635
635
    ctx->_width = d.width();
647
647
        } else {
648
648
            double high = doc->getHeight();
649
649
            if (ctx->_vector_based_target)
650
 
                high *= PT_PER_PX;
 
650
                high *= Inkscape::Util::Quantity::convert(1, "px", "pt");
651
651
 
652
652
            // this transform translates the export drawing to a virtual page (0,0)-(width,height)
653
 
            Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0),
654
 
                                            (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
 
653
            Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? Inkscape::Util::Quantity::convert(1, "pt", "px") : 1.0),
 
654
                                            (d.bottom() - high) * (ctx->_vector_based_target ? Inkscape::Util::Quantity::convert(1, "pt", "px") : 1.0)));
655
655
            ctx->transform(tp);
656
656
        }
657
657
    }