From 85f9e1a0ad2be17c5ba606c4e2d7e83dda30c151 Mon Sep 17 00:00:00 2001 From: "reed@android.com" Date: Mon, 1 Mar 2010 01:10:10 +0000 Subject: [PATCH] more vector4 methods git-svn-id: http://skia.googlecode.com/svn/trunk@515 2bbb7eff-a529-9590-31e7-b0007b416f81 --- experimental/SkMatrix44.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/experimental/SkMatrix44.h b/experimental/SkMatrix44.h index 1fe46d49cf..f86559056a 100644 --- a/experimental/SkMatrix44.h +++ b/experimental/SkMatrix44.h @@ -45,6 +45,36 @@ static const SkMScalar SK_MScalar1 = 1; struct SkVector4 { SkScalar fData[4]; + SkVector4() { + this->set(0, 0, 0, 1); + } + SkVector4(const SkVector4& src) { + memcpy(fData, src.fData, sizeof(fData)); + } + SkVector4(SkScalar x, SkScalar y, SkScalar z, SkScalar w = SK_Scalar1) { + fData[0] = x; + fData[1] = y; + fData[2] = z; + fData[3] = w; + } + + SkVector4& operator=(const SkVector4& src) { + memcpy(fData, src.fData, sizeof(fData)); + return *this; + } + + bool operator==(const SkVector4& v) { + return fData[0] == v.fData[0] && fData[1] == v.fData[1] && + fData[2] == v.fData[2] && fData[3] == v.fData[3]; + } + bool operator!=(const SkVector4& v) { + return !(*this == v); + } + bool equals(SkScalar x, SkScalar y, SkScalar z, SkScalar w = SK_Scalar1) { + return fData[0] == x && fData[1] == y && + fData[2] == z && fData[3] == w; + } + void set(SkScalar x, SkScalar y, SkScalar z, SkScalar w = SK_Scalar1) { fData[0] = x; fData[1] = y;