Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1449 return true; | 1449 return true; |
| 1450 } | 1450 } |
| 1451 return false; | 1451 return false; |
| 1452 } | 1452 } |
| 1453 } | 1453 } |
| 1454 | 1454 |
| 1455 bool SkCanvas::quickReject(const SkPath& path) const { | 1455 bool SkCanvas::quickReject(const SkPath& path) const { |
| 1456 return path.isEmpty() || this->quickReject(path.getBounds()); | 1456 return path.isEmpty() || this->quickReject(path.getBounds()); |
| 1457 } | 1457 } |
| 1458 | 1458 |
| 1459 static inline int pinIntForScalar(int x) { | 1459 static inline int pinIntForScalar(int x) { |
|
caryclark
2013/12/17 13:07:13
this inline is no longer called and can be deleted
| |
| 1460 #ifdef SK_SCALAR_IS_FIXED | |
| 1461 if (x < SK_MinS16) { | |
| 1462 x = SK_MinS16; | |
| 1463 } else if (x > SK_MaxS16) { | |
| 1464 x = SK_MaxS16; | |
| 1465 } | |
| 1466 #endif | |
| 1467 return x; | 1460 return x; |
| 1468 } | 1461 } |
| 1469 | 1462 |
| 1470 bool SkCanvas::getClipBounds(SkRect* bounds) const { | 1463 bool SkCanvas::getClipBounds(SkRect* bounds) const { |
| 1471 SkIRect ibounds; | 1464 SkIRect ibounds; |
| 1472 if (!getClipDeviceBounds(&ibounds)) { | 1465 if (!getClipDeviceBounds(&ibounds)) { |
| 1473 return false; | 1466 return false; |
| 1474 } | 1467 } |
| 1475 | 1468 |
| 1476 SkMatrix inverse; | 1469 SkMatrix inverse; |
| 1477 // if we can't invert the CTM, we can't return local clip bounds | 1470 // if we can't invert the CTM, we can't return local clip bounds |
| 1478 if (!fMCRec->fMatrix->invert(&inverse)) { | 1471 if (!fMCRec->fMatrix->invert(&inverse)) { |
| 1479 if (bounds) { | 1472 if (bounds) { |
| 1480 bounds->setEmpty(); | 1473 bounds->setEmpty(); |
| 1481 } | 1474 } |
| 1482 return false; | 1475 return false; |
| 1483 } | 1476 } |
| 1484 | 1477 |
| 1485 if (NULL != bounds) { | 1478 if (NULL != bounds) { |
| 1486 SkRect r; | 1479 SkRect r; |
| 1487 // adjust it outwards in case we are antialiasing | 1480 // adjust it outwards in case we are antialiasing |
| 1488 const int inset = 1; | 1481 const int inset = 1; |
| 1489 | 1482 |
| 1490 // SkRect::iset() will correctly assert if we pass a value out of range | 1483 r.iset(ibounds.fLeft - inset, ibounds.fTop - inset, |
| 1491 // (when SkScalar==fixed), so we pin to legal values. This does not | 1484 ibounds.fRight + inset, ibounds.fBottom + inset); |
| 1492 // really returnt the correct answer, but its the best we can do given | |
| 1493 // that we've promised to return SkRect (even though we support devices | |
| 1494 // that can be larger than 32K in width or height). | |
| 1495 r.iset(pinIntForScalar(ibounds.fLeft - inset), | |
| 1496 pinIntForScalar(ibounds.fTop - inset), | |
| 1497 pinIntForScalar(ibounds.fRight + inset), | |
| 1498 pinIntForScalar(ibounds.fBottom + inset)); | |
| 1499 inverse.mapRect(bounds, r); | 1485 inverse.mapRect(bounds, r); |
| 1500 } | 1486 } |
| 1501 return true; | 1487 return true; |
| 1502 } | 1488 } |
| 1503 | 1489 |
| 1504 bool SkCanvas::getClipDeviceBounds(SkIRect* bounds) const { | 1490 bool SkCanvas::getClipDeviceBounds(SkIRect* bounds) const { |
| 1505 const SkRasterClip& clip = *fMCRec->fRasterClip; | 1491 const SkRasterClip& clip = *fMCRec->fRasterClip; |
| 1506 if (clip.isEmpty()) { | 1492 if (clip.isEmpty()) { |
| 1507 if (bounds) { | 1493 if (bounds) { |
| 1508 bounds->setEmpty(); | 1494 bounds->setEmpty(); |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2203 return *paint; | 2189 return *paint; |
| 2204 } | 2190 } |
| 2205 | 2191 |
| 2206 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } | 2192 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } |
| 2207 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } | 2193 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } |
| 2208 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } | 2194 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } |
| 2209 | 2195 |
| 2210 /////////////////////////////////////////////////////////////////////////////// | 2196 /////////////////////////////////////////////////////////////////////////////// |
| 2211 | 2197 |
| 2212 SkCanvas::ClipVisitor::~ClipVisitor() { } | 2198 SkCanvas::ClipVisitor::~ClipVisitor() { } |
| OLD | NEW |