LibreOffice Module basegfx (master) 1
rectcliptools.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <sal/types.h>
24
25
26namespace basegfx::utils
27{
28 namespace RectClipFlags
29 {
30 const sal_uInt32 LEFT = sal_Int32(0x01);
31 const sal_uInt32 RIGHT = sal_Int32(0x02);
32 const sal_uInt32 TOP = sal_Int32(0x04);
33 const sal_uInt32 BOTTOM = sal_Int32(0x08);
34 }
35
44 template< class Point, class Rect > inline
45 sal_uInt32 getCohenSutherlandClipFlags( const Point& rP,
46 const Rect& rR )
47 {
48 // maxY | minY | maxX | minX
49 sal_uInt32 clip;
50 clip = (rP.getX() < rR.getMinX()) << 0;
51 clip |= (rP.getX() > rR.getMaxX()) << 1;
52 clip |= (rP.getY() < rR.getMinY()) << 2;
53 clip |= (rP.getY() > rR.getMaxY()) << 3;
54 return clip;
55 }
56
58 template< class Point > inline
59 sal_uInt32 getCohenSutherlandClipFlags( const Point& rP,
60 const B2IBox& rB )
61 {
62 // maxY | minY | maxX | minX
63 sal_uInt32 clip;
64 clip = (rP.getX() < rB.getMinX()) << 0;
65 clip |= (rP.getX() >= rB.getMaxX()) << 1;
66 clip |= (rP.getY() < rB.getMinY()) << 2;
67 clip |= (rP.getY() >= rB.getMaxY()) << 3;
68 return clip;
69 }
70}
71
72/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr tools::Long getX() const
constexpr tools::Long getY() const
A two-dimensional interval over integers.
Definition: b2ibox.hxx:56
sal_Int32 getMaxX() const
get upper bound of the set. returns arbitrary values for empty sets.
Definition: b2ibox.hxx:126
sal_Int32 getMinX() const
get lower bound of the set. returns arbitrary values for empty sets.
Definition: b2ibox.hxx:114
sal_Int32 getMaxY() const
get upper bound of the set. returns arbitrary values for empty sets.
Definition: b2ibox.hxx:132
sal_Int32 getMinY() const
get lower bound of the set. returns arbitrary values for empty sets.
Definition: b2ibox.hxx:120
sal_uInt32 getCohenSutherlandClipFlags(const Point &rP, const Rect &rR)
Calc clip mask for Cohen-Sutherland rectangle clip.