1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | #ifndef sw_Clipper_hpp |
16 | #define sw_Clipper_hpp |
17 | |
18 | namespace sw |
19 | { |
20 | struct DrawCall; |
21 | struct Polygon; |
22 | struct float4; |
23 | |
24 | struct Clipper |
25 | { |
26 | enum ClipFlags |
27 | { |
28 | // Indicates the vertex is outside the respective frustum plane |
29 | CLIP_RIGHT = 1 << 0, |
30 | CLIP_TOP = 1 << 1, |
31 | CLIP_FAR = 1 << 2, |
32 | CLIP_LEFT = 1 << 3, |
33 | CLIP_BOTTOM = 1 << 4, |
34 | CLIP_NEAR = 1 << 5, |
35 | |
36 | CLIP_FRUSTUM = 0x003F, |
37 | |
38 | CLIP_FINITE = 1 << 7, // All position coordinates are finite |
39 | }; |
40 | |
41 | static unsigned int ComputeClipFlags(const float4 &v); |
42 | static bool Clip(Polygon &polygon, int clipFlagsOr, const DrawCall &draw); |
43 | }; |
44 | } |
45 | |
46 | #endif // sw_Clipper_hpp |
47 | |