• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#Topic IRect
2#Alias IRects
3#Alias IRect_Reference
4
5#Subtopic Overview
6    #Subtopic Subtopics
7    #Populate
8    ##
9##
10
11#Struct SkIRect
12
13SkIRect holds four 32 bit integer coordinates describing the upper and
14lower bounds of a rectangle. SkIRect may be created from outer bounds or
15from position, width, and height. SkIRect describes an area; if its right
16is less than or equal to its left, or if its bottom is less than or equal to
17its top, it is considered empty.
18
19#Subtopic Related_Functions
20#Table
21#Legend
22# name                   # description                                ##
23#Legend ##
24# Inset_Outset_Offset    # moves sides                                ##
25# Intersection           # set to shared bounds                       ##
26# Join                   # set to union of bounds                     ##
27# Properties             # side values, center, validity              ##
28# Rounding               # adjust to integer bounds                   ##
29# Set                    # replaces all values                        ##
30# Sorting                # orders sides                               ##
31#Table ##
32#Subtopic ##
33
34#Subtopic Member_Functions
35#Populate
36#Subtopic ##
37
38#Subtopic Members
39#Populate
40
41#Member int32_t  fLeft
42#Line # smaller x-axis bounds ##
43May contain any value. The smaller of the horizontal values when sorted.
44When equal to or greater than fRight, IRect is empty.
45##
46
47#Member int32_t  fTop
48#Line # smaller y-axis bounds ##
49May contain any value. The smaller of the horizontal values when sorted.
50When equal to or greater than fBottom, IRect is empty.
51##
52
53#Member int32_t  fRight
54#Line # larger x-axis bounds ##
55May contain any value. The larger of the vertical values when sorted.
56When equal to or less than fLeft, IRect is empty.
57##
58
59#Member int32_t  fBottom
60#Line # larger y-axis bounds ##
61May contain any value. The larger of the vertical values when sorted.
62When equal to or less than fTop, IRect is empty.
63##
64
65#Subtopic Members ##
66
67#Subtopic Constructors
68#Populate
69
70# ------------------------------------------------------------------------------
71
72#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeEmpty()
73
74#In Constructors
75#Line # returns bounds of (0, 0, 0, 0) ##
76Returns constructed IRect set to (0, 0, 0, 0).
77Many other rectangles are empty; if left is equal to or greater than right,
78or if top is equal to or greater than bottom. Setting all members to zero
79is a convenience, but does not designate a special empty rectangle.
80
81#Return bounds (0, 0, 0, 0) ##
82
83#Example
84    SkIRect rect = SkIRect::MakeEmpty();
85    SkDebugf("MakeEmpty isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
86    rect.offset(10, 10);
87    SkDebugf("offset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
88    rect.inset(10, 10);
89    SkDebugf("inset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
90    rect.outset(20, 20);
91    SkDebugf("outset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
92#StdOut
93MakeEmpty isEmpty: true
94offset rect isEmpty: true
95inset rect isEmpty: true
96outset rect isEmpty: false
97##
98##
99
100#SeeAlso EmptyIRect isEmpty setEmpty SkRect::MakeEmpty
101
102##
103
104# ------------------------------------------------------------------------------
105
106#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeWH(int32_t w, int32_t h)
107
108#In Constructors
109#Line # constructs from int input returning (0, 0, width, height) ##
110Returns constructed IRect set to (0, 0, w, h). Does not validate input; w or h
111may be negative.
112
113#Param w  width of constructed IRect  ##
114#Param h  height of constructed IRect ##
115
116#Return bounds (0, 0, w, h) ##
117
118#Example
119    SkIRect rect1 = SkIRect::MakeWH(25, 35);
120    SkIRect rect2 = SkIRect::MakeSize({25, 35});
121    SkIRect rect3 = SkIRect::MakeXYWH(0, 0, 25, 35);
122    SkIRect rect4 = SkIRect::MakeLTRB(0, 0, 25, 35);
123    SkDebugf("all %s" "equal\n", rect1 == rect2 && rect2 == rect3 && rect3 == rect4 ?
124             "" : "not ");
125#StdOut
126all equal
127##
128##
129
130#SeeAlso MakeSize MakeXYWH SkRect::MakeWH SkRect::MakeIWH
131
132##
133
134# ------------------------------------------------------------------------------
135
136#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeSize(const SkISize& size)
137
138#In Constructors
139#Line # constructs from ISize returning (0, 0, width, height) ##
140Returns constructed IRect set to (0, 0, size.width(), size.height()).
141Does not validate input; size.width() or size.height() may be negative.
142
143#Param size  values for IRect width and height ##
144
145#Return bounds (0, 0, size.width(), size.height()) ##
146
147#Example
148    SkSize size = {25.5f, 35.5f};
149    SkIRect rect = SkIRect::MakeSize(size.toRound());
150    SkDebugf("round width: %d  height: %d\n", rect.width(), rect.height());
151    rect = SkIRect::MakeSize(size.toFloor());
152    SkDebugf("floor width: %d  height: %d\n", rect.width(), rect.height());
153#StdOut
154round width: 26  height: 36
155floor width: 25  height: 35
156##
157##
158
159#SeeAlso MakeWH MakeXYWH SkRect::Make SkRect::MakeIWH
160
161##
162
163# ------------------------------------------------------------------------------
164
165#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
166
167#In Constructors
168#Line # constructs from int left, top, right, bottom ##
169Returns constructed IRect set to (l, t, r, b). Does not sort input; IRect may
170result in fLeft greater than fRight, or fTop greater than fBottom.
171
172#Param l  integer stored in fLeft ##
173#Param t  integer stored in fTop ##
174#Param r  integer stored in fRight ##
175#Param b  integer stored in fBottom ##
176
177#Return bounds (l, t, r, b) ##
178
179#Example
180    SkIRect rect = SkIRect::MakeLTRB(5, 35, 15, 25);
181    SkDebugf("rect: %d, %d, %d, %d  isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
182              rect.bottom(), rect.isEmpty() ? "true" : "false");
183    rect.sort();
184    SkDebugf("rect: %d, %d, %d, %d  isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
185              rect.bottom(), rect.isEmpty() ? "true" : "false");
186#StdOut
187rect: 5, 35, 15, 25  isEmpty: true
188rect: 5, 25, 15, 35  isEmpty: false
189##
190##
191
192#SeeAlso MakeXYWH SkRect::MakeLTRB
193
194##
195
196# ------------------------------------------------------------------------------
197
198#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
199
200#In Constructors
201#Line # constructs from int input returning (x, y, width, height) ##
202Returns constructed IRect set to:
203#Formula
204(x, y, x + w, y + h)
205##
206. Does not validate input;
207w or h may be negative.
208
209#Param x  stored in fLeft ##
210#Param y  stored in fTop ##
211#Param w  added to x and stored in fRight ##
212#Param h  added to y and stored in fBottom ##
213
214#Return bounds at (x, y) with width w and height h ##
215
216#Example
217    SkIRect rect = SkIRect::MakeXYWH(5, 35, -15, 25);
218    SkDebugf("rect: %d, %d, %d, %d  isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
219              rect.bottom(), rect.isEmpty() ? "true" : "false");
220    rect.sort();
221    SkDebugf("rect: %d, %d, %d, %d  isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
222              rect.bottom(), rect.isEmpty() ? "true" : "false");
223#StdOut
224rect: 5, 35, -10, 60  isEmpty: true
225rect: -10, 35, 5, 60  isEmpty: false
226##
227##
228
229#SeeAlso MakeLTRB SkRect::MakeXYWH
230
231##
232
233#Subtopic Constructors ##
234
235
236# ------------------------------------------------------------------------------
237
238#Method int32_t left() const
239
240#Line # returns smaller bounds in x, if sorted ##
241Returns left edge of IRect, if sorted.
242Call sort() to reverse fLeft and fRight if needed.
243
244#Return fLeft ##
245
246#Example
247    SkIRect unsorted = { 15, 5, 10, 25 };
248    SkDebugf("unsorted.fLeft: %d unsorted.left(): %d\n", unsorted.fLeft, unsorted.left());
249    SkIRect sorted = unsorted.makeSorted();
250    SkDebugf("sorted.fLeft: %d sorted.left(): %d\n", sorted.fLeft, sorted.left());
251#StdOut
252unsorted.fLeft: 15 unsorted.left(): 15
253sorted.fLeft: 10 sorted.left(): 10
254##
255##
256
257#SeeAlso fLeft x() SkRect::left()
258
259##
260
261# ------------------------------------------------------------------------------
262
263#Method int32_t top() const
264
265#Line # returns smaller bounds in y, if sorted ##
266Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
267and sort() to reverse fTop and fBottom if needed.
268
269#Return fTop ##
270
271#Example
272    SkIRect unsorted = { 15, 25, 10, 5 };
273    SkDebugf("unsorted.fTop: %d unsorted.top(): %d\n", unsorted.fTop, unsorted.top());
274    SkIRect sorted = unsorted.makeSorted();
275    SkDebugf("sorted.fTop: %d sorted.top(): %d\n", sorted.fTop, sorted.top());
276#StdOut
277unsorted.fTop: 25 unsorted.top(): 25
278sorted.fTop: 5 sorted.top(): 5
279##
280##
281
282#SeeAlso fTop y() SkRect::top()
283
284##
285
286# ------------------------------------------------------------------------------
287
288#Method int32_t right() const
289
290#Line # returns larger bounds in x, if sorted ##
291Returns right edge of IRect, if sorted.
292Call sort() to reverse fLeft and fRight if needed.
293
294#Return fRight ##
295
296#Example
297    SkIRect unsorted = { 15, 25, 10, 5 };
298    SkDebugf("unsorted.fRight: %d unsorted.right(): %d\n", unsorted.fRight, unsorted.right());
299    SkIRect sorted = unsorted.makeSorted();
300    SkDebugf("sorted.fRight: %d sorted.right(): %d\n", sorted.fRight, sorted.right());
301#StdOut
302unsorted.fRight: 10 unsorted.right(): 10
303sorted.fRight: 15 sorted.right(): 15
304##
305##
306
307#SeeAlso fRight SkRect::right()
308
309##
310
311# ------------------------------------------------------------------------------
312
313#Method int32_t bottom() const
314
315#Line # returns larger bounds in y, if sorted ##
316Returns bottom edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
317and sort() to reverse fTop and fBottom if needed.
318
319#Return fBottom ##
320
321#Example
322    SkIRect unsorted = { 15, 25, 10, 5 };
323    SkDebugf("unsorted.fBottom: %d unsorted.bottom(): %d\n", unsorted.fBottom, unsorted.bottom());
324    SkIRect sorted = unsorted.makeSorted();
325    SkDebugf("sorted.fBottom: %d sorted.bottom(): %d\n", sorted.fBottom, sorted.bottom());
326#StdOut
327unsorted.fBottom: 5 unsorted.bottom(): 5
328sorted.fBottom: 25 sorted.bottom(): 25
329##
330##
331
332#SeeAlso fBottom SkRect::bottom()
333
334##
335
336# ------------------------------------------------------------------------------
337
338#Method int32_t x() const
339
340#Line # returns bounds left ##
341Returns left edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
342and sort() to reverse fLeft and fRight if needed.
343
344#Return fLeft ##
345
346#Example
347    SkIRect unsorted = { 15, 5, 10, 25 };
348    SkDebugf("unsorted.fLeft: %d unsorted.x(): %d\n", unsorted.fLeft, unsorted.x());
349    SkIRect sorted = unsorted.makeSorted();
350    SkDebugf("sorted.fLeft: %d sorted.x(): %d\n", sorted.fLeft, sorted.x());
351#StdOut
352unsorted.fLeft: 15 unsorted.x(): 15
353sorted.fLeft: 10 sorted.x(): 10
354##
355##
356
357#SeeAlso fLeft left() y() SkRect::x()
358
359##
360
361# ------------------------------------------------------------------------------
362
363#Method int32_t y() const
364
365#Line # returns bounds top ##
366Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
367and sort() to reverse fTop and fBottom if needed.
368
369#Return fTop ##
370
371#Example
372    SkIRect unsorted = { 15, 25, 10, 5 };
373    SkDebugf("unsorted.fTop: %d unsorted.y(): %d\n", unsorted.fTop, unsorted.y());
374    SkIRect sorted = unsorted.makeSorted();
375    SkDebugf("sorted.fTop: %d sorted.y(): %d\n", sorted.fTop, sorted.y());
376#StdOut
377unsorted.fTop: 25 unsorted.y(): 25
378sorted.fTop: 5 sorted.y(): 5
379##
380##
381
382#SeeAlso fTop top() x() SkRect::y()
383
384##
385
386# ------------------------------------------------------------------------------
387
388#Method int32_t width() const
389
390#Line # returns span in x ##
391Returns span on the x-axis. This does not check if IRect is sorted, or if
392result fits in 32-bit signed integer; result may be negative.
393
394#Return fRight minus fLeft ##
395
396#Example
397    SkIRect unsorted = { 15, 25, 10, 5 };
398    SkDebugf("unsorted width: %d\n", unsorted.width());
399    SkIRect large = { -2147483647, 1, 2147483644, 2 };
400    SkDebugf("large width: %d\n", large.width());
401#StdOut
402unsorted width: -5
403large width: -5
404##
405##
406
407#SeeAlso height() width64() height64() SkRect::width()
408
409##
410
411# ------------------------------------------------------------------------------
412
413#Method int64_t width64() const
414
415#Line # returns span in y as int64_t ##
416Returns span on the x-axis. This does not check if IRect is sorted, so the
417result may be negative. This is safer than calling width() since width() might
418overflow in its calculation.
419
420#Return fRight minus fLeft cast to int64_t ##
421
422#Bug 7489 ##
423# width64 is not yet visible to fiddle
424#NoExample
425SkIRect large = { -2147483647, 1, 2147483644, 2 };
426SkDebugf("width: %d wdith64: %lld\n", large.width(), large.width64());
427#StdOut
428width: -5 width64: 4294967291
429##
430##
431
432#SeeAlso width() height() height64() SkRect::width()
433
434##
435
436# ------------------------------------------------------------------------------
437
438#Method int32_t height() const
439
440#Line # returns span in y ##
441Returns span on the y-axis. This does not check if IRect is sorted, or if
442result fits in 32-bit signed integer; result may be negative.
443
444#Return fBottom minus fTop ##
445
446#Example
447    SkIRect unsorted = { 15, 25, 10, 20 };
448    SkDebugf("unsorted height: %d\n", unsorted.height());
449    SkIRect large = { 1, -2147483647, 2, 2147483644 };
450    SkDebugf("large height: %d\n", large.height());
451#StdOut
452unsorted height: -5
453large height: -5
454##
455##
456
457#SeeAlso width() SkRect::height()
458
459##
460
461# ------------------------------------------------------------------------------
462
463#Method int64_t height64() const
464
465#Line # returns span in y as int64_t ##
466Returns span on the y-axis. This does not check if IRect is sorted, so the
467result may be negative. This is safer than calling height() since height() might
468overflow in its calculation.
469
470#Return fBottom minus fTop cast to int64_t ##
471
472#Bug 7489 ##
473# height64 not yet visible to fiddle
474#NoExample
475SkIRect large = { 1, -2147483647, 2, 2147483644 };
476SkDebugf("height: %d height64: %lld\n", large.height(), large.height64());
477#StdOut
478height: -5 height64: 4294967291
479##
480##
481
482#SeeAlso width() height() width64() SkRect::height()
483
484##
485
486# ------------------------------------------------------------------------------
487
488#Method SkISize size() const
489
490#Line # returns ISize (width, height) ##
491Returns spans on the x-axis and y-axis. This does not check if IRect is sorted,
492or if result fits in 32-bit signed integer; result may be negative.
493
494#Return  ISize (width, height) ##
495
496#Example
497    auto debugster = [](const char* prefix, const SkIRect& rect) -> void {
498        SkISize size = rect.size();
499        SkDebugf("%s ", prefix);
500        SkDebugf("rect: %d, %d, %d, %d  ", rect.left(), rect.top(), rect.right(), rect.bottom());
501        SkDebugf("size: %d, %d\n", size.width(), size.height());
502    };
503    SkIRect rect = {20, 30, 40, 50};
504    debugster("original", rect);
505    rect.offset(20, 20);
506    debugster("  offset", rect);
507    rect.outset(20, 20);
508    debugster("  outset", rect);
509#StdOut
510original rect: 20, 30, 40, 50  size: 20, 20
511  offset rect: 40, 50, 60, 70  size: 20, 20
512  outset rect: 20, 30, 80, 90  size: 60, 60
513##
514##
515
516#SeeAlso height() width() MakeSize
517
518##
519
520# ------------------------------------------------------------------------------
521
522#Method int32_t centerX() const
523
524#Line # returns midpoint in x ##
525Returns average of left edge and right edge. Result does not change if IRect
526is sorted. Result may be incorrect if IRect is far from the origin.
527
528Result is rounded down.
529
530#Return midpoint in x ##
531
532#Example
533#Description
534Dividing by two rounds towards zero. centerX uses a bit shift and rounds down.
535##
536    SkIRect tests[] = {{20, 30, 41, 51}, {-20, -30, -41, -51}, {-10, -10, 11, 11}};
537    for (auto rect : tests) {
538        SkDebugf("left: %3d right: %3d centerX: %3d ", rect.left(), rect.right(), rect.centerX());
539        SkDebugf("div2: %3d\n", (rect.left() + rect.right()) / 2);
540    }
541#StdOut
542left:  20 right:  41 centerX:  30 div2:  30
543left: -20 right: -41 centerX: -31 div2: -30
544left: -10 right:  11 centerX:   0 div2:   0
545##
546##
547
548#SeeAlso centerY SkRect::centerX
549
550##
551
552# ------------------------------------------------------------------------------
553
554#Method int32_t centerY() const
555
556#Line # returns midpoint in y ##
557Returns average of top edge and bottom edge. Result does not change if IRect
558is sorted. Result may be incorrect if IRect is far from the origin.
559
560Result is rounded down.
561
562#Return midpoint in y ##
563
564#Example
565   SkIRect rect = { 0, 0, 2, 2 };
566   rect.offset(0x40000000, 0x40000000);
567   SkDebugf("left: %d right: %d centerX: %d ", rect.left(), rect.right(), rect.centerX());
568   SkDebugf("safe mid x: %d\n", rect.left() / 2 + rect.right() / 2);
569#StdOut
570left: 1073741824 right: 1073741826 centerX: -1073741823 safe mid x: 1073741825
571##
572##
573
574#SeeAlso centerX SkRect::centerY
575
576##
577
578# ------------------------------------------------------------------------------
579
580#Method bool isEmpty() const
581
582#Line # returns true if width or height are zero or negative or they exceed int32_t ##
583Returns true if width() or height() .
584
585#Return true if width() or height() are zero or negative ##
586
587#Example
588    SkIRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
589    for (auto rect : tests) {
590        SkDebugf("rect: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
591                 rect.bottom(), rect.isEmpty() ? "" : " not");
592        rect.sort();
593        SkDebugf("sorted: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
594                 rect.bottom(), rect.isEmpty() ? "" : " not");
595    }
596#StdOut
597rect: {20, 40, 10, 50} is empty
598sorted: {10, 40, 20, 50} is not empty
599rect: {20, 40, 20, 50} is empty
600sorted: {20, 40, 20, 50} is empty
601##
602##
603
604#SeeAlso EmptyIRect MakeEmpty sort SkRect::isEmpty
605
606##
607
608# ------------------------------------------------------------------------------
609
610#Method bool isEmpty64() const
611
612#Line # returns true if width or height are zero or negative ##
613Returns true if fLeft is equal to or greater than fRight, or if fTop is equal
614to or greater than fBottom. Call sort() to reverse rectangles with negative
615width64() or height64().
616
617#Return true if width64() or height64() are zero or negative ##
618
619#Bug 7489 ##
620# isEmpty64 not yet visible to fiddle
621#NoExample
622SkIRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
623for (auto rect : tests) {
624SkDebugf("rect: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
625rect.bottom(), isEmpty64() ? "" : " not");
626rect.sort();
627SkDebugf("sorted: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
628rect.bottom(), isEmpty64() ? "" : " not");
629}
630#StdOut
631rect: {20, 40, 10, 50} is empty
632sorted: {10, 40, 20, 50} is not empty
633rect: {20, 40, 20, 50} is empty
634sorted: {20, 40, 20, 50} is empty
635##
636##
637
638#SeeAlso EmptyIRect MakeEmpty sort SkRect::isEmpty
639
640##
641
642#Subtopic Operators
643#Populate
644
645# ------------------------------------------------------------------------------
646
647#Method bool operator==(const SkIRect& a, const SkIRect& b)
648
649#In Operators
650#Line # returns true if members are equal ##
651Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are
652identical to corresponding members in b.
653
654#Param a  IRect to compare ##
655#Param b  IRect to compare ##
656
657#Return true if members are equal ##
658
659#Example
660    SkIRect test = {0, 0, 2, 2};
661    SkIRect sorted = test.makeSorted();
662    SkDebugf("test %c= sorted\n", test == sorted ? '=' : '!');
663#StdOut
664test == sorted
665##
666##
667
668#SeeAlso operator!=(const SkIRect& a, const SkIRect& b)
669
670##
671
672# ------------------------------------------------------------------------------
673
674#Method bool operator!=(const SkIRect& a, const SkIRect& b)
675
676#In Operators
677#Line # returns true if members are unequal ##
678Returns true if any member in a: fLeft, fTop, fRight, and fBottom; is not
679identical to the corresponding member in b.
680
681#Param a  IRect to compare ##
682#Param b  IRect to compare ##
683
684#Return true if members are not equal ##
685
686#Example
687    SkIRect test = {2, 2, 0, 0};
688    SkIRect sorted = test.makeSorted();
689    SkDebugf("test %c= sorted\n", test != sorted ? '!' : '=');
690#StdOut
691test != sorted
692##
693##
694
695#SeeAlso operator==(const SkIRect& a, const SkIRect& b)
696
697##
698
699#Subtopic Operators ##
700
701# ------------------------------------------------------------------------------
702
703#Method bool is16Bit() const
704
705#Line # returns true if members fit in 16-bit word ##
706Returns true if all members: fLeft, fTop, fRight, and fBottom; values are
707equal to or larger than -32768 and equal to or smaller than 32767.
708
709#Return true if members fit in 16-bit word ##
710
711#Example
712    SkIRect tests[] = {{-32768, -32768, 32767, 32767}, {-32768, -32768, 32768, 32768}};
713    for (auto rect : tests) {
714        SkDebugf("{%d, %d, %d, %d} %s in 16 bits\n", rect.fLeft, rect.fTop, rect.fRight,
715                 rect.fBottom, rect.is16Bit() ? "fits" : "does not fit");
716}
717#StdOut
718{-32768, -32768, 32767, 32767} fits in 16 bits
719{-32768, -32768, 32768, 32768} does not fit in 16 bits
720##
721##
722
723#SeeAlso SkTFitsIn
724
725##
726
727# ------------------------------------------------------------------------------
728
729#Method void setEmpty()
730
731#Line # sets to (0, 0, 0, 0) ##
732Sets IRect to (0, 0, 0, 0).
733
734Many other rectangles are empty; if left is equal to or greater than right,
735or if top is equal to or greater than bottom. Setting all members to zero
736is a convenience, but does not designate a special empty rectangle.
737
738#Example
739    SkIRect rect = {3, 4, 1, 2};
740    for (int i = 0; i < 2; ++i) {
741    SkDebugf("rect: {%d, %d, %d, %d} is %s" "empty\n", rect.fLeft, rect.fTop,
742             rect.fRight, rect.fBottom, rect.isEmpty() ? "" : "not ");
743    rect.setEmpty();
744    }
745#StdOut
746rect: {3, 4, 1, 2} is empty
747rect: {0, 0, 0, 0} is empty
748##
749##
750
751#SeeAlso MakeEmpty SkRect::setEmpty
752
753##
754
755# ------------------------------------------------------------------------------
756
757#Method void set(int32_t left, int32_t top, int32_t right, int32_t bottom)
758
759#Line # sets to (left, top, right, bottom) ##
760Sets IRect to (left, top, right, bottom).
761left and right are not sorted; left is not necessarily less than right.
762top and bottom are not sorted; top is not necessarily less than bottom.
763
764#Param left  assigned to fLeft ##
765#Param top  assigned to fTop ##
766#Param right  assigned to fRight ##
767#Param bottom  assigned to fBottom ##
768
769#Example
770    SkIRect rect1 = {3, 4, 1, 2};
771    SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
772    SkIRect rect2;
773    rect2.set(3, 4, 1, 2);
774    SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
775#StdOut
776rect1: {3, 4, 1, 2}
777rect2: {3, 4, 1, 2}
778##
779##
780
781#SeeAlso setLTRB setXYWH SkRect::set
782
783##
784
785# ------------------------------------------------------------------------------
786
787#Method void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom)
788
789#Line # sets to SkScalar input (left, top, right, bottom) ##
790Sets IRect to (left, top, right, bottom).
791left and right are not sorted; left is not necessarily less than right.
792top and bottom are not sorted; top is not necessarily less than bottom.
793
794#Param left  stored in fLeft ##
795#Param top  stored in fTop ##
796#Param right  stored in fRight ##
797#Param bottom  stored in fBottom ##
798
799#Example
800    SkIRect rect1 = {3, 4, 1, 2};
801    SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
802    SkIRect rect2;
803    rect2.setLTRB(3, 4, 1, 2);
804    SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
805#StdOut
806rect1: {3, 4, 1, 2}
807rect2: {3, 4, 1, 2}
808##
809##
810
811#SeeAlso set setXYWH SkRect::setLTRB
812
813##
814
815# ------------------------------------------------------------------------------
816
817#Method void setXYWH(int32_t x, int32_t y, int32_t width, int32_t height)
818
819#Line # sets to (x, y, width, height) ##
820Sets IRect to:
821#Formula
822(x, y, x + width, y + height)
823##
824. Does not validate input;
825width or height may be negative.
826
827#Param x  stored in fLeft ##
828#Param y  stored in fTop ##
829#Param width  added to x and stored in fRight ##
830#Param height  added to y and stored in fBottom ##
831
832#Example
833    SkIRect rect;
834    rect.setXYWH(5, 35, -15, 25);
835    SkDebugf("rect: %d, %d, %d, %d  isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
836              rect.bottom(), rect.isEmpty() ? "true" : "false");
837    rect.sort();
838    SkDebugf("rect: %d, %d, %d, %d  isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
839              rect.bottom(), rect.isEmpty() ? "true" : "false");
840#StdOut
841rect: 5, 35, -10, 60  isEmpty: true
842rect: -10, 35, 5, 60  isEmpty: false
843##
844##
845
846#SeeAlso MakeXYWH setLTRB set SkRect::setXYWH
847
848##
849
850#Subtopic Inset_Outset_Offset
851#Line # moves sides ##
852
853#Table
854#Legend
855# name                  # description                                                ##
856#Legend ##
857# inset()               # moves the sides symmetrically about the center             ##
858# makeInset             # constructs from sides moved symmetrically about the center ##
859# makeOffset            # constructs from translated sides                           ##
860# makeOutset            # constructs from sides moved symmetrically about the center ##
861# offset()              # translates sides without changing width and height         ##
862#                       # void offset(int32_t dx, int32_t dy)                        ##
863#                       # void offset(const SkIPoint& delta)                         ##
864# offsetTo              # translates to (x, y) without changing width and height     ##
865# outset()              # moves the sides symmetrically about the center             ##
866#Table ##
867
868# ------------------------------------------------------------------------------
869
870#Method SkIRect makeOffset(int32_t dx, int32_t dy) const
871
872#In Inset_Outset_Offset
873#Line # constructs from translated sides ##
874Returns IRect offset by (dx, dy).
875
876If dx is negative, IRect returned is moved to the left.
877If dx is positive, IRect returned is moved to the right.
878If dy is negative, IRect returned is moved upward.
879If dy is positive, IRect returned is moved downward.
880
881#Param dx  offset added to fLeft and fRight ##
882#Param dy  offset added to fTop and fBottom ##
883
884#Return IRect offset in x or y, with original width and height ##
885
886#Example
887    SkIRect rect = { 10, 50, 20, 60 };
888    SkDebugf("rect: %d, %d, %d, %d  isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
889              rect.bottom(), rect.isEmpty() ? "true" : "false");
890    rect = rect.makeOffset(15, 32);
891    SkDebugf("rect: %d, %d, %d, %d  isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
892              rect.bottom(), rect.isEmpty() ? "true" : "false");
893#StdOut
894rect: 10, 50, 20, 60  isEmpty: false
895rect: 25, 82, 35, 92  isEmpty: false
896##
897##
898
899#SeeAlso offset() makeInset makeOutset SkRect::makeOffset
900
901##
902
903# ------------------------------------------------------------------------------
904
905#Method SkIRect makeInset(int32_t dx, int32_t dy) const
906
907#In Inset_Outset_Offset
908#Line # constructs from sides moved symmetrically about the center ##
909Returns IRect, inset by (dx, dy).
910
911If dx is negative, IRect returned is wider.
912If dx is positive, IRect returned is narrower.
913If dy is negative, IRect returned is taller.
914If dy is positive, IRect returned is shorter.
915
916#Param dx  offset added to fLeft and subtracted from fRight ##
917#Param dy  offset added to fTop and subtracted from fBottom ##
918
919#Return IRect inset symmetrically left and right, top and bottom ##
920
921#Example
922    SkIRect rect = { 10, 50, 20, 60 };
923    SkDebugf("rect: %d, %d, %d, %d  isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
924              rect.bottom(), rect.isEmpty() ? "true" : "false");
925    rect = rect.makeInset(15, 32);
926    SkDebugf("rect: %d, %d, %d, %d  isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
927              rect.bottom(), rect.isEmpty() ? "true" : "false");
928#StdOut
929rect: 10, 50, 20, 60  isEmpty: false
930rect: 25, 82, 5, 28  isEmpty: true
931##
932##
933
934#SeeAlso inset() makeOffset makeOutset SkRect::makeInset
935
936##
937
938# ------------------------------------------------------------------------------
939
940#Method SkIRect makeOutset(int32_t dx, int32_t dy) const
941
942#In Inset_Outset_Offset
943#Line # constructs from sides moved symmetrically about the center ##
944Returns IRect, outset by (dx, dy).
945
946If dx is negative, IRect returned is narrower.
947If dx is positive, IRect returned is wider.
948If dy is negative, IRect returned is shorter.
949If dy is positive, IRect returned is taller.
950
951#Param dx  offset subtracted to fLeft and added from fRight ##
952#Param dy  offset subtracted to fTop and added from fBottom ##
953
954#Return IRect outset symmetrically left and right, top and bottom ##
955
956#Example
957    SkIRect rect = { 10, 50, 20, 60 };
958    SkDebugf("rect: %d, %d, %d, %d  isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
959              rect.bottom(), rect.isEmpty() ? "true" : "false");
960    rect = rect.makeOutset(15, 32);
961    SkDebugf("rect: %d, %d, %d, %d  isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
962              rect.bottom(), rect.isEmpty() ? "true" : "false");
963#StdOut
964rect: 10, 50, 20, 60  isEmpty: false
965rect: -5, 18, 35, 92  isEmpty: false
966##
967##
968
969#SeeAlso outset() makeOffset makeInset SkRect::makeOutset
970
971##
972
973# ------------------------------------------------------------------------------
974
975#Method void offset(int32_t dx, int32_t dy)
976
977#In Inset_Outset_Offset
978#Line # translates sides without changing width and height ##
979Offsets IRect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom.
980
981If dx is negative, moves IRect returned to the left.
982If dx is positive, moves IRect returned to the right.
983If dy is negative, moves IRect returned upward.
984If dy is positive, moves IRect returned downward.
985
986#Param dx  offset added to fLeft and fRight ##
987#Param dy  offset added to fTop and fBottom ##
988
989#Example
990    SkIRect rect = { 10, 14, 50, 73 };
991    rect.offset(5, 13);
992    SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
993#StdOut
994rect: 15, 27, 55, 86
995##
996##
997
998#SeeAlso offsetTo makeOffset SkRect::offset
999
1000##
1001
1002# ------------------------------------------------------------------------------
1003
1004#Method void offset(const SkIPoint& delta)
1005
1006#In Inset_Outset_Offset
1007Offsets IRect by adding delta.fX to fLeft, fRight; and by adding delta.fY to
1008fTop, fBottom.
1009
1010If delta.fX is negative, moves IRect returned to the left.
1011If delta.fX is positive, moves IRect returned to the right.
1012If delta.fY is negative, moves IRect returned upward.
1013If delta.fY is positive, moves IRect returned downward.
1014
1015#Param delta  offset added to IRect ##
1016
1017#Example
1018    SkIRect rect = { 10, 14, 50, 73 };
1019    rect.offset({5, 13});
1020    SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1021#StdOut
1022rect: 15, 27, 55, 86
1023##
1024##
1025
1026#SeeAlso offsetTo makeOffset SkRect::offset
1027
1028##
1029
1030# ------------------------------------------------------------------------------
1031
1032#Method void offsetTo(int32_t newX, int32_t newY)
1033
1034#In Inset_Outset_Offset
1035#Line # translates to (x, y) without changing width and height ##
1036Offsets IRect so that fLeft equals newX, and fTop equals newY. width and height
1037are unchanged.
1038
1039#Param newX  stored in fLeft, preserving width() ##
1040#Param newY  stored in fTop, preserving height() ##
1041
1042#Example
1043    SkIRect rect = { 10, 14, 50, 73 };
1044    rect.offsetTo(15, 27);
1045    SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1046#StdOut
1047rect: 15, 27, 55, 86
1048##
1049##
1050
1051#SeeAlso offset makeOffset setXYWH SkRect::offsetTo
1052
1053##
1054
1055# ------------------------------------------------------------------------------
1056
1057#Method void inset(int32_t dx, int32_t dy)
1058
1059#In Inset_Outset_Offset
1060#Line # moves the sides symmetrically about the center ##
1061Insets IRect by (dx,dy).
1062
1063If dx is positive, makes IRect narrower.
1064If dx is negative, makes IRect wider.
1065If dy is positive, makes IRect shorter.
1066If dy is negative, makes IRect taller.
1067
1068#Param dx  offset added to fLeft and subtracted from fRight ##
1069#Param dy  offset added to fTop and subtracted from fBottom ##
1070
1071#Example
1072    SkIRect rect = { 10, 14, 50, 73 };
1073    rect.inset(5, 13);
1074    SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1075#StdOut
1076rect: 15, 27, 45, 60
1077##
1078##
1079
1080#SeeAlso outset makeInset SkRect::inset
1081
1082##
1083
1084# ------------------------------------------------------------------------------
1085
1086#Method void outset(int32_t dx, int32_t dy)
1087
1088#In Inset_Outset_Offset
1089#Line # moves the sides symmetrically about the center ##
1090Outsets IRect by (dx, dy).
1091
1092If dx is positive, makes IRect wider.
1093If dx is negative, makes IRect narrower.
1094If dy is positive, makes IRect taller.
1095If dy is negative, makes IRect shorter.
1096
1097#Param dx  subtracted to fLeft and added from fRight ##
1098#Param dy  subtracted to fTop and added from fBottom ##
1099
1100#Example
1101    SkIRect rect = { 10, 14, 50, 73 };
1102    rect.outset(5, 13);
1103    SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1104#StdOut
1105rect: 5, 1, 55, 86
1106##
1107##
1108
1109#SeeAlso inset makeOutset SkRect::outset
1110
1111##
1112
1113#Subtopic Inset_Outset_Offset ##
1114
1115#Subtopic Intersection
1116#Line # set to shared bounds ##
1117
1118IRects intersect when they enclose a common area. To intersect, each of the pair
1119must describe area; fLeft is less than fRight, and fTop is less than fBottom;
1120empty() returns false. The intersection of IRect pair can be described by:
1121
1122#Formula
1123(max(a.fLeft, b.fLeft), max(a.fTop, b.fTop),
1124 min(a.fRight, b.fRight), min(a.fBottom, b.fBottom))
1125##
1126.
1127
1128The intersection is only meaningful if the resulting IRect is not empty and
1129describes an area: fLeft is less than fRight, and fTop is less than fBottom.
1130
1131#Table
1132#Legend
1133# name                   # description                                                        ##
1134#Legend ##
1135# Intersects             # returns true if areas overlap                                      ##
1136# IntersectsNoEmptyCheck # returns true if areas overlap skips empty check                    ##
1137# contains()             # returns true if points are equal or inside                         ##
1138#                        # bool contains(int32_t x, int32_t y) const                          ##
1139#                        # bool contains(int32_t left, int32_t top, int32_t right, int32_t bottom) const ##
1140#                        # bool contains(const SkIRect& r) const                              ##
1141# intersect()            # sets to shared area; returns true if not empty                     ##
1142#                        # bool intersect(const SkIRect& r)                                   ##
1143#                        # bool intersect(const SkIRect& a, const SkIRect& b)                 ##
1144#                        # bool intersect(int32_t left, int32_t top, int32_t right, int32_t bottom) ##
1145# intersectNoEmptyCheck  # sets to shared area; returns true if not empty skips empty check   ##
1146# quickReject            # returns true if rectangles do not intersect                        ##
1147#Table ##
1148
1149
1150# ------------------------------------------------------------------------------
1151
1152#Method bool quickReject(int l, int t, int r, int b) const
1153
1154#In Intersection
1155#Line # returns true if rectangles do not intersect ##
1156Constructs IRect (l, t, r, b) and returns true if constructed IRect does not
1157intersect IRect. Does not check to see if construction or IRect is empty.
1158
1159Is implemented with short circuit logic so that true can be returned after
1160a single compare.
1161
1162#Param l  x minimum of constructed IRect ##
1163#Param t  y minimum of constructed IRect ##
1164#Param r  x maximum of constructed IRect ##
1165#Param b  y maximum of constructed IRect ##
1166
1167#Return true if construction and IRect have no area in common ##
1168
1169#Example
1170#Description
1171quickReject is the complement of Intersects.
1172##
1173   const SkIRect rect = {7, 11, 13, 17};
1174   const int32_t* r = &rect.fLeft;
1175   const SkIRect tests[] = { {13, 11, 15, 17}, { 7, 7, 13, 11 }, { 12, 16, 14, 18 } };
1176   for (auto& test : tests) {
1177     const int32_t* t = &test.fLeft;
1178     SkDebugf("rect (%d, %d, %d, %d) test(%d, %d, %d, %d) quickReject %s; intersects %s\n",
1179              r[0], r[1], r[2], r[3], t[0], t[1], t[2], t[3],
1180              rect.quickReject(t[0], t[1], t[2], t[3]) ? "true" : "false",
1181              SkIRect::Intersects(rect, test) ? "true" : "false");
1182   }
1183#StdOut
1184rect (7, 11, 13, 17) test(13, 11, 15, 17) quickReject true; intersects false
1185rect (7, 11, 13, 17) test(7, 7, 13, 11) quickReject true; intersects false
1186rect (7, 11, 13, 17) test(12, 16, 14, 18) quickReject false; intersects true
1187##
1188##
1189
1190#SeeAlso Intersects
1191
1192##
1193
1194# ------------------------------------------------------------------------------
1195
1196#Method bool contains(int32_t x, int32_t y) const
1197
1198#In Intersection
1199#Line # returns true if points are equal or inside ##
1200Returns true if:
1201#Formula
1202fLeft <= x < fRight && fTop <= y < fBottom
1203##
1204.
1205Returns false if IRect is empty.
1206
1207Considers input to describe constructed IRect:
1208#Formula
1209(x, y, x + 1, y + 1)
1210##
1211and
1212returns true if constructed area is completely enclosed by IRect area.
1213
1214#Param x  test Point x-coordinate ##
1215#Param y  test Point y-coordinate ##
1216
1217#Return true if (x, y) is inside IRect ##
1218
1219#Example
1220    SkIRect rect = { 30, 50, 40, 60 };
1221    SkIPoint pts[] = { { 30, 50}, { 40, 50}, { 30, 60} };
1222    for (auto pt : pts) {
1223        SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d)\n",
1224                 rect.left(), rect.top(), rect.right(), rect.bottom(),
1225                 rect.contains(pt.x(), pt.y()) ? "contains" : "does not contain", pt.x(), pt.y());
1226    }
1227#StdOut
1228rect: (30, 50, 40, 60) contains (30, 50)
1229rect: (30, 50, 40, 60) does not contain (40, 50)
1230rect: (30, 50, 40, 60) does not contain (30, 60)
1231##
1232##
1233
1234#SeeAlso containsNoEmptyCheck SkRect::contains
1235
1236##
1237
1238# ------------------------------------------------------------------------------
1239
1240#Method bool contains(int32_t left, int32_t top, int32_t right, int32_t bottom) const
1241
1242#In Intersection
1243Constructs IRect to intersect from (left, top, right, bottom). Does not sort
1244construction.
1245
1246Returns true if IRect contains construction.
1247Returns false if IRect is empty or construction is empty.
1248
1249#Param left  x minimum of constructed IRect ##
1250#Param top  y minimum of constructed IRect ##
1251#Param right  x maximum of constructed IRect ##
1252#Param bottom  y maximum of constructed IRect ##
1253
1254#Return true if all sides of IRect are outside construction ##
1255
1256#Example
1257    SkIRect rect = { 30, 50, 40, 60 };
1258    SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1259    for (auto contained : tests) {
1260        bool success = rect.contains(
1261                       contained.left(), contained.top(), contained.right(), contained.bottom());
1262        SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
1263                 rect.left(), rect.top(), rect.right(), rect.bottom(),
1264                 success ? "contains" : "does not contain",
1265                 contained.left(), contained.top(), contained.right(), contained.bottom());
1266    }
1267#StdOut
1268rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1269rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1270rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1271##
1272##
1273
1274#SeeAlso containsNoEmptyCheck SkRect::contains
1275
1276##
1277
1278# ------------------------------------------------------------------------------
1279
1280#Method bool contains(const SkIRect& r) const
1281
1282#In Intersection
1283Returns true if IRect contains r.
1284Returns false if IRect is empty or r is empty.
1285
1286IRect contains r when IRect area completely includes r area.
1287
1288#Param r  IRect contained ##
1289
1290#Return true if all sides of IRect are outside r ##
1291
1292#Example
1293    SkIRect rect = { 30, 50, 40, 60 };
1294    SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1295    for (auto contained : tests) {
1296        SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
1297                 rect.left(), rect.top(), rect.right(), rect.bottom(),
1298                 rect.contains(contained) ? "contains" : "does not contain",
1299                 contained.left(), contained.top(), contained.right(), contained.bottom());
1300    }
1301#StdOut
1302rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1303rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1304rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1305##
1306##
1307
1308#SeeAlso containsNoEmptyCheck SkRect::contains
1309
1310##
1311
1312# ------------------------------------------------------------------------------
1313
1314#Method bool contains(const SkRect& r) const
1315
1316#In Intersection
1317Returns true if IRect contains r.
1318Returns false if IRect is empty or r is empty.
1319
1320IRect contains r when IRect area completely includes r area.
1321
1322#Param r  Rect contained ##
1323
1324#Return true if all sides of IRect are outside r ##
1325
1326#Example
1327    SkIRect rect = { 30, 50, 40, 60 };
1328    SkRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1329    for (auto contained : tests) {
1330        SkDebugf("rect: (%d, %d, %d, %d) %s (%g, %g, %g, %g)\n",
1331                 rect.left(), rect.top(), rect.right(), rect.bottom(),
1332                 rect.contains(contained) ? "contains" : "does not contain",
1333                 contained.left(), contained.top(), contained.right(), contained.bottom());
1334    }
1335#StdOut
1336rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1337rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1338rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1339##
1340##
1341
1342#SeeAlso containsNoEmptyCheck SkRect::contains
1343
1344##
1345
1346# ------------------------------------------------------------------------------
1347
1348#Method bool containsNoEmptyCheck(int32_t left, int32_t top,
1349                              int32_t right, int32_t bottom) const
1350#In Intersection
1351#Line # returns true if points are equal or inside skips empty check ##
1352
1353Constructs IRect from (left, top, right, bottom). Does not sort
1354construction.
1355
1356Returns true if IRect contains construction.
1357Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined.
1358
1359Return is undefined if IRect is empty or construction is empty.
1360
1361#Param left  x minimum of constructed IRect ##
1362#Param top  y minimum of constructed IRect ##
1363#Param right  x maximum of constructed IRect ##
1364#Param bottom  y maximum of constructed IRect ##
1365
1366#Return true if all sides of IRect are outside construction ##
1367
1368#Example
1369    SkIRect rect = { 30, 50, 40, 60 };
1370    SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1371    for (auto contained : tests) {
1372        bool success = rect.containsNoEmptyCheck(
1373                 contained.left(), contained.top(), contained.right(), contained.bottom());
1374        SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
1375                 rect.left(), rect.top(), rect.right(), rect.bottom(),
1376                 success ? "contains" : "does not contain",
1377                 contained.left(), contained.top(), contained.right(), contained.bottom());
1378    }
1379#StdOut
1380rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1381rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1382rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1383##
1384##
1385
1386#SeeAlso contains SkRect::contains
1387
1388##
1389
1390# ------------------------------------------------------------------------------
1391
1392#Method bool containsNoEmptyCheck(const SkIRect& r) const
1393
1394#In Intersection
1395Returns true if IRect contains construction.
1396Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined.
1397
1398Return is undefined if IRect is empty or construction is empty.
1399
1400#Param r  IRect contained ##
1401
1402#Return true if all sides of IRect are outside r ##
1403
1404#Example
1405    SkIRect rect = { 30, 50, 40, 60 };
1406    SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1407    for (auto contained : tests) {
1408        SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
1409                 rect.left(), rect.top(), rect.right(), rect.bottom(),
1410                 rect.containsNoEmptyCheck(contained) ? "contains" : "does not contain",
1411                 contained.left(), contained.top(), contained.right(), contained.bottom());
1412    }
1413#StdOut
1414rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1415rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1416rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1417##
1418##
1419
1420#SeeAlso contains SkRect::contains
1421
1422##
1423
1424# ------------------------------------------------------------------------------
1425
1426#Method bool intersect(const SkIRect& r)
1427
1428#In Intersection
1429#Line # sets to shared area; returns true if not empty ##
1430Returns true if IRect intersects r, and sets IRect to intersection.
1431Returns false if IRect does not intersect r, and leaves IRect unchanged.
1432
1433Returns false if either r or IRect is empty, leaving IRect unchanged.
1434
1435#Param r  limit of result ##
1436
1437#Return true if r and IRect have area in common ##
1438
1439#Example
1440#Description
1441Two SkDebugf calls are required. If the calls are combined, their arguments
1442may not be evaluated in left to right order: the printed intersection may
1443be before or after the call to intersect.
1444##
1445    SkIRect leftRect =  { 10, 40, 50, 80 };
1446    SkIRect rightRect = { 30, 60, 70, 90 };
1447    SkDebugf("%s intersection: ", leftRect.intersect(rightRect) ? "" : "no ");
1448    SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
1449                                 leftRect.right(), leftRect.bottom());
1450#StdOut
1451 intersection: 30, 60, 50, 80
1452##
1453##
1454
1455#SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect
1456
1457##
1458
1459# ------------------------------------------------------------------------------
1460
1461#Method bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& a, const SkIRect& b)
1462
1463#In Intersection
1464Returns true if a intersects b, and sets IRect to intersection.
1465Returns false if a does not intersect b, and leaves IRect unchanged.
1466
1467Returns false if either a or b is empty, leaving IRect unchanged.
1468
1469#Param a  IRect to intersect ##
1470#Param b  IRect to intersect ##
1471
1472#Return true if a and b have area in common ##
1473
1474#Example
1475    SkIRect result;
1476    bool intersected = result.intersect({ 10, 40, 50, 80 }, { 30, 60, 70, 90 });
1477    SkDebugf("%s intersection: %d, %d, %d, %d\n", intersected ? "" : "no ",
1478             result.left(), result.top(), result.right(), result.bottom());
1479#StdOut
1480 intersection: 30, 60, 50, 80
1481##
1482##
1483
1484#SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect
1485
1486##
1487
1488# ------------------------------------------------------------------------------
1489
1490#Method bool SK_WARN_UNUSED_RESULT intersectNoEmptyCheck(const SkIRect& a, const SkIRect& b)
1491
1492#In Intersection
1493#Line # sets to shared area; returns true if not empty skips empty check ##
1494Returns true if a intersects b, and sets IRect to intersection.
1495Returns false if a does not intersect b, and leaves IRect unchanged.
1496
1497Asserts if either a or b is empty, and if SK_DEBUG is defined.
1498
1499#Param a  IRect to intersect ##
1500#Param b  IRect to intersect ##
1501
1502#Return true if a and b have area in common ##
1503
1504#Example
1505    SkIRect result;
1506    bool intersected = result.intersectNoEmptyCheck({ 10, 40, 50, 80 }, { 30, 60, 70, 90 });
1507    SkDebugf("intersection: %d, %d, %d, %d\n",
1508             result.left(), result.top(), result.right(), result.bottom());
1509#StdOut
1510 intersection: 30, 60, 50, 80
1511##
1512##
1513
1514#SeeAlso Intersects intersect join SkRect::intersect
1515
1516##
1517
1518# ------------------------------------------------------------------------------
1519
1520#Method bool intersect(int32_t left, int32_t top, int32_t right, int32_t bottom)
1521
1522#In Intersection
1523Constructs IRect to intersect from (left, top, right, bottom). Does not sort
1524construction.
1525
1526Returns true if IRect intersects construction, and sets IRect to intersection.
1527Returns false if IRect does not intersect construction, and leaves IRect unchanged.
1528
1529Returns false if either construction or IRect is empty, leaving IRect unchanged.
1530
1531#Param left  x minimum of constructed IRect ##
1532#Param top  y minimum of constructed IRect ##
1533#Param right  x maximum of constructed IRect ##
1534#Param bottom  y maximum of constructed IRect ##
1535
1536#Return true if construction and IRect have area in common ##
1537
1538#Example
1539#Description
1540Two SkDebugf calls are required. If the calls are combined, their arguments
1541may not be evaluated in left to right order: the printed intersection may
1542be before or after the call to intersect.
1543##
1544    SkIRect leftRect =  { 10, 40, 50, 80 };
1545    SkDebugf("%s intersection: ", leftRect.intersect(30, 60, 70, 90) ? "" : "no ");
1546    SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
1547                                 leftRect.right(), leftRect.bottom());
1548#StdOut
1549 intersection: 30, 60, 50, 80
1550##
1551##
1552
1553#SeeAlso intersectNoEmptyCheck Intersects join SkRect::intersect
1554
1555##
1556
1557# ------------------------------------------------------------------------------
1558
1559#Method static bool Intersects(const SkIRect& a, const SkIRect& b)
1560
1561#In Intersection
1562#Line # returns true if areas overlap ##
1563Returns true if a intersects b.
1564Returns false if either a or b is empty, or do not intersect.
1565
1566#Param a  IRect to intersect ##
1567#Param b  IRect to intersect ##
1568
1569#Return true if a and b have area in common ##
1570
1571#Example
1572    SkDebugf("%s intersection", SkIRect::Intersects({10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
1573#StdOut
1574 intersection
1575##
1576##
1577
1578#SeeAlso IntersectsNoEmptyCheck intersect SkRect::intersect
1579
1580##
1581
1582# ------------------------------------------------------------------------------
1583
1584#Method static bool IntersectsNoEmptyCheck(const SkIRect& a, const SkIRect& b)
1585
1586#In Intersection
1587#Line # returns true if areas overlap skips empty check ##
1588Returns true if a intersects b.
1589Asserts if either a or b is empty, and if SK_DEBUG is defined.
1590
1591#Param a  IRect to intersect ##
1592#Param b  IRect to intersect ##
1593
1594#Return true if a and b have area in common ##
1595
1596#Example
1597    SkDebugf("%s intersection", SkIRect::IntersectsNoEmptyCheck(
1598            {10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
1599#StdOut
1600 intersection
1601##
1602##
1603
1604#SeeAlso Intersects intersect SkRect::intersect
1605
1606##
1607
1608#Subtopic Intersection ##
1609
1610# ------------------------------------------------------------------------------
1611
1612#Method void join(int32_t left, int32_t top, int32_t right, int32_t bottom)
1613
1614#Line # sets to union of bounds ##
1615Constructs IRect to intersect from (left, top, right, bottom). Does not sort
1616construction.
1617
1618Sets IRect to the union of itself and the construction.
1619
1620Has no effect if construction is empty. Otherwise, if IRect is empty, sets
1621IRect to construction.
1622
1623#Param left  x minimum of constructed IRect ##
1624#Param top  y minimum of constructed IRect ##
1625#Param right  x maximum of constructed IRect ##
1626#Param bottom  y maximum of constructed IRect ##
1627
1628#Example
1629    SkIRect rect = { 10, 20, 15, 25};
1630    rect.join(50, 60, 55, 65);
1631    SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1632#StdOut
1633 join: 10, 20, 55, 65
1634##
1635##
1636
1637#SeeAlso set SkRect::join
1638
1639##
1640
1641# ------------------------------------------------------------------------------
1642
1643#Method void join(const SkIRect& r)
1644
1645Sets IRect to the union of itself and r.
1646
1647Has no effect if r is empty. Otherwise, if IRect is empty, sets IRect to r.
1648
1649#Param r  expansion IRect ##
1650
1651#Example
1652    SkIRect rect = { 10, 20, 15, 25};
1653    rect.join({50, 60, 55, 65});
1654    SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1655#StdOut
1656 join: 10, 20, 55, 65
1657##
1658##
1659
1660#SeeAlso set SkRect::join
1661
1662##
1663
1664# ------------------------------------------------------------------------------
1665
1666#Method void sort()
1667
1668#Line # orders sides from smaller to larger ##
1669Swaps fLeft and fRight if fLeft is greater than fRight; and swaps
1670fTop and fBottom if fTop is greater than fBottom. Result may be empty,
1671and width() and height() will be zero or positive.
1672
1673#Example
1674    SkIRect rect = { 30, 50, 20, 10 };
1675    SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1676    rect.sort();
1677    SkDebugf("sorted: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1678#StdOut
1679rect: 30, 50, 20, 10
1680sorted: 20, 10, 30, 50
1681##
1682##
1683
1684#SeeAlso makeSorted SkRect::sort
1685
1686##
1687
1688# ------------------------------------------------------------------------------
1689
1690#Method SkIRect makeSorted() const
1691
1692#Line # constructs, ordering sides from smaller to larger ##
1693Returns IRect with fLeft and fRight swapped if fLeft is greater than fRight; and
1694with fTop and fBottom swapped if fTop is greater than fBottom. Result may be empty;
1695and width() and height() will be zero or positive.
1696
1697#Return  sorted IRect ##
1698
1699#Example
1700    SkIRect rect = { 30, 50, 20, 10 };
1701    SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1702    SkIRect sort = rect.makeSorted();
1703    SkDebugf("sorted: %d, %d, %d, %d\n", sort.fLeft, sort.fTop, sort.fRight, sort.fBottom);
1704#StdOut
1705rect: 30, 50, 20, 10
1706sorted: 20, 10, 30, 50
1707##
1708##
1709
1710#SeeAlso sort SkRect::makeSorted
1711
1712##
1713
1714# ------------------------------------------------------------------------------
1715
1716#Method static const SkIRect& SK_WARN_UNUSED_RESULT EmptyIRect()
1717
1718#Line # returns immutable bounds of (0, 0, 0, 0) ##
1719Returns a reference to immutable empty IRect, set to (0, 0, 0, 0).
1720
1721#Return  global IRect set to all zeroes ##
1722
1723#Example
1724    const SkIRect& rect = SkIRect::EmptyIRect();
1725    SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1726#StdOut
1727rect: 0, 0, 0, 0
1728##
1729##
1730
1731#SeeAlso MakeEmpty
1732
1733##
1734
1735#Method static SkIRect SK_WARN_UNUSED_RESULT MakeLargest()
1736
1737#Line # deprecated ##
1738#Deprecated
1739##
1740
1741Returns constructed SkIRect setting left and top to most negative value, and
1742setting right and bottom to most positive value.
1743
1744#Return  bounds (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32) ##
1745
1746##
1747
1748#Struct SkIRect ##
1749
1750#Topic IRect ##
1751