Commit d8173210 authored by alokp@chromium.org's avatar alokp@chromium.org

gpu testing: Handle non-integral device pixel ratio.

Device pixel ratio is used to scale test rect and sampling locations.
It can be non-integral on some devices. For example it is 1.325 on
Nexus 7. The scaled quantities - dimensions of screenshot and sampled
pixel locations - need to be converted to integers before they can
be used.

BUG=368495

Review URL: https://codereview.chromium.org/303113004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273951 0039d316-1c4b-4281-b951-d872f2087c98
parent 5f896f2c
......@@ -24,8 +24,8 @@ error_image_cloud_storage_bucket = 'chromium-browser-gpu-tests'
def _CompareScreenshotSamples(screenshot, expectations, device_pixel_ratio):
for expectation in expectations:
location = expectation["location"]
x = location[0] * device_pixel_ratio
y = location[1] * device_pixel_ratio
x = int(location[0] * device_pixel_ratio)
y = int(location[1] * device_pixel_ratio)
if x < 0 or y < 0 or x > screenshot.width or y > screenshot.height:
raise page_test.Failure(
......
......@@ -49,7 +49,7 @@ class _GpuRasterizationValidator(cloud_storage_test_base.ValidatorBase):
device_pixel_ratio = tab.EvaluateJavaScript('window.devicePixelRatio')
if hasattr(page, 'test_rect'):
test_rect = [x * device_pixel_ratio for x in page.test_rect]
test_rect = [int(x * device_pixel_ratio) for x in page.test_rect]
screenshot = screenshot.Crop(
test_rect[0], test_rect[1],
test_rect[2], test_rect[3])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment