KiCad PCB EDA Suite
Loading...
Searching...
No Matches
layer_draw_plan.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef RHI_LAYER_DRAW_PLAN_H
21#define RHI_LAYER_DRAW_PLAN_H
22
23#include <rhi/frame_packet.h>
24
25#include <vector>
26
27
28namespace KIGFX
29{
30
31enum class LAYER_DRAW_MODE : uint8_t
32{
37};
38
52
60inline std::vector<LAYER_DRAW_STEP> RhiPlanLayerDraws( const LAYER_RANGE& aRange,
61 const std::vector<POLARITY_RUN>& aRuns = {} )
62{
64
65 std::vector<LAYER_DRAW_STEP> steps;
66
67 if( aRange.runCount > 0 && aRange.runStart + aRange.runCount <= aRuns.size() )
68 {
69 for( uint32_t ii = aRange.runStart; ii < aRange.runStart + aRange.runCount; ++ii )
70 {
71 const POLARITY_RUN& run = aRuns[ii];
73
74 for( int shape = 0; shape < RHI_SHAPES; ++shape )
75 {
76 steps.push_back( { RHI_SHAPE( shape ), mode, run.negative, false, true, run.start[shape],
77 run.count[shape] } );
78 }
79 }
80
81 return steps;
82 }
83
84 auto instances = [&]( LAYER_DRAW_MODE aMode, bool aNegatives, bool aNearHalf )
85 {
86 for( int shape = 0; shape < RHI_INSTANCED_SHAPES; ++shape )
87 {
88 steps.push_back( { RHI_SHAPE( shape ), aMode, aNegatives, aNearHalf, false,
89 aNegatives ? aRange.negStart[shape] : aRange.start[shape],
90 aNegatives ? aRange.negCount[shape] : aRange.count[shape] } );
91 }
92 };
93
94 if( aRange.depthKnockout )
95 instances( LAYER_DRAW_MODE::MARK, true, true );
96
97 instances( fill, false, false );
98
99 if( !aRange.depthKnockout )
100 instances( LAYER_DRAW_MODE::NEGATIVE, true, false );
101
102 steps.push_back( { RHI_SHAPE_POLYGON, fill, false, false, false, aRange.start[RHI_SHAPE_POLYGON],
103 aRange.count[RHI_SHAPE_POLYGON] } );
104
105 return steps;
106}
107
108} // namespace KIGFX
109
110#endif // RHI_LAYER_DRAW_PLAN_H
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
RHI_SHAPE
Shapes a frame draws, each with its own array and pipelines.
@ RHI_SHAPE_POLYGON
constexpr int RHI_INSTANCED_SHAPES
@ MARK
write depth only, so the layer's later draws stay out of these pixels
@ NEGATIVE
erase what the layer has drawn so far, inside a temp target
@ ONCE
blend, but let each pixel take the layer only once
@ BLEND
ordinary alpha blending
constexpr int RHI_SHAPES
std::vector< LAYER_DRAW_STEP > RhiPlanLayerDraws(const LAYER_RANGE &aRange, const std::vector< POLARITY_RUN > &aRuns={})
Order the draws of one layer range.
One draw of a layer range.
bool ordered
part of a polarity run, taken from the range's drawing order
bool negatives
draws the range's negative elements instead of its normal ones
bool nearHalf
drawn in the nearer half of the layer's depth slice
uint32_t start
first element, or first vertex of a polygon step
One layer's instance ranges within the flat GPU buffers, normal instances before negatives.
RHI_SHAPE_COUNTS negStart
RHI_SHAPE_COUNTS count
bool singleCoverage
Draw straight into the target using the range's own depth slice, either taking each pixel once at tra...
RHI_SHAPE_COUNTS negCount
RHI_SHAPE_COUNTS start
Each shape's normal elements, then for an instanced shape its negatives.
uint32_t runStart
The range's runs in FRAME_DRAW_DESC::polarityRuns, none when its order does not matter.