1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 #ifndef sw_Clipper_hpp
16 #define sw_Clipper_hpp
19 #include "Common/Types.hpp"
32 // Indicates the vertex is outside the respective frustum plane
40 CLIP_FRUSTUM = 0x003F,
42 CLIP_FINITE = 1 << 7, // All position coordinates are finite
44 // User-defined clipping planes
47 CLIP_PLANE2 = 1 << 10,
48 CLIP_PLANE3 = 1 << 11,
49 CLIP_PLANE4 = 1 << 12,
50 CLIP_PLANE5 = 1 << 13,
55 Clipper(bool symmetricNormalizedDepth);
59 unsigned int computeClipFlags(const float4 &v);
60 bool clip(Polygon &polygon, int clipFlagsOr, const DrawCall &draw);
63 void clipNear(Polygon &polygon);
64 void clipFar(Polygon &polygon);
65 void clipLeft(Polygon &polygon);
66 void clipRight(Polygon &polygon);
67 void clipTop(Polygon &polygon);
68 void clipBottom(Polygon &polygon);
69 void clipPlane(Polygon &polygon, const Plane &plane);
71 void clipEdge(float4 &Vo, const float4 &Vi, const float4 &Vj, float di, float dj) const;
73 float n; // Near clip plane distance
77 #endif // sw_Clipper_hpp