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

Side by Side Diff: include/gpu/GrRect.h

Issue 232563007: Add MakeEmpty to GrIRect16 (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2010 Google Inc. 2 * Copyright 2010 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrRect_DEFINED 8 #ifndef GrRect_DEFINED
9 #define GrRect_DEFINED 9 #define GrRect_DEFINED
10 10
11 #include "SkTypes.h" 11 #include "SkTypes.h"
12 #include "SkRect.h" 12 #include "SkRect.h"
13 13
14 struct GrIRect16 { 14 struct GrIRect16 {
15 int16_t fLeft, fTop, fRight, fBottom; 15 int16_t fLeft, fTop, fRight, fBottom;
16 16
17 static GrIRect16 SK_WARN_UNUSED_RESULT MakeEmpty() {
18 GrIRect16 r;
19 r.setEmpty();
20 return r;
21 }
22
17 int width() const { return fRight - fLeft; } 23 int width() const { return fRight - fLeft; }
18 int height() const { return fBottom - fTop; } 24 int height() const { return fBottom - fTop; }
19 int area() const { return this->width() * this->height(); } 25 int area() const { return this->width() * this->height(); }
20 bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; } 26 bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
21 27
28 void setEmpty() { memset(this, 0, sizeof(*this)); }
29
22 void set(const SkIRect& r) { 30 void set(const SkIRect& r) {
23 fLeft = SkToS16(r.fLeft); 31 fLeft = SkToS16(r.fLeft);
24 fTop = SkToS16(r.fTop); 32 fTop = SkToS16(r.fTop);
25 fRight = SkToS16(r.fRight); 33 fRight = SkToS16(r.fRight);
26 fBottom = SkToS16(r.fBottom); 34 fBottom = SkToS16(r.fBottom);
27 } 35 }
28 }; 36 };
29 37
30 #endif 38 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698