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

Unified Diff: src/core/SkValidation.h

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Adding validation helper file Created 7 years, 3 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
Index: src/core/SkValidation.h
diff --git a/src/core/SkValidation.h b/src/core/SkValidation.h
new file mode 100644
index 0000000000000000000000000000000000000000..dba7494e23ce81737017b9939c55bae3175cb6a4
--- /dev/null
+++ b/src/core/SkValidation.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkValidation_DEFINED
reed1 2013/09/04 18:49:36 SkValidationUtils.h might be a more similar naming
sugoi1 2013/09/04 20:14:52 Done.
+#define SkValidation_DEFINED
+
+#include "SkBitmap.h"
+#include "SkXfermode.h"
+
+/** Returns true if coeff's value is in the SkXfermode::Coeff enum.
+ */
+static inline bool IsValidCoeff(SkXfermode::Coeff coeff) {
+ return coeff >= 0 && coeff < SkXfermode::kCoeffCount;
+}
+
+/** Returns true if mode's value is in the SkXfermode::Mode enum.
+ */
+static inline bool IsValidMode(SkXfermode::Mode mode) {
+ return (mode >= 0) && (mode <= SkXfermode::kLastMode);
+}
+
+/** Returns true if config's value is in the SkBitmap::Config enum.
+ */
+static inline bool IsValidConfig(SkBitmap::Config config) {
+ return (config >= 0) && (config <= SkBitmap::kLastConfig);
+}
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698