Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: src/pathops/SkPathOpsRect.h

Issue 12827020: Add base types for path ops (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/pathops/SkPathOpsQuad.cpp ('k') | src/pathops/SkPathOpsRect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7 #ifndef SkPathOpsRect_DEFINED
8 #define SkPathOpsRect_DEFINED
9
10 #include "SkPathOpsPoint.h"
11
12 struct SkDRect {
13 double fLeft, fTop, fRight, fBottom;
14
15 void add(const SkDPoint& pt) {
16 if (fLeft > pt.fX) {
17 fLeft = pt.fX;
18 }
19 if (fTop > pt.fY) {
20 fTop = pt.fY;
21 }
22 if (fRight < pt.fX) {
23 fRight = pt.fX;
24 }
25 if (fBottom < pt.fY) {
26 fBottom = pt.fY;
27 }
28 }
29
30 // FIXME: used by debugging only ?
31 bool contains(const SkDPoint& pt) const {
32 return approximately_between(fLeft, pt.fX, fRight)
33 && approximately_between(fTop, pt.fY, fBottom);
34 }
35
36 bool intersects(SkDRect* r) const {
37 SkASSERT(fLeft <= fRight);
38 SkASSERT(fTop <= fBottom);
39 SkASSERT(r->fLeft <= r->fRight);
40 SkASSERT(r->fTop <= r->fBottom);
41 return r->fLeft <= fRight && fLeft <= r->fRight && r->fTop <= fBottom && fTop <= r->fBottom;
42 }
43
44 void set(const SkDPoint& pt) {
45 fLeft = fRight = pt.fX;
46 fTop = fBottom = pt.fY;
47 }
48
49 void setBounds(const SkDLine&);
50 void setBounds(const SkDCubic&);
51 void setBounds(const SkDQuad&);
52 void setRawBounds(const SkDCubic&);
53 void setRawBounds(const SkDQuad&);
54 };
55
56 #endif
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsQuad.cpp ('k') | src/pathops/SkPathOpsRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698