1 # HG changeset patch |
1 # HG changeset patch |
2 # Parent 37d8d8fc1d9e42887a736102ff9cdab24d7a9aa8 |
2 # Parent 9fcbd287056a40084b1e679f787bf683b291f323 |
3 Taken from https://bugzilla.mozilla.org/show_bug.cgi?id=1504834 |
3 Taken from https://bugzilla.mozilla.org/show_bug.cgi?id=1504834 |
4 |
4 |
5 diff --git a/gfx/2d/DrawTargetSkia.cpp b/gfx/2d/DrawTargetSkia.cpp |
5 diff --git a/gfx/2d/DrawTargetSkia.cpp b/gfx/2d/DrawTargetSkia.cpp |
6 --- a/gfx/2d/DrawTargetSkia.cpp |
6 --- a/gfx/2d/DrawTargetSkia.cpp |
7 +++ b/gfx/2d/DrawTargetSkia.cpp |
7 +++ b/gfx/2d/DrawTargetSkia.cpp |
8 @@ -147,18 +147,17 @@ static IntRect CalculateSurfaceBounds(co |
8 @@ -156,7 +156,8 @@ static IntRect CalculateSurfaceBounds(co |
9 Rect sampledBounds = inverse.TransformBounds(*aBounds); |
|
10 if (!sampledBounds.ToIntRect(&bounds)) { |
|
11 return surfaceBounds; |
|
12 } |
|
13 |
|
14 return surfaceBounds.Intersect(bounds); |
|
15 } |
9 } |
16 |
10 |
17 -static const int kARGBAlphaOffset = |
11 static const int kARGBAlphaOffset = |
18 - SurfaceFormat::A8R8G8B8_UINT32 == SurfaceFormat::B8G8R8A8 ? 3 : 0; |
12 - SurfaceFormat::A8R8G8B8_UINT32 == SurfaceFormat::B8G8R8A8 ? 3 : 0; |
19 +static const int kARGBAlphaOffset = 0; // Skia is always BGRA SurfaceFormat::A8R8G8B8_UINT32 == SurfaceFormat::B8G8R8A8 ? 3 : 0; |
13 + 0; // Skia is always BGRA SurfaceFormat::A8R8G8B8_UINT32 == |
|
14 + // SurfaceFormat::B8G8R8A8 ? 3 : 0; |
20 |
15 |
21 static bool VerifyRGBXFormat(uint8_t* aData, const IntSize& aSize, |
16 static bool VerifyRGBXFormat(uint8_t* aData, const IntSize& aSize, |
22 const int32_t aStride, SurfaceFormat aFormat) { |
17 const int32_t aStride, SurfaceFormat aFormat) { |
23 if (aFormat != SurfaceFormat::B8G8R8X8 || aSize.IsEmpty()) { |
|
24 return true; |
|
25 } |
|
26 // We should've initialized the data to be opaque already |
|
27 // On debug builds, verify that this is actually true. |
|
28 diff --git a/gfx/2d/Types.h b/gfx/2d/Types.h |
18 diff --git a/gfx/2d/Types.h b/gfx/2d/Types.h |
29 --- a/gfx/2d/Types.h |
19 --- a/gfx/2d/Types.h |
30 +++ b/gfx/2d/Types.h |
20 +++ b/gfx/2d/Types.h |
31 @@ -87,25 +87,18 @@ enum class SurfaceFormat : int8_t { |
21 @@ -89,18 +89,11 @@ enum class SurfaceFormat : int8_t { |
32 Depth, |
|
33 |
|
34 // This represents the unknown format. |
22 // This represents the unknown format. |
35 UNKNOWN, // TODO: Replace uses with Maybe<SurfaceFormat>. |
23 UNKNOWN, // TODO: Replace uses with Maybe<SurfaceFormat>. |
36 |
24 |
37 // The following values are endian-independent synonyms. The _UINT32 suffix |
25 -// The following values are endian-independent synonyms. The _UINT32 suffix |
38 // indicates that the name reflects the layout when viewed as a uint32_t |
26 -// indicates that the name reflects the layout when viewed as a uint32_t |
39 // value. |
27 -// value. |
40 -#if MOZ_LITTLE_ENDIAN() |
28 -#if MOZ_LITTLE_ENDIAN() |
|
29 + // The following values are endian-independent synonyms. The _UINT32 suffix |
|
30 + // indicates that the name reflects the layout when viewed as a uint32_t |
|
31 + // value. |
41 A8R8G8B8_UINT32 = B8G8R8A8, // 0xAARRGGBB |
32 A8R8G8B8_UINT32 = B8G8R8A8, // 0xAARRGGBB |
42 X8R8G8B8_UINT32 = B8G8R8X8, // 0x00RRGGBB |
33 X8R8G8B8_UINT32 = B8G8R8X8, // 0x00RRGGBB |
43 -#elif MOZ_BIG_ENDIAN() |
34 -#elif MOZ_BIG_ENDIAN() |
44 - A8R8G8B8_UINT32 = A8R8G8B8, // 0xAARRGGBB |
35 - A8R8G8B8_UINT32 = A8R8G8B8, // 0xAARRGGBB |
45 - X8R8G8B8_UINT32 = X8R8G8B8, // 0x00RRGGBB |
36 - X8R8G8B8_UINT32 = X8R8G8B8, // 0x00RRGGBB |
47 -# error "bad endianness" |
38 -# error "bad endianness" |
48 -#endif |
39 -#endif |
49 |
40 |
50 // The following values are OS and endian-independent synonyms. |
41 // The following values are OS and endian-independent synonyms. |
51 // |
42 // |
52 // TODO(aosmond): When everything blocking bug 1581828 has been resolved, we |
43 diff --git a/gfx/skia/skia/modules/skcms/skcms.cc b/gfx/skia/skia/modules/skcms/skcms.cc |
53 // can make this use R8B8G8A8 and R8B8G8X8 for non-Windows platforms. |
44 --- a/gfx/skia/skia/modules/skcms/skcms.cc |
54 OS_RGBA = A8R8G8B8_UINT32, |
45 +++ b/gfx/skia/skia/modules/skcms/skcms.cc |
55 OS_RGBX = X8R8G8B8_UINT32 |
46 @@ -30,6 +30,8 @@ |
56 }; |
|
57 diff --git a/gfx/skia/skia/third_party/skcms/skcms.cc b/gfx/skia/skia/third_party/skcms/skcms.cc |
|
58 --- a/gfx/skia/skia/third_party/skcms/skcms.cc |
|
59 +++ b/gfx/skia/skia/third_party/skcms/skcms.cc |
|
60 @@ -25,16 +25,18 @@ |
|
61 // it'd be a lot slower. But we want all those headers included so we |
|
62 // can use their features after runtime checks later. |
|
63 #include <smmintrin.h> |
|
64 #include <avxintrin.h> |
|
65 #include <avx2intrin.h> |
|
66 #include <avx512fintrin.h> |
47 #include <avx512fintrin.h> |
67 #include <avx512dqintrin.h> |
48 #include <avx512dqintrin.h> |
68 #endif |
49 #endif |
69 +#else |
50 +#else |
70 + #define SKCMS_PORTABLE |
51 + #define SKCMS_PORTABLE |
71 #endif |
52 #endif |
72 |
53 |
73 // sizeof(x) will return size_t, which is 32-bit on some machines and 64-bit on others. |
54 static bool runtime_cpu_detection = true; |
74 // We have better testing on 64-bit machines, so force 32-bit machines to behave like 64-bit. |
55 @@ -324,20 +326,28 @@ enum { |
75 // |
|
76 // Please do not use sizeof() directly, and size_t only when required. |
|
77 // (We have no way of enforcing these requests...) |
|
78 #define SAFE_SIZEOF(x) ((uint64_t)sizeof(x)) |
|
79 @@ -275,30 +277,38 @@ enum { |
|
80 skcms_Signature_sf32 = 0x73663332, |
|
81 // XYZ is also a PCS signature, so it's defined in skcms.h |
|
82 // skcms_Signature_XYZ = 0x58595A20, |
|
83 }; |
|
84 |
|
85 static uint16_t read_big_u16(const uint8_t* ptr) { |
56 static uint16_t read_big_u16(const uint8_t* ptr) { |
86 uint16_t be; |
57 uint16_t be; |
87 memcpy(&be, ptr, sizeof(be)); |
58 memcpy(&be, ptr, sizeof(be)); |
88 -#if defined(_MSC_VER) |
59 -#if defined(_MSC_VER) |
|
60 - return _byteswap_ushort(be); |
89 +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
61 +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
90 + return be; |
62 + return be; |
91 +#else |
63 #else |
|
64 - return __builtin_bswap16(be); |
92 + #if defined(_MSC_VER) |
65 + #if defined(_MSC_VER) |
93 return _byteswap_ushort(be); |
66 + return _byteswap_ushort(be); |
94 -#else |
|
95 + #else |
67 + #else |
96 return __builtin_bswap16(be); |
68 + return __builtin_bswap16(be); |
97 + #endif |
69 + #endif |
98 #endif |
70 #endif |
99 } |
71 } |
100 |
72 |
101 static uint32_t read_big_u32(const uint8_t* ptr) { |
73 static uint32_t read_big_u32(const uint8_t* ptr) { |
102 uint32_t be; |
74 uint32_t be; |
103 memcpy(&be, ptr, sizeof(be)); |
75 memcpy(&be, ptr, sizeof(be)); |
104 -#if defined(_MSC_VER) |
76 -#if defined(_MSC_VER) |
|
77 - return _byteswap_ulong(be); |
105 +#if __BYTE_ORDER == __ORDER_BIG_ENDIAN__ |
78 +#if __BYTE_ORDER == __ORDER_BIG_ENDIAN__ |
106 + return be; |
79 + return be; |
107 +#else |
80 #else |
|
81 - return __builtin_bswap32(be); |
108 + #if defined(_MSC_VER) |
82 + #if defined(_MSC_VER) |
109 return _byteswap_ulong(be); |
83 + return _byteswap_ulong(be); |
110 -#else |
|
111 + #else |
84 + #else |
112 return __builtin_bswap32(be); |
85 + return __builtin_bswap32(be); |
113 + #endif |
86 + #endif |
114 #endif |
87 #endif |
115 } |
88 } |
116 |
89 |
117 static int32_t read_big_i32(const uint8_t* ptr) { |
|
118 return (int32_t)read_big_u32(ptr); |
|
119 } |
|
120 |
|
121 static float read_big_fixed(const uint8_t* ptr) { |
|