Changeset 268064 in webkit


Ignore:
Timestamp:
Oct 6, 2020, 12:36:02 PM (5 years ago)
Author:
achristensen@apple.com
Message:

Rename namespace Packed to namespace PackedColor
https://bugs.webkit.org/show_bug.cgi?id=217391

Reviewed by Simon Fraser.

Otherwise "using WTF::Packed;" in wtf/Packed.h causes problems if both headers are included in the same translation unit.

  • css/StyleColor.cpp:

(WebCore::StyleColor::colorFromKeyword):

  • css/parser/CSSParserFastPaths.cpp:

(WebCore::finishParsingHexColor):
(WebCore::finishParsingNamedColor):

  • platform/graphics/Color.h:

(WebCore::Color::asInline const):
(WebCore::Color::setColor):
(WebCore::Color::encode const):
(WebCore::Color::decode):

  • platform/graphics/ColorTypes.h:

(WebCore::asSRGBA):
(WebCore::Packed::RGBA::RGBA): Deleted.
(WebCore::Packed::ARGB::ARGB): Deleted.

  • platform/graphics/ImageBackingStore.h:

(WebCore::ImageBackingStore::blendPixel):
(WebCore::ImageBackingStore::pixelValue const):

  • platform/graphics/cg/ColorCG.cpp:

(WebCore::cachedCGColor):

  • platform/graphics/mac/ColorMac.mm:

(WebCore::nsColor):

Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r268063 r268064  
     12020-10-06  Alex Christensen  <achristensen@webkit.org>
     2
     3        Rename namespace Packed to namespace PackedColor
     4        https://bugs.webkit.org/show_bug.cgi?id=217391
     5
     6        Reviewed by Simon Fraser.
     7
     8        Otherwise "using WTF::Packed;" in wtf/Packed.h causes problems if both headers are included in the same translation unit.
     9
     10        * css/StyleColor.cpp:
     11        (WebCore::StyleColor::colorFromKeyword):
     12        * css/parser/CSSParserFastPaths.cpp:
     13        (WebCore::finishParsingHexColor):
     14        (WebCore::finishParsingNamedColor):
     15        * platform/graphics/Color.h:
     16        (WebCore::Color::asInline const):
     17        (WebCore::Color::setColor):
     18        (WebCore::Color::encode const):
     19        (WebCore::Color::decode):
     20        * platform/graphics/ColorTypes.h:
     21        (WebCore::asSRGBA):
     22        (WebCore::Packed::RGBA::RGBA): Deleted.
     23        (WebCore::Packed::ARGB::ARGB): Deleted.
     24        * platform/graphics/ImageBackingStore.h:
     25        (WebCore::ImageBackingStore::blendPixel):
     26        (WebCore::ImageBackingStore::pixelValue const):
     27        * platform/graphics/cg/ColorCG.cpp:
     28        (WebCore::cachedCGColor):
     29        * platform/graphics/mac/ColorMac.mm:
     30        (WebCore::nsColor):
     31
    1322020-10-06  Zalan Bujtas  <zalan@apple.com>
    233
  • trunk/Source/WebCore/css/StyleColor.cpp

    r264311 r268064  
    4242    if (const char* valueName = getValueName(keyword)) {
    4343        if (const NamedColor* namedColor = findColor(valueName, strlen(valueName)))
    44             return asSRGBA(Packed::ARGB { namedColor->ARGBValue });
     44            return asSRGBA(PackedColor::ARGB { namedColor->ARGBValue });
    4545    }
    4646
  • trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp

    r267940 r268064  
    415415    case 3:
    416416        // #abc converts to #aabbcc
    417         // FIXME: Replace conversion to Packed::ARGB with simpler bit math to construct
     417        // FIXME: Replace conversion to PackedColor::ARGB with simpler bit math to construct
    418418        // the SRGBA<uint8_t> directly.
    419         return asSRGBA(Packed::ARGB {
     419        return asSRGBA(PackedColor::ARGB {
    420420               0xFF000000
    421421            | (value & 0xF00) << 12 | (value & 0xF00) << 8
     
    424424    case 4:
    425425        // #abcd converts to ddaabbcc since alpha bytes are the high bytes.
    426         // FIXME: Replace conversion to Packed::ARGB with simpler bit math to construct
     426        // FIXME: Replace conversion to PackedColor::ARGB with simpler bit math to construct
    427427        // the SRGBA<uint8_t> directly.
    428         return asSRGBA(Packed::ARGB {
     428        return asSRGBA(PackedColor::ARGB {
    429429              (value & 0xF) << 28 | (value & 0xF) << 24
    430430            | (value & 0xF000) << 8 | (value & 0xF000) << 4
     
    432432            | (value & 0xF0) | (value & 0xF0) >> 4 });
    433433    case 6:
    434         // FIXME: Replace conversion to Packed::ARGB with simpler bit math to construct
     434        // FIXME: Replace conversion to PackedColor::ARGB with simpler bit math to construct
    435435        // the SRGBA<uint8_t> directly.
    436         return asSRGBA(Packed::ARGB { 0xFF000000 | value });
     436        return asSRGBA(PackedColor::ARGB { 0xFF000000 | value });
    437437    case 8:
    438         return asSRGBA(Packed::RGBA { value });
     438        return asSRGBA(PackedColor::RGBA { value });
    439439    }
    440440    return WTF::nullopt;
     
    540540    if (!namedColor)
    541541        return WTF::nullopt;
    542     return asSRGBA(Packed::ARGB { namedColor->ARGBValue });
     542    return asSRGBA(PackedColor::ARGB { namedColor->ARGBValue });
    543543}
    544544
  • trunk/Source/WebCore/platform/graphics/Color.h

    r264585 r268064  
    394394{
    395395    ASSERT(isInline());
    396     return asSRGBA(Packed::RGBA { static_cast<uint32_t>(m_colorData.inlineColorAndFlags >> 32) });
     396    return asSRGBA(PackedColor::RGBA { static_cast<uint32_t>(m_colorData.inlineColorAndFlags >> 32) });
    397397}
    398398
    399399inline void Color::setColor(SRGBA<uint8_t> color)
    400400{
    401     m_colorData.inlineColorAndFlags = static_cast<uint64_t>(Packed::RGBA { color }.value) << 32;
     401    m_colorData.inlineColorAndFlags = static_cast<uint64_t>(PackedColor::RGBA { color }.value) << 32;
    402402    tagAsValid();
    403403}
     
    466466
    467467    encoder << true;
    468     encoder << Packed::RGBA { asInline() }.value;
     468    encoder << PackedColor::RGBA { asInline() }.value;
    469469}
    470470
     
    505505        return WTF::nullopt;
    506506
    507     return Color { asSRGBA(Packed::RGBA { value }) };
     507    return Color { asSRGBA(PackedColor::RGBA { value }) };
    508508}
    509509
  • trunk/Source/WebCore/platform/graphics/ColorTypes.h

    r264593 r268064  
    357357// Packed Color Formats
    358358
    359 namespace Packed {
     359namespace PackedColor {
    360360
    361361struct RGBA {
     
    389389}
    390390
    391 constexpr SRGBA<uint8_t> asSRGBA(Packed::RGBA color)
     391constexpr SRGBA<uint8_t> asSRGBA(PackedColor::RGBA color)
    392392{
    393393    return { static_cast<uint8_t>(color.value >> 24), static_cast<uint8_t>(color.value >> 16), static_cast<uint8_t>(color.value >> 8), static_cast<uint8_t>(color.value) };
    394394}
    395395
    396 constexpr SRGBA<uint8_t> asSRGBA(Packed::ARGB color)
     396constexpr SRGBA<uint8_t> asSRGBA(PackedColor::ARGB color)
    397397{
    398398    return { static_cast<uint8_t>(color.value >> 16), static_cast<uint8_t>(color.value >> 8), static_cast<uint8_t>(color.value), static_cast<uint8_t>(color.value >> 24) };
  • trunk/Source/WebCore/platform/graphics/ImageBackingStore.h

    r264050 r268064  
    153153            return;
    154154
    155         auto pixel = asSRGBA(Packed::ARGB { *dest });
     155        auto pixel = asSRGBA(PackedColor::ARGB { *dest });
    156156
    157157        if (a >= 255 || !pixel.alpha) {
     
    175175            result = unpremultiplied(result);
    176176
    177         *dest = Packed::ARGB { result }.value;
     177        *dest = PackedColor::ARGB { result }.value;
    178178    }
    179179
     
    232232            result = premultipliedFlooring(result);
    233233
    234         return Packed::ARGB { result }.value;
     234        return PackedColor::ARGB { result }.value;
    235235    }
    236236
  • trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoImageSurfaceBackend.cpp

    r264645 r268064  
    8282        for (int x = 0; x < m_logicalSize.width(); x++) {
    8383            unsigned* pixel = row + x;
    84             auto pixelComponents = unpremultiplied(asSRGBA(Packed::ARGB { *pixel }));
     84            auto pixelComponents = unpremultiplied(asSRGBA(PackedColor::ARGB { *pixel }));
    8585            pixelComponents = { lookUpTable[pixelComponents.red], lookUpTable[pixelComponents.green], lookUpTable[pixelComponents.blue], pixelComponents.alpha };
    86             *pixel = Packed::ARGB { premultipliedCeiling(pixelComponents) }.value;
     86            *pixel = PackedColor::ARGB { premultipliedCeiling(pixelComponents) }.value;
    8787        }
    8888    }
  • trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp

    r264311 r268064  
    5555
    5656    unsigned* pixel = reinterpret_cast_ptr<unsigned*>(cairo_image_surface_get_data(image.get()));
    57     return unpremultiplied(asSRGBA(Packed::ARGB { *pixel }));
     57    return unpremultiplied(asSRGBA(PackedColor::ARGB { *pixel }));
    5858}
    5959
  • trunk/Source/WebCore/platform/graphics/cg/ColorCG.cpp

    r264585 r268064  
    118118{
    119119    if (color.isInline()) {
    120         switch (Packed::RGBA { color.asInline() }.value) {
    121         case Packed::RGBA { Color::transparentBlack }.value: {
     120        switch (PackedColor::RGBA { color.asInline() }.value) {
     121        case PackedColor::RGBA { Color::transparentBlack }.value: {
    122122            static CGColorRef transparentCGColor = leakCGColor(color);
    123123            return transparentCGColor;
    124124        }
    125         case Packed::RGBA { Color::black }.value: {
     125        case PackedColor::RGBA { Color::black }.value: {
    126126            static CGColorRef blackCGColor = leakCGColor(color);
    127127            return blackCGColor;
    128128        }
    129         case Packed::RGBA { Color::white }.value: {
     129        case PackedColor::RGBA { Color::white }.value: {
    130130            static CGColorRef whiteCGColor = leakCGColor(color);
    131131            return whiteCGColor;
  • trunk/Source/WebCore/platform/graphics/mac/ColorMac.mm

    r264585 r268064  
    115115{
    116116    if (color.isInline()) {
    117         switch (Packed::RGBA { color.asInline() }.value) {
    118         case Packed::RGBA { Color::transparentBlack }.value: {
     117        switch (PackedColor::RGBA { color.asInline() }.value) {
     118        case PackedColor::RGBA { Color::transparentBlack }.value: {
    119119            static NSColor *clearColor = [[NSColor colorWithSRGBRed:0 green:0 blue:0 alpha:0] retain];
    120120            return clearColor;
    121121        }
    122         case Packed::RGBA { Color::black }.value: {
     122        case PackedColor::RGBA { Color::black }.value: {
    123123            static NSColor *blackColor = [[NSColor colorWithSRGBRed:0 green:0 blue:0 alpha:1] retain];
    124124            return blackColor;
    125125        }
    126         case Packed::RGBA { Color::white }.value: {
     126        case PackedColor::RGBA { Color::white }.value: {
    127127            static NSColor *whiteColor = [[NSColor colorWithSRGBRed:1 green:1 blue:1 alpha:1] retain];
    128128            return whiteColor;
Note: See TracChangeset for help on using the changeset viewer.