diff options
author | Mike Reed <reed@google.com> | 2010-02-11 06:20:08 -0500 |
---|---|---|
committer | Mike Reed <reed@google.com> | 2010-02-11 06:20:08 -0500 |
commit | 6b79d6ada02fb549f79a1f7ca5efa222be37dee5 (patch) | |
tree | e36de6385ecb0adc4c0d43beab7ba8c3602fab8c | |
parent | 1c980e0d7772f05f570ae0227d91635f017c2227 (diff) | |
download | external_skia-6b79d6ada02fb549f79a1f7ca5efa222be37dee5.zip external_skia-6b79d6ada02fb549f79a1f7ca5efa222be37dee5.tar.gz external_skia-6b79d6ada02fb549f79a1f7ca5efa222be37dee5.tar.bz2 |
refresh from trunk: add static Make for SkSize
-rw-r--r-- | include/core/SkSize.h | 17 | ||||
-rw-r--r-- | tests/PathTest.cpp | 11 |
2 files changed, 27 insertions, 1 deletions
diff --git a/include/core/SkSize.h b/include/core/SkSize.h index d432102..9df9508 100644 --- a/include/core/SkSize.h +++ b/include/core/SkSize.h @@ -7,6 +7,13 @@ template <typename T> struct SkTSize { T fWidth; T fHeight; + static SkTSize Make(T w, T h) { + SkTSize s; + s.fWidth = w; + s.fHeight = h; + return s; + } + void set(T w, T h) { fWidth = w; fHeight = h; @@ -58,11 +65,19 @@ static inline bool operator!=(const SkTSize<T>& a, const SkTSize<T>& b) { /////////////////////////////////////////////////////////////////////////////// -struct SkISize : public SkTSize<int32_t> {}; +typedef SkTSize<int32_t> SkISize; #include "SkScalar.h" struct SkSize : public SkTSize<SkScalar> { + static SkSize Make(SkScalar w, SkScalar h) { + SkSize s; + s.fWidth = w; + s.fHeight = h; + return s; + } + + SkSize& operator=(const SkISize& src) { this->set(SkIntToScalar(src.fWidth), SkIntToScalar(src.fHeight)); return *this; diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp index 89fe93b..9f26d01 100644 --- a/tests/PathTest.cpp +++ b/tests/PathTest.cpp @@ -1,5 +1,6 @@ #include "Test.h" #include "SkPath.h" +#include "SkSize.h" static void check_convex_bounds(skiatest::Reporter* reporter, const SkPath& p, const SkRect& bounds) { @@ -17,6 +18,16 @@ static void check_convex_bounds(skiatest::Reporter* reporter, const SkPath& p, } static void TestPath(skiatest::Reporter* reporter) { + { + SkSize size; + size.fWidth = 3.4f; + size.width(); + size = SkSize::Make(3,4); + SkISize isize = SkISize::Make(3,4); + } + + SkTSize<SkScalar>::Make(3,4); + SkPath p, p2; SkRect bounds, bounds2; |