Commit 4eeae7ba authored by Kenneth Russell's avatar Kenneth Russell Committed by Commit Bot

Invoke color_profile_manager via system Python on macOS.

Until a pyobjc wheel can be provided in Chrome Infra's vpython
environment, which will require a few more steps, manually run this
test with the system Python which has pyobjc built in.

This will allow vpython-as-python to be deployed everywhere, and then
more changes to be made on top.

TBR=ccameron@chromium.org

Bug: 776804, 804174, 812693
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ib6a3a19ff30f2ecb72f51a23ffa028b6789f3ddb
Reviewed-on: https://chromium-review.googlesource.com/924614
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: default avatarRobbie Iannucci <iannucci@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537495}
parent 9c63628b
......@@ -2,34 +2,16 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import atexit
import os
import subprocess
import sys
has_forced_srgb = False
# Force all displays to use an sRGB color profile. By default, restore
# them at exit.
IMPL_PY = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(
__file__))), 'utilities', 'color_profile_manager_impl.py')
def ForceUntilExitSRGB(skip_restoring_color_profile=False):
global has_forced_srgb
if not sys.platform.startswith('darwin'):
return
if has_forced_srgb:
return
has_forced_srgb = True
from gpu_tests import color_profile_manager_mac
# Record the current color profiles.
display_profile_url_map = \
color_profile_manager_mac.GetDisplaysToProfileURLMap()
# Force to sRGB.
for display_id in display_profile_url_map:
color_profile_manager_mac.SetDisplayCustomProfile(
display_id, color_profile_manager_mac.GetSRGBProfileURL())
# Register an atexit handler to restore the previous color profiles.
def Restore():
if skip_restoring_color_profile:
print "Skipping restoring the original color profile"
return
for display_id in display_profile_url_map:
color_profile_manager_mac.SetDisplayCustomProfile(
display_id, display_profile_url_map[display_id])
atexit.register(Restore)
# The Mac-specific Python packages used by the other scripts are only
# available via the system-installed Python.
subprocess.call(['/usr/bin/python', IMPL_PY])
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import atexit
import sys
has_forced_srgb = False
# Force all displays to use an sRGB color profile. By default, restore
# them at exit.
def ForceUntilExitSRGB(skip_restoring_color_profile=False):
global has_forced_srgb
if not sys.platform.startswith('darwin'):
return
if has_forced_srgb:
return
has_forced_srgb = True
import color_profile_manager_mac
# Record the current color profiles.
display_profile_url_map = \
color_profile_manager_mac.GetDisplaysToProfileURLMap()
# Force to sRGB.
for display_id in display_profile_url_map:
color_profile_manager_mac.SetDisplayCustomProfile(
display_id, color_profile_manager_mac.GetSRGBProfileURL())
# Register an atexit handler to restore the previous color profiles.
def Restore():
if skip_restoring_color_profile:
print "Skipping restoring the original color profile"
return
for display_id in display_profile_url_map:
color_profile_manager_mac.SetDisplayCustomProfile(
display_id, display_profile_url_map[display_id])
atexit.register(Restore)
# If invoked as a top-level script, assume that we want to run
# ForceUntilExitSRGB with skip_restoring_color_profile=True (which is
# what all the tests in this directory want).
def main():
ForceUntilExitSRGB(skip_restoring_color_profile=True)
if __name__ == '__main__':
sys.exit(main())
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