aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2017-10-02 16:28:49 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-03 12:35:58 +0000
commit862c19675edb26ed7cba56ae6ca9f98c1e4cbef1 (patch)
tree446fecbce607a64102f08b43fdd6975e5052efdc /src/codec
parentdd7ffa5a557bcaa1daebd0f056a8f1bafb992d4d (diff)
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>
Diffstat (limited to 'src/codec')
-rw-r--r--src/codec/SkAndroidCodec.cpp2
-rw-r--r--src/codec/SkBmpCodec.cpp22
-rw-r--r--src/codec/SkBmpCodec.h4
-rw-r--r--src/codec/SkBmpRLECodec.cpp8
-rw-r--r--src/codec/SkCodec.cpp2
-rw-r--r--src/codec/SkGifCodec.cpp4
-rw-r--r--src/codec/SkIcoCodec.cpp4
-rw-r--r--src/codec/SkJpegCodec.cpp4
-rw-r--r--src/codec/SkMasks.cpp2
-rw-r--r--src/codec/SkPngCodec.cpp2
-rw-r--r--src/codec/SkSwizzler.cpp16
11 files changed, 35 insertions, 35 deletions
diff --git a/src/codec/SkAndroidCodec.cpp b/src/codec/SkAndroidCodec.cpp
index c245f1d7f0..cd23680932 100644
--- a/src/codec/SkAndroidCodec.cpp
+++ b/src/codec/SkAndroidCodec.cpp
@@ -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
diff --git a/src/codec/SkBmpCodec.cpp b/src/codec/SkBmpCodec.cpp
index 60785ba35f..d97dff0971 100644
--- a/src/codec/SkBmpCodec.cpp
+++ b/src/codec/SkBmpCodec.cpp
@@ -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) {
diff --git a/src/codec/SkBmpCodec.h b/src/codec/SkBmpCodec.h
index 651f1be248..3196ae1126 100644
--- a/src/codec/SkBmpCodec.h
+++ b/src/codec/SkBmpCodec.h
@@ -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:
diff --git a/src/codec/SkBmpRLECodec.cpp b/src/codec/SkBmpRLECodec.cpp
index bd4624e6ca..18c0a79504 100644
--- a/src/codec/SkBmpRLECodec.cpp
+++ b/src/codec/SkBmpRLECodec.cpp
@@ -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;
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index 214b157628..9b55790db4 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -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
diff --git a/src/codec/SkGifCodec.cpp b/src/codec/SkGifCodec.cpp
index 970cc980ba..17c8617500 100644
--- a/src/codec/SkGifCodec.cpp
+++ b/src/codec/SkGifCodec.cpp
@@ -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();
diff --git a/src/codec/SkIcoCodec.cpp b/src/codec/SkIcoCodec.cpp
index 74affe6709..fcd31893d2 100644
--- a/src/codec/SkIcoCodec.cpp
+++ b/src/codec/SkIcoCodec.cpp
@@ -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]);
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index 33c316a57c..be5c9f7942 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -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;
}
diff --git a/src/codec/SkMasks.cpp b/src/codec/SkMasks.cpp
index ac97a39d78..79892ed922 100644
--- a/src/codec/SkMasks.cpp
+++ b/src/codec/SkMasks.cpp
@@ -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
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp
index 67995654a9..1c88b4780f 100644
--- a/src/codec/SkPngCodec.cpp
+++ b/src/codec/SkPngCodec.cpp
@@ -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) {
diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp
index 8d865daaf9..84bb09702b 100644
--- a/src/codec/SkSwizzler.cpp
+++ b/src/codec/SkSwizzler.cpp
@@ -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;