commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkValidationUtils_DEFINED |
| 9 | #define SkValidationUtils_DEFINED |
| 10 | |
| 11 | #include "SkBitmap.h" |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 12 | #include "SkBlendMode.h" |
Hal Canary | 6b20a55 | 2017-02-07 14:09:38 -0500 | [diff] [blame] | 13 | #include "SkXfermodePriv.h" |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 14 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 15 | /** Returns true if mode's value is in the SkBlendMode enum. |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 16 | */ |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 17 | static inline bool SkIsValidMode(SkBlendMode mode) { |
| 18 | return (unsigned)mode <= (unsigned)SkBlendMode::kLastMode; |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 19 | } |
| 20 | |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 21 | /** Returns true if the rect's dimensions are between 0 and SK_MaxS32 |
| 22 | */ |
| 23 | static inline bool SkIsValidIRect(const SkIRect& rect) { |
| 24 | return rect.width() >= 0 && rect.height() >= 0; |
| 25 | } |
| 26 | |
| 27 | /** Returns true if the rect's dimensions are between 0 and SK_ScalarMax |
| 28 | */ |
| 29 | static inline bool SkIsValidRect(const SkRect& rect) { |
| 30 | return (rect.fLeft <= rect.fRight) && |
| 31 | (rect.fTop <= rect.fBottom) && |
| 32 | SkScalarIsFinite(rect.width()) && |
| 33 | SkScalarIsFinite(rect.height()); |
| 34 | } |
| 35 | |
| 36 | #endif |