Chromium Code Reviews| Index: src/pathops/SkPathOpsRect.h |
| =================================================================== |
| --- src/pathops/SkPathOpsRect.h (revision 0) |
| +++ src/pathops/SkPathOpsRect.h (revision 0) |
| @@ -0,0 +1,56 @@ |
| +/* |
| + * Copyright 2012 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| +#ifndef SkPathOpsRect_DEFINED |
| +#define SkPathOpsRect_DEFINED |
| + |
| +#include "SkPathOpsPoint.h" |
| + |
| +struct SkDRect { |
| + double fLeft, fTop, fRight, fBottom; |
| + |
| + void add(const SkDPoint& pt) { |
|
whunt
2013/03/22 18:16:06
add is a very overloaded name, I'd recommend "Unio
reed1
2013/03/22 19:00:37
whunt: skia uses lower-case for method names, and
caryclark
2013/03/22 20:05:00
Noted.
caryclark
2013/03/22 20:05:00
Noted.
|
| + if (fLeft > pt.fX) { |
|
whunt
2013/03/22 18:16:06
Use std::min and std::max. In 64 bit mode and any
caryclark
2013/03/22 19:38:51
Noted. In general, it's not necessary to flag and
|
| + fLeft = pt.fX; |
| + } |
| + if (fTop > pt.fY) { |
| + fTop = pt.fY; |
| + } |
| + if (fRight < pt.fX) { |
| + fRight = pt.fX; |
| + } |
| + if (fBottom < pt.fY) { |
| + fBottom = pt.fY; |
| + } |
| + } |
| + |
| + // FIXME: used by debugging only ? |
| + bool contains(const SkDPoint& pt) const { |
| + return approximately_between(fLeft, pt.fX, fRight) |
| + && approximately_between(fTop, pt.fY, fBottom); |
| + } |
| + |
| + bool intersects(SkDRect* r) const { |
| + SkASSERT(fLeft <= fRight); |
| + SkASSERT(fTop <= fBottom); |
| + SkASSERT(r->fLeft <= r->fRight); |
| + SkASSERT(r->fTop <= r->fBottom); |
| + return r->fLeft <= fRight && fLeft <= r->fRight && r->fTop <= fBottom && fTop <= r->fBottom; |
| + } |
| + |
| + void set(const SkDPoint& pt) { |
| + fLeft = fRight = pt.fX; |
| + fTop = fBottom = pt.fY; |
| + } |
| + |
| + void setBounds(const SkDLine&); |
| + void setBounds(const SkDCubic&); |
| + void setBounds(const SkDQuad&); |
| + void setRawBounds(const SkDCubic&); |
| + void setRawBounds(const SkDQuad&); |
| +}; |
| + |
| +#endif |