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

Unified Diff: src/core/Sk4px.h

Issue 1295443002: add asserts on Sk4px::Map functions that our arrays are non-null. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 months 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/Sk4px.h
diff --git a/src/core/Sk4px.h b/src/core/Sk4px.h
index ffde1af504f682504034839b5db142eecf76fa39..996847fa12cdf764ab3fea64d168127601bcb117 100644
--- a/src/core/Sk4px.h
+++ b/src/core/Sk4px.h
@@ -110,6 +110,8 @@ public:
// fn should take an Sk4px (4 src pixels) and return an Sk4px (4 dst pixels).
template <typename Fn, typename Dst>
static void MapSrc(int n, Dst* dst, const SkPMColor* src, const Fn& fn) {
+ SkASSERT(dst);
+ SkASSERT(src);
// This looks a bit odd, but it helps loop-invariant hoisting across different calls to fn.
// Basically, we need to make sure we keep things inside a single loop.
while (n > 0) {
@@ -140,6 +142,8 @@ public:
// As above, but with dst4' = fn(dst4, src4).
template <typename Fn, typename Dst>
static void MapDstSrc(int n, Dst* dst, const SkPMColor* src, const Fn& fn) {
+ SkASSERT(dst);
+ SkASSERT(src);
while (n > 0) {
if (n >= 8) {
Sk4px dst0 = fn(Load4(dst+0), Load4(src+0)),
@@ -168,6 +172,8 @@ public:
// As above, but with dst4' = fn(dst4, alpha4).
template <typename Fn, typename Dst>
static void MapDstAlpha(int n, Dst* dst, const SkAlpha* a, const Fn& fn) {
+ SkASSERT(dst);
+ SkASSERT(a);
while (n > 0) {
if (n >= 8) {
Sk4px dst0 = fn(Load4(dst+0), Load4Alphas(a+0)),
@@ -197,6 +203,9 @@ public:
template <typename Fn, typename Dst>
static void MapDstSrcAlpha(int n, Dst* dst, const SkPMColor* src, const SkAlpha* a,
const Fn& fn) {
+ SkASSERT(dst);
+ SkASSERT(src);
+ SkASSERT(a);
while (n > 0) {
if (n >= 8) {
Sk4px dst0 = fn(Load4(dst+0), Load4(src+0), Load4Alphas(a+0)),
« 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