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

Side by Side Diff: include/core/SkRect.h

Issue 1970003003: Add bounds to GrShape (Closed) Base URL: https://chromium.googlesource.com/skia.git@grshapeisempty
Patch Set: put back const& Created 4 years, 7 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
« no previous file with comments | « no previous file | src/gpu/GrShape.h » ('j') | 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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 SkRect_DEFINED 8 #ifndef SkRect_DEFINED
9 #define SkRect_DEFINED 9 #define SkRect_DEFINED
10 10
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 static const SkIRect gEmpty = { 0, 0, 0, 0 }; 383 static const SkIRect gEmpty = { 0, 0, 0, 0 };
384 return gEmpty; 384 return gEmpty;
385 } 385 }
386 }; 386 };
387 387
388 /** \struct SkRect 388 /** \struct SkRect
389 */ 389 */
390 struct SK_API SkRect { 390 struct SK_API SkRect {
391 SkScalar fLeft, fTop, fRight, fBottom; 391 SkScalar fLeft, fTop, fRight, fBottom;
392 392
393 static SkRect SK_WARN_UNUSED_RESULT MakeEmpty() { 393 static constexpr SkRect SK_WARN_UNUSED_RESULT MakeEmpty() {
394 SkRect r; 394 return SkRect{0, 0, 0, 0};
395 r.setEmpty();
396 return r;
397 } 395 }
398 396
399 static SkRect SK_WARN_UNUSED_RESULT MakeLargest() { 397 static SkRect SK_WARN_UNUSED_RESULT MakeLargest() {
400 SkRect r; 398 SkRect r;
401 r.setLargest(); 399 r.setLargest();
402 return r; 400 return r;
403 } 401 }
404 402
405 static SkRect SK_WARN_UNUSED_RESULT MakeWH(SkScalar w, SkScalar h) { 403 static SkRect SK_WARN_UNUSED_RESULT MakeWH(SkScalar w, SkScalar h) {
406 SkRect r; 404 SkRect r;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 return !SkScalarsEqual((SkScalar*)&a, (SkScalar*)&b, 4); 497 return !SkScalarsEqual((SkScalar*)&a, (SkScalar*)&b, 4);
500 } 498 }
501 499
502 /** return the 4 points that enclose the rectangle (top-left, top-right, bot tom-right, 500 /** return the 4 points that enclose the rectangle (top-left, top-right, bot tom-right,
503 bottom-left). TODO: Consider adding param to control whether quad is CW or CCW. 501 bottom-left). TODO: Consider adding param to control whether quad is CW or CCW.
504 */ 502 */
505 void toQuad(SkPoint quad[4]) const; 503 void toQuad(SkPoint quad[4]) const;
506 504
507 /** Set this rectangle to the empty rectangle (0,0,0,0) 505 /** Set this rectangle to the empty rectangle (0,0,0,0)
508 */ 506 */
509 void setEmpty() { memset(this, 0, sizeof(*this)); } 507 void setEmpty() { *this = MakeEmpty(); }
510 508
511 void set(const SkIRect& src) { 509 void set(const SkIRect& src) {
512 fLeft = SkIntToScalar(src.fLeft); 510 fLeft = SkIntToScalar(src.fLeft);
513 fTop = SkIntToScalar(src.fTop); 511 fTop = SkIntToScalar(src.fTop);
514 fRight = SkIntToScalar(src.fRight); 512 fRight = SkIntToScalar(src.fRight);
515 fBottom = SkIntToScalar(src.fBottom); 513 fBottom = SkIntToScalar(src.fBottom);
516 } 514 }
517 515
518 void set(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) { 516 void set(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) {
519 fLeft = left; 517 fLeft = left;
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 void dumpHex() const { this->dump(true); } 896 void dumpHex() const { this->dump(true); }
899 }; 897 };
900 898
901 inline bool SkIRect::contains(const SkRect& r) const { 899 inline bool SkIRect::contains(const SkRect& r) const {
902 return !r.isEmpty() && !this->isEmpty() && // check for empties 900 return !r.isEmpty() && !this->isEmpty() && // check for empties
903 (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop && 901 (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop &&
904 (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom; 902 (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom;
905 } 903 }
906 904
907 #endif 905 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrShape.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698