drawing-surface.cpp revision 1cf2607271f83cc4b20ccace552395d793055c90
/**
* @file
* @brief Cairo surface that remembers its origin
*//*
* Authors:
* Krzysztof KosiĆski <tweenk.pl@gmail.com>
*
* Copyright (C) 2011 Authors
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <iostream>
#include "display/drawing-surface.h"
#include "display/drawing-context.h"
#include "display/cairo-utils.h"
namespace Inkscape {
using Geom::X;
using Geom::Y;
/** @class DrawingSurface
* @brief Drawing surface that remembers its origin.
*
* This is a very minimalistic wrapper over cairo_surface_t. The main
* extra functionality provided by this class is that it automates
* the mapping from "logical space" (coordinates in the rendering)
* and the "physical space" (surface pixels). For example, patterns
* have to be rendered on tiles which have possibly non-integer
* widths and heights.
*
* This class has delayed allocation functionality - it creates
* the Cairo surface it wraps on the first call to createRawContext()
* of when a DrawingContext is constructed.
*/
/** @brief Creates a surface with the given physical extents.
* When a drawing context is created for this surface, its pixels
* will cover the area under the given rectangle. */
{}
/** @brief Creates a surface with the given logical and physical extents.
* When a drawing context is created for this surface, its pixels
* will cover the area under the given rectangle. IT will contain
* the number of pixels specified by the second argument.
* @param logbox Logical extents of the surface
* @param pixdims Pixel dimensions of the surface. */
{}
/** @brief Wrap a cairo_surface_t.
* This constructor will take an extra reference on @a surface, which will
* be released on destruction. */
{
}
{
if (_surface)
}
/// Get the logical extents of the surface.
DrawingSurface::area() const
{
return r;
}
/// Get the pixel dimensions of the surface
DrawingSurface::pixels() const
{
return _pixels;
}
/// Get the logical width and weight of the surface as a point.
DrawingSurface::dimensions() const
{
return logical_dims;
}
DrawingSurface::origin() const
{
return _origin;
}
DrawingSurface::scale() const
{
return _scale;
}
/// Get the transformation applied to the drawing context on construction.
DrawingSurface::drawingTransform() const
{
return ret;
}
DrawingSurface::type() const
{
// currently hardcoded
return CAIRO_SURFACE_TYPE_IMAGE;
}
/// Drop contents of the surface and release the underlying Cairo object.
void
{
if (_surface) {
}
}
/** @brief Create a drawing context for this surface.
* It's better to use the surface constructor of DrawingContext. */
cairo_t *
{
// deferred allocation
if (!_surface) {
}
}
return ct;
}
DrawingSurface::pixelArea() const
{
return ret;
}
//////////////////////////////////////////////////////////////////////////////
{}
{
}
void
{
}
void
{
if (!r) return;
}
bool
{
return true;
} else {
return false;
}
}
/// Call this during the update phase to schedule a transformation of the cache.
void
{
}
/// Transforms the cache according to the transform specified during the update phase.
/// Call this during render phase, before painting.
void
{
if (is_identity) {
if (_pending_area == old_area) return;
}
bool is_integer_translation = false;
// integer translation or identity with change of area
is_integer_translation = true;
cairo_region_translate(_clean_region, t[X], t[Y]);
if (old_area + t == _pending_area) {
// if the areas match, the only thing to do
// is to ensure that the clean area is not too large
_origin += t;
return;
}
}
}
// otherwise, we need to transform the cache
if (!is_identity) {
}
if (!is_identity && !is_integer_translation) {
// dirty everything
} else {
}
}
/** @brief Paints the clean area from cache and returns the remaining part */
bool
{
return false;
return true;
}
{
return ret;
}
} // end namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :