1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CPPCANVAS_CANVASGRAPHIC_HXX
21 #define INCLUDED_CPPCANVAS_CANVASGRAPHIC_HXX
23 #include <sal/types.h>
25 #include <boost/shared_ptr.hpp>
26 #include <cppcanvas/color.hxx>
27 #include <cppcanvas/canvas.hxx>
36 /* Definition of CanvasGraphic interface */
40 // forward declaration, since tools::PolyPolygon also derives from CanvasGraphic
41 typedef ::boost::shared_ptr
< class PolyPolygon
> PolyPolygonSharedPtr
;
44 /** This interface defines basic properties of
45 objects that can be painted on a Canvas
51 /** These enums determine how the primitive color is combined
52 with the background. When performing this calculations, it
53 is assumed that all color values are premultiplied with
54 the corresponding alpha values (if no alpha is specified,
55 1.0 is assumed). Then, the following general compositing
56 operation is performed:
60 where C is the result color, Ca and Cb are the input
61 colors, premultiplied with alpha, and Fa and Fb are
62 described for the different composite modes (wherein Aa
63 and Ab denote source and destination alpha, respectively).
67 /// Clear destination. Fa = Fb = 0.
70 /// Copy source as-is to destination. Fa = 1, Fb = 0.
73 /// Leave destination as-is. Fa = 0, Fb = 1.
76 /// Copy source over destination. Fa = 1, Fb = 1-Aa.
79 /// Copy source under destination. Fa = 1-Ab, Fb = 1.
82 /// Copy source to destination, but limited to where the destination is. Fa = Ab, Fb = 0.
85 /// Leave destination as is, but only where source was. Fa = 0, Fb = Aa.
88 /// Copy source to destination, but limited to where destination is not. Fa = 1-Ab, Fb = 0.
91 /// Leave destination as is, but only where source has not been. Fa = 0, Fb = 1-Aa.
94 /// Copy source over destination, but only where destination is. Keep destination. Fa = Ab, Fb = 1-Aa.
97 /// Copy destination over source, but only where source is. Keep source. Fa = 1-Ab, Fb = Aa.
100 /// Take only parts where either source or destination, but not both are. Fa = 1-Ab, Fb = 1-Aa.
103 /** simply add contributions of both source and destination. The
104 resulting color values are limited to the permissible color
105 range, and clipped to the maximal value, if exceeded. Fa = 1, Fb = 1.
109 /// Fa = min(1,(1-Ab)/Aa), Fb = 1
113 virtual ~CanvasGraphic() {}
115 /** Set object transformation matrix
117 virtual void setTransformation( const ::basegfx::B2DHomMatrix
& rMatrix
) = 0;
118 /** Get object transformation matrix
120 virtual ::basegfx::B2DHomMatrix
getTransformation() const = 0;
122 /** Set object clipping polygon
124 virtual void setClip( const ::basegfx::B2DPolyPolygon
& rClipPoly
) = 0;
125 /** Clear object clipping polygon
127 virtual void setClip() = 0;
128 /** Get object clipping polygon
130 @return NULL, if no clip is set; otherwise, the current clip poly-polygon is returned
132 virtual ::basegfx::B2DPolyPolygon
const* getClip() const = 0;
134 /** Set object composite mode
136 virtual void setCompositeOp( CompositeOp aOp
) = 0;
137 /** Get object composite mode
139 virtual CompositeOp
getCompositeOp() const = 0;
141 /** Render to parent canvas
143 This method renders the content to the parent canvas,
144 i.e. the canvas this object was constructed for.
146 @return whether the rendering finished successfully.
148 virtual bool draw() const = 0;
152 typedef ::boost::shared_ptr
< ::cppcanvas::CanvasGraphic
> CanvasGraphicSharedPtr
;
155 #endif // INCLUDED_CPPCANVAS_CANVASGRAPHIC_HXX
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */