Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Unified Diff: src/core/SkAAClip.cpp

Issue 1518863002: Fix UB function problems for AA merger. (Closed) Base URL: https://skia.googlesource.com/skia.git@ubsan-function
Patch Set: clean up Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkAAClip.cpp
diff --git a/src/core/SkAAClip.cpp b/src/core/SkAAClip.cpp
index bbd1f555f08d49f1e6d11f346c1dfb93934d771e..0de6d350eb17c390b318b0073177013f026fb1e8 100644
--- a/src/core/SkAAClip.cpp
+++ b/src/core/SkAAClip.cpp
@@ -2056,9 +2056,10 @@ static inline uint16_t mergeOne(uint16_t value, unsigned alpha) {
SkMulDiv255Round(b, alpha));
}
-template <typename T> void mergeT(const T* SK_RESTRICT src, int srcN,
- const uint8_t* SK_RESTRICT row, int rowN,
- T* SK_RESTRICT dst) {
+template <typename T>
+void mergeT(const void* inSrc, int srcN, const uint8_t* SK_RESTRICT row, int rowN, void* inDst) {
+ const T* SK_RESTRICT src = static_cast<const T*>(inSrc);
+ T* SK_RESTRICT dst = static_cast<T*>(inDst);
for (;;) {
SkASSERT(rowN > 0);
SkASSERT(srcN > 0);
@@ -2094,14 +2095,10 @@ static MergeAAProc find_merge_aa_proc(SkMask::Format format) {
SkDEBUGFAIL("unsupported");
return nullptr;
case SkMask::kA8_Format:
- case SkMask::k3D_Format: {
- void (*proc8)(const uint8_t*, int, const uint8_t*, int, uint8_t*) = mergeT;
- return (MergeAAProc)proc8;
- }
- case SkMask::kLCD16_Format: {
- void (*proc16)(const uint16_t*, int, const uint8_t*, int, uint16_t*) = mergeT;
- return (MergeAAProc)proc16;
- }
+ case SkMask::k3D_Format:
+ return mergeT<uint8_t> ;
+ case SkMask::kLCD16_Format:
+ return mergeT<uint16_t>;
default:
SkDEBUGFAIL("unsupported");
return nullptr;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698