# Reftests for downscaling
#
# Downscaling can be a lossy process, so a bit of mismatch is acceptable here,
# as long as it's barely noticeable visually. When necessary, this can be
# explicitly allowed via 'fuzzy'/'fuzzy-if' annotations.
#
# Many of these tests check primarily that we don't lose rows or columns of
# pixels when downscaling by making sure that the result isn't too similar to
# about:blank. A small amount of fuzziness is used to ensure that the tests
# don't pass because of very slight deviations; passing tests should be
# substantially different from about:blank. This fuzziness should *not* be
# removed as doing so would make the tests pass in situations where they
# shouldn't.
#
# IMPORTANT: For robustness, each test should be listed *twice* in this
# manifest -- once with the high quality downscaling pref disabled, and once
# with this pref enabled. The pref is set via "defaults", so
# simply appending a new test to the lists below each of those lines should be
# sufficient.
#
# Also note that Mac OS X has its own system-level downscaling algorithm, so
# tests here may need Mac-specific "fuzzy-if(cocoaWidget,...)" annotations.
# Similarly, modern versions of Windows have slightly different downscaling
# behavior than other platforms, and may require "fuzzy-if(winWidget,...)".


# RUN TESTS NOT AFFECTED BY DOWNSCALE-DURING-DECODE:
# ==================================================
fuzzy(0-14,0-416) == downscale-svg-1a.html downscale-svg-1-ref.html?80
fuzzy(65-65,468-480) == downscale-svg-1b.html downscale-svg-1-ref.html?72
fuzzy(0-8,0-292) == downscale-svg-1c.html downscale-svg-1-ref.html?64
fuzzy(7-7,208-208) == downscale-svg-1d.html downscale-svg-1-ref.html?53
fuzzy(54-55,178-178) == downscale-svg-1e.html downscale-svg-1-ref.html?40
fuzzy(64-64,31-31) == downscale-svg-1f.html downscale-svg-1-ref.html?24

# RUN TESTS WITH DOWNSCALE-DURING-DECODE DISABLED:
# ================================================
defaults pref(image.downscale-during-decode.enabled,false)

fuzzy-if(winWidget,0-16,0-20) fuzzy-if(cocoaWidget,0-106,0-31) == downscale-1.html downscale-1-ref.html

fuzzy(0-20,0-999) != downscale-2a.html?203,52,left about:blank
fuzzy(0-20,0-999) != downscale-2b.html?203,52,left about:blank
fuzzy(0-20,0-999) != downscale-2c.html?203,52,left about:blank
fuzzy(0-20,0-999) != downscale-2d.html?203,52,left about:blank
fuzzy(0-20,0-999) != downscale-2e.html?203,52,left about:blank

fuzzy(0-20,0-999) != downscale-2a.html?205,53,left about:blank
fuzzy(0-20,0-999) != downscale-2b.html?205,53,left about:blank
fuzzy(0-20,0-999) != downscale-2c.html?205,53,left about:blank
fuzzy(0-20,0-999) != downscale-2d.html?205,53,left about:blank
fuzzy(0-20,0-999) != downscale-2e.html?205,53,left about:blank

fuzzy(0-20,0-999) != downscale-2a.html?203,52,right about:blank
fuzzy(0-20,0-999) != downscale-2b.html?203,52,right about:blank
fuzzy(0-20,0-999) != downscale-2c.html?203,52,right about:blank
fuzzy(0-20,0-999) != downscale-2d.html?203,52,right about:blank
fuzzy(0-20,0-999) != downscale-2e.html?203,52,right about:blank

fuzzy(0-20,0-999) != downscale-2a.html?205,53,right about:blank
fuzzy(0-20,0-999) != downscale-2b.html?205,53,right about:blank
fuzzy(0-20,0-999) != downscale-2c.html?205,53,right about:blank
fuzzy(0-20,0-999) != downscale-2d.html?205,53,right about:blank
fuzzy(0-20,0-999) != downscale-2e.html?205,53,right about:blank

fuzzy(0-20,0-999) != downscale-2a.html?203,52,top about:blank
fuzzy(0-20,0-999) != downscale-2b.html?203,52,top about:blank
fuzzy(0-20,0-999) != downscale-2c.html?203,52,top about:blank
fuzzy(0-20,0-999) != downscale-2d.html?203,52,top about:blank
fuzzy(0-20,0-999) != downscale-2e.html?203,52,top about:blank

fuzzy(0-20,0-999) != downscale-2a.html?205,53,top about:blank
fuzzy(0-20,0-999) != downscale-2b.html?205,53,top about:blank
fuzzy(0-20,0-999) != downscale-2c.html?205,53,top about:blank
fuzzy(0-20,0-999) != downscale-2d.html?205,53,top about:blank
fuzzy(0-20,0-999) != downscale-2e.html?205,53,top about:blank

fuzzy(0-20,0-999) != downscale-2a.html?203,52,bottom about:blank
fuzzy(0-20,0-999) != downscale-2b.html?203,52,bottom about:blank
fuzzy(0-20,0-999) != downscale-2c.html?203,52,bottom about:blank
fuzzy(0-20,0-999) != downscale-2d.html?203,52,bottom about:blank
fuzzy(0-20,0-999) != downscale-2e.html?203,52,bottom about:blank

fuzzy(0-20,0-999) != downscale-2a.html?205,53,bottom about:blank
fuzzy(0-20,0-999) != downscale-2b.html?205,53,bottom about:blank
fuzzy(0-20,0-999) != downscale-2c.html?205,53,bottom about:blank
fuzzy(0-20,0-999) != downscale-2d.html?205,53,bottom about:blank
fuzzy(0-20,0-999) != downscale-2e.html?205,53,bottom about:blank

# Skip on Android because it runs reftests via http, and moz-icon isn't
# accessible from http/https origins anymore.
fuzzy(0-27,0-3940) fuzzy-if(gtkWidget,0-0,0-0) skip-if(Android) fuzzy-if(appleSilicon,0-20,0-10123) == downscale-moz-icon-1.html downscale-moz-icon-1-ref.html # gtkWidget Bug 1592059: regular is 2616, no-accel is 0, qr passes with 0

== downscale-png.html?16,16,interlaced downscale-png.html?16,16,normal
== downscale-png.html?24,24,interlaced downscale-png.html?24,24,normal

# Non-transparent and transparent ICO images
== downscale-16px.html?ff-0RGB.ico downscale-16px.html?ff-0RGB.png
fuzzy(0-1,0-1) fuzzy-if(gtkWidget&&swgl,1-1,1-1) == downscale-16px.html?ff-ARGB.ico downscale-16px.html?ff-ARGB.png

# Test downscaling from all supported formats from 256 to 32.
== downscale-32px.html?.bmp downscale-32px-ref.html
== downscale-32px.html?.gif downscale-32px-ref.html
fuzzy(0-1,0-1024) == downscale-32px.html?.jpg downscale-32px-ref.html
== downscale-32px.html?.png downscale-32px-ref.html
== downscale-32px.html?.svg downscale-32px-ref.html
== downscale-32px.html?-bmp-in.ico downscale-32px-ref.html
== downscale-32px.html?-png-in.ico downscale-32px-ref.html

# Test downscaling a JPEG with orientation metadata.
fuzzy(0-1,0-50) == downscale-orient.html downscale-orient-ref.html

# be careful changing fuzzy, the bug this test is testing is if the shade of orange is too dark
fuzzy(0-1,0-144) == 1919368-1.html 1919368-1-ref.html




# RUN TESTS WITH DOWNSCALE-DURING-DECODE ENABLED:
# ===============================================
defaults pref(image.downscale-during-decode.enabled,true)

fuzzy(0-31,0-127) fuzzy-if(winWidget,0-31,0-147) == downscale-1.html downscale-1-ref.html # intermittently 147 pixels on win7 accelerated only (not win8)

fuzzy(0-20,0-999) != downscale-2a.html?203,52,left about:blank
fuzzy(0-20,0-999) != downscale-2b.html?203,52,left about:blank
fuzzy(0-20,0-999) != downscale-2c.html?203,52,left about:blank
fuzzy(0-20,0-999) != downscale-2d.html?203,52,left about:blank
fuzzy(0-20,0-999) != downscale-2e.html?203,52,left about:blank
fuzzy(0-20,0-999) != downscale-2f.html?203,52,left about:blank

fuzzy(0-20,0-999) != downscale-2a.html?205,53,left about:blank
fuzzy(0-20,0-999) != downscale-2b.html?205,53,left about:blank
fuzzy(0-20,0-999) != downscale-2c.html?205,53,left about:blank
fuzzy(0-20,0-999) != downscale-2d.html?205,53,left about:blank
fuzzy(0-20,0-999) != downscale-2e.html?205,53,left about:blank
fuzzy(0-20,0-999) != downscale-2f.html?205,53,left about:blank

fuzzy(0-20,0-999) != downscale-2a.html?203,52,right about:blank
fuzzy(0-20,0-999) != downscale-2b.html?203,52,right about:blank
fuzzy(0-20,0-999) != downscale-2c.html?203,52,right about:blank
fuzzy(0-20,0-999) != downscale-2d.html?203,52,right about:blank
fuzzy(0-20,0-999) != downscale-2e.html?203,52,right about:blank
fuzzy(0-20,0-999) != downscale-2f.html?203,52,right about:blank

fuzzy(0-20,0-999) != downscale-2a.html?205,53,right about:blank
fuzzy(0-20,0-999) != downscale-2b.html?205,53,right about:blank
fuzzy(0-20,0-999) != downscale-2c.html?205,53,right about:blank
fuzzy(0-20,0-999) != downscale-2d.html?205,53,right about:blank
fuzzy(0-20,0-999) != downscale-2e.html?205,53,right about:blank
fuzzy(0-20,0-999) != downscale-2f.html?205,53,right about:blank

fuzzy(0-20,0-999) != downscale-2a.html?203,52,top about:blank
fuzzy(0-20,0-999) != downscale-2b.html?203,52,top about:blank
fuzzy(0-20,0-999) != downscale-2c.html?203,52,top about:blank
fuzzy(0-20,0-999) != downscale-2d.html?203,52,top about:blank
fuzzy(0-20,0-999) != downscale-2e.html?203,52,top about:blank
fuzzy(0-20,0-999) != downscale-2f.html?203,52,top about:blank

fuzzy(0-20,0-999) != downscale-2a.html?205,53,top about:blank
fuzzy(0-20,0-999) != downscale-2b.html?205,53,top about:blank
fuzzy(0-20,0-999) != downscale-2c.html?205,53,top about:blank
fuzzy(0-20,0-999) != downscale-2d.html?205,53,top about:blank
fuzzy(0-20,0-999) != downscale-2e.html?205,53,top about:blank
fuzzy(0-20,0-999) != downscale-2f.html?205,53,top about:blank

fuzzy(0-20,0-999) != downscale-2a.html?203,52,bottom about:blank
fuzzy(0-20,0-999) != downscale-2b.html?203,52,bottom about:blank
fuzzy(0-20,0-999) != downscale-2c.html?203,52,bottom about:blank
fuzzy(0-20,0-999) != downscale-2d.html?203,52,bottom about:blank
fuzzy(0-20,0-999) != downscale-2e.html?203,52,bottom about:blank
fuzzy(0-20,0-999) != downscale-2f.html?203,52,bottom about:blank

fuzzy(0-20,0-999) != downscale-2a.html?205,53,bottom about:blank
fuzzy(0-20,0-999) != downscale-2b.html?205,53,bottom about:blank
fuzzy(0-20,0-999) != downscale-2c.html?205,53,bottom about:blank
fuzzy(0-20,0-999) != downscale-2d.html?205,53,bottom about:blank
fuzzy(0-20,0-999) != downscale-2e.html?205,53,bottom about:blank
fuzzy(0-20,0-999) != downscale-2f.html?205,53,bottom about:blank

# Skip on Android because it runs reftests via http, and moz-icon isn't
# accessible from http/https origins anymore.
fuzzy(0-53,0-6391) skip-if(Android) fuzzy-if(cocoaWidget&&/^14\.70$/.test(os_version)&&isDebugBuild,20-21,11511-12086) fuzzy-if(cocoaWidget&&/^14\.70$/.test(os_version)&&optimized&&!swgl,20-21,11511-12086) fuzzy-if(appleSilicon,0-20,0-11605) fuzzy-if(gtkWidget,18-19,5502-5568) == downscale-moz-icon-1.html downscale-moz-icon-1-ref.html # gtkWidget Bug 1592059, Bug 1934897

== downscale-png.html?16,16,interlaced downscale-png.html?16,16,normal
== downscale-png.html?24,24,interlaced downscale-png.html?24,24,normal

# Non-transparent and transparent ICO images
fuzzy(0-1,0-3) == downscale-16px.html?ff-0RGB.ico downscale-16px.html?ff-0RGB.png
fuzzy(0-3,0-32) fuzzy-if(swgl,3-3,33-33) == downscale-16px.html?ff-ARGB.ico downscale-16px.html?ff-ARGB.png

# Upside-down (negative height) BMP
== downscale-8px.html?top-to-bottom-16x16-24bpp.bmp downscale-8px.html?bmp-size-16x16-24bpp.png

# Test downscaling from all supported formats from 256 to 32.
fuzzy(0-18,0-128) == downscale-32px.html?.bmp downscale-32px-ref.html
fuzzy(0-18,0-128) == downscale-32px.html?.gif downscale-32px-ref.html
fuzzy(0-19,0-992) == downscale-32px.html?.jpg downscale-32px-ref.html
fuzzy(0-18,0-128) == downscale-32px.html?.png downscale-32px-ref.html
== downscale-32px.html?.svg downscale-32px-ref.html
fuzzy(0-18,0-128) == downscale-32px.html?-bmp-in.ico downscale-32px-ref.html
fuzzy(0-18,0-128) == downscale-32px.html?-png-in.ico downscale-32px-ref.html

# Test downscaling a JPEG with orientation metadata.
fuzzy(0-4,0-18) == downscale-orient.html downscale-orient-ref.html

# Test images taller or wider than 32767 pixels.
== huge-1.html?100x32768.png,100,100 huge-1.html?100x100.png,100,100
== huge-1.html?100x32768.png,100,32768 huge-1.html?100x100.png,100,32768
== huge-1.html?32768x100.png,100,100 huge-1.html?100x100.png,100,100
== huge-1.html?32768x100.png,32768,100 huge-1.html?100x100.png,32768,100
== huge-1.html?100x32768.gif,100,100 huge-1.html?100x100.gif,100,100
== huge-1.html?100x32768.gif,100,32768 huge-1.html?100x100.gif,100,32768
== huge-1.html?32768x100.gif,100,100 huge-1.html?100x100.gif,100,100
== huge-1.html?32768x100.gif,32768,100 huge-1.html?100x100.gif,32768,100
== huge-1.html?100x32768.jpg,100,100 huge-1.html?100x100.jpg,100,100
== huge-1.html?100x32768.jpg,100,32768 huge-1.html?100x100.jpg,100,32768
== huge-1.html?32768x100.jpg,100,100 huge-1.html?100x100.jpg,100,100
== huge-1.html?32768x100.jpg,32768,100 huge-1.html?100x100.jpg,32768,100

# be careful changing fuzzy, the bug this test is testing is if the shade of orange is too dark
fuzzy(0-1,0-144) == 1919368-1.html 1919368-1-ref.html

# Only need to run these with downscaling on
!= 1421191-1.html about:blank
== 1404366-1.html about:blank
