SkQP: add slack to model

Change-Id: Id14e5d4d6c5d517c29cd09b815ede1b52604d96a
Reviewed-on: https://skia-review.googlesource.com/99322
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
This commit is contained in:
Hal Canary 2018-01-24 11:22:57 -05:00 committed by Skia Commit-Bot
parent 4a216956df
commit 9ef0989f4c

View File

@ -29,6 +29,17 @@ const (
max_png = "max.png"
)
// `slack` is an amount to add to the max and subtract from the minimim channel
// value for each pixel for the given test. By default, slack is 0.
var slack = map[string]int{
"imagemagnifier": 1,
"xfermodes": 1,
"xfermodes2": 1,
"xfermodes3": 1,
"dashcircle": 1,
"encode-srgb-jpg": 1,
}
type ExportTestRecordArray []search.ExportTestRecord
func (a ExportTestRecordArray) Len() int { return len(a) }
@ -44,6 +55,15 @@ func in(v string, a []string) bool {
return false
}
func clampU8(v int) uint8 {
if v < 0 {
return 0
} else if v > 255 {
return 255
}
return uint8(v)
}
func processTest(testName string, imgUrls []string, output string) error {
if strings.ContainsRune(testName, '/') {
return nil
@ -84,6 +104,15 @@ func processTest(testName string, imgUrls []string, output string) error {
if img_max.Rect.Max.X == 0 {
return nil
}
if delta, ok := slack[testName]; ok {
for i, v := range img_min.Pix {
img_min.Pix[i] = clampU8(int(v) - delta)
}
for i, v := range img_max.Pix {
img_max.Pix[i] = clampU8(int(v) + delta)
}
}
if err := os.Mkdir(output_directory, os.ModePerm); err != nil && !os.IsExist(err) {
return err
}