Proposed fix for crash in Cr70244.
git-svn-id: http://skia.googlecode.com/svn/trunk@764 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
57e6a5342e
commit
116b2bcd2c
@ -296,6 +296,7 @@ struct SkRect {
|
||||
/** Return true if the rectangle's width or height are <= 0
|
||||
*/
|
||||
bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
|
||||
bool hasValidCoordinates() const;
|
||||
SkScalar width() const { return fRight - fLeft; }
|
||||
SkScalar height() const { return fBottom - fTop; }
|
||||
SkScalar centerX() const { return SkScalarHalf(fLeft + fRight); }
|
||||
|
@ -991,6 +991,10 @@ void SkCanvas::computeLocalClipBoundsCompareType(EdgeType et) const {
|
||||
antialiasing (worst case)
|
||||
*/
|
||||
bool SkCanvas::quickReject(const SkRect& rect, EdgeType et) const {
|
||||
|
||||
if (!rect.hasValidCoordinates())
|
||||
return true;
|
||||
|
||||
if (fMCRec->fRegion->isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include "SkRect.h"
|
||||
#include <limits>
|
||||
|
||||
void SkIRect::join(int32_t left, int32_t top, int32_t right, int32_t bottom)
|
||||
{
|
||||
@ -44,6 +45,19 @@ void SkIRect::sort()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename NumType> static inline bool isValidRange(const NumType& x)
|
||||
{
|
||||
static const NumType max = std::numeric_limits<NumType>::max();
|
||||
return x >= -max && x <= max;
|
||||
}
|
||||
|
||||
|
||||
bool SkRect::hasValidCoordinates() const
|
||||
{
|
||||
return isValidRange<SkScalar>(fLeft) && isValidRange<SkScalar>(fRight) &&
|
||||
isValidRange<SkScalar>(fTop) && isValidRange<SkScalar>(fBottom);
|
||||
}
|
||||
|
||||
void SkRect::sort()
|
||||
{
|
||||
if (fLeft > fRight)
|
||||
|
Loading…
Reference in New Issue
Block a user