Skip to content

Commit 8b3c613

Browse files
caixr23fly602
authored andcommitted
fix: Modify the refresh rate accuracy to 0.01
Modify the refresh rate accuracy to 0.01 pms: BUG-318627
1 parent ee19461 commit 8b3c613

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

display1/mode.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,10 @@ func getFirstModeBySize(modes []ModeInfo, width, height uint16) ModeInfo {
253253
}
254254

255255
func getFirstModeBySizeRate(modes []ModeInfo, width, height uint16, rate float64) ModeInfo {
256+
roundedRate := math.Round(rate * 100)
256257
for _, modeInfo := range modes {
257258
if modeInfo.Width == width && modeInfo.Height == height &&
258-
math.Abs(modeInfo.Rate-rate) <= 0.01 {
259+
math.Round(modeInfo.Rate * 100) == roundedRate {
259260
return modeInfo
260261
}
261262
}

display1/monitor_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ func Test_getFirstModeBySize(t *testing.T) {
2222
func Test_getFirstModeBySizeRate(t *testing.T) {
2323
modes := []ModeInfo{{84, "", 1920, 1080, 60.0}, {85, "", 1920, 1080, 50.0},
2424
{95, "", 1600, 1200, 60.0}}
25-
assert.Equal(t, getFirstModeBySizeRate(modes, 1920, 1080, 59.99), ModeInfo{84, "", 1920, 1080, 60.0})
26-
assert.Equal(t, getFirstModeBySizeRate(modes, 1920, 1080, 49.99), ModeInfo{85, "", 1920, 1080, 50.0})
25+
assert.Equal(t, getFirstModeBySizeRate(modes, 1920, 1080, 59.999), ModeInfo{84, "", 1920, 1080, 60.0})
26+
assert.Equal(t, getFirstModeBySizeRate(modes, 1920, 1080, 49.999), ModeInfo{85, "", 1920, 1080, 50.0})
2727
assert.Equal(t, getFirstModeBySizeRate(modes, 1600, 1200, 59), ModeInfo{})
2828
assert.Equal(t, getFirstModeBySizeRate(modes, 1280, 740, 60), ModeInfo{})
2929

0 commit comments

Comments
 (0)