Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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" | |
| 12 #include "SkXfermode.h" | |
| 13 | |
| 14 /** Returns true if coeff's value is in the SkXfermode::Coeff enum. | |
| 15 */ | |
| 16 static inline bool SkIsValidCoeff(SkXfermode::Coeff coeff) { | |
|
mtklein
2013/09/24 22:52:18
I sort of want these to live with their correspond
sugoi1
2013/09/25 21:15:27
I'm not sure about this, but I don't have a strong
| |
| 17 return coeff >= 0 && coeff < SkXfermode::kCoeffCount; | |
| 18 } | |
| 19 | |
| 20 /** Returns true if mode's value is in the SkXfermode::Mode enum. | |
| 21 */ | |
| 22 static inline bool SkIsValidMode(SkXfermode::Mode mode) { | |
| 23 return (mode >= 0) && (mode <= SkXfermode::kLastMode); | |
| 24 } | |
| 25 | |
| 26 /** Returns true if config's value is in the SkBitmap::Config enum. | |
| 27 */ | |
| 28 static inline bool SkIsValidConfig(SkBitmap::Config config) { | |
| 29 return (config >= 0) && (config <= SkBitmap::kLastConfig); | |
| 30 } | |
| 31 | |
| 32 /** Returns true if the rect's dimensions are between 0 and SK_MaxS32 | |
| 33 */ | |
| 34 static inline bool SkIsValidRect(const SkIRect& rect) { | |
|
mtklein
2013/09/24 22:52:18
This is going to be a little confusing. Let's cal
sugoi1
2013/09/25 21:15:27
Done.
| |
| 35 return rect.width() >= 0 && rect.height() >= 0; | |
| 36 } | |
| 37 | |
| 38 /** Returns true if the rect's dimensions are between 0 and SK_ScalarMax | |
| 39 */ | |
| 40 static inline bool SkIsValidRect(const SkRect& rect) { | |
| 41 return !rect.isInverted() && | |
| 42 SkScalarIsFinite(rect.width()) && | |
| 43 SkScalarIsFinite(rect.height()); | |
| 44 } | |
| 45 | |
| 46 #endif | |
| OLD | NEW |