sp-paint-server.h revision e8b02d4335cf15e38ae5419f93d4311193d54123
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Base class for gradients and patterns
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Lauris Kaplinski <lauris@kaplinski.com>
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Jon A. Cruz <jon@joncruz.org>
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Copyright (C) 1999-2002 Lauris Kaplinski
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Copyright (C) 2000-2001 Ximian, Inc.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Copyright (C) 2010 Authors
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Released under GNU GPL, read the file 'COPYING' for more information
ddc0e0b53c661f6e439e3b7072b3ef353eadb4afRichard Lowe#define SP_PAINT_SERVER(obj) (dynamic_cast<SPPaintServer*>((SPObject*)obj))
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis#define SP_IS_PAINT_SERVER(obj) (dynamic_cast<const SPPaintServer*>((SPObject*)obj) != NULL)
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis //There are two ways to render a paint. The simple one is to create cairo_pattern_t structure
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis //on demand by pattern_new method. It is used for gradients. The other one is to add elements
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis //representing PaintServer in NR tree. It is used by hatches and patterns.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis //Either pattern new or all three methods show, hide, setBBox need to be implemented
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis virtual Inkscape::DrawingPattern *show(Inkscape::Drawing &drawing, unsigned int key, Geom::OptRect bbox); // TODO check passing bbox by value. Looks suspicious.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis virtual void setBBox(unsigned int key, Geom::OptRect const &bbox);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Returns the first of {src, src-\>ref-\>getObject(),
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * src-\>ref-\>getObject()-\>ref-\>getObject(),...}
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * for which \a match is true, or NULL if none found.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * The raison d'ĂȘtre of this routine is that it correctly handles cycles in the href chain (e.g., if
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * a gradient gives itself as its href, or if each of two gradients gives the other as its href).
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * \pre SP_IS_GRADIENT(src).
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr JasiukajtisPaintServer *chase_hrefs(PaintServer *src, sigc::slot<bool, PaintServer const *> match) {
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis /* Use a pair of pointers for detecting loops: p1 advances half as fast as p2. If there is a
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis loop, then once p1 has entered the loop, we'll detect it the next time the distance between
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis p1 and p2 is a multiple of the loop size. */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis bool do1 = false;
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis /* We've been here before, so return NULL to indicate that no matching gradient found
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * in the chain. */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis#endif // SEEN_SP_PAINT_SERVER_H
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis Local Variables:
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis c-file-style:"stroustrup"
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis indent-tabs-mode:nil
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis fill-column:99
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :