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 #include "System/Types.hpp" 19 20 namespace sw { 21 22 struct DrawCall; 23 struct Polygon; 24 25 struct Clipper 26 { 27 enum ClipFlags 28 { 29 // Indicates the vertex is outside the respective frustum plane 30 CLIP_RIGHT = 1 << 0, 31 CLIP_TOP = 1 << 1, 32 CLIP_FAR = 1 << 2, 33 CLIP_LEFT = 1 << 3, 34 CLIP_BOTTOM = 1 << 4, 35 CLIP_NEAR = 1 << 5, 36 37 CLIP_SIDES = CLIP_LEFT | CLIP_RIGHT | CLIP_BOTTOM | CLIP_TOP, 38 CLIP_FRUSTUM = CLIP_SIDES | CLIP_NEAR | CLIP_FAR, 39 40 CLIP_FINITE = 1 << 7, // All position coordinates are finite 41 }; 42 43 static bool Clip(Polygon &polygon, int clipFlagsOr, const DrawCall &draw); 44 }; 45 46 } // namespace sw 47 48 #endif // sw_Clipper_hpp 49