Skip to content

Commit c6e3b8b

Browse files
committed
Implement support for adding virtual displays.
Closes #133. Signed-off-by: Thomas Mansencal <[email protected]>
1 parent d270f5c commit c6e3b8b

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

opencolorio_config_aces/config/cg/generate/config.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,34 @@ def ordering(element: dict[str, Any]) -> int:
13411341
data.view_transforms = sorted(data.view_transforms, key=ordering)
13421342
data.looks = sorted(data.looks, key=ordering)
13431343

1344+
# Virtual Display Shared Views
1345+
# ============================
1346+
data.virtual_display_shared_views = list(
1347+
{
1348+
shared_view["view"]
1349+
for shared_view in data.shared_views
1350+
if shared_view["display"]
1351+
in [
1352+
a["name"]
1353+
for a in data.colorspaces
1354+
if a.get("family") == "Display" and a.get("encoding") == "sdr-video"
1355+
]
1356+
}
1357+
)
1358+
1359+
# Virtual Display Views
1360+
# =====================
1361+
data.virtual_display_views = [
1362+
{
1363+
"view": "Raw",
1364+
"view_transform": "",
1365+
"colorspace": "Raw",
1366+
"looks": "",
1367+
"rule": "",
1368+
"description": "",
1369+
}
1370+
]
1371+
13441372
data.profile_version = build_configuration.ocio
13451373

13461374
config = generate_config(data, config_name, validate)

opencolorio_config_aces/config/generation/common.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ class ConfigData:
9393
views : array_like, optional
9494
Config views, an iterable of dicts of display, view
9595
and `Colorspace` names.
96+
virtual_display_shared_views : array_like, optional
97+
Config virtual display shared views, an iterable of shared view names.
98+
virtual_display_views : array_like, optional
99+
Config virtual display views, an iterable of dicts of view, `ViewTransform`,
100+
`Colorspace` names, looks, rule name and description.
96101
active_displays : array_like, optional
97102
Config active displays, an iterable of display names.
98103
active_views : array_like, optional
@@ -144,6 +149,8 @@ class ConfigData:
144149
looks: list[dict[str, Any] | ocio.Look] = field(default_factory=list)
145150
shared_views: list[dict[str, Any]] = field(default_factory=list)
146151
views: list[dict[str, Any]] = field(default_factory=list)
152+
virtual_display_shared_views: list[str] = field(default_factory=list)
153+
virtual_display_views: list[dict[str, Any]] = field(default_factory=list)
147154
active_displays: list[str] = field(default_factory=list)
148155
active_views: list[str] = field(default_factory=list)
149156
file_rules: list[dict[str, Any]] = field(default_factory=list)
@@ -365,6 +372,33 @@ def generate_config(
365372
LOGGER.debug('Adding "%s" view to "%s" display.', view, display)
366373
config.addDisplaySharedView(display, view)
367374

375+
for virtual_display_shared_view in data.virtual_display_shared_views:
376+
LOGGER.debug(
377+
'Adding "%s" virtual display shared view.', virtual_display_shared_view
378+
)
379+
config.addVirtualDisplaySharedView(virtual_display_shared_view)
380+
381+
for virtual_display_view in data.virtual_display_views:
382+
view_name = virtual_display_view["view"]
383+
view_transform = virtual_display_view["view_transform"]
384+
colorspace = virtual_display_view["colorspace"]
385+
looks = virtual_display_view.get("looks", "")
386+
rule = virtual_display_view.get("rule", "")
387+
description = virtual_display_view.get("description", "")
388+
LOGGER.debug(
389+
'Adding "%s" virtual display view using "%s" view transform, "%s" '
390+
'colorspace, "%s" looks, "%s" rule and "%s" description.',
391+
view_name,
392+
view_transform,
393+
colorspace,
394+
looks,
395+
rule,
396+
description,
397+
)
398+
config.addVirtualDisplayView(
399+
view_name, view_transform, colorspace, looks, rule, description
400+
)
401+
368402
if data.active_displays:
369403
LOGGER.debug('Activating "%s" displays.', data.active_displays)
370404
config.setActiveDisplays(",".join(data.active_displays))

0 commit comments

Comments
 (0)