⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 225946 in webkit


Ignore:
Timestamp:
Dec 14, 2017, 5:01:47 PM (9 years ago)
Author:
Simon Fraser
Message:

Fix Windows build after r225915.

Windows doens't have dispatch_once with blocks. Switch to use lambda functions instead.

  • platform/graphics/cg/GraphicsContextCG.cpp:

(WebCore::sRGBColorSpaceRef):
(WebCore::linearRGBColorSpaceRef):
(WebCore::extendedSRGBColorSpaceRef):
(WebCore::displayP3ColorSpaceRef):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r225941 r225946  
     12017-12-14  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Fix Windows build after r225915.
     4
     5        Windows doens't have dispatch_once with blocks. Switch to use lambda functions instead.
     6
     7        * platform/graphics/cg/GraphicsContextCG.cpp:
     8        (WebCore::sRGBColorSpaceRef):
     9        (WebCore::linearRGBColorSpaceRef):
     10        (WebCore::extendedSRGBColorSpaceRef):
     11        (WebCore::displayP3ColorSpaceRef):
     12
    1132017-12-14  Devin Rousso  <webkit@devinrousso.com>
    214
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r225915 r225946  
    7575CGColorSpaceRef sRGBColorSpaceRef()
    7676{
    77     static CGColorSpaceRef sRGBColorSpace;
    78     static dispatch_once_t onceToken;
    79     dispatch_once(&onceToken, ^{
    80         sRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
     77    auto createColorSpace = []() {
    8178#if PLATFORM(WIN)
    8279        // Out-of-date CG installations will not honor kCGColorSpaceSRGB. This logic avoids
    … …  
    8481        // is sRGB, this all works out nicely.
    8582        // FIXME: Is this still needed? rdar://problem/15213515 was fixed.
    86         if (!sRGBColorSpace)
    87             sRGBColorSpace = CGColorSpaceCreateDeviceRGB();
     83        CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
     84        if (!colorSpace)
     85            colorSpace = CGColorSpaceCreateDeviceRGB();
     86        return colorSpace;
     87#else
     88        return CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
    8889#endif // PLATFORM(WIN)
    89     });
     90    };
     91
     92    static CGColorSpaceRef sRGBColorSpace = createColorSpace();
    9093    return sRGBColorSpace;
    9194}
    … …  
    9598CGColorSpaceRef linearRGBColorSpaceRef()
    9699{
    97     static CGColorSpaceRef linearRGBColorSpace;
    98     static dispatch_once_t onceToken;
    99     dispatch_once(&onceToken, ^{
     100    auto createColorSpace = []() {
    100101#if PLATFORM(WIN)
    101102        // FIXME: Windows should be able to use linear sRGB, this is tracked by http://webkit.org/b/80000.
    102         linearRGBColorSpace = sRGBColorSpaceRef();
     103        return sRGBColorSpaceRef();
    103104#else
    104         linearRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceLinearSRGB);
     105        return CGColorSpaceCreateWithName(kCGColorSpaceLinearSRGB);
    105106#endif
    106     });
    107 
     107    };
     108       
     109    static CGColorSpaceRef linearRGBColorSpace = createColorSpace();
    108110    return linearRGBColorSpace;
    109111}
    … …  
    112114CGColorSpaceRef extendedSRGBColorSpaceRef()
    113115{
    114     static CGColorSpaceRef extendedSRGBColorSpace;
    115     static dispatch_once_t onceToken;
    116     dispatch_once(&onceToken, ^{
     116    auto createColorSpace = []() {
    117117#if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
    118         extendedSRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB);
     118        CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB);
    119119#endif
    120120        // If there is no support for extended sRGB, fall back to sRGB.
    121         if (!extendedSRGBColorSpace)
    122             extendedSRGBColorSpace = sRGBColorSpaceRef();
    123     });
     121        if (!colorSpace)
     122            colorSpace = sRGBColorSpaceRef();
     123       
     124        return colorSpace;
     125    };
     126       
     127    static CGColorSpaceRef extendedSRGBColorSpace = createColorSpace();
    124128    return extendedSRGBColorSpace;
    125129}
    … …  
    127131CGColorSpaceRef displayP3ColorSpaceRef()
    128132{
    129     static CGColorSpaceRef displayP3ColorSpace;
    130     static dispatch_once_t onceToken;
    131     dispatch_once(&onceToken, ^{
     133    auto createColorSpace = []() {
    132134#if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 101100)
    133         displayP3ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceDisplayP3);
     135        return CGColorSpaceCreateWithName(kCGColorSpaceDisplayP3);
    134136#else
    135         displayP3ColorSpace = sRGBColorSpaceRef();
     137        return sRGBColorSpaceRef();
    136138#endif
    137     });
     139    };
     140
     141    static CGColorSpaceRef displayP3ColorSpace = createColorSpace();
    138142    return displayP3ColorSpace;
    139143}
Note: See TracChangeset for help on using the changeset viewer.