本文整理汇总了C++中geom::Rect::roundOutwards方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::roundOutwards方法的具体用法?C++ Rect::roundOutwards怎么用?C++ Rect::roundOutwards使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geom::Rect
的用法示例。
在下文中一共展示了Rect::roundOutwards方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_cairo
void FilterImage::render_cairo(FilterSlot &slot)
{
if (!feImageHref)
return;
//cairo_surface_t *input = slot.getcairo(_input);
// Viewport is filter primitive area (in user coordinates).
// Note: viewport calculation in non-trivial. Do not rely
// on get_matrix_primitiveunits2pb().
Geom::Rect vp = filter_primitive_area( slot.get_units() );
slot.set_primitive_area(_output, vp); // Needed for tiling
double feImageX = vp.min()[Geom::X];
double feImageY = vp.min()[Geom::Y];
double feImageWidth = vp.width();
double feImageHeight = vp.height();
// feImage is suppose to use the same parameters as a normal SVG image.
// If a width or height is set to zero, the image is not suppose to be displayed.
// This does not seem to be what Firefox or Opera does, nor does the W3C displacement
// filter test expect this behavior. If the width and/or height are zero, we use
// the width and height of the object bounding box.
Geom::Affine m = slot.get_units().get_matrix_user2filterunits().inverse();
Geom::Point bbox_00 = Geom::Point(0,0) * m;
Geom::Point bbox_w0 = Geom::Point(1,0) * m;
Geom::Point bbox_0h = Geom::Point(0,1) * m;
double bbox_width = Geom::distance(bbox_00, bbox_w0);
double bbox_height = Geom::distance(bbox_00, bbox_0h);
if( feImageWidth == 0 ) feImageWidth = bbox_width;
if( feImageHeight == 0 ) feImageHeight = bbox_height;
// Internal image, like <use>
if (from_element) {
if (!SVGElem) return;
// TODO: do not recreate the rendering tree every time
// TODO: the entire thing is a hack, we should give filter primitives an "update" method
// like the one for DrawingItems
document->ensureUpToDate();
Drawing drawing;
Geom::OptRect optarea = SVGElem->visualBounds();
if (!optarea) return;
unsigned const key = SPItem::display_key_new(1);
DrawingItem *ai = SVGElem->invoke_show(drawing, key, SP_ITEM_SHOW_DISPLAY);
if (!ai) {
g_warning("feImage renderer: error creating DrawingItem for SVG Element");
return;
}
drawing.setRoot(ai);
Geom::Rect area = *optarea;
Geom::Affine user2pb = slot.get_units().get_matrix_user2pb();
/* FIXME: These variables are currently unused. Why were they calculated?
double scaleX = feImageWidth / area.width();
double scaleY = feImageHeight / area.height();
*/
Geom::Rect sa = slot.get_slot_area();
cairo_surface_t *out = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
sa.width(), sa.height());
Inkscape::DrawingContext dc(out, sa.min());
dc.transform(user2pb); // we are now in primitive units
dc.translate(feImageX, feImageY);
// dc.scale(scaleX, scaleY); No scaling should be done
Geom::IntRect render_rect = area.roundOutwards();
// dc.translate(render_rect.min()); This seems incorrect
// Update to renderable state
drawing.update(render_rect);
drawing.render(dc, render_rect);
SVGElem->invoke_hide(key);
// For the moment, we'll assume that any image is in sRGB color space
set_cairo_surface_ci(out, SP_CSS_COLOR_INTERPOLATION_SRGB);
slot.set(_output, out);
cairo_surface_destroy(out);
return;
}
// External image, like <image>
if (!image && !broken_ref) {
broken_ref = true;
/* TODO: If feImageHref is absolute, then use that (preferably handling the
* case that it's not a file URI). Otherwise, go up the tree looking
* for an xml:base attribute, and use that as the base URI for resolving
* the relative feImageHref URI. Otherwise, if document->base is valid,
* then use that as the base URI. Otherwise, use feImageHref directly
* (i.e. interpreting it as relative to our current working directory).
* (See http://www.w3.org/TR/xmlbase/#resolution .) */
gchar *fullname = feImageHref;
if ( !g_file_test( fullname, G_FILE_TEST_EXISTS ) ) {
// Try to load from relative postion combined with document base
//.........这里部分代码省略.........