Remove static initializers in SkCodec
Bug: 768878 Switch const declarations to constexpr where appropriate. Speculative fix for crbug.com/768878. Change-Id: I7fc356e623ce7a0f2b87e92e9a8ed95d5c423d79 Reviewed-on: https://skia-review.googlesource.com/54101 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Chris Blume <cblume@chromium.org>
This commit is contained in:
parent
dd7ffa5a55
commit
862c19675e
@ -42,7 +42,7 @@ static float calculate_area(SkPoint abc[]) {
|
||||
return 0.5f * SkTAbs(a.fX*b.fY + b.fX*c.fY - a.fX*c.fY - c.fX*b.fY - b.fX*a.fY);
|
||||
}
|
||||
|
||||
static const float kSRGB_D50_GamutArea = 0.084f;
|
||||
static constexpr float kSRGB_D50_GamutArea = 0.084f;
|
||||
|
||||
static bool is_wide_gamut(const SkColorSpace* colorSpace) {
|
||||
// Determine if the source image has a gamut that is wider than sRGB. If so, we
|
||||
|
@ -81,17 +81,17 @@ std::unique_ptr<SkCodec> SkBmpCodec::MakeFromIco(std::unique_ptr<SkStream> strea
|
||||
}
|
||||
|
||||
// Header size constants
|
||||
static const uint32_t kBmpHeaderBytes = 14;
|
||||
static const uint32_t kBmpHeaderBytesPlusFour = kBmpHeaderBytes + 4;
|
||||
static const uint32_t kBmpOS2V1Bytes = 12;
|
||||
static const uint32_t kBmpOS2V2Bytes = 64;
|
||||
static const uint32_t kBmpInfoBaseBytes = 16;
|
||||
static const uint32_t kBmpInfoV1Bytes = 40;
|
||||
static const uint32_t kBmpInfoV2Bytes = 52;
|
||||
static const uint32_t kBmpInfoV3Bytes = 56;
|
||||
static const uint32_t kBmpInfoV4Bytes = 108;
|
||||
static const uint32_t kBmpInfoV5Bytes = 124;
|
||||
static const uint32_t kBmpMaskBytes = 12;
|
||||
static constexpr uint32_t kBmpHeaderBytes = 14;
|
||||
static constexpr uint32_t kBmpHeaderBytesPlusFour = kBmpHeaderBytes + 4;
|
||||
static constexpr uint32_t kBmpOS2V1Bytes = 12;
|
||||
static constexpr uint32_t kBmpOS2V2Bytes = 64;
|
||||
static constexpr uint32_t kBmpInfoBaseBytes = 16;
|
||||
static constexpr uint32_t kBmpInfoV1Bytes = 40;
|
||||
static constexpr uint32_t kBmpInfoV2Bytes = 52;
|
||||
static constexpr uint32_t kBmpInfoV3Bytes = 56;
|
||||
static constexpr uint32_t kBmpInfoV4Bytes = 108;
|
||||
static constexpr uint32_t kBmpInfoV5Bytes = 124;
|
||||
static constexpr uint32_t kBmpMaskBytes = 12;
|
||||
|
||||
static BmpHeaderType get_header_type(size_t infoBytes) {
|
||||
if (infoBytes >= kBmpInfoBaseBytes) {
|
||||
|
@ -102,8 +102,8 @@ protected:
|
||||
* BMPs are typically encoded as BGRA/BGR so this is a more efficient choice
|
||||
* than RGBA.
|
||||
*/
|
||||
static const SkColorType kXformSrcColorType = kBGRA_8888_SkColorType;
|
||||
static const auto kXformSrcColorFormat = SkColorSpaceXform::kBGRA_8888_ColorFormat;
|
||||
static constexpr SkColorType kXformSrcColorType = kBGRA_8888_SkColorType;
|
||||
static constexpr auto kXformSrcColorFormat = SkColorSpaceXform::kBGRA_8888_ColorFormat;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -338,10 +338,10 @@ int SkBmpRLECodec::decodeRLE(const SkImageInfo& dstInfo, void* dst, size_t dstRo
|
||||
const int height = dstInfo.height();
|
||||
|
||||
// Set RLE flags
|
||||
static const uint8_t RLE_ESCAPE = 0;
|
||||
static const uint8_t RLE_EOL = 0;
|
||||
static const uint8_t RLE_EOF = 1;
|
||||
static const uint8_t RLE_DELTA = 2;
|
||||
constexpr uint8_t RLE_ESCAPE = 0;
|
||||
constexpr uint8_t RLE_EOL = 0;
|
||||
constexpr uint8_t RLE_EOF = 1;
|
||||
constexpr uint8_t RLE_DELTA = 2;
|
||||
|
||||
// Destination parameters
|
||||
int x = 0;
|
||||
|
@ -32,7 +32,7 @@ struct DecoderProc {
|
||||
std::unique_ptr<SkCodec> (*MakeFromStream)(std::unique_ptr<SkStream>, SkCodec::Result*);
|
||||
};
|
||||
|
||||
static const DecoderProc gDecoderProcs[] = {
|
||||
static constexpr DecoderProc gDecoderProcs[] = {
|
||||
#ifdef SK_HAS_JPEG_LIBRARY
|
||||
{ SkJpegCodec::IsJpeg, SkJpegCodec::MakeFromStream },
|
||||
#endif
|
||||
|
@ -156,8 +156,8 @@ int SkGifCodec::onGetRepetitionCount() {
|
||||
return fReader->loopCount();
|
||||
}
|
||||
|
||||
static const SkColorType kXformSrcColorType = kRGBA_8888_SkColorType;
|
||||
static const SkAlphaType kXformAlphaType = kUnpremul_SkAlphaType;
|
||||
static constexpr SkColorType kXformSrcColorType = kRGBA_8888_SkColorType;
|
||||
static constexpr SkAlphaType kXformAlphaType = kUnpremul_SkAlphaType;
|
||||
|
||||
void SkGifCodec::initializeColorTable(const SkImageInfo& dstInfo, int frameIndex) {
|
||||
SkColorType colorTableColorType = dstInfo.colorType();
|
||||
|
@ -29,8 +29,8 @@ bool SkIcoCodec::IsIco(const void* buffer, size_t bytesRead) {
|
||||
std::unique_ptr<SkCodec> SkIcoCodec::MakeFromStream(std::unique_ptr<SkStream> stream,
|
||||
Result* result) {
|
||||
// Header size constants
|
||||
static const uint32_t kIcoDirectoryBytes = 6;
|
||||
static const uint32_t kIcoDirEntryBytes = 16;
|
||||
constexpr uint32_t kIcoDirectoryBytes = 6;
|
||||
constexpr uint32_t kIcoDirEntryBytes = 16;
|
||||
|
||||
// Read the directory header
|
||||
std::unique_ptr<uint8_t[]> dirBuffer(new uint8_t[kIcoDirectoryBytes]);
|
||||
|
@ -30,7 +30,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
bool SkJpegCodec::IsJpeg(const void* buffer, size_t bytesRead) {
|
||||
static const uint8_t jpegSig[] = { 0xFF, 0xD8, 0xFF };
|
||||
constexpr uint8_t jpegSig[] = { 0xFF, 0xD8, 0xFF };
|
||||
return bytesRead >= 3 && !memcmp(buffer, jpegSig, sizeof(jpegSig));
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ static bool is_orientation_marker(jpeg_marker_struct* marker, SkCodec::Origin* o
|
||||
}
|
||||
|
||||
const uint8_t* data = marker->data;
|
||||
static const uint8_t kExifSig[] { 'E', 'x', 'i', 'f', '\0' };
|
||||
constexpr uint8_t kExifSig[] { 'E', 'x', 'i', 'f', '\0' };
|
||||
if (memcmp(data, kExifSig, sizeof(kExifSig))) {
|
||||
return false;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
* Used to convert 1-7 bit color components into 8-bit color components
|
||||
*
|
||||
*/
|
||||
const static uint8_t n_bit_to_8_bit_lookup_table[] = {
|
||||
static constexpr uint8_t n_bit_to_8_bit_lookup_table[] = {
|
||||
// 1 bit
|
||||
0, 255,
|
||||
// 2 bits
|
||||
|
@ -244,7 +244,7 @@ bool SkPngCodec::processData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static const SkColorType kXformSrcColorType = kRGBA_8888_SkColorType;
|
||||
static constexpr SkColorType kXformSrcColorType = kRGBA_8888_SkColorType;
|
||||
|
||||
// Note: SkColorTable claims to store SkPMColors, which is not necessarily the case here.
|
||||
bool SkPngCodec::createColorTable(const SkImageInfo& dstInfo) {
|
||||
|
@ -154,14 +154,14 @@ static void swizzle_bit_to_565(
|
||||
static void swizzle_bit_to_f16(
|
||||
void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
|
||||
int bpp, int deltaSrc, int offset, const SkPMColor* /*ctable*/) {
|
||||
static const uint64_t kWhite = (((uint64_t) SK_Half1) << 0) |
|
||||
(((uint64_t) SK_Half1) << 16) |
|
||||
(((uint64_t) SK_Half1) << 32) |
|
||||
(((uint64_t) SK_Half1) << 48);
|
||||
static const uint64_t kBlack = (((uint64_t) 0) << 0) |
|
||||
(((uint64_t) 0) << 16) |
|
||||
(((uint64_t) 0) << 32) |
|
||||
(((uint64_t) SK_Half1) << 48);
|
||||
constexpr uint64_t kWhite = (((uint64_t) SK_Half1) << 0) |
|
||||
(((uint64_t) SK_Half1) << 16) |
|
||||
(((uint64_t) SK_Half1) << 32) |
|
||||
(((uint64_t) SK_Half1) << 48);
|
||||
constexpr uint64_t kBlack = (((uint64_t) 0) << 0) |
|
||||
(((uint64_t) 0) << 16) |
|
||||
(((uint64_t) 0) << 32) |
|
||||
(((uint64_t) SK_Half1) << 48);
|
||||
|
||||
uint64_t* SK_RESTRICT dst = (uint64_t*) dstRow;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user