@@ -3305,6 +3305,22 @@ void Config::setViewingRules(ConstViewingRulesRcPtr viewingRules)
3305
3305
getImpl ()->resetCacheIDs ();
3306
3306
}
3307
3307
3308
+ bool Config::viewIsShared (const char * dispName, const char * viewName) const
3309
+ {
3310
+ if (!viewName || !*viewName) return false ;
3311
+
3312
+ for (int v = 0 ; v < getNumViews (VIEW_SHARED, dispName); v++)
3313
+ {
3314
+ const char * sharedViewName = getView (VIEW_SHARED, dispName, v);
3315
+ if (sharedViewName && *sharedViewName && Platform::Strcasecmp (sharedViewName, viewName) == 0 )
3316
+ {
3317
+ return true ;
3318
+ }
3319
+ }
3320
+
3321
+ return false ;
3322
+ }
3323
+
3308
3324
void Config::addSharedView (const char * view, const char * viewTransform,
3309
3325
const char * colorSpace, const char * looks,
3310
3326
const char * rule, const char * description)
@@ -3358,6 +3374,19 @@ void Config::removeSharedView(const char * view)
3358
3374
}
3359
3375
}
3360
3376
3377
+ void Config::clearSharedViews ()
3378
+ {
3379
+ int numViews = getNumViews (VIEW_SHARED, nullptr );
3380
+ for (int v = numViews - 1 ; v >= 0 ; v--)
3381
+ {
3382
+ const char * sharedViewName = getView (VIEW_SHARED, nullptr , v);
3383
+ if (sharedViewName && *sharedViewName)
3384
+ {
3385
+ removeSharedView (sharedViewName);
3386
+ }
3387
+ }
3388
+ }
3389
+
3361
3390
const char * Config::getDefaultDisplay () const
3362
3391
{
3363
3392
return getDisplay (0 );
@@ -3487,6 +3516,43 @@ const char * Config::getView(const char * display, const char * colorspace, int
3487
3516
return " " ;
3488
3517
}
3489
3518
3519
+
3520
+ bool Config::ViewsAreEqual (const ConstConfigRcPtr & first,
3521
+ const ConstConfigRcPtr & second,
3522
+ const char * dispName, // may be empty or nullptr for shared views
3523
+ const char * viewName)
3524
+ {
3525
+ // It's ok to call this even for displays/views that don't exist, it will simply return false.
3526
+
3527
+ // Note that this will return true even if the view is display-defined in one config and a reference
3528
+ // to a shared view in the other config (both within the same display), as long as the contents match.
3529
+
3530
+ // These calls return null if either the display or view doesn't exist (regardless if it's active).
3531
+ const char * cs1 = first->getDisplayViewColorSpaceName (dispName, viewName);
3532
+ const char * cs2 = second->getDisplayViewColorSpaceName (dispName, viewName);
3533
+
3534
+ // If the color space is not null, the display and view exist.
3535
+ if (cs1 && *cs1 && cs2 && *cs2)
3536
+ {
3537
+ // Both configs have a display and view by this name, now check the contents.
3538
+ if (Platform::Strcasecmp (cs1, cs2) == 0 )
3539
+ {
3540
+ // Note the remaining strings may be empty in a valid view.
3541
+ // Intentionally not checking the description since it is not a functional difference.
3542
+ if ( (Platform::Strcasecmp (first->getDisplayViewLooks (dispName, viewName),
3543
+ second->getDisplayViewLooks (dispName, viewName)) == 0 ) &&
3544
+ (Platform::Strcasecmp (first->getDisplayViewTransformName (dispName, viewName),
3545
+ second->getDisplayViewTransformName (dispName, viewName)) == 0 ) &&
3546
+ (Platform::Strcasecmp (first->getDisplayViewRule (dispName, viewName),
3547
+ second->getDisplayViewRule (dispName, viewName)) == 0 ) )
3548
+ {
3549
+ return true ;
3550
+ }
3551
+ }
3552
+ }
3553
+ return false ;
3554
+ }
3555
+
3490
3556
const char * Config::getDisplayViewTransformName (const char * display, const char * view) const
3491
3557
{
3492
3558
const View * viewPtr = getImpl ()->getView (display, view);
@@ -3525,6 +3591,21 @@ const char * Config::getDisplayViewDescription(const char * display, const char
3525
3591
return viewPtr ? viewPtr->m_description .c_str () : " " ;
3526
3592
}
3527
3593
3594
+ bool Config::displayHasView (const char * dispName, const char * viewName) const
3595
+ {
3596
+ // This returns null if either the display or view doesn't exist.
3597
+ // It works regardless of whether the display or view are active,
3598
+ // and it works regardless of whether the view is display-defined
3599
+ // or if the display has this as a shared view.
3600
+ //
3601
+ // It will only check config level shared views if dispName is null.
3602
+ // It will not check config level shared views if dispName is not null.
3603
+ const char * cs = getDisplayViewColorSpaceName (dispName, viewName);
3604
+
3605
+ // All views must have a color space, so if it's not empty, the view exists.
3606
+ return (cs && *cs);
3607
+ }
3608
+
3528
3609
void Config::addDisplaySharedView (const char * display, const char * sharedView)
3529
3610
{
3530
3611
if (!display || !*display)
@@ -3695,6 +3776,30 @@ void Config::clearDisplays()
3695
3776
getImpl ()->resetCacheIDs ();
3696
3777
}
3697
3778
3779
+ bool Config::hasVirtualView (const char * viewName) const
3780
+ {
3781
+ const char * cs = getVirtualDisplayViewColorSpaceName (viewName);
3782
+
3783
+ // All views must have a color space, so if it's not empty, the view exists.
3784
+ return (cs && *cs);
3785
+ }
3786
+
3787
+ bool Config::virtualViewIsShared (const char * viewName) const
3788
+ {
3789
+ if (!viewName || !*viewName) return false ;
3790
+
3791
+ for (int v = 0 ; v < getVirtualDisplayNumViews (VIEW_SHARED); v++)
3792
+ {
3793
+ const char * sharedViewName = getVirtualDisplayView (VIEW_SHARED, v);
3794
+ if (sharedViewName && *sharedViewName && Platform::Strcasecmp (sharedViewName, viewName) == 0 )
3795
+ {
3796
+ return true ;
3797
+ }
3798
+ }
3799
+
3800
+ return false ;
3801
+ }
3802
+
3698
3803
void Config::addVirtualDisplayView (const char * view,
3699
3804
const char * viewTransform,
3700
3805
const char * colorSpace,
@@ -3795,10 +3900,44 @@ const char * Config::getVirtualDisplayView(ViewType type, int index) const noexc
3795
3900
return " " ;
3796
3901
}
3797
3902
3903
+ bool Config::VirtualViewsAreEqual (const ConstConfigRcPtr & first,
3904
+ const ConstConfigRcPtr & second,
3905
+ const char * viewName)
3906
+ {
3907
+ const char * cs1 = first->getVirtualDisplayViewColorSpaceName (viewName);
3908
+ const char * cs2 = second->getVirtualDisplayViewColorSpaceName (viewName);
3909
+
3910
+ // If the color space is not null, the display and view exist.
3911
+ if (cs1 && *cs1 && cs2 && *cs2)
3912
+ {
3913
+ if (Platform::Strcasecmp (cs1, cs2) == 0 )
3914
+ {
3915
+ // Note the remaining strings may be empty in a valid view.
3916
+ // Intentionally not checking the description since it is not a functional difference.
3917
+ if ( (Platform::Strcasecmp (first->getVirtualDisplayViewLooks (viewName),
3918
+ second->getVirtualDisplayViewLooks (viewName)) == 0 ) &&
3919
+ (Platform::Strcasecmp (first->getVirtualDisplayViewTransformName (viewName),
3920
+ second->getVirtualDisplayViewTransformName (viewName)) == 0 ) &&
3921
+ (Platform::Strcasecmp (first->getVirtualDisplayViewRule (viewName),
3922
+ second->getVirtualDisplayViewRule (viewName)) == 0 ) )
3923
+ {
3924
+ return true ;
3925
+ }
3926
+ }
3927
+ }
3928
+ return false ;
3929
+ }
3930
+
3798
3931
const char * Config::getVirtualDisplayViewTransformName (const char * view) const noexcept
3799
3932
{
3800
3933
if (!view) return " " ;
3801
3934
3935
+ // Get the view transform name for the case where a virtual view is shared.
3936
+ if (virtualViewIsShared (view))
3937
+ {
3938
+ return getDisplayViewTransformName (nullptr , view);
3939
+ }
3940
+
3802
3941
ViewVec::const_iterator iter = FindView (getImpl ()->m_virtualDisplay .m_views , view);
3803
3942
if (iter != getImpl ()->m_virtualDisplay .m_views .end ())
3804
3943
{
@@ -3812,6 +3951,12 @@ const char * Config::getVirtualDisplayViewColorSpaceName(const char * view) cons
3812
3951
{
3813
3952
if (!view) return " " ;
3814
3953
3954
+ // Get the colorspace name for the case where a virtual view is shared.
3955
+ if (virtualViewIsShared (view))
3956
+ {
3957
+ return getDisplayViewColorSpaceName (nullptr , view);
3958
+ }
3959
+
3815
3960
ViewVec::const_iterator iter = FindView (getImpl ()->m_virtualDisplay .m_views , view);
3816
3961
if (iter != getImpl ()->m_virtualDisplay .m_views .end ())
3817
3962
{
@@ -3825,6 +3970,12 @@ const char * Config::getVirtualDisplayViewLooks(const char * view) const noexcep
3825
3970
{
3826
3971
if (!view) return " " ;
3827
3972
3973
+ // Get the view looks for the case where a virtual view is shared
3974
+ if (virtualViewIsShared (view))
3975
+ {
3976
+ return getDisplayViewLooks (nullptr , view);
3977
+ }
3978
+
3828
3979
ViewVec::const_iterator iter = FindView (getImpl ()->m_virtualDisplay .m_views , view);
3829
3980
if (iter != getImpl ()->m_virtualDisplay .m_views .end ())
3830
3981
{
@@ -3838,6 +3989,12 @@ const char * Config::getVirtualDisplayViewRule(const char * view) const noexcept
3838
3989
{
3839
3990
if (!view) return " " ;
3840
3991
3992
+ // Get the view rule for the case where a virtual view is shared
3993
+ if (virtualViewIsShared (view))
3994
+ {
3995
+ return getDisplayViewRule (nullptr , view);
3996
+ }
3997
+
3841
3998
ViewVec::const_iterator iter = FindView (getImpl ()->m_virtualDisplay .m_views , view);
3842
3999
if (iter != getImpl ()->m_virtualDisplay .m_views .end ())
3843
4000
{
@@ -3851,6 +4008,12 @@ const char * Config::getVirtualDisplayViewDescription(const char * view) const n
3851
4008
{
3852
4009
if (!view) return " " ;
3853
4010
4011
+ // Get the view description for the case where a virtual view is shared
4012
+ if (virtualViewIsShared (view))
4013
+ {
4014
+ return getDisplayViewDescription (nullptr , view);
4015
+ }
4016
+
3854
4017
ViewVec::const_iterator iter = FindView (getImpl ()->m_virtualDisplay .m_views , view);
3855
4018
if (iter != getImpl ()->m_virtualDisplay .m_views .end ())
3856
4019
{
0 commit comments