Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 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 | |
Nicolas Capens | d37b0ab | 2019-12-13 09:35:16 -0500 | [diff] [blame] | 18 | #include "System/Types.hpp" |
| 19 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 20 | namespace sw { |
| 21 | |
| 22 | struct DrawCall; |
| 23 | struct Polygon; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 24 | |
| 25 | struct Clipper |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 26 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 27 | enum ClipFlags |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 28 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 29 | // Indicates the vertex is outside the respective frustum plane |
Ben Clayton | fccfc56 | 2019-12-17 20:37:31 +0000 | [diff] [blame] | 30 | CLIP_RIGHT = 1 << 0, |
| 31 | CLIP_TOP = 1 << 1, |
| 32 | CLIP_FAR = 1 << 2, |
| 33 | CLIP_LEFT = 1 << 3, |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 34 | CLIP_BOTTOM = 1 << 4, |
Ben Clayton | fccfc56 | 2019-12-17 20:37:31 +0000 | [diff] [blame] | 35 | CLIP_NEAR = 1 << 5, |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 36 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 37 | CLIP_FRUSTUM = 0x003F, |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 38 | |
Ben Clayton | fccfc56 | 2019-12-17 20:37:31 +0000 | [diff] [blame] | 39 | CLIP_FINITE = 1 << 7, // All position coordinates are finite |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 40 | }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 41 | |
| 42 | static unsigned int ComputeClipFlags(const float4 &v); |
| 43 | static bool Clip(Polygon &polygon, int clipFlagsOr, const DrawCall &draw); |
| 44 | }; |
| 45 | |
| 46 | } // namespace sw |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 47 | |
Ben Clayton | fccfc56 | 2019-12-17 20:37:31 +0000 | [diff] [blame] | 48 | #endif // sw_Clipper_hpp |