aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2018-06-14 14:41:22 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-18 17:22:18 +0000
commite72e773ad0684626ba4ed79f97b7f36cd8e5c923 (patch)
tree921a6efa730cd115a3539d6ce71e16cdb6f2dc7c /bench
parent19c1233c447f625c2522e7ecd0a0adecc629bb2f (diff)
remove SkTCast
SkTCast is functionally equivalent to reinterpret_cast. The comment about SkTCast helping to avoid strict alising issues is not true. Dereferencing a pointer cast to a pointer of an unrelated type is always undefined, even if smuggled through a union like in SkTCast. To really avoid aliasing issues, you need to make a union[1] of the two value types, or better, memcpy between values. I've had to fix MatrixText.cpp where switching to reinterpret_cast actually let Clang notice and warn that we're exploiting undefined behavior, and GrSwizzle.h and SkCamera.cpp caught by GCC. I've switched SkTLList over to use SkAlignedSTStorage, which seems to help convince some GCC versions that fObj is used in a sound way. [1] The union punning trick is non-standard in C++, but GCC and MSVC both explicitly support it. I believe Clang does not officially explicitly support it, but probably does quietly for GCC compatibility. Change-Id: I71822e82c962f9aaac8be24d3c0f39f4f8b05026 Reviewed-on: https://skia-review.googlesource.com/134947 Commit-Queue: Mike Klein <mtklein@chromium.org> Commit-Queue: Brian Salomon <bsalomon@google.com> Auto-Submit: Mike Klein <mtklein@chromium.org> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'bench')
-rw-r--r--bench/MathBench.cpp4
-rw-r--r--bench/RectBench.cpp4
2 files changed, 4 insertions, 4 deletions
diff --git a/bench/MathBench.cpp b/bench/MathBench.cpp
index 7f3408e8e4..74b89a3204 100644
--- a/bench/MathBench.cpp
+++ b/bench/MathBench.cpp
@@ -76,8 +76,8 @@ protected:
int count) = 0;
void performTest(float* SK_RESTRICT dst, const float* SK_RESTRICT src, int count) override {
- uint32_t* d = SkTCast<uint32_t*>(dst);
- const uint32_t* s = SkTCast<const uint32_t*>(src);
+ uint32_t* d = reinterpret_cast<uint32_t*>(dst);
+ const uint32_t* s = reinterpret_cast<const uint32_t*>(src);
this->performITest(d, s, count);
}
private:
diff --git a/bench/RectBench.cpp b/bench/RectBench.cpp
index 386fb43dfb..407c3a976f 100644
--- a/bench/RectBench.cpp
+++ b/bench/RectBench.cpp
@@ -185,7 +185,7 @@ protected:
for (size_t i = 0; i < sizes; i++) {
paint.setStrokeWidth(gSizes[i]);
this->setupPaint(&paint);
- canvas->drawPoints(fMode, N * 2, SkTCast<SkPoint*>(fRects), paint);
+ canvas->drawPoints(fMode, N * 2, reinterpret_cast<SkPoint*>(fRects), paint);
paint.setColor(fColors[i % N]);
}
}
@@ -263,7 +263,7 @@ protected:
this->setupPaint(&paint);
paint.setColor(color);
paint.setAlpha(alpha);
- canvas->drawPoints(fMode, N * 2, SkTCast<SkPoint*>(fRects), paint);
+ canvas->drawPoints(fMode, N * 2, reinterpret_cast<SkPoint*>(fRects), paint);
}
}
}