aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--docs/SkBitmap_Reference.bmh53
-rw-r--r--docs/SkIPoint_Reference.bmh210
-rw-r--r--docs/SkIRect_Reference.bmh3342
-rw-r--r--docs/SkImage_Reference.bmh140
-rw-r--r--docs/SkPaint_Reference.bmh12
-rw-r--r--docs/SkPoint_Reference.bmh784
-rw-r--r--site/user/api/SkBitmap_Reference.md66
-rw-r--r--site/user/api/SkImage_Reference.md55
-rw-r--r--site/user/api/SkPaint_Reference.md4
-rw-r--r--site/user/api/catalog.htm54
10 files changed, 2467 insertions, 2253 deletions
diff --git a/docs/SkBitmap_Reference.bmh b/docs/SkBitmap_Reference.bmh
index 4e0525e85f..6608876937 100644
--- a/docs/SkBitmap_Reference.bmh
+++ b/docs/SkBitmap_Reference.bmh
@@ -122,6 +122,7 @@ is useful to position one or more Bitmaps within a shared pixel array.
# peekPixels # Returns Pixmap if possible. ##
# pixelRef # Returns Pixel_Ref, or nullptr. ##
# pixelRefOrigin # Returns offset within Pixel_Ref. ##
+# pixmap() # Returns Pixmap if possible. ##
# readPixels # Copies and converts pixels. ##
# readyToDraw # Returns true if address of pixels is not nullptr. ##
# refColorSpace # Returns Image_Info Color_Space. ##
@@ -447,6 +448,56 @@ two width:1 height:1 colorType:kRGBA_8888_SkColorType alphaType:kOpaque_SkAlphaT
# ------------------------------------------------------------------------------
+#Method SkPixmap pixmap() const
+
+Returns Pixmap with Bitmap pixel address, row bytes, and Image_Info, if address is available.
+If pixel address is not available, returns default constructed Pixmap: nullptr pixels,
+kUnknown_SkColorType, kUnknown_SkAlphaType, width and height of zero.
+
+Returned Pixmap becomes invalid on any future change to Bitmap
+
+#Return Pixmap describing Bitmap, if pixels are readable; otherwise containing zeroes ##
+
+#Example
+ SkBitmap bitmap;
+ bitmap.allocPixels(SkImageInfo::MakeN32Premul(10, 11));
+ SkCanvas offscreen(bitmap);
+ offscreen.clear(SK_ColorWHITE);
+ SkPaint paint;
+ offscreen.drawString("&", 0, 10, paint);
+ SkPixmap pixmap = bitmap.pixmap();
+ if (pixmap.addr()) {
+ const SkPMColor* pixels = pixmap.addr32();
+ SkPMColor pmWhite = pixels[0];
+ for (int y = 0; y < bitmap.height(); ++y) {
+ for (int x = 0; x < bitmap.width(); ++x) {
+ SkDebugf("%c", *pixels++ == pmWhite ? '-' : 'x');
+ }
+ SkDebugf("\n");
+ }
+ }
+ #StdOut
+----------
+---xx-----
+--x--x----
+--x-------
+--xx------
+--x-x---x-
+-x---x--x-
+-x----xx--
+-xx---x---
+--xxxx-xx-
+----------
+ #StdOut ##
+
+##
+
+#SeeAlso peekPixels installPixels readPixels writePixels
+
+##
+
+# ------------------------------------------------------------------------------
+
#Method const SkImageInfo& info() const
Returns width, height, Alpha_Type, Color_Type, and Color_Space.
@@ -3401,7 +3452,7 @@ x---x-
#StdOut ##
##
-#SeeAlso installPixels readPixels writePixels
+#SeeAlso pixmap() installPixels readPixels writePixels
##
diff --git a/docs/SkIPoint_Reference.bmh b/docs/SkIPoint_Reference.bmh
index 178a14f2c3..ed37167a12 100644
--- a/docs/SkIPoint_Reference.bmh
+++ b/docs/SkIPoint_Reference.bmh
@@ -129,10 +129,10 @@ Returns true if fX and fY are both zero.
#Return true if fX is zero and fY is zero ##
#Example
-SkIPoint pt = { 0, -0};
+SkIPoint pt = { 0, -0};
SkDebugf("pt.isZero() == %s\n", pt.isZero() ? "true" : "false");
#StdOut
-pt.isZero() == true
+pt.isZero() == true
##
##
@@ -171,17 +171,17 @@ Returns IPoint changing the signs of fX and fY.
#Return IPoint as (-fX, -fY) ##
#Example
-SkIPoint test[] = { {0, -0}, {-1, -2},
- { SK_MaxS32, SK_MinS32 },
- { SK_NaN32, -SK_NaN32 } };
-for (const SkIPoint& pt : test) {
- SkIPoint negPt = -pt;
- SkDebugf("pt: %d, %d negate: %d, %d\n", pt.fX, pt.fY, negPt.fX, negPt.fY);
+SkIPoint test[] = { {0, -0}, {-1, -2},
+ { SK_MaxS32, SK_MinS32 },
+ { SK_NaN32, -SK_NaN32 } };
+for (const SkIPoint& pt : test) {
+ SkIPoint negPt = -pt;
+ SkDebugf("pt: %d, %d negate: %d, %d\n", pt.fX, pt.fY, negPt.fX, negPt.fY);
}
#StdOut
-pt: 0, 0 negate: 0, 0
-pt: -1, -2 negate: 1, 2
-pt: 2147483647, -2147483647 negate: -2147483647, 2147483647
+pt: 0, 0 negate: 0, 0
+pt: -1, -2 negate: 1, 2
+pt: 2147483647, -2147483647 negate: -2147483647, 2147483647
pt: -2147483648, -2147483648 negate: -2147483648, -2147483648
##
##
@@ -204,24 +204,24 @@ Offsets IPoint by IVector v. Sets IPoint to
#Example
#Height 64
- auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void {
- for (size_t i = 0; i < count - 1; ++i) {
- SkPoint p0, p1;
- p0.iset(pts[i]);
- p1.iset(pts[i + 1]);
- canvas->drawLine(p0, p1, paint);
- }
- };
- SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } };
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
- canvas->scale(30, 15);
- draw_lines(points, SK_ARRAY_COUNT(points), paint);
- points[1] += {1, 1};
- points[2] += {-1, -1};
- paint.setColor(SK_ColorRED);
- draw_lines(points, SK_ARRAY_COUNT(points), paint);
+ auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void {
+ for (size_t i = 0; i < count - 1; ++i) {
+ SkPoint p0, p1;
+ p0.iset(pts[i]);
+ p1.iset(pts[i + 1]);
+ canvas->drawLine(p0, p1, paint);
+ }
+ };
+ SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } };
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->scale(30, 15);
+ draw_lines(points, SK_ARRAY_COUNT(points), paint);
+ points[1] += {1, 1};
+ points[2] += {-1, -1};
+ paint.setColor(SK_ColorRED);
+ draw_lines(points, SK_ARRAY_COUNT(points), paint);
##
#SeeAlso operator+(const SkIPoint& a, const SkIVector& b) SkPoint::operator+=(const SkVector& v)
@@ -242,24 +242,24 @@ Subtracts IVector v from IPoint. Sets IPoint to:
#Example
#Height 64
- auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void {
- for (size_t i = 0; i < count - 1; ++i) {
- SkPoint p0, p1;
- p0.iset(pts[i]);
- p1.iset(pts[i + 1]);
- canvas->drawLine(p0, p1, paint);
- }
- };
- SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } };
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
- canvas->scale(30, 15);
- draw_lines(points, SK_ARRAY_COUNT(points), paint);
- points[1] -= {1, 1};
- points[2] -= {-1, -1};
- paint.setColor(SK_ColorRED);
- draw_lines(points, SK_ARRAY_COUNT(points), paint);
+ auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void {
+ for (size_t i = 0; i < count - 1; ++i) {
+ SkPoint p0, p1;
+ p0.iset(pts[i]);
+ p1.iset(pts[i + 1]);
+ canvas->drawLine(p0, p1, paint);
+ }
+ };
+ SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } };
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->scale(30, 15);
+ draw_lines(points, SK_ARRAY_COUNT(points), paint);
+ points[1] -= {1, 1};
+ points[2] -= {-1, -1};
+ paint.setColor(SK_ColorRED);
+ draw_lines(points, SK_ARRAY_COUNT(points), paint);
##
#SeeAlso operator-(const SkIPoint& a, const SkIPoint& b) SkPoint::operator-=(const SkVector& v)
@@ -278,14 +278,14 @@ Returns true if IPoint is equivalent to IPoint constructed from (x, y).
#Return true if IPoint equals (x, y) ##
#Example
-SkIPoint test[] = { {0, -0}, {-1, -2}, {SK_MaxS32, -1}, {SK_NaN32, -1} };
-for (const SkIPoint& pt : test) {
- SkDebugf("pt: %d, %d %c= pt\n", pt.fX, pt.fY, pt.equals(pt.fX, pt.fY) ? '=' : '!');
+SkIPoint test[] = { {0, -0}, {-1, -2}, {SK_MaxS32, -1}, {SK_NaN32, -1} };
+for (const SkIPoint& pt : test) {
+ SkDebugf("pt: %d, %d %c= pt\n", pt.fX, pt.fY, pt.equals(pt.fX, pt.fY) ? '=' : '!');
}
#StdOut
-pt: 0, 0 == pt
-pt: -1, -2 == pt
-pt: 2147483647, -1 == pt
+pt: 0, 0 == pt
+pt: -1, -2 == pt
+pt: 2147483647, -1 == pt
pt: -2147483648, -1 == pt
##
##
@@ -306,14 +306,14 @@ Returns true if a is equivalent to b.
#Return true if a.fX == b.fX and a.fY == b.fY ##
#Example
-SkIPoint test[] = { {0, -0}, {-1, -2}, {SK_MaxS32, -1}, {SK_NaN32, -1} };
-for (const SkIPoint& pt : test) {
- SkDebugf("pt: %d, %d %c= pt\n", pt.fX, pt.fY, pt == pt ? '=' : '!');
+SkIPoint test[] = { {0, -0}, {-1, -2}, {SK_MaxS32, -1}, {SK_NaN32, -1} };
+for (const SkIPoint& pt : test) {
+ SkDebugf("pt: %d, %d %c= pt\n", pt.fX, pt.fY, pt == pt ? '=' : '!');
}
#StdOut
-pt: 0, 0 == pt
-pt: -1, -2 == pt
-pt: 2147483647, -1 == pt
+pt: 0, 0 == pt
+pt: -1, -2 == pt
+pt: 2147483647, -1 == pt
pt: -2147483648, -1 == pt
##
##
@@ -334,14 +334,14 @@ Returns true if a is not equivalent to b.
#Return true if a.fX != b.fX or a.fY != b.fY ##
#Example
-SkIPoint test[] = { {0, -0}, {-1, -2}, {SK_MaxS32, -1}, {SK_NaN32, -1} };
-for (const SkIPoint& pt : test) {
- SkDebugf("pt: %d, %d %c= pt\n", pt.fX, pt.fY, pt != pt ? '!' : '=');
+SkIPoint test[] = { {0, -0}, {-1, -2}, {SK_MaxS32, -1}, {SK_NaN32, -1} };
+for (const SkIPoint& pt : test) {
+ SkDebugf("pt: %d, %d %c= pt\n", pt.fX, pt.fY, pt != pt ? '!' : '=');
}
#StdOut
-pt: 0, 0 == pt
-pt: -1, -2 == pt
-pt: 2147483647, -1 == pt
+pt: 0, 0 == pt
+pt: -1, -2 == pt
+pt: 2147483647, -1 == pt
pt: -2147483648, -1 == pt
##
##
@@ -369,24 +369,24 @@ Can also be used to subtract IVector from IVector, returning IVector.
#Example
#Height 64
- auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void {
- for (size_t i = 0; i < count - 1; ++i) {
- SkPoint p0, p1;
- p0.iset(pts[i]);
- p1.iset(pts[i + 1]);
- canvas->drawLine(p0, p1, paint);
- }
- };
- SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } };
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
- canvas->scale(30, 15);
- draw_lines(points, SK_ARRAY_COUNT(points), paint);
- points[1] += points[0] - points[3];
- points[2] -= points[1] - points[0];
- paint.setColor(SK_ColorRED);
- draw_lines(points, SK_ARRAY_COUNT(points), paint);
+ auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void {
+ for (size_t i = 0; i < count - 1; ++i) {
+ SkPoint p0, p1;
+ p0.iset(pts[i]);
+ p1.iset(pts[i + 1]);
+ canvas->drawLine(p0, p1, paint);
+ }
+ };
+ SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } };
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->scale(30, 15);
+ draw_lines(points, SK_ARRAY_COUNT(points), paint);
+ points[1] += points[0] - points[3];
+ points[2] -= points[1] - points[0];
+ paint.setColor(SK_ColorRED);
+ draw_lines(points, SK_ARRAY_COUNT(points), paint);
##
#SeeAlso operator-=(const SkIVector& v)
@@ -413,28 +413,28 @@ Can also be used to add IVector to IVector, returning IVector.
#Example
#Height 128
- auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void {
- for (size_t i = 0; i < count - 1; ++i) {
- SkPoint p0, p1;
- p0.iset(pts[i]);
- p1.iset(pts[i + 1]);
- canvas->drawLine(p0, p1, paint);
- }
- };
- SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } };
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
- canvas->scale(30, 15);
- draw_lines(points, SK_ARRAY_COUNT(points), paint);
- SkIPoint mod = {4, 1};
- for (auto& point : points) {
- point = point + mod;
- mod.fX -= 1;
- mod.fY += 1;
- }
- paint.setColor(SK_ColorRED);
- draw_lines(points, SK_ARRAY_COUNT(points), paint);
+ auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void {
+ for (size_t i = 0; i < count - 1; ++i) {
+ SkPoint p0, p1;
+ p0.iset(pts[i]);
+ p1.iset(pts[i + 1]);
+ canvas->drawLine(p0, p1, paint);
+ }
+ };
+ SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } };
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->scale(30, 15);
+ draw_lines(points, SK_ARRAY_COUNT(points), paint);
+ SkIPoint mod = {4, 1};
+ for (auto& point : points) {
+ point = point + mod;
+ mod.fX -= 1;
+ mod.fY += 1;
+ }
+ paint.setColor(SK_ColorRED);
+ draw_lines(points, SK_ARRAY_COUNT(points), paint);
##
#SeeAlso operator+=(const SkIVector& v)
diff --git a/docs/SkIRect_Reference.bmh b/docs/SkIRect_Reference.bmh
index bdc694f8d5..b29020bb1b 100644
--- a/docs/SkIRect_Reference.bmh
+++ b/docs/SkIRect_Reference.bmh
@@ -1,1671 +1,1671 @@
-#Topic IRect
-#Alias IRect_Reference
-
-#Struct SkIRect
-
-SkIRect holds four 32 bit integer coordinates describing the upper and
-lower bounds of a rectangle. SkIRect may be created from outer bounds or
-from position, width, and height. SkIRect describes an area; if its right
-is less than or equal to its left, or if its bottom is less than or equal to
-its top, it is considered empty.
-
-#Topic Overview
-
-#Subtopic Subtopics
-#ToDo manually add subtopics ##
-#Table
-#Legend
-# topics # description ##
-#Legend ##
-#Table ##
-##
-
-#Subtopic Operators
-#Table
-#Legend
-# description # function ##
-#Legend ##
-# bool operator!=(const SkIRect& a, const SkIRect& b) # Returns true if members are unequal. ##
-# bool operator==(const SkIRect& a, const SkIRect& b) # Returns true if members are equal. ##
-#Table ##
-#Subtopic ##
-
-#Subtopic Member_Functions
-#Table
-#Legend
-# description # function ##
-#Legend ##
-# EmptyIRect # Returns immutable bounds of (0, 0, 0, 0). ##
-# Intersects # Returns true if areas overlap. ##
-# IntersectsNoEmptyCheck # Returns true if areas overlap. Skips empty check. ##
-# MakeEmpty # Returns bounds of (0, 0, 0, 0). ##
-# MakeLTRB # Constructs from int left, top, right, bottom. ##
-# MakeLargest # Constructs from (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32). ##
-# MakeSize # Constructs from ISize returning (0, 0, width, height). ##
-# MakeWH # Constructs from int input returning (0, 0, width, height). ##
-# MakeXYWH # Constructs from int input returning (x, y, width, height). ##
-# bottom() # Returns larger bounds in y, if sorted. ##
-# centerX # Returns midpoint in x. ##
-# centerY # Returns midpoint in y. ##
-# contains() # Returns true if points are equal or inside. ##
-# containsNoEmptyCheck # Returns true if points are equal or inside. Skips empty check. ##
-# height() # Returns span in y. ##
-# inset() # Moves the sides symmetrically about the center. ##
-# intersect # Sets to shared area; returns true if not empty. ##
-# intersectNoEmptyCheck # Sets to shared area; returns true if not empty. Skips empty check. ##
-# is16Bit # Returns true if members fit in 16-bit word. ##
-# isEmpty # Returns true if width or height are zero or negative. ##
-# isLargest # Returns true if equal to (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32). ##
-# join() # Sets to union of bounds. ##
-# left() # Returns smaller bounds in x, if sorted. ##
-# makeInset # Constructs from sides moved symmetrically about the center. ##
-# makeOffset # Constructs from translated sides. ##
-# makeOutset # Constructs from sides moved symmetrically about the center. ##
-# makeSorted # Constructs, ordering sides from smaller to larger. ##
-# offset() # Translates sides without changing width and height. ##
-# offsetTo # Translates to (x, y) without changing width and height. ##
-# outset() # Moves the sides symmetrically about the center. ##
-# quickReject # Returns true if rectangles do not intersect. ##
-# right() # Returns larger bounds in x, if sorted. ##
-# set() # Sets to (left, top, right, bottom). ##
-# setEmpty # Sets to (0, 0, 0, 0). ##
-# setLTRB # Sets to SkScalar input (left, top, right, bottom). ##
-# setLargest # Sets to (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32). ##
-# setLargestInverted # Sets to (SK_MaxS32, SK_MaxS32, SK_MinS32, SK_MinS32). ##
-# setXYWH # Sets to (x, y, width, height). ##
-# size() # Returns ISize (width, height). ##
-# sort() # Orders sides from smaller to larger. ##
-# top() # Returns smaller bounds in y, if sorted. ##
-# width() # Returns span in x. ##
-# x() # Returns bounds left. ##
-# y() # Returns bounds top. ##
-#Table ##
-#Subtopic ##
-
-#Topic ##
-
-#Member int32_t fLeft
-May contain any value. The smaller of the horizontal values when sorted.
-When equal to or greater than fRight, IRect is empty.
-##
-
-#Member int32_t fTop
-May contain any value. The smaller of the horizontal values when sorted.
-When equal to or greater than fBottom, IRect is empty.
-##
-
-#Member int32_t fRight
-May contain any value. The larger of the vertical values when sorted.
-When equal to or less than fLeft, IRect is empty.
-##
-
-#Member int32_t fBottom
-May contain any value. The larger of the vertical values when sorted.
-When equal to or less than fTop, IRect is empty.
-##
-
-# ------------------------------------------------------------------------------
-
-#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeEmpty()
-
-Returns constructed IRect set to (0, 0, 0, 0).
-Many other rectangles are empty; if left is equal to or greater than right,
-or if top is equal to or greater than bottom. Setting all members to zero
-is a convenience, but does not designate a special empty rectangle.
-
-#Return bounds (0, 0, 0, 0) ##
-
-#Example
- SkIRect rect = SkIRect::MakeEmpty();
- SkDebugf("MakeEmpty isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
- rect.offset(10, 10);
- SkDebugf("offset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
- rect.inset(10, 10);
- SkDebugf("inset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
- rect.outset(20, 20);
- SkDebugf("outset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
-#StdOut
-MakeEmpty isEmpty: true
-offset rect isEmpty: true
-inset rect isEmpty: true
-outset rect isEmpty: false
-##
-##
-
-#SeeAlso EmptyIRect isEmpty setEmpty setLargestInverted SkRect::MakeEmpty
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method static SkIRect SK_WARN_UNUSED_RESULT MakeLargest()
-
-Returns constructed IRect setting left and top to most negative value, and
-setting right and bottom to most positive value.
-
-#Return bounds (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32) ##
-
-#Example
- SkIRect rect = SkIRect::MakeLargest();
- SkDebugf("MakeLargest isLargest: %s\n", rect.isLargest() ? "true" : "false");
- SkDebugf("MakeLargest isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
- rect.outset(1, 1);
- SkDebugf("outset isLargest: %s\n", rect.isLargest() ? "true" : "false");
- SkDebugf("outset isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
-#StdOut
-MakeLargest isLargest: true
-MakeLargest isEmpty: false
-outset isLargest: false
-outset isEmpty: true
-##
-##
-
-#SeeAlso isLargest setLargest SkRect::MakeLargest
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeWH(int32_t w, int32_t h)
-
-Returns constructed IRect set to (0, 0, w, h). Does not validate input; w or h
-may be negative.
-
-#Param w width of constructed Rect ##
-#Param h height of constructed Rect ##
-
-#Return bounds (0, 0, w, h) ##
-
-#Example
- SkIRect rect1 = SkIRect::MakeWH(25, 35);
- SkIRect rect2 = SkIRect::MakeSize({25, 35});
- SkIRect rect3 = SkIRect::MakeXYWH(0, 0, 25, 35);
- SkIRect rect4 = SkIRect::MakeLTRB(0, 0, 25, 35);
- SkDebugf("all %s" "equal\n", rect1 == rect2 && rect2 == rect3 && rect3 == rect4 ?
- "" : "not ");
-#StdOut
-all equal
-##
-##
-
-#SeeAlso MakeSize MakeXYWH SkRect::MakeWH SkRect::MakeIWH
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeSize(const SkISize& size)
-
-Returns constructed IRect set to (0, 0, size.width(), size.height()).
-Does not validate input; size.width() or size.height() may be negative.
-
-#Param size values for Rect width and height ##
-
-#Return bounds (0, 0, size.width(), size.height()) ##
-
-#Example
- SkSize size = {25.5f, 35.5f};
- SkIRect rect = SkIRect::MakeSize(size.toRound());
- SkDebugf("round width: %d height: %d\n", rect.width(), rect.height());
- rect = SkIRect::MakeSize(size.toFloor());
- SkDebugf("floor width: %d height: %d\n", rect.width(), rect.height());
-#StdOut
-round width: 26 height: 36
-floor width: 25 height: 35
-##
-##
-
-#SeeAlso MakeWH MakeXYWH SkRect::Make SkRect::MakeIWH
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
-
-Returns constructed IRect set to (l, t, r, b). Does not sort input; Rect may
-result in fLeft greater than fRight, or fTop greater than fBottom.
-
-#Param l integer stored in fLeft ##
-#Param t integer stored in fTop ##
-#Param r integer stored in fRight ##
-#Param b integer stored in fBottom ##
-
-#Return bounds (l, t, r, b) ##
-
-#Example
- SkIRect rect = SkIRect::MakeLTRB(5, 35, 15, 25);
- SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
- rect.bottom(), rect.isEmpty() ? "true" : "false");
- rect.sort();
- SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
- rect.bottom(), rect.isEmpty() ? "true" : "false");
-#StdOut
-rect: 5, 35, 15, 25 isEmpty: true
-rect: 5, 25, 15, 35 isEmpty: false
-##
-##
-
-#SeeAlso MakeXYWH SkRect::MakeLTRB
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
-
-Returns constructed IRect set to:
-#Formula
-(x, y, x + w, y + h)
-##
-. Does not validate input;
-w or h may be negative.
-
-#Param x stored in fLeft ##
-#Param y stored in fTop ##
-#Param w added to x and stored in fRight ##
-#Param h added to y and stored in fBottom ##
-
-#Return bounds at (x, y) with width w and height h ##
-
-#Example
- SkIRect rect = SkIRect::MakeXYWH(5, 35, -15, 25);
- SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
- rect.bottom(), rect.isEmpty() ? "true" : "false");
- rect.sort();
- SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
- rect.bottom(), rect.isEmpty() ? "true" : "false");
-#StdOut
-rect: 5, 35, -10, 60 isEmpty: true
-rect: -10, 35, 5, 60 isEmpty: false
-##
-##
-
-#SeeAlso MakeLTRB SkRect::MakeXYWH
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method int left() const
-
-Returns left edge of IRect, if sorted.
-Call sort() to reverse fLeft and fRight if needed.
-
-#Return fLeft ##
-
-#Example
- SkIRect unsorted = { 15, 5, 10, 25 };
- SkDebugf("unsorted.fLeft: %d unsorted.left(): %d\n", unsorted.fLeft, unsorted.left());
- SkIRect sorted = unsorted.makeSorted();
- SkDebugf("sorted.fLeft: %d sorted.left(): %d\n", sorted.fLeft, sorted.left());
-#StdOut
-unsorted.fLeft: 15 unsorted.left(): 15
-sorted.fLeft: 10 sorted.left(): 10
-##
-##
-
-#SeeAlso fLeft x() SkRect::left()
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method int top() const
-
-Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
-and sort() to reverse fTop and fBottom if needed.
-
-#Return fTop ##
-
-#Example
- SkIRect unsorted = { 15, 25, 10, 5 };
- SkDebugf("unsorted.fTop: %d unsorted.top(): %d\n", unsorted.fTop, unsorted.top());
- SkIRect sorted = unsorted.makeSorted();
- SkDebugf("sorted.fTop: %d sorted.top(): %d\n", sorted.fTop, sorted.top());
-#StdOut
-unsorted.fTop: 25 unsorted.top(): 25
-sorted.fTop: 5 sorted.top(): 5
-##
-##
-
-#SeeAlso fTop y() SkRect::top()
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method int right() const
-
-Returns right edge of IRect, if sorted.
-Call sort() to reverse fLeft and fRight if needed.
-
-#Return fRight ##
-
-#Example
- SkIRect unsorted = { 15, 25, 10, 5 };
- SkDebugf("unsorted.fRight: %d unsorted.right(): %d\n", unsorted.fRight, unsorted.right());
- SkIRect sorted = unsorted.makeSorted();
- SkDebugf("sorted.fRight: %d sorted.right(): %d\n", sorted.fRight, sorted.right());
-#StdOut
-unsorted.fRight: 10 unsorted.right(): 10
-sorted.fRight: 15 sorted.right(): 15
-##
-##
-
-#SeeAlso fRight SkRect::right()
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method int bottom() const
-
-Returns bottom edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
-and sort() to reverse fTop and fBottom if needed.
-
-#Return fBottom ##
-
-#Example
- SkIRect unsorted = { 15, 25, 10, 5 };
- SkDebugf("unsorted.fBottom: %d unsorted.bottom(): %d\n", unsorted.fBottom, unsorted.bottom());
- SkIRect sorted = unsorted.makeSorted();
- SkDebugf("sorted.fBottom: %d sorted.bottom(): %d\n", sorted.fBottom, sorted.bottom());
-#StdOut
-unsorted.fBottom: 5 unsorted.bottom(): 5
-sorted.fBottom: 25 sorted.bottom(): 25
-##
-##
-
-#SeeAlso fBottom SkRect::bottom()
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method int x() const
-
-Returns left edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
-and sort() to reverse fLeft and fRight if needed.
-
-#Return fLeft ##
-
-#Example
- SkIRect unsorted = { 15, 5, 10, 25 };
- SkDebugf("unsorted.fLeft: %d unsorted.x(): %d\n", unsorted.fLeft, unsorted.x());
- SkIRect sorted = unsorted.makeSorted();
- SkDebugf("sorted.fLeft: %d sorted.x(): %d\n", sorted.fLeft, sorted.x());
-#StdOut
-unsorted.fLeft: 15 unsorted.x(): 15
-sorted.fLeft: 10 sorted.x(): 10
-##
-##
-
-#SeeAlso fLeft left() y() SkRect::x()
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method int y() const
-
-Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
-and sort() to reverse fTop and fBottom if needed.
-
-#Return fTop ##
-
-#Example
- SkIRect unsorted = { 15, 25, 10, 5 };
- SkDebugf("unsorted.fTop: %d unsorted.y(): %d\n", unsorted.fTop, unsorted.y());
- SkIRect sorted = unsorted.makeSorted();
- SkDebugf("sorted.fTop: %d sorted.y(): %d\n", sorted.fTop, sorted.y());
-#StdOut
-unsorted.fTop: 25 unsorted.y(): 25
-sorted.fTop: 5 sorted.y(): 5
-##
-##
-
-#SeeAlso fTop top() x() SkRect::y()
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method int width() const
-
-Returns span on the x-axis. This does not check if IRect is sorted, or if
-result fits in 32-bit signed integer; result may be negative.
-
-#Return fRight minus fLeft ##
-
-#Example
- SkIRect unsorted = { 15, 25, 10, 5 };
- SkDebugf("unsorted width: %d\n", unsorted.width());
- SkIRect large = { -2147483647, 1, 2147483644, 2 };
- SkDebugf("large width: %d\n", large.width());
-#StdOut
-unsorted width: -5
-large width: -5
-##
-##
-
-#SeeAlso height() SkRect::width()
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method int height() const
-
-Returns span on the y-axis. This does not check if IRect is sorted, or if
-result fits in 32-bit signed integer; result may be negative.
-
-#Return fBottom minus fTop ##
-
-#Example
- SkIRect unsorted = { 15, 25, 10, 20 };
- SkDebugf("unsorted height: %d\n", unsorted.height());
- SkIRect large = { 1, -2147483647, 2, 2147483644 };
- SkDebugf("large height: %d\n", large.height());
-#StdOut
-unsorted height: -5
-large height: -5
-##
-##
-
-#SeeAlso width() SkRect::height()
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method SkISize size() const
-
-Returns spans on the x-axis and y-axis. This does not check if IRect is sorted,
-or if result fits in 32-bit signed integer; result may be negative.
-
-#Return ISize (width, height) ##
-
-#Example
- auto debugster = [](const char* prefix, const SkIRect& rect) -> void {
- SkISize size = rect.size();
- SkDebugf("%s ", prefix);
- SkDebugf("rect: %d, %d, %d, %d ", rect.left(), rect.top(), rect.right(), rect.bottom());
- SkDebugf("size: %d, %d\n", size.width(), size.height());
- };
- SkIRect rect = {20, 30, 40, 50};
- debugster("original", rect);
- rect.offset(20, 20);
- debugster(" offset", rect);
- rect.outset(20, 20);
- debugster(" outset", rect);
-#StdOut
-original rect: 20, 30, 40, 50 size: 20, 20
- offset rect: 40, 50, 60, 70 size: 20, 20
- outset rect: 20, 30, 80, 90 size: 60, 60
-##
-##
-
-#SeeAlso height() width() MakeSize
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method int centerX() const
-
-Returns average of left edge and right edge. Result does not change if Rect
-is sorted. Result may be incorrect if Rect is far from the origin.
-
-Result is rounded down.
-
-#Return midpoint in x ##
-
-#Example
-#Description
-Dividing by two rounds towards zero. centerX uses a bit shift and rounds down.
-##
- SkIRect tests[] = {{20, 30, 41, 51}, {-20, -30, -41, -51}, {-10, -10, 11, 11}};
- for (auto rect : tests) {
- SkDebugf("left: %3d right: %3d centerX: %3d ", rect.left(), rect.right(), rect.centerX());
- SkDebugf("div2: %3d\n", (rect.left() + rect.right()) / 2);
- }
-#StdOut
-left: 20 right: 41 centerX: 30 div2: 30
-left: -20 right: -41 centerX: -31 div2: -30
-left: -10 right: 11 centerX: 0 div2: 0
-##
-##
-
-#SeeAlso centerY SkRect::centerX
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method int centerY() const
-
-Returns average of top edge and bottom edge. Result does not change if Rect
-is sorted. Result may be incorrect if Rect is far from the origin.
-
-Result is rounded down.
-
-#Return midpoint in y ##
-
-#Example
- SkIRect rect = { 0, 0, 2, 2 };
- rect.offset(0x40000000, 0x40000000);
- SkDebugf("left: %d right: %d centerX: %d ", rect.left(), rect.right(), rect.centerX());
- SkDebugf("safe mid x: %d\n", rect.left() / 2 + rect.right() / 2);
-#StdOut
-left: 1073741824 right: 1073741826 centerX: -1073741823 safe mid x: 1073741825
-##
-##
-
-#SeeAlso centerX SkRect::centerY
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool isEmpty() const
-
-Returns true if fLeft is equal to or greater than fRight, or if fTop is equal
-to or greater than fBottom. Call sort() to reverse rectangles with negative
-width() or height().
-
-#Return true if width() or height() are zero or negative ##
-
-#Example
- SkIRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
- for (auto rect : tests) {
- SkDebugf("rect: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
- rect.bottom(), rect.isEmpty() ? "" : " not");
- rect.sort();
- SkDebugf("sorted: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
- rect.bottom(), rect.isEmpty() ? "" : " not");
- }
-#StdOut
-rect: {20, 40, 10, 50} is empty
-sorted: {10, 40, 20, 50} is not empty
-rect: {20, 40, 20, 50} is empty
-sorted: {20, 40, 20, 50} is empty
-##
-##
-
-#SeeAlso EmptyIRect MakeEmpty sort SkRect::isEmpty
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool isLargest() const
-
-Returns true if IRect encloses largest possible area.
-
-#Return true if equal to (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32) ##
-
-#Example
-#Description
-Note that the width is not negative, yet it cannot be represented as a 32-bit
-signed integer.
-##
- SkIRect large = SkIRect::MakeLargest();
- SkDebugf("large is largest: %s\n" ,large.isLargest() ? "true" : "false");
- SkDebugf("large width %d\n", large.width());
- SkDebugf("large is empty: %s\n", large.isEmpty() ? "true" : "false");
-#StdOut
-large is largest: true
-large width -2
-large is empty: false
-##
-##
-
-#SeeAlso MakeLargest SkRect::isLargest
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool operator==(const SkIRect& a, const SkIRect& b)
-
-Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are
-identical to corresponding members in b.
-
-#Param a IRect to compare ##
-#Param b IRect to compare ##
-
-#Return true if members are equal ##
-
-#Example
- SkIRect test = {0, 0, 2, 2};
- SkIRect sorted = test.makeSorted();
- SkDebugf("test %c= sorted\n", test == sorted ? '=' : '!');
-#StdOut
-test == sorted
-##
-##
-
-#SeeAlso operator!=(const SkIRect& a, const SkIRect& b)
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool operator!=(const SkIRect& a, const SkIRect& b)
-
-Returns true if any member in a: fLeft, fTop, fRight, and fBottom; is not
-identical to the corresponding member in b.
-
-#Param a IRect to compare ##
-#Param b IRect to compare ##
-
-#Return true if members are not equal ##
-
-#Example
- SkIRect test = {2, 2, 0, 0};
- SkIRect sorted = test.makeSorted();
- SkDebugf("test %c= sorted\n", test != sorted ? '!' : '=');
-#StdOut
-test != sorted
-##
-##
-
-#SeeAlso operator==(const SkIRect& a, const SkIRect& b)
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool is16Bit() const
-
-Returns true if all members: fLeft, fTop, fRight, and fBottom; values are
-equal to or larger than -32768 and equal to or smaller than 32767.
-
-#Return true if members fit in 16-bit word ##
-
-#Example
- SkIRect tests[] = {{-32768, -32768, 32767, 32767}, {-32768, -32768, 32768, 32768}};
- for (auto rect : tests) {
- SkDebugf("{%d, %d, %d, %d} %s in 16 bits\n", rect.fLeft, rect.fTop, rect.fRight,
- rect.fBottom, rect.is16Bit() ? "fits" : "does not fit");
-}
-#StdOut
-{-32768, -32768, 32767, 32767} fits in 16 bits
-{-32768, -32768, 32768, 32768} does not fit in 16 bits
-##
-##
-
-#SeeAlso SkTFitsIn
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void setEmpty()
-
-Sets IRect to (0, 0, 0, 0).
-
-Many other rectangles are empty; if left is equal to or greater than right,
-or if top is equal to or greater than bottom. Setting all members to zero
-is a convenience, but does not designate a special empty rectangle.
-
-#Example
- SkIRect rect = {3, 4, 1, 2};
- for (int i = 0; i < 2; ++i) {
- SkDebugf("rect: {%d, %d, %d, %d} is %s" "empty\n", rect.fLeft, rect.fTop,
- rect.fRight, rect.fBottom, rect.isEmpty() ? "" : "not ");
- rect.setEmpty();
- }
-#StdOut
-rect: {3, 4, 1, 2} is empty
-rect: {0, 0, 0, 0} is empty
-##
-##
-
-#SeeAlso MakeEmpty SkRect::setEmpty
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void set(int32_t left, int32_t top, int32_t right, int32_t bottom)
-
-Sets IRect to (left, top, right, bottom).
-left and right are not sorted; left is not necessarily less than right.
-top and bottom are not sorted; top is not necessarily less than bottom.
-
-#Param left assigned to fLeft ##
-#Param top assigned to fTop ##
-#Param right assigned to fRight ##
-#Param bottom assigned to fBottom ##
-
-#Example
- SkIRect rect1 = {3, 4, 1, 2};
- SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
- SkIRect rect2;
- rect2.set(3, 4, 1, 2);
- SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
-#StdOut
-rect1: {3, 4, 1, 2}
-rect2: {3, 4, 1, 2}
-##
-##
-
-#SeeAlso setLTRB setXYWH SkRect::set
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom)
-
-Sets IRect to (left, top, right, bottom).
-left and right are not sorted; left is not necessarily less than right.
-top and bottom are not sorted; top is not necessarily less than bottom.
-
-#Param left stored in fLeft ##
-#Param top stored in fTop ##
-#Param right stored in fRight ##
-#Param bottom stored in fBottom ##
-
-#Example
- SkIRect rect1 = {3, 4, 1, 2};
- SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
- SkIRect rect2;
- rect2.setLTRB(3, 4, 1, 2);
- SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
-#StdOut
-rect1: {3, 4, 1, 2}
-rect2: {3, 4, 1, 2}
-##
-##
-
-#SeeAlso set setXYWH SkRect::setLTRB
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void setXYWH(int32_t x, int32_t y, int32_t width, int32_t height)
-
-Sets IRect to:
-#Formula
-(x, y, x + width, y + height)
-##
-. Does not validate input;
-width or height may be negative.
-
-#Param x stored in fLeft ##
-#Param y stored in fTop ##
-#Param width added to x and stored in fRight ##
-#Param height added to y and stored in fBottom ##
-
-#Example
- SkIRect rect;
- rect.setXYWH(5, 35, -15, 25);
- SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
- rect.bottom(), rect.isEmpty() ? "true" : "false");
- rect.sort();
- SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
- rect.bottom(), rect.isEmpty() ? "true" : "false");
-#StdOut
-rect: 5, 35, -10, 60 isEmpty: true
-rect: -10, 35, 5, 60 isEmpty: false
-##
-##
-
-#SeeAlso MakeXYWH setLTRB set SkRect::setXYWH
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void setLargest()
-
-Sets rectangle left and top to most negative value, and sets
-right and bottom to most positive value.
-
-#Example
- SkIRect rect;
- rect.setLargest();
- SkDebugf("MakeLargest isLargest: %s\n", rect.isLargest() ? "true" : "false");
- SkDebugf("MakeLargest isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
- rect.outset(1, 1);
- SkDebugf("outset isLargest: %s\n", rect.isLargest() ? "true" : "false");
- SkDebugf("outset isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
-#StdOut
-MakeLargest isLargest: true
-MakeLargest isEmpty: false
-outset isLargest: false
-outset isEmpty: true
-##
-##
-
-#SeeAlso MakeLargest isLargest setLargestInverted SK_MinS32 SK_MaxS32
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void setLargestInverted()
-#ToDo move this to private
-##
-
-Sets rectangle left and top to most positive value, and sets
-right and bottom to most negative value. This is used internally to
-flag that a condition is met, but otherwise has no special purpose.
-
-#NoExample
-##
-
-#SeeAlso setEmpty setLargest
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method SkIRect makeOffset(int32_t dx, int32_t dy) const
-
-Returns IRect offset by (dx, dy).
-
-If dx is negative, IRect returned is moved to the left.
-If dx is positive, IRect returned is moved to the right.
-If dy is negative, IRect returned is moved upward.
-If dy is positive, IRect returned is moved downward.
-
-#Param dx offset added to fLeft and fRight ##
-#Param dy offset added to fTop and fBottom ##
-
-#Return Rect offset in x or y, with original width and height ##
-
-#Example
- SkIRect rect = { 10, 50, 20, 60 };
- SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
- rect.bottom(), rect.isEmpty() ? "true" : "false");
- rect = rect.makeOffset(15, 32);
- SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
- rect.bottom(), rect.isEmpty() ? "true" : "false");
-#StdOut
-rect: 10, 50, 20, 60 isEmpty: false
-rect: 25, 82, 35, 92 isEmpty: false
-##
-##
-
-#SeeAlso offset() makeInset makeOutset SkRect::makeOffset
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method SkIRect makeInset(int32_t dx, int32_t dy) const
-
-Returns IRect, inset by (dx, dy).
-
-If dx is negative, IRect returned is wider.
-If dx is positive, IRect returned is narrower.
-If dy is negative, IRect returned is taller.
-If dy is positive, IRect returned is shorter.
-
-#Param dx offset added to fLeft and subtracted from fRight ##
-#Param dy offset added to fTop and subtracted from fBottom ##
-
-#Return Rect inset symmetrically left and right, top and bottom ##
-
-#Example
- SkIRect rect = { 10, 50, 20, 60 };
- SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
- rect.bottom(), rect.isEmpty() ? "true" : "false");
- rect = rect.makeInset(15, 32);
- SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
- rect.bottom(), rect.isEmpty() ? "true" : "false");
-#StdOut
-rect: 10, 50, 20, 60 isEmpty: false
-rect: 25, 82, 5, 28 isEmpty: true
-##
-##
-
-#SeeAlso inset() makeOffset makeOutset SkRect::makeInset
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method SkIRect makeOutset(int32_t dx, int32_t dy) const
-
-Returns IRect, outset by (dx, dy).
-
-If dx is negative, IRect returned is narrower.
-If dx is positive, IRect returned is wider.
-If dy is negative, IRect returned is shorter.
-If dy is positive, IRect returned is taller.
-
-#Param dx offset subtracted to fLeft and added from fRight ##
-#Param dy offset subtracted to fTop and added from fBottom ##
-
-#Return Rect outset symmetrically left and right, top and bottom ##
-
-#Example
- SkIRect rect = { 10, 50, 20, 60 };
- SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
- rect.bottom(), rect.isEmpty() ? "true" : "false");
- rect = rect.makeOutset(15, 32);
- SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
- rect.bottom(), rect.isEmpty() ? "true" : "false");
-#StdOut
-rect: 10, 50, 20, 60 isEmpty: false
-rect: -5, 18, 35, 92 isEmpty: false
-##
-##
-
-#SeeAlso outset() makeOffset makeInset SkRect::makeOutset
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void offset(int32_t dx, int32_t dy)
-
-Offsets IRect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom.
-
-If dx is negative, moves IRect returned to the left.
-If dx is positive, moves IRect returned to the right.
-If dy is negative, moves IRect returned upward.
-If dy is positive, moves IRect returned downward.
-
-#Param dx offset added to fLeft and fRight ##
-#Param dy offset added to fTop and fBottom ##
-
-#Example
- SkIRect rect = { 10, 14, 50, 73 };
- rect.offset(5, 13);
- SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
-#StdOut
-rect: 15, 27, 55, 86
-##
-##
-
-#SeeAlso offsetTo makeOffset SkRect::offset
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void offset(const SkIPoint& delta)
-
-Offsets IRect by adding delta.fX to fLeft, fRight; and by adding delta.fY to
-fTop, fBottom.
-
-If delta.fX is negative, moves IRect returned to the left.
-If delta.fX is positive, moves IRect returned to the right.
-If delta.fY is negative, moves IRect returned upward.
-If delta.fY is positive, moves IRect returned downward.
-
-#Param delta offset added to IRect ##
-
-#Example
- SkIRect rect = { 10, 14, 50, 73 };
- rect.offset({5, 13});
- SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
-#StdOut
-rect: 15, 27, 55, 86
-##
-##
-
-#SeeAlso offsetTo makeOffset SkRect::offset
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void offsetTo(int32_t newX, int32_t newY)
-
-Offsets IRect so that fLeft equals newX, and fTop equals newY. width and height
-are unchanged.
-
-#Param newX stored in fLeft, preserving width() ##
-#Param newY stored in fTop, preserving height() ##
-
-#Example
- SkIRect rect = { 10, 14, 50, 73 };
- rect.offsetTo(15, 27);
- SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
-#StdOut
-rect: 15, 27, 55, 86
-##
-##
-
-#SeeAlso offset makeOffset setXYWH SkRect::offsetTo
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void inset(int32_t dx, int32_t dy)
-
-Insets IRect by (dx,dy).
-
-If dx is positive, makes IRect narrower.
-If dx is negative, makes IRect wider.
-If dy is positive, makes IRect shorter.
-If dy is negative, makes IRect taller.
-
-#Param dx offset added to fLeft and subtracted from fRight ##
-#Param dy offset added to fTop and subtracted from fBottom ##
-
-#Example
- SkIRect rect = { 10, 14, 50, 73 };
- rect.inset(5, 13);
- SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
-#StdOut
-rect: 15, 27, 45, 60
-##
-##
-
-#SeeAlso outset makeInset SkRect::inset
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void outset(int32_t dx, int32_t dy)
-
-Outsets IRect by (dx, dy).
-
-If dx is positive, makes Rect wider.
-If dx is negative, makes Rect narrower.
-If dy is positive, makes Rect taller.
-If dy is negative, makes Rect shorter.
-
-#Param dx subtracted to fLeft and added from fRight ##
-#Param dy subtracted to fTop and added from fBottom ##
-
-#Example
- SkIRect rect = { 10, 14, 50, 73 };
- rect.outset(5, 13);
- SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
-#StdOut
-rect: 5, 1, 55, 86
-##
-##
-
-#SeeAlso inset makeOutset SkRect::outset
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool quickReject(int l, int t, int r, int b) const
-
-Constructs IRect (l, t, r, b) and returns true if constructed IRect does not
-intersect IRect. Does not check to see if construction or IRect is empty.
-
-Is implemented with short circuit logic so that true can be returned after
-a single compare.
-
-#Param l x minimum of constructed Rect ##
-#Param t y minimum of constructed Rect ##
-#Param r x maximum of constructed Rect ##
-#Param b y maximum of constructed Rect ##
-
-#Return true if construction and IRect have no area in common ##
-
-#Example
-#Description
-quickReject is the complement of Intersects.
-##
- const SkIRect rect = {7, 11, 13, 17};
- const int32_t* r = &rect.fLeft;
- const SkIRect tests[] = { {13, 11, 15, 17}, { 7, 7, 13, 11 }, { 12, 16, 14, 18 } };
- for (auto& test : tests) {
- const int32_t* t = &test.fLeft;
- SkDebugf("rect (%d, %d, %d, %d) test(%d, %d, %d, %d) quickReject %s; intersects %s\n",
- r[0], r[1], r[2], r[3], t[0], t[1], t[2], t[3],
- rect.quickReject(t[0], t[1], t[2], t[3]) ? "true" : "false",
- SkIRect::Intersects(rect, test) ? "true" : "false");
- }
-#StdOut
-rect (7, 11, 13, 17) test(13, 11, 15, 17) quickReject true; intersects false
-rect (7, 11, 13, 17) test(7, 7, 13, 11) quickReject true; intersects false
-rect (7, 11, 13, 17) test(12, 16, 14, 18) quickReject false; intersects true
-##
-##
-
-#SeeAlso Intersects
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool contains(int32_t x, int32_t y) const
-
-Returns true if:
-#Formula
-fLeft <= x < fRight && fTop <= y < fBottom
-##
-.
-Returns false if Rect is empty.
-
-Considers input to describe constructed IRect:
-#Formula
-(x, y, x + 1, y + 1)
-##
-and
-returns true if constructed area is completely enclosed by IRect area.
-
-#Param x test Point x-coordinate ##
-#Param y test Point y-coordinate ##
-
-#Return true if (x, y) is inside IRect ##
-
-#Example
- SkIRect rect = { 30, 50, 40, 60 };
- SkIPoint pts[] = { { 30, 50}, { 40, 50}, { 30, 60} };
- for (auto pt : pts) {
- SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d)\n",
- rect.left(), rect.top(), rect.right(), rect.bottom(),
- rect.contains(pt.x(), pt.y()) ? "contains" : "does not contain", pt.x(), pt.y());
- }
-#StdOut
-rect: (30, 50, 40, 60) contains (30, 50)
-rect: (30, 50, 40, 60) does not contain (40, 50)
-rect: (30, 50, 40, 60) does not contain (30, 60)
-##
-##
-
-#SeeAlso containsNoEmptyCheck SkRect::contains
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool contains(int32_t left, int32_t top, int32_t right, int32_t bottom) const
-
-Constructs Rect to intersect from (left, top, right, bottom). Does not sort
-construction.
-
-Returns true if Rect contains construction.
-Returns false if Rect is empty or construction is empty.
-
-#Param left x minimum of constructed Rect ##
-#Param top y minimum of constructed Rect ##
-#Param right x maximum of constructed Rect ##
-#Param bottom y maximum of constructed Rect ##
-
-#Return true if all sides of IRect are outside construction ##
-
-#Example
- SkIRect rect = { 30, 50, 40, 60 };
- SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
- for (auto contained : tests) {
- bool success = rect.contains(
- contained.left(), contained.top(), contained.right(), contained.bottom());
- SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
- rect.left(), rect.top(), rect.right(), rect.bottom(),
- success ? "contains" : "does not contain",
- contained.left(), contained.top(), contained.right(), contained.bottom());
- }
-#StdOut
-rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
-rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
-rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
-##
-##
-
-#SeeAlso containsNoEmptyCheck SkRect::contains
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool contains(const SkIRect& r) const
-
-Returns true if Rect contains r.
-Returns false if Rect is empty or r is empty.
-
-Rect contains r when Rect area completely includes r area.
-
-#Param r IRect contained ##
-
-#Return true if all sides of IRect are outside r ##
-
-#Example
- SkIRect rect = { 30, 50, 40, 60 };
- SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
- for (auto contained : tests) {
- SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
- rect.left(), rect.top(), rect.right(), rect.bottom(),
- rect.contains(contained) ? "contains" : "does not contain",
- contained.left(), contained.top(), contained.right(), contained.bottom());
- }
-#StdOut
-rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
-rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
-rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
-##
-##
-
-#SeeAlso containsNoEmptyCheck SkRect::contains
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool contains(const SkRect& r) const
-
-Returns true if Rect contains r.
-Returns false if Rect is empty or r is empty.
-
-Rect contains r when Rect area completely includes r area.
-
-#Param r Rect contained ##
-
-#Return true if all sides of IRect are outside r ##
-
-#Example
- SkIRect rect = { 30, 50, 40, 60 };
- SkRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
- for (auto contained : tests) {
- SkDebugf("rect: (%d, %d, %d, %d) %s (%g, %g, %g, %g)\n",
- rect.left(), rect.top(), rect.right(), rect.bottom(),
- rect.contains(contained) ? "contains" : "does not contain",
- contained.left(), contained.top(), contained.right(), contained.bottom());
- }
-#StdOut
-rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
-rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
-rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
-##
-##
-
-#SeeAlso containsNoEmptyCheck SkRect::contains
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool containsNoEmptyCheck(int32_t left, int32_t top,
- int32_t right, int32_t bottom) const
-
-Constructs IRect from (left, top, right, bottom). Does not sort
-construction.
-
-Returns true if Rect contains construction.
-Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined.
-
-Return is undefined if Rect is empty or construction is empty.
-
-#Param left x minimum of constructed Rect ##
-#Param top y minimum of constructed Rect ##
-#Param right x maximum of constructed Rect ##
-#Param bottom y maximum of constructed Rect ##
-
-#Return true if all sides of IRect are outside construction ##
-
-#Example
- SkIRect rect = { 30, 50, 40, 60 };
- SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
- for (auto contained : tests) {
- bool success = rect.containsNoEmptyCheck(
- contained.left(), contained.top(), contained.right(), contained.bottom());
- SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
- rect.left(), rect.top(), rect.right(), rect.bottom(),
- success ? "contains" : "does not contain",
- contained.left(), contained.top(), contained.right(), contained.bottom());
- }
-#StdOut
-rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
-rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
-rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
-##
-##
-
-#SeeAlso contains SkRect::contains
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool containsNoEmptyCheck(const SkIRect& r) const
-
-Returns true if Rect contains construction.
-Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined.
-
-Return is undefined if Rect is empty or construction is empty.
-
-#Param r Rect contained ##
-
-#Return true if all sides of IRect are outside r ##
-
-#Example
- SkIRect rect = { 30, 50, 40, 60 };
- SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
- for (auto contained : tests) {
- SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
- rect.left(), rect.top(), rect.right(), rect.bottom(),
- rect.containsNoEmptyCheck(contained) ? "contains" : "does not contain",
- contained.left(), contained.top(), contained.right(), contained.bottom());
- }
-#StdOut
-rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
-rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
-rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
-##
-##
-
-#SeeAlso contains SkRect::contains
-
-##
-
-#Topic Intersection
-
-IRects intersect when they enclose a common area. To intersect, each of the pair
-must describe area; fLeft is less than fRight, and fTop is less than fBottom;
-empty() returns false. The intersection of IRect pair can be described by:
-#Formula
-(max(a.fLeft, b.fLeft), max(a.fTop, b.fTop),
- min(a.fRight, b.fRight), min(a.fBottom, b.fBottom))
-##
-The intersection is only meaningful if the resulting IRect is not empty and
-describes an area: fLeft is less than fRight, and fTop is less than fBottom.
-
-# ------------------------------------------------------------------------------
-
-#Method bool intersect(const SkIRect& r)
-
-Returns true if IRect intersects r, and sets IRect to intersection.
-Returns false if IRect does not intersect r, and leaves IRect unchanged.
-
-Returns false if either r or IRect is empty, leaving IRect unchanged.
-
-#Param r limit of result ##
-
-#Return true if r and Rect have area in common ##
-
-#Example
-#Description
-Two SkDebugf calls are required. If the calls are combined, their arguments
-may not be evaluated in left to right order: the printed intersection may
-be before or after the call to intersect.
-##
- SkIRect leftRect = { 10, 40, 50, 80 };
- SkIRect rightRect = { 30, 60, 70, 90 };
- SkDebugf("%s intersection: ", leftRect.intersect(rightRect) ? "" : "no ");
- SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
- leftRect.right(), leftRect.bottom());
-#StdOut
- intersection: 30, 60, 50, 80
-##
-##
-
-#SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& a, const SkIRect& b)
-
-Returns true if a intersects b, and sets IRect to intersection.
-Returns false if a does not intersect b, and leaves IRect unchanged.
-
-Returns false if either a or b is empty, leaving IRect unchanged.
-
-#Param a IRect to intersect ##
-#Param b IRect to intersect ##
-
-#Return true if a and b have area in common ##
-
-#Example
- SkIRect result;
- bool intersected = result.intersect({ 10, 40, 50, 80 }, { 30, 60, 70, 90 });
- SkDebugf("%s intersection: %d, %d, %d, %d\n", intersected ? "" : "no ",
- result.left(), result.top(), result.right(), result.bottom());
-#StdOut
- intersection: 30, 60, 50, 80
-##
-##
-
-#SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool SK_WARN_UNUSED_RESULT intersectNoEmptyCheck(const SkIRect& a, const SkIRect& b)
-
-Returns true if a intersects b, and sets IRect to intersection.
-Returns false if a does not intersect b, and leaves IRect unchanged.
-
-Asserts if either a or b is empty, and if SK_DEBUG is defined.
-
-#Param a IRect to intersect ##
-#Param b IRect to intersect ##
-
-#Return true if a and b have area in common ##
-
-#Example
- SkIRect result;
- bool intersected = result.intersectNoEmptyCheck({ 10, 40, 50, 80 }, { 30, 60, 70, 90 });
- SkDebugf("intersection: %d, %d, %d, %d\n",
- result.left(), result.top(), result.right(), result.bottom());
-#StdOut
- intersection: 30, 60, 50, 80
-##
-##
-
-#SeeAlso Intersects intersect join SkRect::intersect
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method bool intersect(int32_t left, int32_t top, int32_t right, int32_t bottom)
-
-Constructs IRect to intersect from (left, top, right, bottom). Does not sort
-construction.
-
-Returns true if IRect intersects construction, and sets IRect to intersection.
-Returns false if IRect does not intersect construction, and leaves IRect unchanged.
-
-Returns false if either construction or IRect is empty, leaving IRect unchanged.
-
-#Param left x minimum of constructed IRect ##
-#Param top y minimum of constructed IRect ##
-#Param right x maximum of constructed IRect ##
-#Param bottom y maximum of constructed IRect ##
-
-#Return true if construction and IRect have area in common ##
-
-#Example
-#Description
-Two SkDebugf calls are required. If the calls are combined, their arguments
-may not be evaluated in left to right order: the printed intersection may
-be before or after the call to intersect.
-##
- SkIRect leftRect = { 10, 40, 50, 80 };
- SkDebugf("%s intersection: ", leftRect.intersect(30, 60, 70, 90) ? "" : "no ");
- SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
- leftRect.right(), leftRect.bottom());
-#StdOut
- intersection: 30, 60, 50, 80
-##
-##
-
-#SeeAlso intersectNoEmptyCheck Intersects join SkRect::intersect
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method static bool Intersects(const SkIRect& a, const SkIRect& b)
-
-Returns true if a intersects b.
-Returns false if either a or b is empty, or do not intersect.
-
-#Param a IRect to intersect ##
-#Param b IRect to intersect ##
-
-#Return true if a and b have area in common ##
-
-#Example
- SkDebugf("%s intersection", SkIRect::Intersects({10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
-#StdOut
- intersection
-##
-##
-
-#SeeAlso IntersectsNoEmptyCheck intersect SkRect::intersect
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method static bool IntersectsNoEmptyCheck(const SkIRect& a, const SkIRect& b)
-
-Returns true if a intersects b.
-Asserts if either a or b is empty, and if SK_DEBUG is defined.
-
-#Param a IRect to intersect ##
-#Param b IRect to intersect ##
-
-#Return true if a and b have area in common ##
-
-#Example
- SkDebugf("%s intersection", SkIRect::IntersectsNoEmptyCheck(
- {10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
-#StdOut
- intersection
-##
-##
-
-#SeeAlso Intersects intersect SkRect::intersect
-
-##
-
-#Topic Intersection ##
-
-# ------------------------------------------------------------------------------
-
-#Method void join(int32_t left, int32_t top, int32_t right, int32_t bottom)
-
-Constructs Rect to intersect from (left, top, right, bottom). Does not sort
-construction.
-
-Sets Rect to the union of itself and the construction.
-
-Has no effect if construction is empty. Otherwise, if Rect is empty, sets
-Rect to construction.
-
-#Param left x minimum of constructed Rect ##
-#Param top y minimum of constructed Rect ##
-#Param right x maximum of constructed Rect ##
-#Param bottom y maximum of constructed Rect ##
-
-#Example
- SkIRect rect = { 10, 20, 15, 25};
- rect.join(50, 60, 55, 65);
- SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
-#StdOut
- join: 10, 20, 55, 65
-##
-##
-
-#SeeAlso set SkRect::join
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void join(const SkIRect& r)
-
-Sets Rect to the union of itself and r.
-
-Has no effect if r is empty. Otherwise, if Rect is empty, sets Rect to r.
-
-#Param r expansion Rect ##
-
-#Example
- SkIRect rect = { 10, 20, 15, 25};
- rect.join({50, 60, 55, 65});
- SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
-#StdOut
- join: 10, 20, 55, 65
-##
-##
-
-#SeeAlso set SkRect::join
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void sort()
-
-Swaps fLeft and fRight if fLeft is greater than fRight; and swaps
-fTop and fBottom if fTop is greater than fBottom. Result may be empty,
-and width() and height() will be zero or positive.
-
-#Example
- SkIRect rect = { 30, 50, 20, 10 };
- SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
- rect.sort();
- SkDebugf("sorted: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
-#StdOut
-rect: 30, 50, 20, 10
-sorted: 20, 10, 30, 50
-##
-##
-
-#SeeAlso makeSorted SkRect::sort
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method SkIRect makeSorted() const
-
-Returns Rect with fLeft and fRight swapped if fLeft is greater than fRight; and
-with fTop and fBottom swapped if fTop is greater than fBottom. Result may be empty;
-and width() and height() will be zero or positive.
-
-#Return sorted IRect ##
-
-#Example
- SkIRect rect = { 30, 50, 20, 10 };
- SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
- SkIRect sort = rect.makeSorted();
- SkDebugf("sorted: %d, %d, %d, %d\n", sort.fLeft, sort.fTop, sort.fRight, sort.fBottom);
-#StdOut
-rect: 30, 50, 20, 10
-sorted: 20, 10, 30, 50
-##
-##
-
-#SeeAlso sort SkRect::makeSorted
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method static const SkIRect& SK_WARN_UNUSED_RESULT EmptyIRect()
-
-Returns a reference to immutable empty IRect, set to (0, 0, 0, 0).
-
-#Return global IRect set to all zeroes ##
-
-#Example
- const SkIRect& rect = SkIRect::EmptyIRect();
- SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
-#StdOut
-rect: 0, 0, 0, 0
-##
-##
-
-#SeeAlso MakeEmpty
-
-##
-
-#Struct SkIRect ##
-
-#Topic IRect ##
+#Topic IRect
+#Alias IRect_Reference
+
+#Struct SkIRect
+
+SkIRect holds four 32 bit integer coordinates describing the upper and
+lower bounds of a rectangle. SkIRect may be created from outer bounds or
+from position, width, and height. SkIRect describes an area; if its right
+is less than or equal to its left, or if its bottom is less than or equal to
+its top, it is considered empty.
+
+#Topic Overview
+
+#Subtopic Subtopics
+#ToDo manually add subtopics ##
+#Table
+#Legend
+# topics # description ##
+#Legend ##
+#Table ##
+##
+
+#Subtopic Operators
+#Table
+#Legend
+# description # function ##
+#Legend ##
+# bool operator!=(const SkIRect& a, const SkIRect& b) # Returns true if members are unequal. ##
+# bool operator==(const SkIRect& a, const SkIRect& b) # Returns true if members are equal. ##
+#Table ##
+#Subtopic ##
+
+#Subtopic Member_Functions
+#Table
+#Legend
+# description # function ##
+#Legend ##
+# EmptyIRect # Returns immutable bounds of (0, 0, 0, 0). ##
+# Intersects # Returns true if areas overlap. ##
+# IntersectsNoEmptyCheck # Returns true if areas overlap. Skips empty check. ##
+# MakeEmpty # Returns bounds of (0, 0, 0, 0). ##
+# MakeLTRB # Constructs from int left, top, right, bottom. ##
+# MakeLargest # Constructs from (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32). ##
+# MakeSize # Constructs from ISize returning (0, 0, width, height). ##
+# MakeWH # Constructs from int input returning (0, 0, width, height). ##
+# MakeXYWH # Constructs from int input returning (x, y, width, height). ##
+# bottom() # Returns larger bounds in y, if sorted. ##
+# centerX # Returns midpoint in x. ##
+# centerY # Returns midpoint in y. ##
+# contains() # Returns true if points are equal or inside. ##
+# containsNoEmptyCheck # Returns true if points are equal or inside. Skips empty check. ##
+# height() # Returns span in y. ##
+# inset() # Moves the sides symmetrically about the center. ##
+# intersect # Sets to shared area; returns true if not empty. ##
+# intersectNoEmptyCheck # Sets to shared area; returns true if not empty. Skips empty check. ##
+# is16Bit # Returns true if members fit in 16-bit word. ##
+# isEmpty # Returns true if width or height are zero or negative. ##
+# isLargest # Returns true if equal to (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32). ##
+# join() # Sets to union of bounds. ##
+# left() # Returns smaller bounds in x, if sorted. ##
+# makeInset # Constructs from sides moved symmetrically about the center. ##
+# makeOffset # Constructs from translated sides. ##
+# makeOutset # Constructs from sides moved symmetrically about the center. ##
+# makeSorted # Constructs, ordering sides from smaller to larger. ##
+# offset() # Translates sides without changing width and height. ##
+# offsetTo # Translates to (x, y) without changing width and height. ##
+# outset() # Moves the sides symmetrically about the center. ##
+# quickReject # Returns true if rectangles do not intersect. ##
+# right() # Returns larger bounds in x, if sorted. ##
+# set() # Sets to (left, top, right, bottom). ##
+# setEmpty # Sets to (0, 0, 0, 0). ##
+# setLTRB # Sets to SkScalar input (left, top, right, bottom). ##
+# setLargest # Sets to (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32). ##
+# setLargestInverted # Sets to (SK_MaxS32, SK_MaxS32, SK_MinS32, SK_MinS32). ##
+# setXYWH # Sets to (x, y, width, height). ##
+# size() # Returns ISize (width, height). ##
+# sort() # Orders sides from smaller to larger. ##
+# top() # Returns smaller bounds in y, if sorted. ##
+# width() # Returns span in x. ##
+# x() # Returns bounds left. ##
+# y() # Returns bounds top. ##
+#Table ##
+#Subtopic ##
+
+#Topic ##
+
+#Member int32_t fLeft
+May contain any value. The smaller of the horizontal values when sorted.
+When equal to or greater than fRight, IRect is empty.
+##
+
+#Member int32_t fTop
+May contain any value. The smaller of the horizontal values when sorted.
+When equal to or greater than fBottom, IRect is empty.
+##
+
+#Member int32_t fRight
+May contain any value. The larger of the vertical values when sorted.
+When equal to or less than fLeft, IRect is empty.
+##
+
+#Member int32_t fBottom
+May contain any value. The larger of the vertical values when sorted.
+When equal to or less than fTop, IRect is empty.
+##
+
+# ------------------------------------------------------------------------------
+
+#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeEmpty()
+
+Returns constructed IRect set to (0, 0, 0, 0).
+Many other rectangles are empty; if left is equal to or greater than right,
+or if top is equal to or greater than bottom. Setting all members to zero
+is a convenience, but does not designate a special empty rectangle.
+
+#Return bounds (0, 0, 0, 0) ##
+
+#Example
+ SkIRect rect = SkIRect::MakeEmpty();
+ SkDebugf("MakeEmpty isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+ rect.offset(10, 10);
+ SkDebugf("offset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+ rect.inset(10, 10);
+ SkDebugf("inset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+ rect.outset(20, 20);
+ SkDebugf("outset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+#StdOut
+MakeEmpty isEmpty: true
+offset rect isEmpty: true
+inset rect isEmpty: true
+outset rect isEmpty: false
+##
+##
+
+#SeeAlso EmptyIRect isEmpty setEmpty setLargestInverted SkRect::MakeEmpty
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method static SkIRect SK_WARN_UNUSED_RESULT MakeLargest()
+
+Returns constructed IRect setting left and top to most negative value, and
+setting right and bottom to most positive value.
+
+#Return bounds (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32) ##
+
+#Example
+ SkIRect rect = SkIRect::MakeLargest();
+ SkDebugf("MakeLargest isLargest: %s\n", rect.isLargest() ? "true" : "false");
+ SkDebugf("MakeLargest isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+ rect.outset(1, 1);
+ SkDebugf("outset isLargest: %s\n", rect.isLargest() ? "true" : "false");
+ SkDebugf("outset isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+#StdOut
+MakeLargest isLargest: true
+MakeLargest isEmpty: false
+outset isLargest: false
+outset isEmpty: true
+##
+##
+
+#SeeAlso isLargest setLargest SkRect::MakeLargest
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeWH(int32_t w, int32_t h)
+
+Returns constructed IRect set to (0, 0, w, h). Does not validate input; w or h
+may be negative.
+
+#Param w width of constructed Rect ##
+#Param h height of constructed Rect ##
+
+#Return bounds (0, 0, w, h) ##
+
+#Example
+ SkIRect rect1 = SkIRect::MakeWH(25, 35);
+ SkIRect rect2 = SkIRect::MakeSize({25, 35});
+ SkIRect rect3 = SkIRect::MakeXYWH(0, 0, 25, 35);
+ SkIRect rect4 = SkIRect::MakeLTRB(0, 0, 25, 35);
+ SkDebugf("all %s" "equal\n", rect1 == rect2 && rect2 == rect3 && rect3 == rect4 ?
+ "" : "not ");
+#StdOut
+all equal
+##
+##
+
+#SeeAlso MakeSize MakeXYWH SkRect::MakeWH SkRect::MakeIWH
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeSize(const SkISize& size)
+
+Returns constructed IRect set to (0, 0, size.width(), size.height()).
+Does not validate input; size.width() or size.height() may be negative.
+
+#Param size values for Rect width and height ##
+
+#Return bounds (0, 0, size.width(), size.height()) ##
+
+#Example
+ SkSize size = {25.5f, 35.5f};
+ SkIRect rect = SkIRect::MakeSize(size.toRound());
+ SkDebugf("round width: %d height: %d\n", rect.width(), rect.height());
+ rect = SkIRect::MakeSize(size.toFloor());
+ SkDebugf("floor width: %d height: %d\n", rect.width(), rect.height());
+#StdOut
+round width: 26 height: 36
+floor width: 25 height: 35
+##
+##
+
+#SeeAlso MakeWH MakeXYWH SkRect::Make SkRect::MakeIWH
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
+
+Returns constructed IRect set to (l, t, r, b). Does not sort input; Rect may
+result in fLeft greater than fRight, or fTop greater than fBottom.
+
+#Param l integer stored in fLeft ##
+#Param t integer stored in fTop ##
+#Param r integer stored in fRight ##
+#Param b integer stored in fBottom ##
+
+#Return bounds (l, t, r, b) ##
+
+#Example
+ SkIRect rect = SkIRect::MakeLTRB(5, 35, 15, 25);
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect.sort();
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut
+rect: 5, 35, 15, 25 isEmpty: true
+rect: 5, 25, 15, 35 isEmpty: false
+##
+##
+
+#SeeAlso MakeXYWH SkRect::MakeLTRB
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
+
+Returns constructed IRect set to:
+#Formula
+(x, y, x + w, y + h)
+##
+. Does not validate input;
+w or h may be negative.
+
+#Param x stored in fLeft ##
+#Param y stored in fTop ##
+#Param w added to x and stored in fRight ##
+#Param h added to y and stored in fBottom ##
+
+#Return bounds at (x, y) with width w and height h ##
+
+#Example
+ SkIRect rect = SkIRect::MakeXYWH(5, 35, -15, 25);
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect.sort();
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut
+rect: 5, 35, -10, 60 isEmpty: true
+rect: -10, 35, 5, 60 isEmpty: false
+##
+##
+
+#SeeAlso MakeLTRB SkRect::MakeXYWH
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method int left() const
+
+Returns left edge of IRect, if sorted.
+Call sort() to reverse fLeft and fRight if needed.
+
+#Return fLeft ##
+
+#Example
+ SkIRect unsorted = { 15, 5, 10, 25 };
+ SkDebugf("unsorted.fLeft: %d unsorted.left(): %d\n", unsorted.fLeft, unsorted.left());
+ SkIRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fLeft: %d sorted.left(): %d\n", sorted.fLeft, sorted.left());
+#StdOut
+unsorted.fLeft: 15 unsorted.left(): 15
+sorted.fLeft: 10 sorted.left(): 10
+##
+##
+
+#SeeAlso fLeft x() SkRect::left()
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method int top() const
+
+Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
+and sort() to reverse fTop and fBottom if needed.
+
+#Return fTop ##
+
+#Example
+ SkIRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted.fTop: %d unsorted.top(): %d\n", unsorted.fTop, unsorted.top());
+ SkIRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fTop: %d sorted.top(): %d\n", sorted.fTop, sorted.top());
+#StdOut
+unsorted.fTop: 25 unsorted.top(): 25
+sorted.fTop: 5 sorted.top(): 5
+##
+##
+
+#SeeAlso fTop y() SkRect::top()
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method int right() const
+
+Returns right edge of IRect, if sorted.
+Call sort() to reverse fLeft and fRight if needed.
+
+#Return fRight ##
+
+#Example
+ SkIRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted.fRight: %d unsorted.right(): %d\n", unsorted.fRight, unsorted.right());
+ SkIRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fRight: %d sorted.right(): %d\n", sorted.fRight, sorted.right());
+#StdOut
+unsorted.fRight: 10 unsorted.right(): 10
+sorted.fRight: 15 sorted.right(): 15
+##
+##
+
+#SeeAlso fRight SkRect::right()
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method int bottom() const
+
+Returns bottom edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
+and sort() to reverse fTop and fBottom if needed.
+
+#Return fBottom ##
+
+#Example
+ SkIRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted.fBottom: %d unsorted.bottom(): %d\n", unsorted.fBottom, unsorted.bottom());
+ SkIRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fBottom: %d sorted.bottom(): %d\n", sorted.fBottom, sorted.bottom());
+#StdOut
+unsorted.fBottom: 5 unsorted.bottom(): 5
+sorted.fBottom: 25 sorted.bottom(): 25
+##
+##
+
+#SeeAlso fBottom SkRect::bottom()
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method int x() const
+
+Returns left edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
+and sort() to reverse fLeft and fRight if needed.
+
+#Return fLeft ##
+
+#Example
+ SkIRect unsorted = { 15, 5, 10, 25 };
+ SkDebugf("unsorted.fLeft: %d unsorted.x(): %d\n", unsorted.fLeft, unsorted.x());
+ SkIRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fLeft: %d sorted.x(): %d\n", sorted.fLeft, sorted.x());
+#StdOut
+unsorted.fLeft: 15 unsorted.x(): 15
+sorted.fLeft: 10 sorted.x(): 10
+##
+##
+
+#SeeAlso fLeft left() y() SkRect::x()
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method int y() const
+
+Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
+and sort() to reverse fTop and fBottom if needed.
+
+#Return fTop ##
+
+#Example
+ SkIRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted.fTop: %d unsorted.y(): %d\n", unsorted.fTop, unsorted.y());
+ SkIRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fTop: %d sorted.y(): %d\n", sorted.fTop, sorted.y());
+#StdOut
+unsorted.fTop: 25 unsorted.y(): 25
+sorted.fTop: 5 sorted.y(): 5
+##
+##
+
+#SeeAlso fTop top() x() SkRect::y()
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method int width() const
+
+Returns span on the x-axis. This does not check if IRect is sorted, or if
+result fits in 32-bit signed integer; result may be negative.
+
+#Return fRight minus fLeft ##
+
+#Example
+ SkIRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted width: %d\n", unsorted.width());
+ SkIRect large = { -2147483647, 1, 2147483644, 2 };
+ SkDebugf("large width: %d\n", large.width());
+#StdOut
+unsorted width: -5
+large width: -5
+##
+##
+
+#SeeAlso height() SkRect::width()
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method int height() const
+
+Returns span on the y-axis. This does not check if IRect is sorted, or if
+result fits in 32-bit signed integer; result may be negative.
+
+#Return fBottom minus fTop ##
+
+#Example
+ SkIRect unsorted = { 15, 25, 10, 20 };
+ SkDebugf("unsorted height: %d\n", unsorted.height());
+ SkIRect large = { 1, -2147483647, 2, 2147483644 };
+ SkDebugf("large height: %d\n", large.height());
+#StdOut
+unsorted height: -5
+large height: -5
+##
+##
+
+#SeeAlso width() SkRect::height()
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method SkISize size() const
+
+Returns spans on the x-axis and y-axis. This does not check if IRect is sorted,
+or if result fits in 32-bit signed integer; result may be negative.
+
+#Return ISize (width, height) ##
+
+#Example
+ auto debugster = [](const char* prefix, const SkIRect& rect) -> void {
+ SkISize size = rect.size();
+ SkDebugf("%s ", prefix);
+ SkDebugf("rect: %d, %d, %d, %d ", rect.left(), rect.top(), rect.right(), rect.bottom());
+ SkDebugf("size: %d, %d\n", size.width(), size.height());
+ };
+ SkIRect rect = {20, 30, 40, 50};
+ debugster("original", rect);
+ rect.offset(20, 20);
+ debugster(" offset", rect);
+ rect.outset(20, 20);
+ debugster(" outset", rect);
+#StdOut
+original rect: 20, 30, 40, 50 size: 20, 20
+ offset rect: 40, 50, 60, 70 size: 20, 20
+ outset rect: 20, 30, 80, 90 size: 60, 60
+##
+##
+
+#SeeAlso height() width() MakeSize
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method int centerX() const
+
+Returns average of left edge and right edge. Result does not change if Rect
+is sorted. Result may be incorrect if Rect is far from the origin.
+
+Result is rounded down.
+
+#Return midpoint in x ##
+
+#Example
+#Description
+Dividing by two rounds towards zero. centerX uses a bit shift and rounds down.
+##
+ SkIRect tests[] = {{20, 30, 41, 51}, {-20, -30, -41, -51}, {-10, -10, 11, 11}};
+ for (auto rect : tests) {
+ SkDebugf("left: %3d right: %3d centerX: %3d ", rect.left(), rect.right(), rect.centerX());
+ SkDebugf("div2: %3d\n", (rect.left() + rect.right()) / 2);
+ }
+#StdOut
+left: 20 right: 41 centerX: 30 div2: 30
+left: -20 right: -41 centerX: -31 div2: -30
+left: -10 right: 11 centerX: 0 div2: 0
+##
+##
+
+#SeeAlso centerY SkRect::centerX
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method int centerY() const
+
+Returns average of top edge and bottom edge. Result does not change if Rect
+is sorted. Result may be incorrect if Rect is far from the origin.
+
+Result is rounded down.
+
+#Return midpoint in y ##
+
+#Example
+ SkIRect rect = { 0, 0, 2, 2 };
+ rect.offset(0x40000000, 0x40000000);
+ SkDebugf("left: %d right: %d centerX: %d ", rect.left(), rect.right(), rect.centerX());
+ SkDebugf("safe mid x: %d\n", rect.left() / 2 + rect.right() / 2);
+#StdOut
+left: 1073741824 right: 1073741826 centerX: -1073741823 safe mid x: 1073741825
+##
+##
+
+#SeeAlso centerX SkRect::centerY
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool isEmpty() const
+
+Returns true if fLeft is equal to or greater than fRight, or if fTop is equal
+to or greater than fBottom. Call sort() to reverse rectangles with negative
+width() or height().
+
+#Return true if width() or height() are zero or negative ##
+
+#Example
+ SkIRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
+ for (auto rect : tests) {
+ SkDebugf("rect: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "" : " not");
+ rect.sort();
+ SkDebugf("sorted: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "" : " not");
+ }
+#StdOut
+rect: {20, 40, 10, 50} is empty
+sorted: {10, 40, 20, 50} is not empty
+rect: {20, 40, 20, 50} is empty
+sorted: {20, 40, 20, 50} is empty
+##
+##
+
+#SeeAlso EmptyIRect MakeEmpty sort SkRect::isEmpty
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool isLargest() const
+
+Returns true if IRect encloses largest possible area.
+
+#Return true if equal to (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32) ##
+
+#Example
+#Description
+Note that the width is not negative, yet it cannot be represented as a 32-bit
+signed integer.
+##
+ SkIRect large = SkIRect::MakeLargest();
+ SkDebugf("large is largest: %s\n" ,large.isLargest() ? "true" : "false");
+ SkDebugf("large width %d\n", large.width());
+ SkDebugf("large is empty: %s\n", large.isEmpty() ? "true" : "false");
+#StdOut
+large is largest: true
+large width -2
+large is empty: false
+##
+##
+
+#SeeAlso MakeLargest SkRect::isLargest
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool operator==(const SkIRect& a, const SkIRect& b)
+
+Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are
+identical to corresponding members in b.
+
+#Param a IRect to compare ##
+#Param b IRect to compare ##
+
+#Return true if members are equal ##
+
+#Example
+ SkIRect test = {0, 0, 2, 2};
+ SkIRect sorted = test.makeSorted();
+ SkDebugf("test %c= sorted\n", test == sorted ? '=' : '!');
+#StdOut
+test == sorted
+##
+##
+
+#SeeAlso operator!=(const SkIRect& a, const SkIRect& b)
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool operator!=(const SkIRect& a, const SkIRect& b)
+
+Returns true if any member in a: fLeft, fTop, fRight, and fBottom; is not
+identical to the corresponding member in b.
+
+#Param a IRect to compare ##
+#Param b IRect to compare ##
+
+#Return true if members are not equal ##
+
+#Example
+ SkIRect test = {2, 2, 0, 0};
+ SkIRect sorted = test.makeSorted();
+ SkDebugf("test %c= sorted\n", test != sorted ? '!' : '=');
+#StdOut
+test != sorted
+##
+##
+
+#SeeAlso operator==(const SkIRect& a, const SkIRect& b)
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool is16Bit() const
+
+Returns true if all members: fLeft, fTop, fRight, and fBottom; values are
+equal to or larger than -32768 and equal to or smaller than 32767.
+
+#Return true if members fit in 16-bit word ##
+
+#Example
+ SkIRect tests[] = {{-32768, -32768, 32767, 32767}, {-32768, -32768, 32768, 32768}};
+ for (auto rect : tests) {
+ SkDebugf("{%d, %d, %d, %d} %s in 16 bits\n", rect.fLeft, rect.fTop, rect.fRight,
+ rect.fBottom, rect.is16Bit() ? "fits" : "does not fit");
+}
+#StdOut
+{-32768, -32768, 32767, 32767} fits in 16 bits
+{-32768, -32768, 32768, 32768} does not fit in 16 bits
+##
+##
+
+#SeeAlso SkTFitsIn
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method void setEmpty()
+
+Sets IRect to (0, 0, 0, 0).
+
+Many other rectangles are empty; if left is equal to or greater than right,
+or if top is equal to or greater than bottom. Setting all members to zero
+is a convenience, but does not designate a special empty rectangle.
+
+#Example
+ SkIRect rect = {3, 4, 1, 2};
+ for (int i = 0; i < 2; ++i) {
+ SkDebugf("rect: {%d, %d, %d, %d} is %s" "empty\n", rect.fLeft, rect.fTop,
+ rect.fRight, rect.fBottom, rect.isEmpty() ? "" : "not ");
+ rect.setEmpty();
+ }
+#StdOut
+rect: {3, 4, 1, 2} is empty
+rect: {0, 0, 0, 0} is empty
+##
+##
+
+#SeeAlso MakeEmpty SkRect::setEmpty
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method void set(int32_t left, int32_t top, int32_t right, int32_t bottom)
+
+Sets IRect to (left, top, right, bottom).
+left and right are not sorted; left is not necessarily less than right.
+top and bottom are not sorted; top is not necessarily less than bottom.
+
+#Param left assigned to fLeft ##
+#Param top assigned to fTop ##
+#Param right assigned to fRight ##
+#Param bottom assigned to fBottom ##
+
+#Example
+ SkIRect rect1 = {3, 4, 1, 2};
+ SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
+ SkIRect rect2;
+ rect2.set(3, 4, 1, 2);
+ SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
+#StdOut
+rect1: {3, 4, 1, 2}
+rect2: {3, 4, 1, 2}
+##
+##
+
+#SeeAlso setLTRB setXYWH SkRect::set
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom)
+
+Sets IRect to (left, top, right, bottom).
+left and right are not sorted; left is not necessarily less than right.
+top and bottom are not sorted; top is not necessarily less than bottom.
+
+#Param left stored in fLeft ##
+#Param top stored in fTop ##
+#Param right stored in fRight ##
+#Param bottom stored in fBottom ##
+
+#Example
+ SkIRect rect1 = {3, 4, 1, 2};
+ SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
+ SkIRect rect2;
+ rect2.setLTRB(3, 4, 1, 2);
+ SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
+#StdOut
+rect1: {3, 4, 1, 2}
+rect2: {3, 4, 1, 2}
+##
+##
+
+#SeeAlso set setXYWH SkRect::setLTRB
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method void setXYWH(int32_t x, int32_t y, int32_t width, int32_t height)
+
+Sets IRect to:
+#Formula
+(x, y, x + width, y + height)
+##
+. Does not validate input;
+width or height may be negative.
+
+#Param x stored in fLeft ##
+#Param y stored in fTop ##
+#Param width added to x and stored in fRight ##
+#Param height added to y and stored in fBottom ##
+
+#Example
+ SkIRect rect;
+ rect.setXYWH(5, 35, -15, 25);
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect.sort();
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut
+rect: 5, 35, -10, 60 isEmpty: true
+rect: -10, 35, 5, 60 isEmpty: false
+##
+##
+
+#SeeAlso MakeXYWH setLTRB set SkRect::setXYWH
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method void setLargest()
+
+Sets rectangle left and top to most negative value, and sets
+right and bottom to most positive value.
+
+#Example
+ SkIRect rect;
+ rect.setLargest();
+ SkDebugf("MakeLargest isLargest: %s\n", rect.isLargest() ? "true" : "false");
+ SkDebugf("MakeLargest isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+ rect.outset(1, 1);
+ SkDebugf("outset isLargest: %s\n", rect.isLargest() ? "true" : "false");
+ SkDebugf("outset isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+#StdOut
+MakeLargest isLargest: true
+MakeLargest isEmpty: false
+outset isLargest: false
+outset isEmpty: true
+##
+##
+
+#SeeAlso MakeLargest isLargest setLargestInverted SK_MinS32 SK_MaxS32
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method void setLargestInverted()
+#ToDo move this to private
+##
+
+Sets rectangle left and top to most positive value, and sets
+right and bottom to most negative value. This is used internally to
+flag that a condition is met, but otherwise has no special purpose.
+
+#NoExample
+##
+
+#SeeAlso setEmpty setLargest
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method SkIRect makeOffset(int32_t dx, int32_t dy) const
+
+Returns IRect offset by (dx, dy).
+
+If dx is negative, IRect returned is moved to the left.
+If dx is positive, IRect returned is moved to the right.
+If dy is negative, IRect returned is moved upward.
+If dy is positive, IRect returned is moved downward.
+
+#Param dx offset added to fLeft and fRight ##
+#Param dy offset added to fTop and fBottom ##
+
+#Return Rect offset in x or y, with original width and height ##
+
+#Example
+ SkIRect rect = { 10, 50, 20, 60 };
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect = rect.makeOffset(15, 32);
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut
+rect: 10, 50, 20, 60 isEmpty: false
+rect: 25, 82, 35, 92 isEmpty: false
+##
+##
+
+#SeeAlso offset() makeInset makeOutset SkRect::makeOffset
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method SkIRect makeInset(int32_t dx, int32_t dy) const
+
+Returns IRect, inset by (dx, dy).
+
+If dx is negative, IRect returned is wider.
+If dx is positive, IRect returned is narrower.
+If dy is negative, IRect returned is taller.
+If dy is positive, IRect returned is shorter.
+
+#Param dx offset added to fLeft and subtracted from fRight ##
+#Param dy offset added to fTop and subtracted from fBottom ##
+
+#Return Rect inset symmetrically left and right, top and bottom ##
+
+#Example
+ SkIRect rect = { 10, 50, 20, 60 };
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect = rect.makeInset(15, 32);
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut
+rect: 10, 50, 20, 60 isEmpty: false
+rect: 25, 82, 5, 28 isEmpty: true
+##
+##
+
+#SeeAlso inset() makeOffset makeOutset SkRect::makeInset
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method SkIRect makeOutset(int32_t dx, int32_t dy) const
+
+Returns IRect, outset by (dx, dy).
+
+If dx is negative, IRect returned is narrower.
+If dx is positive, IRect returned is wider.
+If dy is negative, IRect returned is shorter.
+If dy is positive, IRect returned is taller.
+
+#Param dx offset subtracted to fLeft and added from fRight ##
+#Param dy offset subtracted to fTop and added from fBottom ##
+
+#Return Rect outset symmetrically left and right, top and bottom ##
+
+#Example
+ SkIRect rect = { 10, 50, 20, 60 };
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect = rect.makeOutset(15, 32);
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut
+rect: 10, 50, 20, 60 isEmpty: false
+rect: -5, 18, 35, 92 isEmpty: false
+##
+##
+
+#SeeAlso outset() makeOffset makeInset SkRect::makeOutset
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method void offset(int32_t dx, int32_t dy)
+
+Offsets IRect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom.
+
+If dx is negative, moves IRect returned to the left.
+If dx is positive, moves IRect returned to the right.
+If dy is negative, moves IRect returned upward.
+If dy is positive, moves IRect returned downward.
+
+#Param dx offset added to fLeft and fRight ##
+#Param dy offset added to fTop and fBottom ##
+
+#Example
+ SkIRect rect = { 10, 14, 50, 73 };
+ rect.offset(5, 13);
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 15, 27, 55, 86
+##
+##
+
+#SeeAlso offsetTo makeOffset SkRect::offset
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method void offset(const SkIPoint& delta)
+
+Offsets IRect by adding delta.fX to fLeft, fRight; and by adding delta.fY to
+fTop, fBottom.
+
+If delta.fX is negative, moves IRect returned to the left.
+If delta.fX is positive, moves IRect returned to the right.
+If delta.fY is negative, moves IRect returned upward.
+If delta.fY is positive, moves IRect returned downward.
+
+#Param delta offset added to IRect ##
+
+#Example
+ SkIRect rect = { 10, 14, 50, 73 };
+ rect.offset({5, 13});
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 15, 27, 55, 86
+##
+##
+
+#SeeAlso offsetTo makeOffset SkRect::offset
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method void offsetTo(int32_t newX, int32_t newY)
+
+Offsets IRect so that fLeft equals newX, and fTop equals newY. width and height
+are unchanged.
+
+#Param newX stored in fLeft, preserving width() ##
+#Param newY stored in fTop, preserving height() ##
+
+#Example
+ SkIRect rect = { 10, 14, 50, 73 };
+ rect.offsetTo(15, 27);
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 15, 27, 55, 86
+##
+##
+
+#SeeAlso offset makeOffset setXYWH SkRect::offsetTo
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method void inset(int32_t dx, int32_t dy)
+
+Insets IRect by (dx,dy).
+
+If dx is positive, makes IRect narrower.
+If dx is negative, makes IRect wider.
+If dy is positive, makes IRect shorter.
+If dy is negative, makes IRect taller.
+
+#Param dx offset added to fLeft and subtracted from fRight ##
+#Param dy offset added to fTop and subtracted from fBottom ##
+
+#Example
+ SkIRect rect = { 10, 14, 50, 73 };
+ rect.inset(5, 13);
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 15, 27, 45, 60
+##
+##
+
+#SeeAlso outset makeInset SkRect::inset
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method void outset(int32_t dx, int32_t dy)
+
+Outsets IRect by (dx, dy).
+
+If dx is positive, makes Rect wider.
+If dx is negative, makes Rect narrower.
+If dy is positive, makes Rect taller.
+If dy is negative, makes Rect shorter.
+
+#Param dx subtracted to fLeft and added from fRight ##
+#Param dy subtracted to fTop and added from fBottom ##
+
+#Example
+ SkIRect rect = { 10, 14, 50, 73 };
+ rect.outset(5, 13);
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 5, 1, 55, 86
+##
+##
+
+#SeeAlso inset makeOutset SkRect::outset
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool quickReject(int l, int t, int r, int b) const
+
+Constructs IRect (l, t, r, b) and returns true if constructed IRect does not
+intersect IRect. Does not check to see if construction or IRect is empty.
+
+Is implemented with short circuit logic so that true can be returned after
+a single compare.
+
+#Param l x minimum of constructed Rect ##
+#Param t y minimum of constructed Rect ##
+#Param r x maximum of constructed Rect ##
+#Param b y maximum of constructed Rect ##
+
+#Return true if construction and IRect have no area in common ##
+
+#Example
+#Description
+quickReject is the complement of Intersects.
+##
+ const SkIRect rect = {7, 11, 13, 17};
+ const int32_t* r = &rect.fLeft;
+ const SkIRect tests[] = { {13, 11, 15, 17}, { 7, 7, 13, 11 }, { 12, 16, 14, 18 } };
+ for (auto& test : tests) {
+ const int32_t* t = &test.fLeft;
+ SkDebugf("rect (%d, %d, %d, %d) test(%d, %d, %d, %d) quickReject %s; intersects %s\n",
+ r[0], r[1], r[2], r[3], t[0], t[1], t[2], t[3],
+ rect.quickReject(t[0], t[1], t[2], t[3]) ? "true" : "false",
+ SkIRect::Intersects(rect, test) ? "true" : "false");
+ }
+#StdOut
+rect (7, 11, 13, 17) test(13, 11, 15, 17) quickReject true; intersects false
+rect (7, 11, 13, 17) test(7, 7, 13, 11) quickReject true; intersects false
+rect (7, 11, 13, 17) test(12, 16, 14, 18) quickReject false; intersects true
+##
+##
+
+#SeeAlso Intersects
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool contains(int32_t x, int32_t y) const
+
+Returns true if:
+#Formula
+fLeft <= x < fRight && fTop <= y < fBottom
+##
+.
+Returns false if Rect is empty.
+
+Considers input to describe constructed IRect:
+#Formula
+(x, y, x + 1, y + 1)
+##
+and
+returns true if constructed area is completely enclosed by IRect area.
+
+#Param x test Point x-coordinate ##
+#Param y test Point y-coordinate ##
+
+#Return true if (x, y) is inside IRect ##
+
+#Example
+ SkIRect rect = { 30, 50, 40, 60 };
+ SkIPoint pts[] = { { 30, 50}, { 40, 50}, { 30, 60} };
+ for (auto pt : pts) {
+ SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d)\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom(),
+ rect.contains(pt.x(), pt.y()) ? "contains" : "does not contain", pt.x(), pt.y());
+ }
+#StdOut
+rect: (30, 50, 40, 60) contains (30, 50)
+rect: (30, 50, 40, 60) does not contain (40, 50)
+rect: (30, 50, 40, 60) does not contain (30, 60)
+##
+##
+
+#SeeAlso containsNoEmptyCheck SkRect::contains
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool contains(int32_t left, int32_t top, int32_t right, int32_t bottom) const
+
+Constructs Rect to intersect from (left, top, right, bottom). Does not sort
+construction.
+
+Returns true if Rect contains construction.
+Returns false if Rect is empty or construction is empty.
+
+#Param left x minimum of constructed Rect ##
+#Param top y minimum of constructed Rect ##
+#Param right x maximum of constructed Rect ##
+#Param bottom y maximum of constructed Rect ##
+
+#Return true if all sides of IRect are outside construction ##
+
+#Example
+ SkIRect rect = { 30, 50, 40, 60 };
+ SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
+ for (auto contained : tests) {
+ bool success = rect.contains(
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom(),
+ success ? "contains" : "does not contain",
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ }
+#StdOut
+rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
+rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
+rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
+##
+##
+
+#SeeAlso containsNoEmptyCheck SkRect::contains
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool contains(const SkIRect& r) const
+
+Returns true if Rect contains r.
+Returns false if Rect is empty or r is empty.
+
+Rect contains r when Rect area completely includes r area.
+
+#Param r IRect contained ##
+
+#Return true if all sides of IRect are outside r ##
+
+#Example
+ SkIRect rect = { 30, 50, 40, 60 };
+ SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
+ for (auto contained : tests) {
+ SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom(),
+ rect.contains(contained) ? "contains" : "does not contain",
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ }
+#StdOut
+rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
+rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
+rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
+##
+##
+
+#SeeAlso containsNoEmptyCheck SkRect::contains
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool contains(const SkRect& r) const
+
+Returns true if Rect contains r.
+Returns false if Rect is empty or r is empty.
+
+Rect contains r when Rect area completely includes r area.
+
+#Param r Rect contained ##
+
+#Return true if all sides of IRect are outside r ##
+
+#Example
+ SkIRect rect = { 30, 50, 40, 60 };
+ SkRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
+ for (auto contained : tests) {
+ SkDebugf("rect: (%d, %d, %d, %d) %s (%g, %g, %g, %g)\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom(),
+ rect.contains(contained) ? "contains" : "does not contain",
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ }
+#StdOut
+rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
+rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
+rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
+##
+##
+
+#SeeAlso containsNoEmptyCheck SkRect::contains
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool containsNoEmptyCheck(int32_t left, int32_t top,
+ int32_t right, int32_t bottom) const
+
+Constructs IRect from (left, top, right, bottom). Does not sort
+construction.
+
+Returns true if Rect contains construction.
+Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined.
+
+Return is undefined if Rect is empty or construction is empty.
+
+#Param left x minimum of constructed Rect ##
+#Param top y minimum of constructed Rect ##
+#Param right x maximum of constructed Rect ##
+#Param bottom y maximum of constructed Rect ##
+
+#Return true if all sides of IRect are outside construction ##
+
+#Example
+ SkIRect rect = { 30, 50, 40, 60 };
+ SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
+ for (auto contained : tests) {
+ bool success = rect.containsNoEmptyCheck(
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom(),
+ success ? "contains" : "does not contain",
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ }
+#StdOut
+rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
+rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
+rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
+##
+##
+
+#SeeAlso contains SkRect::contains
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool containsNoEmptyCheck(const SkIRect& r) const
+
+Returns true if Rect contains construction.
+Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined.
+
+Return is undefined if Rect is empty or construction is empty.
+
+#Param r Rect contained ##
+
+#Return true if all sides of IRect are outside r ##
+
+#Example
+ SkIRect rect = { 30, 50, 40, 60 };
+ SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
+ for (auto contained : tests) {
+ SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom(),
+ rect.containsNoEmptyCheck(contained) ? "contains" : "does not contain",
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ }
+#StdOut
+rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
+rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
+rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
+##
+##
+
+#SeeAlso contains SkRect::contains
+
+##
+
+#Topic Intersection
+
+IRects intersect when they enclose a common area. To intersect, each of the pair
+must describe area; fLeft is less than fRight, and fTop is less than fBottom;
+empty() returns false. The intersection of IRect pair can be described by:
+#Formula
+(max(a.fLeft, b.fLeft), max(a.fTop, b.fTop),
+ min(a.fRight, b.fRight), min(a.fBottom, b.fBottom))
+##
+The intersection is only meaningful if the resulting IRect is not empty and
+describes an area: fLeft is less than fRight, and fTop is less than fBottom.
+
+# ------------------------------------------------------------------------------
+
+#Method bool intersect(const SkIRect& r)
+
+Returns true if IRect intersects r, and sets IRect to intersection.
+Returns false if IRect does not intersect r, and leaves IRect unchanged.
+
+Returns false if either r or IRect is empty, leaving IRect unchanged.
+
+#Param r limit of result ##
+
+#Return true if r and Rect have area in common ##
+
+#Example
+#Description
+Two SkDebugf calls are required. If the calls are combined, their arguments
+may not be evaluated in left to right order: the printed intersection may
+be before or after the call to intersect.
+##
+ SkIRect leftRect = { 10, 40, 50, 80 };
+ SkIRect rightRect = { 30, 60, 70, 90 };
+ SkDebugf("%s intersection: ", leftRect.intersect(rightRect) ? "" : "no ");
+ SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
+ leftRect.right(), leftRect.bottom());
+#StdOut
+ intersection: 30, 60, 50, 80
+##
+##
+
+#SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& a, const SkIRect& b)
+
+Returns true if a intersects b, and sets IRect to intersection.
+Returns false if a does not intersect b, and leaves IRect unchanged.
+
+Returns false if either a or b is empty, leaving IRect unchanged.
+
+#Param a IRect to intersect ##
+#Param b IRect to intersect ##
+
+#Return true if a and b have area in common ##
+
+#Example
+ SkIRect result;
+ bool intersected = result.intersect({ 10, 40, 50, 80 }, { 30, 60, 70, 90 });
+ SkDebugf("%s intersection: %d, %d, %d, %d\n", intersected ? "" : "no ",
+ result.left(), result.top(), result.right(), result.bottom());
+#StdOut
+ intersection: 30, 60, 50, 80
+##
+##
+
+#SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool SK_WARN_UNUSED_RESULT intersectNoEmptyCheck(const SkIRect& a, const SkIRect& b)
+
+Returns true if a intersects b, and sets IRect to intersection.
+Returns false if a does not intersect b, and leaves IRect unchanged.
+
+Asserts if either a or b is empty, and if SK_DEBUG is defined.
+
+#Param a IRect to intersect ##
+#Param b IRect to intersect ##
+
+#Return true if a and b have area in common ##
+
+#Example
+ SkIRect result;
+ bool intersected = result.intersectNoEmptyCheck({ 10, 40, 50, 80 }, { 30, 60, 70, 90 });
+ SkDebugf("intersection: %d, %d, %d, %d\n",
+ result.left(), result.top(), result.right(), result.bottom());
+#StdOut
+ intersection: 30, 60, 50, 80
+##
+##
+
+#SeeAlso Intersects intersect join SkRect::intersect
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method bool intersect(int32_t left, int32_t top, int32_t right, int32_t bottom)
+
+Constructs IRect to intersect from (left, top, right, bottom). Does not sort
+construction.
+
+Returns true if IRect intersects construction, and sets IRect to intersection.
+Returns false if IRect does not intersect construction, and leaves IRect unchanged.
+
+Returns false if either construction or IRect is empty, leaving IRect unchanged.
+
+#Param left x minimum of constructed IRect ##
+#Param top y minimum of constructed IRect ##
+#Param right x maximum of constructed IRect ##
+#Param bottom y maximum of constructed IRect ##
+
+#Return true if construction and IRect have area in common ##
+
+#Example
+#Description
+Two SkDebugf calls are required. If the calls are combined, their arguments
+may not be evaluated in left to right order: the printed intersection may
+be before or after the call to intersect.
+##
+ SkIRect leftRect = { 10, 40, 50, 80 };
+ SkDebugf("%s intersection: ", leftRect.intersect(30, 60, 70, 90) ? "" : "no ");
+ SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
+ leftRect.right(), leftRect.bottom());
+#StdOut
+ intersection: 30, 60, 50, 80
+##
+##
+
+#SeeAlso intersectNoEmptyCheck Intersects join SkRect::intersect
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method static bool Intersects(const SkIRect& a, const SkIRect& b)
+
+Returns true if a intersects b.
+Returns false if either a or b is empty, or do not intersect.
+
+#Param a IRect to intersect ##
+#Param b IRect to intersect ##
+
+#Return true if a and b have area in common ##
+
+#Example
+ SkDebugf("%s intersection", SkIRect::Intersects({10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
+#StdOut
+ intersection
+##
+##
+
+#SeeAlso IntersectsNoEmptyCheck intersect SkRect::intersect
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method static bool IntersectsNoEmptyCheck(const SkIRect& a, const SkIRect& b)
+
+Returns true if a intersects b.
+Asserts if either a or b is empty, and if SK_DEBUG is defined.
+
+#Param a IRect to intersect ##
+#Param b IRect to intersect ##
+
+#Return true if a and b have area in common ##
+
+#Example
+ SkDebugf("%s intersection", SkIRect::IntersectsNoEmptyCheck(
+ {10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
+#StdOut
+ intersection
+##
+##
+
+#SeeAlso Intersects intersect SkRect::intersect
+
+##
+
+#Topic Intersection ##
+
+# ------------------------------------------------------------------------------
+
+#Method void join(int32_t left, int32_t top, int32_t right, int32_t bottom)
+
+Constructs Rect to intersect from (left, top, right, bottom). Does not sort
+construction.
+
+Sets Rect to the union of itself and the construction.
+
+Has no effect if construction is empty. Otherwise, if Rect is empty, sets
+Rect to construction.
+
+#Param left x minimum of constructed Rect ##
+#Param top y minimum of constructed Rect ##
+#Param right x maximum of constructed Rect ##
+#Param bottom y maximum of constructed Rect ##
+
+#Example
+ SkIRect rect = { 10, 20, 15, 25};
+ rect.join(50, 60, 55, 65);
+ SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+ join: 10, 20, 55, 65
+##
+##
+
+#SeeAlso set SkRect::join
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method void join(const SkIRect& r)
+
+Sets Rect to the union of itself and r.
+
+Has no effect if r is empty. Otherwise, if Rect is empty, sets Rect to r.
+
+#Param r expansion Rect ##
+
+#Example
+ SkIRect rect = { 10, 20, 15, 25};
+ rect.join({50, 60, 55, 65});
+ SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+ join: 10, 20, 55, 65
+##
+##
+
+#SeeAlso set SkRect::join
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method void sort()
+
+Swaps fLeft and fRight if fLeft is greater than fRight; and swaps
+fTop and fBottom if fTop is greater than fBottom. Result may be empty,
+and width() and height() will be zero or positive.
+
+#Example
+ SkIRect rect = { 30, 50, 20, 10 };
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+ rect.sort();
+ SkDebugf("sorted: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 30, 50, 20, 10
+sorted: 20, 10, 30, 50
+##
+##
+
+#SeeAlso makeSorted SkRect::sort
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method SkIRect makeSorted() const
+
+Returns Rect with fLeft and fRight swapped if fLeft is greater than fRight; and
+with fTop and fBottom swapped if fTop is greater than fBottom. Result may be empty;
+and width() and height() will be zero or positive.
+
+#Return sorted IRect ##
+
+#Example
+ SkIRect rect = { 30, 50, 20, 10 };
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+ SkIRect sort = rect.makeSorted();
+ SkDebugf("sorted: %d, %d, %d, %d\n", sort.fLeft, sort.fTop, sort.fRight, sort.fBottom);
+#StdOut
+rect: 30, 50, 20, 10
+sorted: 20, 10, 30, 50
+##
+##
+
+#SeeAlso sort SkRect::makeSorted
+
+##
+
+# ------------------------------------------------------------------------------
+
+#Method static const SkIRect& SK_WARN_UNUSED_RESULT EmptyIRect()
+
+Returns a reference to immutable empty IRect, set to (0, 0, 0, 0).
+
+#Return global IRect set to all zeroes ##
+
+#Example
+ const SkIRect& rect = SkIRect::EmptyIRect();
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 0, 0, 0, 0
+##
+##
+
+#SeeAlso MakeEmpty
+
+##
+
+#Struct SkIRect ##
+
+#Topic IRect ##
diff --git a/docs/SkImage_Reference.bmh b/docs/SkImage_Reference.bmh
index d0cb2fa0d8..b0e319291d 100644
--- a/docs/SkImage_Reference.bmh
+++ b/docs/SkImage_Reference.bmh
@@ -146,7 +146,16 @@ pixels is not nullptr, and contains enough data for Image.
#Return Image sharing pixels, or nullptr ##
#Example
-// incomplete
+#Image 3
+ size_t rowBytes = image->width() * SkColorTypeBytesPerPixel(kRGBA_8888_SkColorType);
+ sk_sp<SkData> data = SkData::MakeUninitialized(rowBytes * image->height());
+ SkImageInfo dstInfo = SkImageInfo::MakeN32(image->width(), image->height(),
+ kPremul_SkAlphaType);
+ image->readPixels(dstInfo, data->writable_data(), rowBytes, 0, 0, SkImage::kAllow_CachingHint);
+ sk_sp<SkImage> raw = SkImage::MakeRasterData(dstInfo.makeColorType(kRGBA_8888_SkColorType),
+ data, rowBytes);
+ canvas->drawImage(image, 0, 0);
+ canvas->drawImage(raw.get(), 128, 0);
##
#SeeAlso MakeRasterCopy MakeFromGenerator
@@ -176,10 +185,14 @@ provided by caller when Image is created, and may be nullptr.
RasterReleaseProc rasterReleaseProc,
ReleaseContext releaseContext)
-Creates Image from pixmap, sharing pixmap pixels. Pixels must remain valid and
+Creates Image from pixmap, sharing Pixmap pixels. Pixels must remain valid and
unchanged until rasterReleaseProc is called. rasterReleaseProc is passed
releaseContext when Image is deleted or no longer refers to pixmap pixels.
+Pass nullptr for rasterReleaseProc to share Pixmap without requiring a callback
+when Image is released. Pass nullptr for releaseContext if rasterReleaseProc
+does not require state.
+
Image is returned if pixmap is valid. Valid Pixmap parameters include:
dimensions are greater than zero;
each dimension fits in 29 bits;
@@ -188,13 +201,32 @@ row bytes are large enough to hold one row of pixels;
pixel address is not nullptr.
#Param pixmap Image_Info, pixel address, and row bytes ##
-#Param rasterReleaseProc function called when pixels can be released ##
-#Param releaseContext state passed to rasterReleaseProc ##
+#Param rasterReleaseProc function called when pixels can be released; or nullptr ##
+#Param releaseContext state passed to rasterReleaseProc; or nullptr ##
-#Return incomplete ##
+#Return Image sharing pixmap ##
#Example
-// incomplete
+#Function
+static void releaseProc(const void* pixels, SkImage::ReleaseContext context) {
+ int* countPtr = static_cast<int*>(context);
+ *countPtr += 1;
+}
+##
+
+void draw(SkCanvas* canvas) {
+ SkColor color = 0;
+ SkPixmap pixmap(SkImageInfo::MakeN32(1, 1, kPremul_SkAlphaType), &color, 4);
+ int releaseCount = 0;
+ sk_sp<SkImage> image(SkImage::MakeFromRaster(pixmap, releaseProc, &releaseCount));
+ SkDebugf("before reset: %d\n", releaseCount);
+ image.reset();
+ SkDebugf("after reset: %d\n", releaseCount);
+}
+#StdOut
+before reset: 0
+after reset: 1
+##
##
#SeeAlso MakeRasterCopy MakeRasterData MakeFromGenerator RasterReleaseProc ReleaseContext
@@ -221,7 +253,29 @@ pixel address is not nullptr.
#Return created Image, or nullptr ##
#Example
-// incomplete
+#Description
+The first Bitmap is shared; writing to the pixel memory changes the first
+Image.
+The second Bitmap is marked immutable, and is copied; writing to the pixel
+memory does not alter the second Image.
+##
+#Height 50
+ uint8_t storage[][5] = {{ 0xCA, 0xDA, 0xCA, 0xC9, 0xA3 },
+ { 0xAC, 0xA8, 0x89, 0xA7, 0x87 },
+ { 0x9B, 0xB5, 0xE5, 0x95, 0x46 },
+ { 0x90, 0x81, 0xC5, 0x71, 0x33 },
+ { 0x75, 0x55, 0x44, 0x40, 0x30 }};
+ SkImageInfo imageInfo = SkImageInfo::Make(5, 5, kGray_8_SkColorType, kOpaque_SkAlphaType);
+ SkPixmap pixmap(imageInfo, storage[0], sizeof(storage) / 5);
+ SkBitmap bitmap;
+ bitmap.installPixels(pixmap);
+ sk_sp<SkImage> image1 = SkImage::MakeFromBitmap(bitmap);
+ bitmap.setImmutable();
+ sk_sp<SkImage> image2 = SkImage::MakeFromBitmap(bitmap);
+ *pixmap.writable_addr8(2, 2) = 0x00;
+ canvas->scale(10, 10);
+ canvas->drawImage(image1, 0, 0);
+ canvas->drawImage(image2, 10, 0);
##
#SeeAlso MakeFromRaster MakeRasterCopy MakeFromGenerator MakeRasterData
@@ -233,12 +287,14 @@ pixel address is not nullptr.
#Method static sk_sp<SkImage> MakeFromGenerator(std::unique_ptr<SkImageGenerator> imageGenerator,
const SkIRect* subset = nullptr)
-Creates Image based from imageGenerator.
-Takes ownership of imageGenerator; it may not be used elsewhere.
-If subset is not nullptr, it must be contained within imageGenerator data bounds.
+Creates Image from data returned by imageGenerator. Generated data is owned by Image and may not
+be shared or accessed.
-Image is returned if generator data is valid. Valid data parameters vary
-by type of data and platform.
+subset allows selecting a portion of the full image. Pass nullptr to select the entire image;
+otherwise, subset must be contained by image bounds.
+
+Image is returned if generator data is valid. Valid data parameters vary by type of data
+and platform.
imageGenerator may wrap Picture data, codec data, or custom data.
@@ -248,7 +304,16 @@ imageGenerator may wrap Picture data, codec data, or custom data.
#Return created Image, or nullptr ##
#Example
-// incomplete
+#Description
+The generator returning Picture cannot be shared; std::move transfers ownership to generated Image.
+##
+ SkPictureRecorder recorder;
+ recorder.beginRecording(100, 100)->drawColor(SK_ColorRED);
+ auto picture = recorder.finishRecordingAsPicture();
+ auto gen = SkImageGenerator::MakeFromPicture({100, 100}, picture, nullptr, nullptr,
+ SkImage::BitDepth::kU8, SkColorSpace::MakeSRGB());
+ sk_sp<SkImage> image = SkImage::MakeFromGenerator(std::move(gen));
+ canvas->drawImage(image, 0, 0);
##
#SeeAlso MakeFromEncoded
@@ -260,7 +325,8 @@ imageGenerator may wrap Picture data, codec data, or custom data.
#Method static sk_sp<SkImage> MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect* subset = nullptr)
Creates Image from encoded data.
-If a subset is not nullptr, it must be contained within encoded data bounds.
+subset allows selecting a portion of the full image. Pass nullptr to select the entire image;
+otherwise, subset must be contained by image bounds.
Image is returned if format of the encoded data is recognized and supported.
Recognized formats vary by platfrom.
@@ -270,8 +336,11 @@ Recognized formats vary by platfrom.
#Return created Image, or nullptr ##
-#Example
-// incomplete
+#Bug 7343
+Waiting on fiddle to support returning image as SkData
+##
+
+#NoExample
##
#SeeAlso MakeFromGenerator
@@ -307,7 +376,24 @@ Recognized formats vary by GPU back-end.
#Return created Image, or nullptr ##
#Example
-// incomplete
+#Image 3
+#Platform gpu
+#Height 128
+#Description
+A back-end texture has been created and uploaded to the GPU outside of this example.
+##
+GrContext* context = canvas->getGrContext();
+if (!context) {
+ return;
+}
+canvas->scale(.25f, .25f);
+int x = 0;
+for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin } ) {
+ sk_sp<SkImage> image = SkImage::MakeFromTexture(canvas->getGrContext(), backEndTexture,
+ origin, kOpaque_SkAlphaType, nullptr);
+ canvas->drawImage(image, x, 0);
+x += 512;
+}
##
#SeeAlso MakeFromAdoptedTexture SkSurface::MakeFromBackendTexture
@@ -343,8 +429,26 @@ Recognized formats vary by GPU back-end.
#Return created Image, or nullptr ##
+#ToDo
+This doesn't do anything clever with TextureReleaseProc because it may not get called
+within the lifetime of the example
+##
+
#Example
-// incomplete
+GrContext* context = canvas->getGrContext();
+if (!context) {
+ return;
+}
+auto debugster = [](SkImage::ReleaseContext context) -> void {
+ *((int *) context) += 128;
+};
+int x = 0;
+for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin } ) {
+ sk_sp<SkImage> image = SkImage::MakeFromTexture(canvas->getGrContext(), backEndTexture,
+ origin, kOpaque_SkAlphaType, nullptr, debugster, &x);
+ canvas->drawImage(image, x, 0);
+ x += 128;
+}
##
#SeeAlso MakeFromAdoptedTexture SkSurface::MakeFromBackendTexture
diff --git a/docs/SkPaint_Reference.bmh b/docs/SkPaint_Reference.bmh
index 099fe65f50..aff9a7146d 100644
--- a/docs/SkPaint_Reference.bmh
+++ b/docs/SkPaint_Reference.bmh
@@ -1,4 +1,4 @@
-#Topic Paint
+#Topic Paint
#Alias Paint_Reference
#Class SkPaint
@@ -1906,8 +1906,8 @@ on the output device, which may have more or fewer bits, and may have a differen
Unpremultiplied, packing 8-bit components for Alpha, Red, Blue, and Green.
#Param color Unpremultiplied Color_ARGB ##
-
- #Example
+
+ #Example
SkPaint green1, green2;
unsigned a = 255;
unsigned r = 0;
@@ -2598,7 +2598,7 @@ void draw(SkCanvas* canvas) {
#Method Join getStrokeJoin() const
- The geometry drawn at the corners of strokes.
+ The geometry drawn at the corners of strokes.
#Return one of: kMiter_Join, kRound_Join, kBevel_Join ##
@@ -2617,7 +2617,7 @@ void draw(SkCanvas* canvas) {
#Method void setStrokeJoin(Join join)
- The geometry drawn at the corners of strokes.
+ The geometry drawn at the corners of strokes.
#Param join one of: kMiter_Join, kRound_Join, kBevel_Join;
otherwise, has no effect
@@ -4448,7 +4448,7 @@ void draw(SkCanvas* canvas) {
dimensions required by stroking and Path_Effect.
Returns the same result as getFontMetrics.
- #Return recommended spacing between lines ##
+ #Return recommended spacing between lines ##
#Example
SkPaint paint;
diff --git a/docs/SkPoint_Reference.bmh b/docs/SkPoint_Reference.bmh
index bac5186f3b..6eeb1a5703 100644
--- a/docs/SkPoint_Reference.bmh
+++ b/docs/SkPoint_Reference.bmh
@@ -152,12 +152,12 @@ Returns true if fX and fY are both zero.
#Return true if fX is zero and fY is zero ##
#Example
-SkPoint pt = { 0.f, -0.f};
-SkDebugf("pt.fX=%c%g pt.fY=%c%g\n", std::signbit(pt.fX) ? '-' : '+', fabsf(pt.fX),
- std::signbit(pt.fY) ? '-' : '+', fabsf(pt.fY));
+SkPoint pt = { 0.f, -0.f};
+SkDebugf("pt.fX=%c%g pt.fY=%c%g\n", std::signbit(pt.fX) ? '-' : '+', fabsf(pt.fX),
+ std::signbit(pt.fY) ? '-' : '+', fabsf(pt.fY));
SkDebugf("pt.isZero() == %s\n", pt.isZero() ? "true" : "false");
#StdOut
-pt.fX=+0 pt.fY=-0
+pt.fX=+0 pt.fY=-0
pt.isZero() == true
##
##
@@ -202,8 +202,8 @@ casts x and y to avoid the error.
#Param y new value for fY ##
#Example
-SkPoint pt1, pt2 = { SK_MinS16, SK_MaxS16 };
-pt1.iset(SK_MinS16, SK_MaxS16);
+SkPoint pt1, pt2 = { SK_MinS16, SK_MaxS16 };
+pt1.iset(SK_MinS16, SK_MaxS16);
SkDebugf("pt1 %c= pt2\n", pt1 == pt2 ? '=' : '!');
##
@@ -224,13 +224,13 @@ This safely casts p.fX and p.fY to avoid the error.
#Param p IPoint members promoted to SkScalar ##
#Example
-SkIPoint iPt = { SK_MinS32, SK_MaxS32 };
-SkPoint fPt;
-fPt.iset(iPt);
+SkIPoint iPt = { SK_MinS32, SK_MaxS32 };
+SkPoint fPt;
+fPt.iset(iPt);
SkDebugf("iPt: %d, %d\n", iPt.fX, iPt.fY);
SkDebugf("fPt: %g, %g\n", fPt.fX, fPt.fY);
#StdOut
-iPt: -2147483647, 2147483647
+iPt: -2147483647, 2147483647
fPt: -2.14748e+09, 2.14748e+09
##
##
@@ -248,18 +248,18 @@ Sets fX to absolute value of pt.fX; and fY to absolute value of pt.fY.
#Param pt members providing magnitude for fX and fY ##
#Example
-SkPoint test[] = { {0.f, -0.f}, {-1, -2},
- { SK_ScalarInfinity, SK_ScalarNegativeInfinity },
- { SK_ScalarNaN, -SK_ScalarNaN } };
-for (const SkPoint& pt : test) {
- SkPoint absPt;
- absPt.setAbs(pt);
- SkDebugf("pt: %g, %g abs: %g, %g\n", pt.fX, pt.fY, absPt.fX, absPt.fY);
+SkPoint test[] = { {0.f, -0.f}, {-1, -2},
+ { SK_ScalarInfinity, SK_ScalarNegativeInfinity },
+ { SK_ScalarNaN, -SK_ScalarNaN } };
+for (const SkPoint& pt : test) {
+ SkPoint absPt;
+ absPt.setAbs(pt);
+ SkDebugf("pt: %g, %g abs: %g, %g\n", pt.fX, pt.fY, absPt.fX, absPt.fY);
}
#StdOut
-pt: 0, -0 abs: 0, 0
-pt: -1, -2 abs: 1, 2
-pt: inf, -inf abs: inf, inf
+pt: 0, -0 abs: 0, 0
+pt: -1, -2 abs: 1, 2
+pt: inf, -inf abs: inf, inf
pt: nan, -nan abs: nan, nan
##
##
@@ -279,17 +279,17 @@ Adds offset to each Point in points array with count entries.
#Param offset Vector added to points ##
#Example
- SkPaint paint;
- paint.setAntiAlias(true);
- SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
- { 6, 4 }, { 7, 5 }, { 5, 7 },
- { 4, 6 }, { 3, 7 }, { 1, 5 },
- { 2, 4 }, { 1, 3 }, { 3, 1 } };
- canvas->scale(30, 15);
- paint.setStyle(SkPaint::kStroke_Style);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
- SkPoint::Offset(points, SK_ARRAY_COUNT(points), { 1, 9 } );
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
+ { 6, 4 }, { 7, 5 }, { 5, 7 },
+ { 4, 6 }, { 3, 7 }, { 1, 5 },
+ { 2, 4 }, { 1, 3 }, { 3, 1 } };
+ canvas->scale(30, 15);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ SkPoint::Offset(points, SK_ARRAY_COUNT(points), { 1, 9 } );
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
##
#SeeAlso offset operator+=(const SkVector& v)
@@ -308,17 +308,17 @@ Adds offset (dx, dy) to each Point in points array of length count.
#Param dy added to fY in points ##
#Example
- SkPaint paint;
- paint.setAntiAlias(true);
- SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
- { 6, 4 }, { 7, 5 }, { 5, 7 },
- { 4, 6 }, { 3, 7 }, { 1, 5 },
- { 2, 4 }, { 1, 3 }, { 3, 1 } };
- canvas->scale(30, 15);
- paint.setStyle(SkPaint::kStroke_Style);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
- SkPoint::Offset(points, SK_ARRAY_COUNT(points), 1, 9);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
+ { 6, 4 }, { 7, 5 }, { 5, 7 },
+ { 4, 6 }, { 3, 7 }, { 1, 5 },
+ { 2, 4 }, { 1, 3 }, { 3, 1 } };
+ canvas->scale(30, 15);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ SkPoint::Offset(points, SK_ARRAY_COUNT(points), 1, 9);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
##
#SeeAlso offset operator+=(const SkVector& v)
@@ -336,18 +336,18 @@ Adds offset (dx, dy) to Point.
#Example
#Height 128
- SkPaint paint;
- paint.setAntiAlias(true);
- SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
- { 6, 4 }, { 7, 5 }, { 5, 7 },
- { 4, 6 }, { 3, 7 }, { 1, 5 },
- { 2, 4 }, { 1, 3 }, { 3, 1 } };
- canvas->scale(30, 15);
- paint.setStyle(SkPaint::kStroke_Style);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
- points[1].offset(1, 1);
- paint.setColor(SK_ColorRED);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
+ { 6, 4 }, { 7, 5 }, { 5, 7 },
+ { 4, 6 }, { 3, 7 }, { 1, 5 },
+ { 2, 4 }, { 1, 3 }, { 3, 1 } };
+ canvas->scale(30, 15);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ points[1].offset(1, 1);
+ paint.setColor(SK_ColorRED);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
##
#SeeAlso Offset operator+=(const SkVector& v)
@@ -369,19 +369,19 @@ sqrt(fX * fX + fY * fY)
#Example
#Height 192
- SkPaint paint;
- paint.setAntiAlias(true);
- const SkPoint points[] = { { 90, 30 }, { 120, 150 }, { 150, 30 }, { 210, 90 } };
- const SkPoint origin = {30, 140};
- for (auto point : points) {
- canvas->drawLine(origin, point, paint);
- SkAutoCanvasRestore acr(canvas, true);
- SkScalar angle = SkScalarATan2((point.fY - origin.fY), point.fX - origin.fX);
- canvas->rotate(angle * 180 / SK_ScalarPI, origin.fX, origin.fY);
- SkString length("length = ");
- length.appendScalar(point.length());
- canvas->drawString(length, origin.fX + 25, origin.fY - 4, paint);
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ const SkPoint points[] = { { 90, 30 }, { 120, 150 }, { 150, 30 }, { 210, 90 } };
+ const SkPoint origin = {30, 140};
+ for (auto point : points) {
+ canvas->drawLine(origin, point, paint);
+ SkAutoCanvasRestore acr(canvas, true);
+ SkScalar angle = SkScalarATan2((point.fY - origin.fY), point.fX - origin.fX);
+ canvas->rotate(angle * 180 / SK_ScalarPI, origin.fX, origin.fY);
+ SkString length("length = ");
+ length.appendScalar(point.length());
+ canvas->drawString(length, origin.fX + 25, origin.fY - 4, paint);
+ }
##
#SeeAlso distanceToOrigin Length setLength Distance
@@ -403,20 +403,20 @@ sqrt(fX * fX + fY * fY)
#Example
#Height 192
- SkPaint paint;
- paint.setAntiAlias(true);
- const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } };
- const SkPoint origin = {0, 0};
- canvas->translate(30, 140);
- for (auto point : points) {
- canvas->drawLine(origin, point, paint);
- SkAutoCanvasRestore acr(canvas, true);
- SkScalar angle = SkScalarATan2((point.fY - origin.fY), point.fX - origin.fX);
- canvas->rotate(angle * 180 / SK_ScalarPI, origin.fX, origin.fY);
- SkString distance("distance = ");
- distance.appendScalar(point.distanceToOrigin());
- canvas->drawString(distance, origin.fX + 25, origin.fY - 4, paint);
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } };
+ const SkPoint origin = {0, 0};
+ canvas->translate(30, 140);
+ for (auto point : points) {
+ canvas->drawLine(origin, point, paint);
+ SkAutoCanvasRestore acr(canvas, true);
+ SkScalar angle = SkScalarATan2((point.fY - origin.fY), point.fX - origin.fX);
+ canvas->rotate(angle * 180 / SK_ScalarPI, origin.fX, origin.fY);
+ SkString distance("distance = ");
+ distance.appendScalar(point.distanceToOrigin());
+ canvas->drawString(distance, origin.fX + 25, origin.fY - 4, paint);
+ }
##
#SeeAlso length Length setLength Distance
@@ -434,20 +434,20 @@ false; otherwise returns true.
#Return true if former length is not zero or nearly zero ##
#Example
- SkPaint paint;
- paint.setAntiAlias(true);
- const SkPoint lines[][2] = { {{ 30, 110 }, { 190, 30 }},
- {{ 120, 140 }, { 30, 220 }}};
- for (auto line : lines) {
- canvas->drawLine(line[0], line[1], paint);
- SkVector vector = line[1] - line[0];
- if (vector.normalize()) {
- SkVector rotate90 = { -vector.fY, vector.fX };
- rotate90 *= 10.f;
- canvas->drawLine(line[0] - rotate90, line[0] + rotate90, paint);
- canvas->drawLine(line[1] - rotate90, line[1] + rotate90, paint);
- }
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ const SkPoint lines[][2] = { {{ 30, 110 }, { 190, 30 }},
+ {{ 120, 140 }, { 30, 220 }}};
+ for (auto line : lines) {
+ canvas->drawLine(line[0], line[1], paint);
+ SkVector vector = line[1] - line[0];
+ if (vector.normalize()) {
+ SkVector rotate90 = { -vector.fY, vector.fX };
+ rotate90 *= 10.f;
+ canvas->drawLine(line[0] - rotate90, line[0] + rotate90, paint);
+ canvas->drawLine(line[1] - rotate90, line[1] + rotate90, paint);
+ }
+ }
##
#SeeAlso Normalize setLength length Length
@@ -468,22 +468,22 @@ sets Vector to (0, 0) and returns false; otherwise returns true.
#Return true if (x, y) length is not zero or nearly zero ##
#Example
- SkPaint paint;
- paint.setAntiAlias(true);
- const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } };
- const SkPoint origin = {0, 0};
- canvas->translate(30, 140);
- for (auto point : points) {
- paint.setStrokeWidth(1);
- paint.setColor(SK_ColorBLACK);
- canvas->drawLine(origin, point, paint);
- SkVector normal;
- normal.setNormalize(point.fX, point.fY);
- normal *= 100;
- paint.setStrokeWidth(10);
- paint.setColor(0x3f4512bf);
- canvas->drawLine(origin, normal, paint);
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } };
+ const SkPoint origin = {0, 0};
+ canvas->translate(30, 140);
+ for (auto point : points) {
+ paint.setStrokeWidth(1);
+ paint.setColor(SK_ColorBLACK);
+ canvas->drawLine(origin, point, paint);
+ SkVector normal;
+ normal.setNormalize(point.fX, point.fY);
+ normal *= 100;
+ paint.setStrokeWidth(10);
+ paint.setColor(0x3f4512bf);
+ canvas->drawLine(origin, normal, paint);
+ }
##
#SeeAlso normalize setLength
@@ -504,21 +504,21 @@ true.
#Example
#Height 160
- SkPaint paint;
- paint.setAntiAlias(true);
- const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } };
- const SkPoint origin = {0, 0};
- canvas->translate(30, 140);
- for (auto point : points) {
- paint.setStrokeWidth(1);
- paint.setColor(SK_ColorBLACK);
- canvas->drawLine(origin, point, paint);
- SkVector normal = point;
- normal.setLength(100);
- paint.setStrokeWidth(10);
- paint.setColor(0x3f45bf12);
- canvas->drawLine(origin, normal, paint);
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } };
+ const SkPoint origin = {0, 0};
+ canvas->translate(30, 140);
+ for (auto point : points) {
+ paint.setStrokeWidth(1);
+ paint.setColor(SK_ColorBLACK);
+ canvas->drawLine(origin, point, paint);
+ SkVector normal = point;
+ normal.setLength(100);
+ paint.setStrokeWidth(10);
+ paint.setColor(0x3f45bf12);
+ canvas->drawLine(origin, normal, paint);
+ }
##
#SeeAlso length Length setNormalize setAbs
@@ -541,21 +541,21 @@ true.
#Example
#Height 160
- SkPaint paint;
- paint.setAntiAlias(true);
- const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } };
- const SkPoint origin = {0, 0};
- canvas->translate(30, 140);
- for (auto point : points) {
- paint.setStrokeWidth(1);
- paint.setColor(SK_ColorBLACK);
- canvas->drawLine(origin, point, paint);
- SkVector normal;
- normal.setLength(point.fX, point.fY, 100);
- paint.setStrokeWidth(10);
- paint.setColor(0x3fbf4512);
- canvas->drawLine(origin, normal, paint);
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } };
+ const SkPoint origin = {0, 0};
+ canvas->translate(30, 140);
+ for (auto point : points) {
+ paint.setStrokeWidth(1);
+ paint.setColor(SK_ColorBLACK);
+ canvas->drawLine(origin, point, paint);
+ SkVector normal;
+ normal.setLength(point.fX, point.fY, 100);
+ paint.setStrokeWidth(10);
+ paint.setColor(0x3fbf4512);
+ canvas->drawLine(origin, normal, paint);
+ }
##
#SeeAlso length Length setNormalize setAbs
@@ -572,16 +572,16 @@ Sets dst to Point times scale. dst may be Point to modify Point in place.
#Param dst storage for scaled Point ##
#Example
- SkPaint paint;
- paint.setAntiAlias(true);
- SkPoint point = {40, -15}, scaled;
- SkPoint origin = {30, 110};
- for (auto scale : {1, 2, 3, 5}) {
- paint.setStrokeWidth(scale * 5);
- paint.setARGB(0x7f, 0x9f, 0xbf, 0x33 * scale);
- point.scale(scale, &scaled);
- canvas->drawLine(origin, origin + scaled, paint);
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkPoint point = {40, -15}, scaled;
+ SkPoint origin = {30, 110};
+ for (auto scale : {1, 2, 3, 5}) {
+ paint.setStrokeWidth(scale * 5);
+ paint.setARGB(0x7f, 0x9f, 0xbf, 0x33 * scale);
+ point.scale(scale, &scaled);
+ canvas->drawLine(origin, origin + scaled, paint);
+ }
##
#SeeAlso operator*(SkScalar scale)_const operator*=(SkScalar scale) setLength
@@ -597,16 +597,16 @@ Scales Point in place by scale.
#Param value factor to multiply Point by ##
#Example
- SkPaint paint;
- paint.setAntiAlias(true);
- SkPoint point = {40, -15};
- SkPoint origin = {30, 110};
- for (auto scale : {1, 2, 3, 5}) {
- paint.setStrokeWidth(scale * 5);
- paint.setARGB(0x7f, 0x9f, 0xbf, 0x33 * scale);
- point.scale(scale);
- canvas->drawLine(origin, origin + point, paint);
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkPoint point = {40, -15};
+ SkPoint origin = {30, 110};
+ for (auto scale : {1, 2, 3, 5}) {
+ paint.setStrokeWidth(scale * 5);
+ paint.setARGB(0x7f, 0x9f, 0xbf, 0x33 * scale);
+ point.scale(scale);
+ canvas->drawLine(origin, origin + point, paint);
+ }
##
#SeeAlso operator*(SkScalar scale)_const operator*=(SkScalar scale) setLength
@@ -620,18 +620,18 @@ Scales Point in place by scale.
Changes the sign of fX and fY.
#Example
-SkPoint test[] = { {0.f, -0.f}, {-1, -2},
- { SK_ScalarInfinity, SK_ScalarNegativeInfinity },
- { SK_ScalarNaN, -SK_ScalarNaN } };
-for (const SkPoint& pt : test) {
- SkPoint negPt = pt;
- negPt.negate();
- SkDebugf("pt: %g, %g negate: %g, %g\n", pt.fX, pt.fY, negPt.fX, negPt.fY);
+SkPoint test[] = { {0.f, -0.f}, {-1, -2},
+ { SK_ScalarInfinity, SK_ScalarNegativeInfinity },
+ { SK_ScalarNaN, -SK_ScalarNaN } };
+for (const SkPoint& pt : test) {
+ SkPoint negPt = pt;
+ negPt.negate();
+ SkDebugf("pt: %g, %g negate: %g, %g\n", pt.fX, pt.fY, negPt.fX, negPt.fY);
}
#StdOut
-pt: 0, -0 negate: -0, 0
-pt: -1, -2 negate: 1, 2
-pt: inf, -inf negate: -inf, inf
+pt: 0, -0 negate: -0, 0
+pt: -1, -2 negate: 1, 2
+pt: inf, -inf negate: -inf, inf
pt: nan, -nan negate: -nan, nan
##
##
@@ -649,17 +649,17 @@ Returns Point changing the signs of fX and fY.
#Return Point as (-fX, -fY) ##
#Example
-SkPoint test[] = { {0.f, -0.f}, {-1, -2},
- { SK_ScalarInfinity, SK_ScalarNegativeInfinity },
- { SK_ScalarNaN, -SK_ScalarNaN } };
-for (const SkPoint& pt : test) {
- SkPoint negPt = -pt;
- SkDebugf("pt: %g, %g negate: %g, %g\n", pt.fX, pt.fY, negPt.fX, negPt.fY);
+SkPoint test[] = { {0.f, -0.f}, {-1, -2},
+ { SK_ScalarInfinity, SK_ScalarNegativeInfinity },
+ { SK_ScalarNaN, -SK_ScalarNaN } };
+for (const SkPoint& pt : test) {
+ SkPoint negPt = -pt;
+ SkDebugf("pt: %g, %g negate: %g, %g\n", pt.fX, pt.fY, negPt.fX, negPt.fY);
}
#StdOut
-pt: 0, -0 negate: -0, 0
-pt: -1, -2 negate: 1, 2
-pt: inf, -inf negate: -inf, inf
+pt: 0, -0 negate: -0, 0
+pt: -1, -2 negate: 1, 2
+pt: inf, -inf negate: -inf, inf
pt: nan, -nan negate: -nan, nan
##
##
@@ -682,19 +682,19 @@ Adds Vector v to Point. Sets Point to:
#Example
#Height 128
- SkPaint paint;
- paint.setAntiAlias(true);
- SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
- { 6, 4 }, { 7, 5 }, { 5, 7 },
- { 4, 6 }, { 3, 7 }, { 1, 5 },
- { 2, 4 }, { 1, 3 }, { 3, 1 } };
- canvas->scale(30, 15);
- paint.setStyle(SkPaint::kStroke_Style);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
- points[1] += {1, 1};
- points[2] += {-1, -1};
- paint.setColor(SK_ColorRED);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
+ { 6, 4 }, { 7, 5 }, { 5, 7 },
+ { 4, 6 }, { 3, 7 }, { 1, 5 },
+ { 2, 4 }, { 1, 3 }, { 3, 1 } };
+ canvas->scale(30, 15);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ points[1] += {1, 1};
+ points[2] += {-1, -1};
+ paint.setColor(SK_ColorRED);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
##
#SeeAlso offset() operator+(const SkPoint& a, const SkVector& b) SkIPoint::operator+=(const SkIVector& v)
@@ -715,19 +715,19 @@ Subtracts Vector v from Point. Sets Point to:
#Example
#Height 128
- SkPaint paint;
- paint.setAntiAlias(true);
- SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
- { 6, 4 }, { 7, 5 }, { 5, 7 },
- { 4, 6 }, { 3, 7 }, { 1, 5 },
- { 2, 4 }, { 1, 3 }, { 3, 1 } };
- canvas->scale(30, 15);
- paint.setStyle(SkPaint::kStroke_Style);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
- points[1] -= {1, 1};
- points[2] -= {-1, -1};
- paint.setColor(SK_ColorRED);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
+ { 6, 4 }, { 7, 5 }, { 5, 7 },
+ { 4, 6 }, { 3, 7 }, { 1, 5 },
+ { 2, 4 }, { 1, 3 }, { 3, 1 } };
+ canvas->scale(30, 15);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ points[1] -= {1, 1};
+ points[2] -= {-1, -1};
+ paint.setColor(SK_ColorRED);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
##
#SeeAlso offset() operator-(const SkPoint& a, const SkPoint& b) SkIPoint::operator-=(const SkIVector& v)
@@ -746,20 +746,20 @@ Returns Point multiplied by scale.
#Example
#Height 128
- SkPaint paint;
- paint.setAntiAlias(true);
- SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
- { 6, 4 }, { 7, 5 }, { 5, 7 },
- { 4, 6 }, { 3, 7 }, { 1, 5 },
- { 2, 4 }, { 1, 3 }, { 3, 1 } };
- canvas->scale(15, 10);
- paint.setStyle(SkPaint::kStroke_Style);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
- for (auto& point : points) {
- point = point * 1.5f;
- }
- paint.setColor(SK_ColorRED);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
+ { 6, 4 }, { 7, 5 }, { 5, 7 },
+ { 4, 6 }, { 3, 7 }, { 1, 5 },
+ { 2, 4 }, { 1, 3 }, { 3, 1 } };
+ canvas->scale(15, 10);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ for (auto& point : points) {
+ point = point * 1.5f;
+ }
+ paint.setColor(SK_ColorRED);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
##
#SeeAlso operator*=(SkScalar scale) scale() setLength setNormalize
@@ -781,20 +781,20 @@ Multiplies Point by scale. Sets Point to:
#Example
#Height 128
- SkPaint paint;
- paint.setAntiAlias(true);
- SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
- { 6, 4 }, { 7, 5 }, { 5, 7 },
- { 4, 6 }, { 3, 7 }, { 1, 5 },
- { 2, 4 }, { 1, 3 }, { 3, 1 } };
- canvas->scale(15, 10);
- paint.setStyle(SkPaint::kStroke_Style);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
- for (auto& point : points) {
- point *= 2;
- }
- paint.setColor(SK_ColorRED);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
+ { 6, 4 }, { 7, 5 }, { 5, 7 },
+ { 4, 6 }, { 3, 7 }, { 1, 5 },
+ { 2, 4 }, { 1, 3 }, { 3, 1 } };
+ canvas->scale(15, 10);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ for (auto& point : points) {
+ point *= 2;
+ }
+ paint.setColor(SK_ColorRED);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
##
#SeeAlso operator*(SkScalar scale)_const scale() setLength setNormalize
@@ -810,14 +810,14 @@ Returns true if both fX and fY are measurable values.
#Return true for values other than infinities and NaN ##
#Example
-SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} };
-for (const SkPoint& pt : test) {
- SkDebugf("pt: %g, %g finite: %s\n", pt.fX, pt.fY, pt.isFinite() ? "true" : "false");
+SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} };
+for (const SkPoint& pt : test) {
+ SkDebugf("pt: %g, %g finite: %s\n", pt.fX, pt.fY, pt.isFinite() ? "true" : "false");
}
#StdOut
-pt: 0, -0 finite: true
-pt: -1, -2 finite: true
-pt: inf, 1 finite: false
+pt: 0, -0 finite: true
+pt: -1, -2 finite: true
+pt: inf, 1 finite: false
pt: nan, -1 finite: false
##
##
@@ -838,14 +838,14 @@ Returns true if Point is equivalent to Point constructed from (x, y).
#Return true if Point equals (x, y) ##
#Example
-SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} };
-for (const SkPoint& pt : test) {
- SkDebugf("pt: %g, %g %c= pt\n", pt.fX, pt.fY, pt.equals(pt.fX, pt.fY) ? '=' : '!');
+SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} };
+for (const SkPoint& pt : test) {
+ SkDebugf("pt: %g, %g %c= pt\n", pt.fX, pt.fY, pt.equals(pt.fX, pt.fY) ? '=' : '!');
}
#StdOut
-pt: 0, -0 == pt
-pt: -1, -2 == pt
-pt: inf, 1 == pt
+pt: 0, -0 == pt
+pt: -1, -2 == pt
+pt: inf, 1 == pt
pt: nan, -1 != pt
##
##
@@ -866,14 +866,14 @@ Returns true if a is equivalent to b.
#Return true if a.fX == b.fX and a.fY == b.fY ##
#Example
-SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} };
-for (const SkPoint& pt : test) {
- SkDebugf("pt: %g, %g %c= pt\n", pt.fX, pt.fY, pt == pt ? '=' : '!');
+SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} };
+for (const SkPoint& pt : test) {
+ SkDebugf("pt: %g, %g %c= pt\n", pt.fX, pt.fY, pt == pt ? '=' : '!');
}
#StdOut
-pt: 0, -0 == pt
-pt: -1, -2 == pt
-pt: inf, 1 == pt
+pt: 0, -0 == pt
+pt: -1, -2 == pt
+pt: inf, 1 == pt
pt: nan, -1 != pt
##
##
@@ -894,14 +894,14 @@ Returns true if a is not equivalent to b.
#Return true if a.fX != b.fX or a.fY != b.fY ##
#Example
-SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} };
-for (const SkPoint& pt : test) {
- SkDebugf("pt: %g, %g %c= pt\n", pt.fX, pt.fY, pt != pt ? '!' : '=');
+SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} };
+for (const SkPoint& pt : test) {
+ SkDebugf("pt: %g, %g %c= pt\n", pt.fX, pt.fY, pt != pt ? '!' : '=');
}
#StdOut
-pt: 0, -0 == pt
-pt: -1, -2 == pt
-pt: inf, 1 == pt
+pt: 0, -0 == pt
+pt: -1, -2 == pt
+pt: inf, 1 == pt
pt: nan, -1 != pt
##
##
@@ -929,19 +929,19 @@ Can also be used to subtract Vector from Vector, returning Vector.
#Return Vector from b to a ##
#Example
- SkPaint paint;
- paint.setAntiAlias(true);
- SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
- { 6, 4 }, { 7, 5 }, { 5, 7 },
- { 4, 6 }, { 3, 7 }, { 1, 5 },
- { 2, 4 }, { 1, 3 }, { 3, 1 } };
- canvas->scale(30, 15);
- paint.setStyle(SkPaint::kStroke_Style);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
- points[1] += points[0] - points[2];
- points[2] -= points[3] - points[5];
- paint.setColor(SK_ColorRED);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
+ { 6, 4 }, { 7, 5 }, { 5, 7 },
+ { 4, 6 }, { 3, 7 }, { 1, 5 },
+ { 2, 4 }, { 1, 3 }, { 3, 1 } };
+ canvas->scale(30, 15);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ points[1] += points[0] - points[2];
+ points[2] -= points[3] - points[5];
+ paint.setColor(SK_ColorRED);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
##
#SeeAlso operator-=(const SkVector& v) offset()
@@ -967,23 +967,23 @@ Can also be used to add Vector to Vector, returning Vector.
#Return Point equal to a offset by b ##
#Example
- SkPaint paint;
- paint.setAntiAlias(true);
- SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
- { 6, 4 }, { 7, 5 }, { 5, 7 },
- { 4, 6 }, { 3, 7 }, { 1, 5 },
- { 2, 4 }, { 1, 3 }, { 3, 1 } };
- canvas->scale(30, 15);
- paint.setStyle(SkPaint::kStroke_Style);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
- SkVector mod = {1, 1};
- for (auto& point : points) {
- point = point + mod;
- mod.fX *= 1.1f;
- mod.fY += .2f;
- }
- paint.setColor(SK_ColorRED);
- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 },
+ { 6, 4 }, { 7, 5 }, { 5, 7 },
+ { 4, 6 }, { 3, 7 }, { 1, 5 },
+ { 2, 4 }, { 1, 3 }, { 3, 1 } };
+ canvas->scale(30, 15);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
+ SkVector mod = {1, 1};
+ for (auto& point : points) {
+ point = point + mod;
+ mod.fX *= 1.1f;
+ mod.fY += .2f;
+ }
+ paint.setColor(SK_ColorRED);
+ canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint);
##
#SeeAlso operator+=(const SkVector& v) offset()
@@ -1008,19 +1008,19 @@ sqrt(x * x + y * y)
#Example
#Height 192
- SkPaint paint;
- paint.setAntiAlias(true);
- const SkPoint points[] = { { 90, 30 }, { 120, 150 }, { 150, 30 }, { 210, 90 } };
- const SkPoint origin = {30, 140};
- for (auto point : points) {
- canvas->drawLine(origin, point, paint);
- SkAutoCanvasRestore acr(canvas, true);
- SkScalar angle = SkScalarATan2((point.fY - origin.fY), point.fX - origin.fX);
- canvas->rotate(angle * 180 / SK_ScalarPI, origin.fX, origin.fY);
- SkString length("length = ");
- length.appendScalar(SkPoint::Length(point.fX, point.fY));
- canvas->drawString(length, origin.fX + 25, origin.fY - 4, paint);
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ const SkPoint points[] = { { 90, 30 }, { 120, 150 }, { 150, 30 }, { 210, 90 } };
+ const SkPoint origin = {30, 140};
+ for (auto point : points) {
+ canvas->drawLine(origin, point, paint);
+ SkAutoCanvasRestore acr(canvas, true);
+ SkScalar angle = SkScalarATan2((point.fY - origin.fY), point.fX - origin.fX);
+ canvas->rotate(angle * 180 / SK_ScalarPI, origin.fX, origin.fY);
+ SkString length("length = ");
+ length.appendScalar(SkPoint::Length(point.fX, point.fY));
+ canvas->drawString(length, origin.fX + 25, origin.fY - 4, paint);
+ }
##
#SeeAlso length() Distance setLength
@@ -1044,22 +1044,22 @@ Note that normalize() is faster if prior length is not required.
#Return original vec length ##
#Example
- SkPaint paint;
- paint.setAntiAlias(true);
- const SkPoint lines[][2] = { {{ 30, 110 }, { 190, 30 }},
- {{ 30, 220 }, { 120, 140 }}};
- for (auto line : lines) {
- canvas->drawLine(line[0], line[1], paint);
- SkVector vector = line[1] - line[0];
- SkScalar priorLength = SkPoint::Normalize(&vector);
- SkVector rotate90 = { -vector.fY, vector.fX };
- rotate90 *= 10.f;
- canvas->drawLine(line[0] - rotate90, line[0] + rotate90, paint);
- canvas->drawLine(line[1] - rotate90, line[1] + rotate90, paint);
- SkString length("length = ");
- length.appendScalar(priorLength);
- canvas->drawString(length, line[0].fX + 25, line[0].fY - 4, paint);
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ const SkPoint lines[][2] = { {{ 30, 110 }, { 190, 30 }},
+ {{ 30, 220 }, { 120, 140 }}};
+ for (auto line : lines) {
+ canvas->drawLine(line[0], line[1], paint);
+ SkVector vector = line[1] - line[0];
+ SkScalar priorLength = SkPoint::Normalize(&vector);
+ SkVector rotate90 = { -vector.fY, vector.fX };
+ rotate90 *= 10.f;
+ canvas->drawLine(line[0] - rotate90, line[0] + rotate90, paint);
+ canvas->drawLine(line[1] - rotate90, line[1] + rotate90, paint);
+ SkString length("length = ");
+ length.appendScalar(priorLength);
+ canvas->drawString(length, line[0].fX + 25, line[0].fY - 4, paint);
+ }
##
#SeeAlso normalize() setLength Length
@@ -1079,21 +1079,21 @@ Returns the Euclidean_Distance between a and b.
#Example
#Height 192
- SkPaint paint;
- paint.setAntiAlias(true);
- const SkPoint lines[][2] = {{{-10, -10}, {90, 30}}, {{0, 0}, {150, 30}}, {{10, 25}, {120, 150}}};
- const SkPoint origin = {30, 160};
- for (auto line : lines) {
- SkPoint a = origin + line[0];
- const SkPoint& b = line[1];
- canvas->drawLine(a, b, paint);
- SkAutoCanvasRestore acr(canvas, true);
- SkScalar angle = SkScalarATan2((b.fY - a.fY), b.fX - a.fX);
- canvas->rotate(angle * 180 / SK_ScalarPI, a.fX, a.fY);
- SkString distance("distance = ");
- distance.appendScalar(SkPoint::Distance(a, b));
- canvas->drawString(distance, a.fX + 25, a.fY - 4, paint);
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ const SkPoint lines[][2] = {{{-10, -10}, {90, 30}}, {{0, 0}, {150, 30}}, {{10, 25}, {120, 150}}};
+ const SkPoint origin = {30, 160};
+ for (auto line : lines) {
+ SkPoint a = origin + line[0];
+ const SkPoint& b = line[1];
+ canvas->drawLine(a, b, paint);
+ SkAutoCanvasRestore acr(canvas, true);
+ SkScalar angle = SkScalarATan2((b.fY - a.fY), b.fX - a.fX);
+ canvas->rotate(angle * 180 / SK_ScalarPI, a.fX, a.fY);
+ SkString distance("distance = ");
+ distance.appendScalar(SkPoint::Distance(a, b));
+ canvas->drawString(distance, a.fX + 25, a.fY - 4, paint);
+ }
##
#SeeAlso length() setLength
@@ -1112,19 +1112,19 @@ Returns the dot product of Vector a and Vector b.
#Return product of input magnitudes and cosine of the angle between them ##
#Example
- SkPaint paint;
- paint.setAntiAlias(true);
- SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}},
- {{-20, -24}, {-24, -20}}};
- SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}};
- paint.setStrokeWidth(2);
- for (size_t i = 0; i < 4; ++i) {
- canvas->drawLine(center[i], center[i] + vectors[i][0], paint);
- canvas->drawLine(center[i], center[i] + vectors[i][1], paint);
- SkString str;
- str.printf("dot = %g", SkPoint::DotProduct(vectors[i][0], vectors[i][1]));
- canvas->drawString(str, center[i].fX, center[i].fY, paint);
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}},
+ {{-20, -24}, {-24, -20}}};
+ SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}};
+ paint.setStrokeWidth(2);
+ for (size_t i = 0; i < 4; ++i) {
+ canvas->drawLine(center[i], center[i] + vectors[i][0], paint);
+ canvas->drawLine(center[i], center[i] + vectors[i][1], paint);
+ SkString str;
+ str.printf("dot = %g", SkPoint::DotProduct(vectors[i][0], vectors[i][1]));
+ canvas->drawString(str, center[i].fX, center[i].fY, paint);
+ }
##
#SeeAlso dot CrossProduct
@@ -1147,23 +1147,23 @@ term equals the returned value.
#Return area spanned by Vectors signed by angle direction ##
#Example
- SkPaint paint;
- paint.setAntiAlias(true);
- SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}},
- {{-20, -24}, {-24, -20}}};
- SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}};
- paint.setStrokeWidth(2);
- for (size_t i = 0; i < 4; ++i) {
- paint.setColor(SK_ColorRED);
- canvas->drawLine(center[i], center[i] + vectors[i][0], paint);
- paint.setColor(SK_ColorBLUE);
- canvas->drawLine(center[i], center[i] + vectors[i][1], paint);
- SkString str;
- SkScalar cross = SkPoint::CrossProduct(vectors[i][1], vectors[i][0]);
- str.printf("cross = %g", cross);
- paint.setColor(cross >= 0 ? SK_ColorRED : SK_ColorBLUE);
- canvas->drawString(str, center[i].fX, center[i].fY, paint);
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}},
+ {{-20, -24}, {-24, -20}}};
+ SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}};
+ paint.setStrokeWidth(2);
+ for (size_t i = 0; i < 4; ++i) {
+ paint.setColor(SK_ColorRED);
+ canvas->drawLine(center[i], center[i] + vectors[i][0], paint);
+ paint.setColor(SK_ColorBLUE);
+ canvas->drawLine(center[i], center[i] + vectors[i][1], paint);
+ SkString str;
+ SkScalar cross = SkPoint::CrossProduct(vectors[i][1], vectors[i][0]);
+ str.printf("cross = %g", cross);
+ paint.setColor(cross >= 0 ? SK_ColorRED : SK_ColorBLUE);
+ canvas->drawString(str, center[i].fX, center[i].fY, paint);
+ }
##
#SeeAlso cross DotProduct
@@ -1185,23 +1185,23 @@ The cross product z term equals the returned value.
#Return area spanned by Vectors signed by angle direction ##
#Example
- SkPaint paint;
- paint.setAntiAlias(true);
- SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}},
- {{-20, -24}, {-24, -20}}};
- SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}};
- paint.setStrokeWidth(2);
- for (size_t i = 0; i < 4; ++i) {
- paint.setColor(SK_ColorRED);
- canvas->drawLine(center[i], center[i] + vectors[i][0], paint);
- paint.setColor(SK_ColorBLUE);
- canvas->drawLine(center[i], center[i] + vectors[i][1], paint);
- SkString str;
- SkScalar cross = vectors[i][0].cross(vectors[i][1]);
- str.printf("cross = %g", cross);
- paint.setColor(cross >= 0 ? SK_ColorRED : SK_ColorBLUE);
- canvas->drawString(str, center[i].fX, center[i].fY, paint);
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}},
+ {{-20, -24}, {-24, -20}}};
+ SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}};
+ paint.setStrokeWidth(2);
+ for (size_t i = 0; i < 4; ++i) {
+ paint.setColor(SK_ColorRED);
+ canvas->drawLine(center[i], center[i] + vectors[i][0], paint);
+ paint.setColor(SK_ColorBLUE);
+ canvas->drawLine(center[i], center[i] + vectors[i][1], paint);
+ SkString str;
+ SkScalar cross = vectors[i][0].cross(vectors[i][1]);
+ str.printf("cross = %g", cross);
+ paint.setColor(cross >= 0 ? SK_ColorRED : SK_ColorBLUE);
+ canvas->drawString(str, center[i].fX, center[i].fY, paint);
+ }
##
#SeeAlso CrossProduct dot
@@ -1219,19 +1219,19 @@ Returns the dot product of Vector and Vector vec.
#Return product of input magnitudes and cosine of the angle between them ##
#Example
- SkPaint paint;
- paint.setAntiAlias(true);
- SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}},
- {{-20, -24}, {-24, -20}}};
- SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}};
- paint.setStrokeWidth(2);
- for (size_t i = 0; i < 4; ++i) {
- canvas->drawLine(center[i], center[i] + vectors[i][0], paint);
- canvas->drawLine(center[i], center[i] + vectors[i][1], paint);
- SkString str;
- str.printf("dot = %g", vectors[i][0].dot(vectors[i][1]));
- canvas->drawString(str, center[i].fX, center[i].fY, paint);
- }
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}},
+ {{-20, -24}, {-24, -20}}};
+ SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}};
+ paint.setStrokeWidth(2);
+ for (size_t i = 0; i < 4; ++i) {
+ canvas->drawLine(center[i], center[i] + vectors[i][0], paint);
+ canvas->drawLine(center[i], center[i] + vectors[i][1], paint);
+ SkString str;
+ str.printf("dot = %g", vectors[i][0].dot(vectors[i][1]));
+ canvas->drawString(str, center[i].fX, center[i].fY, paint);
+ }
##
#SeeAlso DotProduct cross
diff --git a/site/user/api/SkBitmap_Reference.md b/site/user/api/SkBitmap_Reference.md
index bf0d99dda3..fc30b242c9 100644
--- a/site/user/api/SkBitmap_Reference.md
+++ b/site/user/api/SkBitmap_Reference.md
@@ -107,6 +107,7 @@ is useful to position one or more <a href="#Bitmap">Bitmaps</a> within a shared
| <a href="#SkBitmap_peekPixels">peekPixels</a> | Returns <a href="SkPixmap_Reference#Pixmap">Pixmap</a> if possible. |
| <a href="#SkBitmap_pixelRef">pixelRef</a> | Returns <a href="undocumented#Pixel_Ref">Pixel Ref</a>, or nullptr. |
| <a href="#SkBitmap_pixelRefOrigin">pixelRefOrigin</a> | Returns offset within <a href="undocumented#Pixel_Ref">Pixel Ref</a>. |
+| <a href="#SkBitmap_pixmap">pixmap</a> | Returns <a href="SkPixmap_Reference#Pixmap">Pixmap</a> if possible. |
| <a href="#SkBitmap_readPixels">readPixels</a> | Copies and converts pixels. |
| <a href="#SkBitmap_readyToDraw">readyToDraw</a> | Returns true if address of pixels is not nullptr. |
| <a href="#SkBitmap_refColorSpace">refColorSpace</a> | Returns <a href="undocumented#Image_Info">Image Info</a> <a href="undocumented#Color_Space">Color Space</a>. |
@@ -475,6 +476,51 @@ two width:1 height:1 colorType:kRGBA_8888_SkColorType alphaType:kOpaque_SkAlphaT
---
+<a name="SkBitmap_pixmap"></a>
+## pixmap
+
+<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
+SkPixmap pixmap() const
+</pre>
+
+Returns <a href="SkPixmap_Reference#Pixmap">Pixmap</a> with <a href="#Bitmap">Bitmap</a> pixel address, row bytes, and <a href="undocumented#Image_Info">Image Info</a>, if address is available.
+If pixel address is not available, returns default constructed <a href="SkPixmap_Reference#Pixmap">Pixmap</a>: nullptr pixels,
+<a href="undocumented#SkColorType">kUnknown SkColorType</a>, <a href="undocumented#SkAlphaType">kUnknown SkAlphaType</a>, <a href="#SkBitmap_width">width</a> and <a href="#SkBitmap_height">height</a> of zero.
+
+Returned <a href="SkPixmap_Reference#Pixmap">Pixmap</a> becomes invalid on any future change to <a href="#Bitmap">Bitmap</a>
+
+### Return Value
+
+<a href="SkPixmap_Reference#Pixmap">Pixmap</a> describing <a href="#Bitmap">Bitmap</a>, if pixels are readable; otherwise containing zeroes
+
+### Example
+
+<div><fiddle-embed name="4e2da4cff5fa3752b630a63080b44752">
+
+#### Example Output
+
+~~~~
+----------
+---xx-----
+--x--x----
+--x-------
+--xx------
+--x-x---x-
+-x---x--x-
+-x----xx--
+-xx---x---
+--xxxx-xx-
+----------
+~~~~
+
+</fiddle-embed></div>
+
+### See Also
+
+<a href="#SkBitmap_peekPixels">peekPixels</a> <a href="#SkBitmap_installPixels">installPixels</a> <a href="#SkBitmap_readPixels">readPixels</a> <a href="#SkBitmap_writePixels">writePixels</a>
+
+---
+
<a name="SkBitmap_info"></a>
## info
@@ -1982,15 +2028,15 @@ true if <a href="undocumented#Image_Info">Image Info</a> is set to <a href="#SkB
bool installPixels(const SkPixmap& pixmap)
</pre>
-Sets <a href="undocumented#Image_Info">Image Info</a> to <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a>.<a href="#SkBitmap_info">info</a> following the rules in <a href="#SkBitmap_setInfo">setInfo</a>, and creates
-<a href="undocumented#Pixel_Ref">Pixel Ref</a> containing <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a>.addr() and <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a>.<a href="#SkBitmap_rowBytes">rowBytes</a>.
+Sets <a href="undocumented#Image_Info">Image Info</a> to <a href="#SkBitmap_pixmap">pixmap</a>.<a href="#SkBitmap_info">info</a> following the rules in <a href="#SkBitmap_setInfo">setInfo</a>, and creates
+<a href="undocumented#Pixel_Ref">Pixel Ref</a> containing <a href="#SkBitmap_pixmap">pixmap</a>.addr() and <a href="#SkBitmap_pixmap">pixmap</a>.<a href="#SkBitmap_rowBytes">rowBytes</a>.
-If <a href="undocumented#Image_Info">Image Info</a> could not be set, or <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a>.<a href="#SkBitmap_rowBytes">rowBytes</a> is less than
+If <a href="undocumented#Image_Info">Image Info</a> could not be set, or <a href="#SkBitmap_pixmap">pixmap</a>.<a href="#SkBitmap_rowBytes">rowBytes</a> is less than
<a href="#SkImageInfo_minRowBytes">SkImageInfo::minRowBytes</a>: calls <a href="#SkBitmap_reset">reset</a>, and returns false.
-Otherwise, if <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a>.addr() equals nullptr: sets <a href="undocumented#Image_Info">Image Info</a>, returns true.
+Otherwise, if <a href="#SkBitmap_pixmap">pixmap</a>.addr() equals nullptr: sets <a href="undocumented#Image_Info">Image Info</a>, returns true.
-Caller must ensure that <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a> is valid for the lifetime of <a href="#Bitmap">Bitmap</a> and <a href="undocumented#Pixel_Ref">Pixel Ref</a>.
+Caller must ensure that <a href="#SkBitmap_pixmap">pixmap</a> is valid for the lifetime of <a href="#Bitmap">Bitmap</a> and <a href="undocumented#Pixel_Ref">Pixel Ref</a>.
### Parameters
@@ -2001,7 +2047,7 @@ Caller must ensure that <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a> is
### Return Value
-true if <a href="undocumented#Image_Info">Image Info</a> was set to <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a>.<a href="#SkBitmap_info">info</a>
+true if <a href="undocumented#Image_Info">Image Info</a> was set to <a href="#SkBitmap_pixmap">pixmap</a>.<a href="#SkBitmap_info">info</a>
### Example
@@ -3369,11 +3415,11 @@ true if <a href="#Alpha">Alpha</a> layer was constructed in <a href="#SkBitmap_e
bool peekPixels(SkPixmap* pixmap) const
</pre>
-Copies <a href="#Bitmap">Bitmap</a> pixel address, row bytes, and <a href="undocumented#Image_Info">Image Info</a> to <a href="#SkBitmap_peekPixels_pixmap">pixmap</a>, if address
+Copies <a href="#Bitmap">Bitmap</a> pixel address, row bytes, and <a href="undocumented#Image_Info">Image Info</a> to <a href="#SkBitmap_pixmap">pixmap</a>, if address
is available, and returns true. If pixel address is not available, return
-false and leave <a href="#SkBitmap_peekPixels_pixmap">pixmap</a> unchanged.
+false and leave <a href="#SkBitmap_pixmap">pixmap</a> unchanged.
-<a href="#SkBitmap_peekPixels_pixmap">pixmap</a> contents become invalid on any future change to <a href="#Bitmap">Bitmap</a>.
+<a href="#SkBitmap_pixmap">pixmap</a> contents become invalid on any future change to <a href="#Bitmap">Bitmap</a>.
### Parameters
@@ -3410,7 +3456,7 @@ x---x-
### See Also
-<a href="#SkBitmap_installPixels">installPixels</a> <a href="#SkBitmap_readPixels">readPixels</a> <a href="#SkBitmap_writePixels">writePixels</a>
+<a href="#SkBitmap_pixmap">pixmap</a> <a href="#SkBitmap_installPixels">installPixels</a> <a href="#SkBitmap_readPixels">readPixels</a> <a href="#SkBitmap_writePixels">writePixels</a>
---
diff --git a/site/user/api/SkImage_Reference.md b/site/user/api/SkImage_Reference.md
index 58cf70d918..1ba1cdd0c3 100644
--- a/site/user/api/SkImage_Reference.md
+++ b/site/user/api/SkImage_Reference.md
@@ -142,7 +142,7 @@ size of pixel row or larger</td>
### Example
-<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
+<div><fiddle-embed name="367bdf6ee6ef2482eea95d4a9887c9b0"></fiddle-embed></div>
### See Also
@@ -171,10 +171,14 @@ static sk_sp&lt;SkImage&gt; MakeFromRaster(const SkPixmap& pixmap, RasterRelease
ReleaseContext releaseContext)
</pre>
-Creates <a href="#Image">Image</a> from <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a>, sharing <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a> pixels. Pixels must remain valid and
+Creates <a href="#Image">Image</a> from <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a>, sharing <a href="SkPixmap_Reference#Pixmap">Pixmap</a> pixels. Pixels must remain valid and
unchanged until <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a> is called. <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a> is passed
<a href="#SkImage_MakeFromRaster_releaseContext">releaseContext</a> when <a href="#Image">Image</a> is deleted or no longer refers to <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a> pixels.
+Pass nullptr for <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a> to share <a href="SkPixmap_Reference#Pixmap">Pixmap</a> without requiring a callback
+when <a href="#Image">Image</a> is released. Pass nullptr for <a href="#SkImage_MakeFromRaster_releaseContext">releaseContext</a> if <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a>
+does not require state.
+
<a href="#Image">Image</a> is returned if <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a> is valid. Valid <a href="SkPixmap_Reference#Pixmap">Pixmap</a> parameters include:
<a href="#SkImage_dimensions">dimensions</a> are greater than zero;
each dimension fits in 29 bits;
@@ -187,19 +191,28 @@ pixel address is not nullptr.
<table> <tr> <td><a name="SkImage_MakeFromRaster_pixmap"> <code><strong>pixmap </strong></code> </a></td> <td>
<a href="#Info">Image Info</a>, pixel address, and row bytes</td>
</tr> <tr> <td><a name="SkImage_MakeFromRaster_rasterReleaseProc"> <code><strong>rasterReleaseProc </strong></code> </a></td> <td>
-function called when pixels can be released</td>
+function called when pixels can be released; or nullptr</td>
</tr> <tr> <td><a name="SkImage_MakeFromRaster_releaseContext"> <code><strong>releaseContext </strong></code> </a></td> <td>
-state passed to <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a></td>
+state passed to <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a>; or nullptr</td>
</tr>
</table>
### Return Value
-incomplete
+<a href="#Image">Image</a> sharing <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a>
### Example
-<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
+<div><fiddle-embed name="275356b65d18c8868f4434137350cddc">
+
+#### Example Output
+
+~~~~
+before reset: 0
+after reset: 1
+~~~~
+
+</fiddle-embed></div>
### See Also
@@ -238,7 +251,10 @@ created <a href="#Image">Image</a>, or nullptr
### Example
-<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
+<div><fiddle-embed name="cf2cf53321e4e6a77c2841bfbc0ef707"><div>The first <a href="SkBitmap_Reference#Bitmap">Bitmap</a> is shared; writing to the pixel memory changes the first
+<a href="#Image">Image</a>.
+The second <a href="SkBitmap_Reference#Bitmap">Bitmap</a> is marked immutable, and is copied; writing to the pixel
+memory does not alter the second <a href="#Image">Image</a>.</div></fiddle-embed></div>
### See Also
@@ -254,12 +270,14 @@ static sk_sp&lt;SkImage&gt; MakeFromGenerator(std::unique_ptr&lt;SkImageGenerato
const SkIRect* subset = nullptr)
</pre>
-Creates <a href="#Image">Image</a> based from <a href="#SkImage_MakeFromGenerator_imageGenerator">imageGenerator</a>.
-Takes ownership of <a href="#SkImage_MakeFromGenerator_imageGenerator">imageGenerator</a>; it may not be used elsewhere.
-If <a href="#SkImage_MakeFromGenerator_subset">subset</a> is not nullptr, it must be contained within <a href="#SkImage_MakeFromGenerator_imageGenerator">imageGenerator</a> data <a href="#SkImage_bounds">bounds</a>.
+Creates <a href="#Image">Image</a> from data returned by <a href="#SkImage_MakeFromGenerator_imageGenerator">imageGenerator</a>. Generated data is owned by <a href="#Image">Image</a> and may not
+be shared or accessed.
-<a href="#Image">Image</a> is returned if generator data is valid. Valid data parameters vary
-by type of data and platform.
+<a href="#SkImage_MakeFromGenerator_subset">subset</a> allows selecting a portion of the full image. Pass nullptr to select the entire image;
+otherwise, <a href="#SkImage_MakeFromGenerator_subset">subset</a> must be contained by image <a href="#SkImage_bounds">bounds</a>.
+
+<a href="#Image">Image</a> is returned if generator data is valid. Valid data parameters vary by type of data
+and platform.
<a href="#SkImage_MakeFromGenerator_imageGenerator">imageGenerator</a> may wrap <a href="undocumented#Picture">Picture</a> data, codec data, or custom data.
@@ -278,7 +296,7 @@ created <a href="#Image">Image</a>, or nullptr
### Example
-<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
+<div><fiddle-embed name="ba59d292a18cb0e8a90e1bb143115f1d"><div>The generator returning <a href="undocumented#Picture">Picture</a> cannot be shared; std::move transfers ownership to generated <a href="#Image">Image</a>.</div></fiddle-embed></div>
### See Also
@@ -294,7 +312,8 @@ static sk_sp&lt;SkImage&gt; MakeFromEncoded(sk_sp&lt;SkData&gt; encoded, const S
</pre>
Creates <a href="#Image">Image</a> from <a href="#SkImage_MakeFromEncoded_encoded">encoded</a> data.
-If a <a href="#SkImage_MakeFromEncoded_subset">subset</a> is not nullptr, it must be contained within <a href="#SkImage_MakeFromEncoded_encoded">encoded</a> data <a href="#SkImage_bounds">bounds</a>.
+<a href="#SkImage_MakeFromEncoded_subset">subset</a> allows selecting a portion of the full image. Pass nullptr to select the entire image;
+otherwise, <a href="#SkImage_MakeFromEncoded_subset">subset</a> must be contained by image <a href="#SkImage_bounds">bounds</a>.
<a href="#Image">Image</a> is returned if format of the <a href="#SkImage_MakeFromEncoded_encoded">encoded</a> data is recognized and supported.
Recognized formats vary by platfrom.
@@ -312,10 +331,6 @@ data of <a href="#Image">Image</a> to decode</td>
created <a href="#Image">Image</a>, or nullptr
-### Example
-
-<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
-
### See Also
<a href="#SkImage_MakeFromGenerator">MakeFromGenerator</a>
@@ -359,7 +374,7 @@ created <a href="#Image">Image</a>, or nullptr
### Example
-<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
+<div><fiddle-embed name="2faa98d6a1d578010326af17ee7e4d2a" gpu="true"><div>A back-end texture has been created and uploaded to the <a href="undocumented#GPU">GPU</a> outside of this example.</div></fiddle-embed></div>
### See Also
@@ -408,7 +423,7 @@ created <a href="#Image">Image</a>, or nullptr
### Example
-<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
+<div><fiddle-embed name="dea2835da4be78d1e9ab4be58010d1ad"></fiddle-embed></div>
### See Also
diff --git a/site/user/api/SkPaint_Reference.md b/site/user/api/SkPaint_Reference.md
index e7b2b49b20..ef8d1afd0d 100644
--- a/site/user/api/SkPaint_Reference.md
+++ b/site/user/api/SkPaint_Reference.md
@@ -2606,7 +2606,7 @@ May be used to verify that <a href="#Stroke_Join">Stroke Join</a> is a legal val
Join getStrokeJoin() const
</pre>
-The geometry drawn at the corners of strokes.
+The geometry drawn at the corners of strokes.
### Return Value
@@ -2637,7 +2637,7 @@ kMiter_Join == default stroke join
void setStrokeJoin(Join join)
</pre>
-The geometry drawn at the corners of strokes.
+The geometry drawn at the corners of strokes.
### Parameters
diff --git a/site/user/api/catalog.htm b/site/user/api/catalog.htm
index 4cb0f9f39d..ee48589741 100644
--- a/site/user/api/catalog.htm
+++ b/site/user/api/catalog.htm
@@ -273,6 +273,13 @@
"name": "SkBitmap::pixelRefOrigin",
"stdout": "source origin: 0, 0\\nsubset origin: 32, 64\\n"
},
+ "SkBitmap_pixmap": {
+ "code": "void draw(SkCanvas* canvas) {\n SkBitmap bitmap;\n bitmap.allocPixels(SkImageInfo::MakeN32Premul(10, 11));\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorWHITE);\n SkPaint paint;\n offscreen.drawString(\"&\", 0, 10, paint);\n SkPixmap pixmap = bitmap.pixmap();\n if (pixmap.addr()) {\n const SkPMColor* pixels = pixmap.addr32();\n SkPMColor pmWhite = pixels[0];\n for (int y = 0; y < bitmap.height(); ++y) {\n for (int x = 0; x < bitmap.width(); ++x) {\n SkDebugf(\"%c\", *pixels++ == pmWhite ? '-' : 'x');\n }\n SkDebugf(\"\\n\");\n }\n }\n}",
+ "hash": "4e2da4cff5fa3752b630a63080b44752",
+ "file": "SkBitmap_Reference",
+ "name": "SkBitmap::pixmap()",
+ "stdout": "----------\\n---xx-----\\n--x--x----\\n--x-------\\n--xx------\\n--x-x---x-\\n-x---x--x-\\n-x----xx--\\n-xx---x---\\n--xxxx-xx-\\n----------\\n"
+ },
"SkBitmap_refColorSpace": {
"code": "void draw(SkCanvas* canvas) {\n SkBitmap bitmap1, bitmap2;\n bitmap1.setInfo(SkImageInfo::MakeN32(16, 32, kPremul_SkAlphaType, \n SkColorSpace::MakeSRGBLinear()));\n bitmap2.setInfo(SkImageInfo::MakeN32(16, 32, kPremul_SkAlphaType,\n bitmap1.refColorSpace()));\n SkColorSpace* colorSpace = bitmap2.colorSpace();\n SkDebugf(\"gammaCloseToSRGB: %s gammaIsLinear: %s isSRGB: %s\\n\",\n colorSpace->gammaCloseToSRGB() ? \"true\" : \"false\",\n colorSpace->gammaIsLinear() ? \"true\" : \"false\",\n colorSpace->isSRGB() ? \"true\" : \"false\");\n}",
"hash": "972e9bb22c1ce94bb97b2d106168280e",
@@ -1029,6 +1036,13 @@
"name": "SkIRect::y()",
"stdout": "unsorted.fTop: 25 unsorted.y(): 25\\nsorted.fTop: 5 sorted.y(): 5\\n"
},
+ "SkImage_MakeFromRaster": {
+ "code": "static void releaseProc(const void* pixels, SkImage::ReleaseContext context) {\n int* countPtr = static_cast<int*>(context);\n *countPtr += 1;\n}\n\nvoid draw(SkCanvas* canvas) {\n SkColor color = 0;\n SkPixmap pixmap(SkImageInfo::MakeN32(1, 1, kPremul_SkAlphaType), &color, 4);\n int releaseCount = 0;\n sk_sp<SkImage> image(SkImage::MakeFromRaster(pixmap, releaseProc, &releaseCount));\n SkDebugf(\"before reset: %d\\n\", releaseCount);\n image.reset();\n SkDebugf(\"after reset: %d\\n\", releaseCount);\n}\n",
+ "hash": "275356b65d18c8868f4434137350cddc",
+ "file": "SkImage_Reference",
+ "name": "SkImage::MakeFromRaster",
+ "stdout": "before reset: 0\\nafter reset: 1\\n"
+ },
"SkMatrix_I": {
"code": "void draw(SkCanvas* canvas) {\n SkMatrix m1, m2, m3;\n m1.reset();\n m2.setIdentity();\n m3 = SkMatrix::I();\n SkDebugf(\"m1 %c= m2\\n\", m1 == m2 ? '=' : '!');\n SkDebugf(\"m2 %c= m3\\n\", m1 == m2 ? '=' : '!');\n}",
"hash": "d961d91020f19037204a8c3fd8cb1060",
@@ -4766,26 +4780,18 @@
"name": "SkImage::MakeFromAdoptedTexture"
},
"SkImage_MakeFromBitmap": {
- "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}",
+ "code": "void draw(SkCanvas* canvas) {\n uint8_t storage[][5] = {{ 0xCA, 0xDA, 0xCA, 0xC9, 0xA3 },\n { 0xAC, 0xA8, 0x89, 0xA7, 0x87 },\n { 0x9B, 0xB5, 0xE5, 0x95, 0x46 },\n { 0x90, 0x81, 0xC5, 0x71, 0x33 },\n { 0x75, 0x55, 0x44, 0x40, 0x30 }};\n SkImageInfo imageInfo = SkImageInfo::Make(5, 5, kGray_8_SkColorType, kOpaque_SkAlphaType);\n SkPixmap pixmap(imageInfo, storage[0], sizeof(storage) / 5);\n SkBitmap bitmap;\n bitmap.installPixels(pixmap);\n sk_sp<SkImage> image1 = SkImage::MakeFromBitmap(bitmap);\n bitmap.setImmutable();\n sk_sp<SkImage> image2 = SkImage::MakeFromBitmap(bitmap);\n *pixmap.writable_addr8(2, 2) = 0x00;\n canvas->scale(10, 10);\n canvas->drawImage(image1, 0, 0);\n canvas->drawImage(image2, 10, 0);\n}",
"width": 256,
- "height": 256,
- "hash": "882e8e0103048009a25cfc20400492f7",
+ "height": 50,
+ "hash": "cf2cf53321e4e6a77c2841bfbc0ef707",
"file": "SkImage_Reference",
"name": "SkImage::MakeFromBitmap"
},
- "SkImage_MakeFromEncoded": {
- "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}",
- "width": 256,
- "height": 256,
- "hash": "882e8e0103048009a25cfc20400492f7",
- "file": "SkImage_Reference",
- "name": "SkImage::MakeFromEncoded"
-},
"SkImage_MakeFromGenerator": {
- "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}",
+ "code": "void draw(SkCanvas* canvas) {\n SkPictureRecorder recorder;\n recorder.beginRecording(100, 100)->drawColor(SK_ColorRED);\n auto picture = recorder.finishRecordingAsPicture();\n auto gen = SkImageGenerator::MakeFromPicture({100, 100}, picture, nullptr, nullptr,\n SkImage::BitDepth::kU8, SkColorSpace::MakeSRGB());\n sk_sp<SkImage> image = SkImage::MakeFromGenerator(std::move(gen));\n canvas->drawImage(image, 0, 0);\n}",
"width": 256,
"height": 256,
- "hash": "882e8e0103048009a25cfc20400492f7",
+ "hash": "ba59d292a18cb0e8a90e1bb143115f1d",
"file": "SkImage_Reference",
"name": "SkImage::MakeFromGenerator"
},
@@ -4805,27 +4811,19 @@
"file": "SkImage_Reference",
"name": "SkImage::MakeFromPicture"
},
- "SkImage_MakeFromRaster": {
- "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}",
- "width": 256,
- "height": 256,
- "hash": "882e8e0103048009a25cfc20400492f7",
- "file": "SkImage_Reference",
- "name": "SkImage::MakeFromRaster"
-},
"SkImage_MakeFromTexture": {
- "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}",
+ "code": "void draw(SkCanvas* canvas) {\n GrContext* context = canvas->getGrContext();\n if (!context) {\n return;\n }\n canvas->scale(.25f, .25f);\n int x = 0;\n for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin } ) {\n sk_sp<SkImage> image = SkImage::MakeFromTexture(canvas->getGrContext(), backEndTexture,\n origin, kOpaque_SkAlphaType, nullptr);\n canvas->drawImage(image, x, 0);\n x += 512;\n }\n}",
"width": 256,
- "height": 256,
- "hash": "882e8e0103048009a25cfc20400492f7",
+ "height": 128,
+ "hash": "2faa98d6a1d578010326af17ee7e4d2a",
"file": "SkImage_Reference",
"name": "SkImage::MakeFromTexture"
},
"SkImage_MakeFromTexture_2": {
- "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}",
+ "code": "void draw(SkCanvas* canvas) {\n GrContext* context = canvas->getGrContext();\n if (!context) {\n return;\n }\n auto debugster = [](SkImage::ReleaseContext context) -> void {\n *((int *) context) += 128;\n };\n int x = 0;\n for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin } ) {\n sk_sp<SkImage> image = SkImage::MakeFromTexture(canvas->getGrContext(), backEndTexture,\n origin, kOpaque_SkAlphaType, nullptr, debugster, &x);\n canvas->drawImage(image, x, 0);\n x += 128;\n }\n}",
"width": 256,
"height": 256,
- "hash": "882e8e0103048009a25cfc20400492f7",
+ "hash": "dea2835da4be78d1e9ab4be58010d1ad",
"file": "SkImage_Reference",
"name": "SkImage::MakeFromTexture_2"
},
@@ -4846,10 +4844,10 @@
"name": "SkImage::MakeRasterCopy"
},
"SkImage_MakeRasterData": {
- "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}",
+ "code": "void draw(SkCanvas* canvas) {\n size_t rowBytes = image->width() * SkColorTypeBytesPerPixel(kRGBA_8888_SkColorType);\n sk_sp<SkData> data = SkData::MakeUninitialized(rowBytes * image->height());\n SkImageInfo dstInfo = SkImageInfo::MakeN32(image->width(), image->height(), \n kPremul_SkAlphaType);\n image->readPixels(dstInfo, data->writable_data(), rowBytes, 0, 0, SkImage::kAllow_CachingHint);\n sk_sp<SkImage> raw = SkImage::MakeRasterData(dstInfo.makeColorType(kRGBA_8888_SkColorType),\n data, rowBytes);\n canvas->drawImage(image, 0, 0);\n canvas->drawImage(raw.get(), 128, 0);\n}",
"width": 256,
"height": 256,
- "hash": "882e8e0103048009a25cfc20400492f7",
+ "hash": "367bdf6ee6ef2482eea95d4a9887c9b0",
"file": "SkImage_Reference",
"name": "SkImage::MakeRasterData"
},