11using System ;
22using System . Runtime . InteropServices ;
3+ using NvAPIWrapper . Native . Helpers ;
34
45namespace NvAPIWrapper . Native . Display . Structures
56{
@@ -25,6 +26,113 @@ public struct Timing : IEquatable<Timing>
2526 internal readonly uint _PixelClockIn10KHertz ;
2627 internal readonly TimingExtra _Extra ;
2728
29+ /// <summary>
30+ /// Creates an instance of <see cref="Timing" /> structure.
31+ /// </summary>
32+ /// <param name="horizontalVisible">The horizontal visible pixels</param>
33+ /// <param name="verticalVisible">The vertical visible pixels</param>
34+ /// <param name="horizontalBorder">The horizontal border pixels</param>
35+ /// <param name="verticalBorder">The vertical border pixels</param>
36+ /// <param name="horizontalFrontPorch">The horizontal front porch pixels</param>
37+ /// <param name="verticalFrontPorch">The vertical front porch pixels</param>
38+ /// <param name="horizontalSyncWidth">The horizontal sync width pixels</param>
39+ /// <param name="verticalSyncWidth">The vertical sync width pixels</param>
40+ /// <param name="horizontalTotal">The horizontal total pixels</param>
41+ /// <param name="verticalTotal">The vertical total pixels</param>
42+ /// <param name="horizontalPolarity">The horizontal sync polarity</param>
43+ /// <param name="verticalPolarity">The vertical sync polarity</param>
44+ /// <param name="scanMode">The scan mode</param>
45+ /// <param name="extra">The extra timing information</param>
46+ public Timing (
47+ ushort horizontalVisible ,
48+ ushort verticalVisible ,
49+ ushort horizontalBorder ,
50+ ushort verticalBorder ,
51+ ushort horizontalFrontPorch ,
52+ ushort verticalFrontPorch ,
53+ ushort horizontalSyncWidth ,
54+ ushort verticalSyncWidth ,
55+ ushort horizontalTotal ,
56+ ushort verticalTotal ,
57+ TimingHorizontalSyncPolarity horizontalPolarity ,
58+ TimingVerticalSyncPolarity verticalPolarity ,
59+ TimingScanMode scanMode ,
60+ TimingExtra extra
61+ )
62+ {
63+ this = typeof ( Timing ) . Instantiate < Timing > ( ) ;
64+
65+ _HorizontalVisible = horizontalVisible ;
66+ _HorizontalBorder = horizontalBorder ;
67+ _HorizontalFrontPorch = horizontalFrontPorch ;
68+ _HorizontalSyncWidth = horizontalSyncWidth ;
69+ _HorizontalTotal = horizontalTotal ;
70+ _HorizontalSyncPolarity = horizontalPolarity ;
71+
72+ _VerticalVisible = verticalVisible ;
73+ _VerticalBorder = verticalBorder ;
74+ _VerticalFrontPorch = verticalFrontPorch ;
75+ _VerticalSyncWidth = verticalSyncWidth ;
76+ _VerticalTotal = verticalTotal ;
77+ _VerticalSyncPolarity = verticalPolarity ;
78+
79+ _ScanMode = scanMode ;
80+ _PixelClockIn10KHertz =
81+ ( uint ) ( horizontalTotal * verticalTotal * ( extra . FrequencyInMillihertz / 1000d ) / 10000 ) ;
82+
83+ _Extra = extra ;
84+ }
85+
86+ /// <summary>
87+ /// Creates an instance of <see cref="Timing" /> structure.
88+ /// </summary>
89+ /// <param name="horizontalVisible">The horizontal visible pixels</param>
90+ /// <param name="verticalVisible">The vertical visible pixels</param>
91+ /// <param name="horizontalBorder">The horizontal border pixels</param>
92+ /// <param name="verticalBorder">The vertical border pixels</param>
93+ /// <param name="horizontalFrontPorch">The horizontal front porch pixels</param>
94+ /// <param name="verticalFrontPorch">The vertical front porch pixels</param>
95+ /// <param name="horizontalSyncWidth">The horizontal sync width pixels</param>
96+ /// <param name="verticalSyncWidth">The vertical sync width pixels</param>
97+ /// <param name="horizontalTotal">The horizontal total pixels</param>
98+ /// <param name="verticalTotal">The vertical total pixels</param>
99+ /// <param name="horizontalPolarity">The horizontal sync polarity</param>
100+ /// <param name="verticalPolarity">The vertical sync polarity</param>
101+ /// <param name="scanMode">The scan mode</param>
102+ /// <param name="refreshRateFrequencyInHz">The frequency in hertz</param>
103+ /// <param name="horizontalPixelRepetition">The number of identical horizontal pixels that are repeated; 1 = no repetition</param>
104+ public Timing (
105+ ushort horizontalVisible ,
106+ ushort verticalVisible ,
107+ ushort horizontalBorder ,
108+ ushort verticalBorder ,
109+ ushort horizontalFrontPorch ,
110+ ushort verticalFrontPorch ,
111+ ushort horizontalSyncWidth ,
112+ ushort verticalSyncWidth ,
113+ ushort horizontalTotal ,
114+ ushort verticalTotal ,
115+ TimingHorizontalSyncPolarity horizontalPolarity ,
116+ TimingVerticalSyncPolarity verticalPolarity ,
117+ TimingScanMode scanMode ,
118+ double refreshRateFrequencyInHz ,
119+ ushort horizontalPixelRepetition = 1
120+ ) : this (
121+ horizontalVisible , verticalVisible , horizontalBorder ,
122+ verticalBorder , horizontalFrontPorch , verticalFrontPorch ,
123+ horizontalSyncWidth , verticalSyncWidth , horizontalTotal ,
124+ verticalTotal , horizontalPolarity , verticalPolarity , scanMode ,
125+ new TimingExtra (
126+ refreshRateFrequencyInHz ,
127+ $ "CUST:{ horizontalVisible } x{ verticalVisible } x{ refreshRateFrequencyInHz : F3} Hz",
128+ 0 ,
129+ 0 ,
130+ horizontalPixelRepetition
131+ )
132+ )
133+ {
134+ }
135+
28136 /// <inheritdoc />
29137 public bool Equals ( Timing other )
30138 {
@@ -53,7 +161,7 @@ public override bool Equals(object obj)
53161 return false ;
54162 }
55163
56- return obj is Timing && Equals ( ( Timing ) obj ) ;
164+ return obj is Timing timing && Equals ( timing ) ;
57165 }
58166
59167 /// <inheritdoc />
@@ -82,123 +190,193 @@ public override int GetHashCode()
82190 }
83191
84192 /// <summary>
85- /// Horizontal visible
193+ /// Checks two instance of <see cref="Timing" /> for equality.
194+ /// </summary>
195+ /// <param name="left">The first instance.</param>
196+ /// <param name="right">The second instance.</param>
197+ /// <returns>Returns a boolean value indicating if the two instances are equal; otherwise false</returns>
198+ public static bool operator == ( Timing left , Timing right )
199+ {
200+ return left . Equals ( right ) ;
201+ }
202+
203+ /// <summary>
204+ /// Checks two instance of <see cref="Timing" /> for in equality.
205+ /// </summary>
206+ /// <param name="left">The first instance.</param>
207+ /// <param name="right">The second instance.</param>
208+ /// <returns>Returns a boolean value indicating if the two instances are not equal; otherwise false</returns>
209+ public static bool operator != ( Timing left , Timing right )
210+ {
211+ return ! ( left == right ) ;
212+ }
213+
214+ /// <summary>
215+ /// Get the horizontal visible pixels
86216 /// </summary>
87217 public int HorizontalVisible
88218 {
89219 get => _HorizontalVisible ;
90220 }
91221
92222 /// <summary>
93- /// Horizontal border
223+ /// Get the horizontal border pixels
94224 /// </summary>
95225 public int HorizontalBorder
96226 {
97227 get => _HorizontalBorder ;
98228 }
99229
100230 /// <summary>
101- /// Horizontal front porch
231+ /// Get the horizontal front porch pixels
102232 /// </summary>
103233 public int HorizontalFrontPorch
104234 {
105235 get => _HorizontalFrontPorch ;
106236 }
107237
108238 /// <summary>
109- /// Horizontal sync width
239+ /// Get the horizontal sync width pixels
110240 /// </summary>
111241 public int HorizontalSyncWidth
112242 {
113243 get => _HorizontalSyncWidth ;
114244 }
115245
116246 /// <summary>
117- /// Horizontal total
247+ /// Get the horizontal total pixels
118248 /// </summary>
119249 public int HorizontalTotal
120250 {
121251 get => _HorizontalTotal ;
122252 }
123253
124254 /// <summary>
125- /// Horizontal sync polarity
255+ /// Get the horizontal sync polarity
126256 /// </summary>
127257 public TimingHorizontalSyncPolarity HorizontalSyncPolarity
128258 {
129259 get => _HorizontalSyncPolarity ;
130260 }
131261
132262 /// <summary>
133- /// Vertical visible
263+ /// Get the vertical visible pixels
134264 /// </summary>
135265 public int VerticalVisible
136266 {
137267 get => _VerticalVisible ;
138268 }
139269
140270 /// <summary>
141- /// Vertical border
271+ /// Get the vertical border pixels
142272 /// </summary>
143273 public int VerticalBorder
144274 {
145275 get => _VerticalBorder ;
146276 }
147277
148278 /// <summary>
149- /// Vertical front porch
279+ /// Get the vertical front porch pixels
150280 /// </summary>
151281 public int VerticalFrontPorch
152282 {
153283 get => _VerticalFrontPorch ;
154284 }
155285
156286 /// <summary>
157- /// Vertical sync width
287+ /// Get the vertical sync width pixels
158288 /// </summary>
159289 public int VerticalSyncWidth
160290 {
161291 get => _VerticalSyncWidth ;
162292 }
163293
164294 /// <summary>
165- /// Vertical total
295+ /// Get the vertical total pixels
166296 /// </summary>
167297 public int VerticalTotal
168298 {
169299 get => _VerticalTotal ;
170300 }
171301
172302 /// <summary>
173- /// Vertical sync polarity
303+ /// Get the vertical sync polarity
174304 /// </summary>
175305 public TimingVerticalSyncPolarity VerticalSyncPolarity
176306 {
177307 get => _VerticalSyncPolarity ;
178308 }
179309
180310 /// <summary>
181- /// Scan mode
311+ /// Get the scan mode
182312 /// </summary>
183313 public TimingScanMode ScanMode
184314 {
185315 get => _ScanMode ;
186316 }
187317
188318 /// <summary>
189- /// Pixel clock in 10 kHz
319+ /// Get the pixel clock in 10 kHz
190320 /// </summary>
191321 public int PixelClockIn10KHertz
192322 {
193323 get => ( int ) _PixelClockIn10KHertz ;
194324 }
195325
196326 /// <summary>
197- /// Other timing related extras
327+ /// Get the other timing related extras
198328 /// </summary>
199329 public TimingExtra Extra
200330 {
201331 get => _Extra ;
202332 }
333+
334+ /// <summary>
335+ /// Gets the horizontal active pixels
336+ /// </summary>
337+ public int HorizontalActive
338+ {
339+ get => HorizontalVisible + HorizontalBorder ;
340+ }
341+
342+ /// <summary>
343+ /// Gets the vertical active pixels
344+ /// </summary>
345+ public int VerticalActive
346+ {
347+ get => VerticalVisible + VerticalBorder ;
348+ }
349+
350+ /// <summary>
351+ /// Gets the horizontal back porch pixels
352+ /// </summary>
353+ public int HorizontalBackPorch
354+ {
355+ get => HorizontalBlanking - ( HorizontalFrontPorch + HorizontalSyncWidth ) ;
356+ }
357+
358+ /// <summary>
359+ /// Gets the horizontal blanking pixels
360+ /// </summary>
361+ public int HorizontalBlanking
362+ {
363+ get => HorizontalTotal - ( HorizontalActive + HorizontalBorder ) ;
364+ }
365+
366+ /// <summary>
367+ /// Gets vertical back porch pixels
368+ /// </summary>
369+ public int VerticalBackPorch
370+ {
371+ get => VerticalBlanking - ( VerticalFrontPorch + VerticalSyncWidth ) ;
372+ }
373+
374+ /// <summary>
375+ /// Gets the vertical blanking pixels
376+ /// </summary>
377+ public int VerticalBlanking
378+ {
379+ get => VerticalTotal - ( VerticalActive + VerticalBorder ) ;
380+ }
203381 }
204382}
0 commit comments