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

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

Issue 1893433002: In SkDraw::drawRect, use SkPath for huge rects. Base URL: https://skia.googlesource.com/skia@fixed-assert
Patch Set: Created 4 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
« no previous file with comments | « gm/bigrect.cpp ('k') | include/core/SkRegion.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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 r.setEmpty(); 395 r.setEmpty();
396 return r; 396 return r;
397 } 397 }
398 398
399 static SkRect SK_WARN_UNUSED_RESULT MakeLargest() { 399 static SkRect SK_WARN_UNUSED_RESULT MakeLargest() {
400 SkRect r; 400 SkRect r;
401 r.setLargest(); 401 r.setLargest();
402 return r; 402 return r;
403 } 403 }
404 404
405 /**
406 * Make the largest SkRect for which canRound() returns true.
407 */
408 static SkRect SK_WARN_UNUSED_RESULT MakeLargestS32() {
409 const SkRect r = MakeLTRB(-SK_MaxS32Scalar, -SK_MaxS32Scalar,
410 SK_MaxS32Scalar, SK_MaxS32Scalar);
411 SkASSERT(r == Make(r.round()));
412 return r;
413 }
414
405 static SkRect SK_WARN_UNUSED_RESULT MakeWH(SkScalar w, SkScalar h) { 415 static SkRect SK_WARN_UNUSED_RESULT MakeWH(SkScalar w, SkScalar h) {
406 SkRect r; 416 SkRect r;
407 r.set(0, 0, w, h); 417 r.set(0, 0, w, h);
408 return r; 418 return r;
409 } 419 }
410 420
411 static SkRect SK_WARN_UNUSED_RESULT MakeIWH(int w, int h) { 421 static SkRect SK_WARN_UNUSED_RESULT MakeIWH(int w, int h) {
412 SkRect r; 422 SkRect r;
413 r.set(0, 0, SkIntToScalar(w), SkIntToScalar(h)); 423 r.set(0, 0, SkIntToScalar(w), SkIntToScalar(h));
414 return r; 424 return r;
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 * Returns true if the specified rectangle r is inside or equal to this rect angle. 817 * Returns true if the specified rectangle r is inside or equal to this rect angle.
808 */ 818 */
809 bool contains(const SkIRect& r) const { 819 bool contains(const SkIRect& r) const {
810 // todo: can we eliminate the this->isEmpty check? 820 // todo: can we eliminate the this->isEmpty check?
811 return !r.isEmpty() && !this->isEmpty() && 821 return !r.isEmpty() && !this->isEmpty() &&
812 fLeft <= SkIntToScalar(r.fLeft) && fTop <= SkIntToScalar(r.fTop) && 822 fLeft <= SkIntToScalar(r.fLeft) && fTop <= SkIntToScalar(r.fTop) &&
813 fRight >= SkIntToScalar(r.fRight) && fBottom >= SkIntToScalar(r. fBottom); 823 fRight >= SkIntToScalar(r.fRight) && fBottom >= SkIntToScalar(r. fBottom);
814 } 824 }
815 825
816 /** 826 /**
827 * Return true if round(SkIRect) and roundOut(SkIRect) will not overflow Sk IRect.
828 */
829 bool canRound() const;
830
831 /**
817 * Set the dst rectangle by rounding this rectangle's coordinates to their 832 * Set the dst rectangle by rounding this rectangle's coordinates to their
818 * nearest integer values using SkScalarRoundToInt. 833 * nearest integer values using SkScalarRoundToInt.
819 */ 834 */
820 void round(SkIRect* dst) const { 835 void round(SkIRect* dst) const {
821 SkASSERT(dst); 836 SkASSERT(dst);
822 dst->set(SkScalarRoundToInt(fLeft), SkScalarRoundToInt(fTop), 837 dst->set(SkScalarRoundToInt(fLeft), SkScalarRoundToInt(fTop),
823 SkScalarRoundToInt(fRight), SkScalarRoundToInt(fBottom)); 838 SkScalarRoundToInt(fRight), SkScalarRoundToInt(fBottom));
824 } 839 }
825 840
826 /** 841 /**
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 /** 906 /**
892 * cast-safe way to treat the rect as an array of (4) SkScalars. 907 * cast-safe way to treat the rect as an array of (4) SkScalars.
893 */ 908 */
894 const SkScalar* asScalars() const { return &fLeft; } 909 const SkScalar* asScalars() const { return &fLeft; }
895 910
896 void dump(bool asHex) const; 911 void dump(bool asHex) const;
897 void dump() const { this->dump(false); } 912 void dump() const { this->dump(false); }
898 void dumpHex() const { this->dump(true); } 913 void dumpHex() const { this->dump(true); }
899 }; 914 };
900 915
901 inline bool SkIRect::contains(const SkRect& r) const {
902 return !r.isEmpty() && !this->isEmpty() && // check for empties
903 (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop &&
904 (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom;
905 }
906
907 #endif 916 #endif
OLDNEW
« no previous file with comments | « gm/bigrect.cpp ('k') | include/core/SkRegion.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698