diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-12 21:01:41 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-12 21:01:41 +0000 |
commit | 52e935d04c59135739c3a68fb6e19d313dc6d5ad (patch) | |
tree | 95f7ab178b045bef4456cbf92c6aa7e476becd99 /skia/corecg/SkRect.cpp | |
parent | 30fab79877b4bb067944b74d98346ac9bb6bfc7e (diff) | |
download | chromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.zip chromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.tar.gz chromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.tar.bz2 |
New drop of Skia. This is up to CL 121320.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6925 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/corecg/SkRect.cpp')
-rw-r--r-- | skia/corecg/SkRect.cpp | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/skia/corecg/SkRect.cpp b/skia/corecg/SkRect.cpp index f32b27e..d602754 100644 --- a/skia/corecg/SkRect.cpp +++ b/skia/corecg/SkRect.cpp @@ -1,19 +1,18 @@ -/* libs/corecg/SkRect.cpp -** -** Copyright 2006, Google Inc. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "SkRect.h" @@ -67,17 +66,33 @@ void SkRect::set(const SkPoint pts[], int count) { SkASSERT((pts && count > 0) || count == 0); - if (count <= 0) - memset(this, 0, sizeof(SkRect)); - else - { + if (count <= 0) { + bzero(this, sizeof(SkRect)); + } else { +#ifdef SK_SCALAR_SLOW_COMPARES + int32_t l, t, r, b; + + l = r = SkScalarAs2sCompliment(pts[0].fX); + t = b = SkScalarAs2sCompliment(pts[0].fY); + + for (int i = 1; i < count; i++) { + int32_t x = SkScalarAs2sCompliment(pts[i].fX); + int32_t y = SkScalarAs2sCompliment(pts[i].fY); + + if (x < l) l = x; else if (x > r) r = x; + if (y < t) t = y; else if (y > b) b = y; + } + this->set(Sk2sComplimentAsScalar(l), + Sk2sComplimentAsScalar(t), + Sk2sComplimentAsScalar(r), + Sk2sComplimentAsScalar(b)); +#else SkScalar l, t, r, b; l = r = pts[0].fX; t = b = pts[0].fY; - for (int i = 1; i < count; i++) - { + for (int i = 1; i < count; i++) { SkScalar x = pts[i].fX; SkScalar y = pts[i].fY; @@ -85,6 +100,7 @@ void SkRect::set(const SkPoint pts[], int count) if (y < t) t = y; else if (y > b) b = y; } this->set(l, t, r, b); +#endif } } |