1cb93a386Sopenharmony_ci// Copyright 2016 The SwiftShader Authors. All Rights Reserved. 2cb93a386Sopenharmony_ci// 3cb93a386Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License"); 4cb93a386Sopenharmony_ci// you may not use this file except in compliance with the License. 5cb93a386Sopenharmony_ci// You may obtain a copy of the License at 6cb93a386Sopenharmony_ci// 7cb93a386Sopenharmony_ci// http://www.apache.org/licenses/LICENSE-2.0 8cb93a386Sopenharmony_ci// 9cb93a386Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software 10cb93a386Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS, 11cb93a386Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12cb93a386Sopenharmony_ci// See the License for the specific language governing permissions and 13cb93a386Sopenharmony_ci// limitations under the License. 14cb93a386Sopenharmony_ci 15cb93a386Sopenharmony_ci#ifndef sw_Polygon_hpp 16cb93a386Sopenharmony_ci#define sw_Polygon_hpp 17cb93a386Sopenharmony_ci 18cb93a386Sopenharmony_ci#include "Vertex.hpp" 19cb93a386Sopenharmony_ci 20cb93a386Sopenharmony_cinamespace sw 21cb93a386Sopenharmony_ci{ 22cb93a386Sopenharmony_ci struct Polygon 23cb93a386Sopenharmony_ci { 24cb93a386Sopenharmony_ci Polygon(const float4 *P0, const float4 *P1, const float4 *P2) 25cb93a386Sopenharmony_ci { 26cb93a386Sopenharmony_ci P[0][0] = P0; 27cb93a386Sopenharmony_ci P[0][1] = P1; 28cb93a386Sopenharmony_ci P[0][2] = P2; 29cb93a386Sopenharmony_ci 30cb93a386Sopenharmony_ci n = 3; 31cb93a386Sopenharmony_ci i = 0; 32cb93a386Sopenharmony_ci b = 0; 33cb93a386Sopenharmony_ci } 34cb93a386Sopenharmony_ci 35cb93a386Sopenharmony_ci Polygon(const float4 *P, int n) 36cb93a386Sopenharmony_ci { 37cb93a386Sopenharmony_ci for(int i = 0; i < n; i++) 38cb93a386Sopenharmony_ci { 39cb93a386Sopenharmony_ci this->P[0][i] = &P[i]; 40cb93a386Sopenharmony_ci } 41cb93a386Sopenharmony_ci 42cb93a386Sopenharmony_ci this->n = n; 43cb93a386Sopenharmony_ci this->i = 0; 44cb93a386Sopenharmony_ci this->b = 0; 45cb93a386Sopenharmony_ci } 46cb93a386Sopenharmony_ci 47cb93a386Sopenharmony_ci float4 B[16]; // Buffer for clipped vertices 48cb93a386Sopenharmony_ci const float4 *P[16][16]; // Pointers to clipped polygon's vertices 49cb93a386Sopenharmony_ci 50cb93a386Sopenharmony_ci int n; // Number of vertices 51cb93a386Sopenharmony_ci int i; // Level of P to use 52cb93a386Sopenharmony_ci int b; // Next available new vertex 53cb93a386Sopenharmony_ci }; 54cb93a386Sopenharmony_ci} 55cb93a386Sopenharmony_ci 56cb93a386Sopenharmony_ci#endif // sw_Polygon_hpp 57