diff options
author | Cary Clark <caryclark@skia.org> | 2018-02-27 09:54:21 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-27 15:12:59 +0000 |
commit | f895a420c93f18df10dc95da182025847a0e061a (patch) | |
tree | 8108cfdf8afa28275f7abc3df54d428973ae0dda | |
parent | 0a3b12bbcec77cb7007e0c3421a84affdc27a146 (diff) |
work on skimageinfo
work on skimageinfo
Docs-Preview: https://skia.org/?cl=109081
TBR=caryclark@google.com
Bug: skia:6898
Change-Id: I4d1734647ef1fa879d08b04c64142c7f16abc858
Reviewed-on: https://skia-review.googlesource.com/109081
Commit-Queue: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
-rw-r--r-- | docs/SkBitmap_Reference.bmh | 4 | ||||
-rw-r--r-- | docs/SkImageInfo_Reference.bmh | 600 | ||||
-rw-r--r-- | docs/SkImage_Reference.bmh | 3 | ||||
-rw-r--r-- | docs/SkPaint_Reference.bmh | 2 | ||||
-rw-r--r-- | docs/illustrations.bmh | 452 | ||||
-rw-r--r-- | docs/status.json | 1 | ||||
-rw-r--r-- | docs/undocumented.bmh | 25 | ||||
-rw-r--r-- | site/user/api/SkBitmap_Reference.md | 4 | ||||
-rw-r--r-- | site/user/api/SkImageInfo_Reference.md | 276 | ||||
-rw-r--r-- | site/user/api/SkImage_Reference.md | 33 | ||||
-rw-r--r-- | site/user/api/SkPaint_Reference.md | 2 | ||||
-rw-r--r-- | site/user/api/catalog.htm | 184 | ||||
-rw-r--r-- | site/user/api/undocumented.md | 47 | ||||
-rw-r--r-- | tools/bookmaker/bookmaker.cpp | 95 | ||||
-rw-r--r-- | tools/bookmaker/bookmaker.h | 21 | ||||
-rw-r--r-- | tools/bookmaker/fiddleParser.cpp | 26 | ||||
-rw-r--r-- | tools/bookmaker/includeWriter.cpp | 9 | ||||
-rw-r--r-- | tools/bookmaker/mdOut.cpp | 39 | ||||
-rw-r--r-- | tools/bookmaker/spellCheck.cpp | 2 |
19 files changed, 1631 insertions, 194 deletions
diff --git a/docs/SkBitmap_Reference.bmh b/docs/SkBitmap_Reference.bmh index a11330a6ce..39719a9149 100644 --- a/docs/SkBitmap_Reference.bmh +++ b/docs/SkBitmap_Reference.bmh @@ -3275,7 +3275,7 @@ Uses HeapAllocator to reserve memory for dst Pixel_Ref. Sets dst to Alpha described by pixels. Returns false if dst cannot be written to or dst pixels cannot be allocated. -If paint is not nullptr and contains Mask_Filter, SkMaskFilter::filterMask +If paint is not nullptr and contains Mask_Filter, SkMaskFilter generates Mask_Alpha from Bitmap. Uses HeapAllocator to reserve memory for dst Pixel_Ref. Sets offset to top-left position for dst for alignment with Bitmap; (0, 0) unless SkMaskFilter generates mask. @@ -3322,7 +3322,7 @@ Pixel_Ref. Sets offset to top-left position for dst for alignment with Bitmap; Sets dst to Alpha described by pixels. Returns false if dst cannot be written to or dst pixels cannot be allocated. -If paint is not nullptr and contains Mask_Filter, SkMaskFilter::filterMask +If paint is not nullptr and contains Mask_Filter, SkMaskFilter generates Mask_Alpha from Bitmap. allocator may reference a custom allocation class or be set to nullptr to use HeapAllocator. Sets offset to top-left position for dst for alignment with Bitmap; (0, 0) unless SkMaskFilter generates diff --git a/docs/SkImageInfo_Reference.bmh b/docs/SkImageInfo_Reference.bmh index 946fc842fd..38e5a6d736 100644 --- a/docs/SkImageInfo_Reference.bmh +++ b/docs/SkImageInfo_Reference.bmh @@ -1,6 +1,16 @@ #Topic Image_Info #Alias Image_Info_Reference +Image_Info specifies the dimensions and encoding of the pixels in a Bitmap. +The dimensions are integral width and height. The encoding is how pixel +bits describe Color_Alpha, transparency; Color components red, blue, +and green; and Color_Space, the range and linearity of colors. + +Image_Info describes an uncompressed raster pixels. In contrast, Image +additionally describes compressed pixels like PNG, and Surface describes +destinations on the GPU. Image and Surface may be specified by Image_Info, +but Image and Surface may not contain Image_Info. + #Subtopic Overview #Subtopic Subtopic #Populate @@ -13,11 +23,12 @@ # ------------------------------------------------------------------------------ #Subtopic Alpha_Type -#Line # incomplete ## +#Line # encoding for pixel transparency ## #Alias Alpha_Type #Alias Alpha_Types + #Enum SkAlphaType -#Line # incomplete ## +#Line # encoding for pixel transparency ## #Code enum SkAlphaType { @@ -29,36 +40,157 @@ }; ## -Describes how to interpret the alpha component of a pixel. +Describes how to interpret the alpha component of a pixel. A pixel may +be opaque, or Color_Alpha, describing multiple levels of transparency. + +In simple blending, Color_Alpha weights the draw color and the destination +color to create a new color. If alpha describes a weight from zero to one: + +#Formula + new color = draw color * alpha + destination color * (1 - alpha) +## + +In practice alpha is encoded in two or more bits, where 1.0 equals all bits set. + +Color_RGB may have Color_Alpha included in each component value; the stored +value is the original Color_RGB multiplied by Color_Alpha. Premultiplied color +components improve performance. #Const kUnknown_SkAlphaType 0 +Alpha_Type is uninitialized. ## #Const kOpaque_SkAlphaType 1 -All pixels are stored as opaque. +Pixels are opaque. The Color_Type must have no explicit alpha +component, or all alpha components must be set to their maximum value. ## #Const kPremul_SkAlphaType 2 -All pixels have their alpha premultiplied in their color components. -This is the natural format for the rendering target pixels. +Pixels have alpha premultiplied into color components. +Surface pixels must be premultiplied. ## #Const kUnpremul_SkAlphaType 3 -All pixels have their color components stored without any regard to the -alpha. e.g. this is the default configuration for PNG images. -kUnpremul_SkAlphaType is supported only for input images. Rendering cannot -generate this on output. +Pixel color component values are independent of alpha value. +Images generated from encoded data like PNG do not premultiply pixel color +components. kUnpremul_SkAlphaType is supported for Image pixels, but not for +Surface pixels. ## -#Example -// incomplete +#NoExample ## -#SeeAlso incomplete +#SeeAlso SkColorType SkColorSpace #Enum SkAlphaType ## + +#Subtopic Opaque + +Use Opaque as a hint to optimize drawing when alpha component +of all pixel is set to its maximum value of 1.0; all alpha component bits are set. +If Image_Info is set to Opaque but all alpha values are not 1.0, results are +undefined. + +#Example +#Height 64 +#Description +SkPreMultiplyARGB parameter a is set to 255, its maximum value, and is interpreted +as Color_Alpha of 1.0. kOpaque_SkAlphaType may be set to improve performance. +If SkPreMultiplyARGB parameter a is set to a value smaller than 255, +kPremul_SkAlphaType must be used instead to avoid undefined results. +The four displayed values are the original component values, though not necessarily +in the same order. +## + SkPMColor color = SkPreMultiplyARGB(255, 50, 100, 150); + SkString s; + s.printf("%u %u %u %u", SkColorGetA(color), SkColorGetR(color), + SkColorGetG(color), SkColorGetB(color)); + SkPaint paint; + paint.setAntiAlias(true); + canvas->drawString(s, 10, 62, paint); + canvas->scale(50, 50); + SkBitmap bitmap; + SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kOpaque_SkAlphaType); + if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) { + canvas->drawBitmap(bitmap, 0, 0); + } +## + +#Subtopic Opaque ## + +#Subtopic Premul + +Use Premul when stored color components are the original color multiplied by the +alpha component. The alpha component range of 0.0 to 1.0 is achieved by dividing +the integer bit value by the maximum bit value. + +#Formula +stored color = original color * alpha / max alpha +## + +The color component must be equal to or smaller than the alpha component, +or the results are undefined. + +#Example +#Description +SkPreMultiplyARGB parameter a is set to 150, less than its maximum value, and is +interpreted as Color_Alpha of about 0.6. kPremul_SkAlphaType must be set, since +SkPreMultiplyARGB parameter a is set to a value smaller than 255, +to avoid undefined results. +The four displayed values reflect that the alpha component has been multiplied +by the original color. +## +#Height 64 + SkPMColor color = SkPreMultiplyARGB(150, 50, 100, 150); + SkString s; + s.printf("%u %u %u %u", SkColorGetA(color), SkColorGetR(color), + SkColorGetG(color), SkColorGetB(color)); + SkPaint paint; + paint.setAntiAlias(true); + canvas->drawString(s, 10, 62, paint); + canvas->scale(50, 50); + SkBitmap bitmap; + SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kPremul_SkAlphaType); + if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) { + canvas->drawBitmap(bitmap, 0, 0); + } +## + +#Subtopic Premul ## + +#Subtopic Unpremul + +Use Unpremul if stored color components are not divided by the alpha component. +Some drawing destinations may not support Unpremul. + +#Bug 7079 +#Example +#Description +SkColorSetARGB parameter a is set to 150, less than its maximum value, and is +interpreted as Color_Alpha of about 0.6. color is not premultiplied; +color components may have values greater than color alpha. +The four displayed values are the original component values, though not necessarily +in the same order. +## + SkColor color = SkColorSetARGB(150, 50, 100, 255); + SkString s; + s.printf("%u %u %u %u", SkColorGetA(color), SkColorGetR(color), + SkColorGetG(color), SkColorGetB(color)); + SkPaint paint; + paint.setAntiAlias(true); + canvas->drawString(s, 10, 62, paint); + canvas->scale(50, 50); + SkBitmap bitmap; + SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kUnpremul_SkAlphaType); + if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) { + canvas->drawBitmap(bitmap, 0, 0); + } +## + +#Subtopic Unpremul ## + #Subtopic Alpha_Type ## # ------------------------------------------------------------------------------ #Subtopic Color_Type -#Line # incomplete ## +#Line # encoding for pixel color ## #Alias Color_Type #Alias Color_Types @@ -68,7 +200,7 @@ generate this on output. ## #Enum SkColorType -#Line # incomplete ## +#Line # encoding for pixel color ## #Code enum SkColorType { @@ -89,7 +221,8 @@ generate this on output. }; ## -Describes how to interpret the components of a pixel. +Describes how pixel bits encode color. A pixel may be an alpha mask, a +gray level, Color_RGB, or Color_ARGB. kN32_SkColorType selects the native 32-bit Color_ARGB format. On Little_Endian processors, pixels containing 8-bit Color_ARGB components pack into 32-bit @@ -97,38 +230,467 @@ kBGRA_8888_SkColorType. On Big_Endian processors, pixels pack into 32-bit kRGBA_8888_SkColorType. #Const kUnknown_SkColorType 0 + ## #Const kAlpha_8_SkColorType 1 + Encodes Color_Alpha as Alpha_8 pixel in an 8-bit byte. ## #Const kRGB_565_SkColorType 2 + Encodes Color_RGB as BGR_565 pixel in a 16-bit word. ## #Const kARGB_4444_SkColorType 3 + Encodes Color_ARGB as ABGR_4444 pixel in a 16-bit word. ## #Const kRGBA_8888_SkColorType 4 + Encodes Color_ARGB as RGBA_8888 pixel in a 32-bit word. ## #Const kRGB_888x_SkColorType 5 + Encodes Color_RGB as RGB_888x pixel in a 32-bit word. ## #Const kBGRA_8888_SkColorType 6 + Encodes Color_ARGB as BGRA_8888 pixel in a 32-bit word. ## #Const kRGBA_1010102_SkColorType 7 + Encodes Color_ARGB as RGBA_1010102 pixel in a 32-bit word. ## #Const kRGB_101010x_SkColorType 8 + Encodes Color_RGB as RGB_101010x pixel in a 32-bit word. ## #Const kGray_8_SkColorType 9 + Encodes Color_Gray as Gray_8 in an 8-bit byte. ## #Const kRGBA_F16_SkColorType 10 + Encodes Color_ARGB as RGBA_F16 in a 64-bit word. ## + #ToDo can be 4 or 6; how to document? ## #Const kN32_SkColorType 4 + Encodes Color_ARGB as either RGBA_8888 or BGRA_8888, whichever + is native to the platform. ## -#Example -// incomplete +#NoExample ## -#SeeAlso incomplete +#SeeAlso SkAlphaType SkColorSpace #Enum SkColorType ## + +#Subtopic Alpha_8 + +Alpha_8 is an 8-bit byte pixel encoding that represents transparency. A value of zero is +completely transparent; a value of 255 is completely opaque. Bitmap with Alpha_8 +pixels does not visibly draw, because its pixels have no color information. +The paired SkAlphaType is ignored. + +#Example +#Description +Alpha_8 pixels can modify another draw. orangePaint fills the bounds of bitmap, +with its transparency set to alpha8 pixel value. +## +#Height 64 + canvas->scale(16, 16); + SkBitmap bitmap; + SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kAlpha_8_SkColorType, kOpaque_SkAlphaType); + bitmap.allocPixels(imageInfo); + SkCanvas offscreen(bitmap); + offscreen.clear(SK_ColorGREEN); + SkPaint orangePaint; + orangePaint.setARGB(0xFF, 0xFF, 0xA5, 0x00); + canvas->drawBitmap(bitmap, 0, 0, &orangePaint); + uint8_t alpha8[] = { 0xFF, 0xBB, 0x77, 0x33 }; + SkPixmap alphaPixmap(imageInfo, &alpha8, imageInfo.minRowBytes()); + if (bitmap.writePixels(alphaPixmap, 0, 0)) { + canvas->drawBitmap(bitmap, 2, 2, &orangePaint); + } +## +## + +#Subtopic BGR_565 + +BGR_565 is a 16-bit word pixel encoding that contains five bits of blue, +six bits of green, and five bits of red. BGR_565 is fully opaque as if its +Color_Alpha was set to one, and should always be paired with kOpaque_SkAlphaType. + +#Illustration + +#Example +#Height 96 + canvas->scale(16, 16); + SkBitmap bitmap; + SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_565_SkColorType, kOpaque_SkAlphaType); + bitmap.allocPixels(imageInfo); + SkCanvas offscreen(bitmap); + offscreen.clear(SK_ColorGREEN); + canvas->drawBitmap(bitmap, 0, 0); + auto pack565 = [](unsigned r, unsigned g, unsigned b) -> uint16_t { + return (b << 0) | (g << 5) | (r << 11); + }; + uint16_t red565[] = { pack565(0x1F, 0x00, 0x00), pack565(0x17, 0x00, 0x00), + pack565(0x0F, 0x00, 0x00), pack565(0x07, 0x00, 0x00) }; + uint16_t blue565[] = { pack565(0x00, 0x00, 0x1F), pack565(0x00, 0x00, 0x17), + pack565(0x00, 0x00, 0x0F), pack565(0x00, 0x00, 0x07) }; + SkPixmap redPixmap(imageInfo, &red565, imageInfo.minRowBytes()); + if (bitmap.writePixels(redPixmap, 0, 0)) { + canvas->drawBitmap(bitmap, 2, 2); + } + SkPixmap bluePixmap(imageInfo, &blue565, imageInfo.minRowBytes()); + if (bitmap.writePixels(bluePixmap, 0, 0)) { + canvas->drawBitmap(bitmap, 4, 4); + } +## +## + +#Subtopic ABGR_4444 + +ABGR_4444 is a 16-bit word pixel encoding that contains four bits of alpha, +four bits of blue, four bits of green, and four bits of red. + +#Illustration + +If paired with kPremul_SkAlphaType: blue, green, and red components are +premultiplied by the alpha value. If blue, green, or red is greater than alpha, +the drawn result is undefined. + +If paired with kUnpremul_SkAlphaType: alpha, blue, green, and red components +may have any value. There may be a performance penalty with unpremultipled +pixels. + +If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; +blue, green, and red components are fully opaque. If any alpha component is +less than 15, the drawn result is undefined. + +#Bug 7648 + +#Example +#Height 96 + canvas->scale(16, 16); + SkBitmap bitmap; + SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kARGB_4444_SkColorType, kPremul_SkAlphaType); + bitmap.allocPixels(imageInfo); + SkCanvas offscreen(bitmap); + offscreen.clear(SK_ColorGREEN); + canvas->drawBitmap(bitmap, 0, 0); + auto pack4444 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint16_t { + return (a << 0) | (b << 4) | (g << 8) | (r << 12); + }; + uint16_t red4444[] = { pack4444(0xF, 0xF, 0x0, 0x0), pack4444(0xF, 0xb, 0x0, 0x0), + pack4444(0xF, 0x7, 0x0, 0x0), pack4444(0xF, 0x3, 0x0, 0x0) }; + uint16_t blue4444[] = { pack4444(0xF, 0x0, 0x0, 0xF), pack4444(0xF, 0x0, 0x0, 0xb), + pack4444(0xF, 0x0, 0x0, 0x7), pack4444(0xF, 0x0, 0x0, 0x3) }; + SkPixmap redPixmap(imageInfo, &red4444, imageInfo.minRowBytes()); + if (bitmap.writePixels(redPixmap, 0, 0)) { + canvas->drawBitmap(bitmap, 2, 2); + } + SkPixmap bluePixmap(imageInfo, &blue4444, imageInfo.minRowBytes()); + if (bitmap.writePixels(bluePixmap, 0, 0)) { + canvas->drawBitmap(bitmap, 4, 4); + } +## +## + +#Subtopic RGBA_8888 + +RGBA_8888 is a 32-bit word pixel encoding that contains eight bits of red, +eight bits of green, eight bits of blue, and eight bits of alpha. + +#Illustration + +If paired with kPremul_SkAlphaType: red, green, and blue components are +premultiplied by the alpha value. If red, green, or blue is greater than alpha, +the drawn result is undefined. + +If paired with kUnpremul_SkAlphaType: alpha, red, green, and blue components +may have any value. There may be a performance penalty with unpremultipled +pixels. + +If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; +red, green, and blue components are fully opaque. If any alpha component is +less than 255, the drawn result is undefined. + +On Big_Endian platforms, RGBA_8888 is the native Color_Type, and will have +the best performance. Use kN32_SkColorType to choose the best Color_Type for +the platform at compile time. + +#Example +#Height 96 + canvas->scale(16, 16); + SkBitmap bitmap; + SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_8888_SkColorType, kPremul_SkAlphaType); + bitmap.allocPixels(imageInfo); + SkCanvas offscreen(bitmap); + offscreen.clear(SK_ColorGREEN); + canvas->drawBitmap(bitmap, 0, 0); + auto pack8888 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint32_t { + return (r << 0) | (g << 8) | (b << 16) | (a << 24); + }; + uint32_t red8888[] = { pack8888(0xFF, 0xFF, 0x0, 0x0), pack8888(0xFF, 0xbb, 0x0, 0x0), + pack8888(0xFF, 0x77, 0x0, 0x0), pack8888(0xFF, 0x33, 0x0, 0x0) }; + uint32_t blue8888[] = { pack8888(0xFF, 0x0, 0x0, 0x0FF), pack8888(0xFF, 0x0, 0x0, 0x0bb), + pack8888(0xFF, 0x0, 0x0, 0x077), pack8888(0xFF, 0x0, 0x0, 0x033) }; + SkPixmap redPixmap(imageInfo, &red8888, imageInfo.minRowBytes()); + if (bitmap.writePixels(redPixmap, 0, 0)) { + canvas->drawBitmap(bitmap, 2, 2); + } + SkPixmap bluePixmap(imageInfo, &blue8888, imageInfo.minRowBytes()); + if (bitmap.writePixels(bluePixmap, 0, 0)) { + canvas->drawBitmap(bitmap, 4, 4); + } +## +## + +#Subtopic RGB_888x + +RGB_888x is a 32-bit word pixel encoding that contains eight bits of red, +eight bits of green, eight bits of blue, and eight unused bits. RGB_888x is fully +opaque as if its Color_Alpha was set to one, and should always be paired with +kOpaque_SkAlphaType. + +#Illustration + +#Example +#Bug 7645 +#Height 96 +#Platform cpu + canvas->scale(16, 16); + SkBitmap bitmap; + SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_888x_SkColorType, kOpaque_SkAlphaType); + bitmap.allocPixels(imageInfo); + SkCanvas offscreen(bitmap); + offscreen.clear(SK_ColorGREEN); + canvas->drawBitmap(bitmap, 0, 0); + auto pack888 = [](unsigned r, unsigned g, unsigned b) -> uint32_t { + return (r << 0) | (g << 8) | (b << 16); + }; + uint32_t red888[] = { pack888(0xFF, 0x00, 0x00), pack888(0xbb, 0x00, 0x00), + pack888(0x77, 0x00, 0x00), pack888(0x33, 0x00, 0x00) }; + uint32_t blue888[] = { pack888(0x00, 0x00, 0xFF), pack888(0x00, 0x00, 0xbb), + pack888(0x00, 0x00, 0x77), pack888(0x00, 0x00, 0x33) }; + if (bitmap.installPixels(imageInfo, (void*) red888, imageInfo.minRowBytes())) { + canvas->drawBitmap(bitmap, 2, 2); + } + if (bitmap.installPixels(imageInfo, (void*) blue888, imageInfo.minRowBytes())) { + canvas->drawBitmap(bitmap, 4, 4); + } +## +## + +#Subtopic BGRA_8888 + +BGRA_8888 is a 32-bit word pixel encoding that contains eight bits of blue, +eight bits of green, eight bits of red, and eight bits of alpha. + +#Illustration + +If paired with kPremul_SkAlphaType: blue, green, and red components are +premultiplied by the alpha value. If blue, green, or red is greater than alpha, +the drawn result is undefined. + +If paired with kUnpremul_SkAlphaType: blue, green, red, and alpha components +may have any value. There may be a performance penalty with unpremultipled +pixels. + +If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; +blue, green, and red components are fully opaque. If any alpha component is +less than 255, the drawn result is undefined. + +On Little_Endian platforms, BGRA_8888 is the native Color_Type, and will have +the best performance. Use kN32_SkColorType to choose the best Color_Type for +the platform at compile time. + +#Example +#Height 96 + canvas->scale(16, 16); + SkBitmap bitmap; + SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kBGRA_8888_SkColorType, kPremul_SkAlphaType); + bitmap.allocPixels(imageInfo); + SkCanvas offscreen(bitmap); + offscreen.clear(SK_ColorGREEN); + canvas->drawBitmap(bitmap, 0, 0); + auto pack8888 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint32_t { + return (b << 0) | (g << 8) | (r << 16) | (a << 24); + }; + uint32_t red8888[] = { pack8888(0xFF, 0xFF, 0x0, 0x0), pack8888(0xFF, 0xbb, 0x0, 0x0), + pack8888(0xFF, 0x99, 0x0, 0x0), pack8888(0xFF, 0x55, 0x0, 0x0) }; + uint32_t blue8888[] = { pack8888(0xFF, 0x0, 0x0, 0x0FF), pack8888(0xFF, 0x0, 0x0, 0x0bb), + pack8888(0xFF, 0x0, 0x0, 0x099), pack8888(0xFF, 0x0, 0x0, 0x055) }; + SkPixmap redPixmap(imageInfo, &red8888, imageInfo.minRowBytes()); + if (bitmap.writePixels(redPixmap, 0, 0)) { + canvas->drawBitmap(bitmap, 2, 2); + } + SkPixmap bluePixmap(imageInfo, &blue8888, imageInfo.minRowBytes()); + if (bitmap.writePixels(bluePixmap, 0, 0)) { + canvas->drawBitmap(bitmap, 4, 4); + } +## +## + +#Subtopic RGBA_1010102 + +RGBA_1010102 is a 32-bit word pixel encoding that contains ten bits of red, +ten bits of green, ten bits of blue, and two bits of alpha. Possible alpha +values are zero: fully transparent; one: 33% opaque; two: 67% opaque; +three: fully opaque. + +#Illustration + +If paired with kPremul_SkAlphaType: red, green, and blue components are +premultiplied by the alpha value. If red, green, or blue is greater than the +alpha replicated to ten bits, the drawn result is undefined. + +If paired with kUnpremul_SkAlphaType: alpha, red, green, and blue components +may have any value. There may be a performance penalty with unpremultipled +pixels. + +If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; +red, green, and blue components are fully opaque. If any alpha component is +less than 3, the drawn result is undefined. + +#Example +#Bug 7645 +#Height 96 +#Platform cpu + canvas->scale(16, 16); + SkBitmap bitmap; + SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_1010102_SkColorType, kOpaque_SkAlphaType); + bitmap.allocPixels(imageInfo); + SkCanvas offscreen(bitmap); + offscreen.clear(SK_ColorGREEN); + canvas->drawBitmap(bitmap, 0, 0); + auto pack1010102 = [](unsigned r, unsigned g, unsigned b, unsigned a) -> uint32_t { + return (r << 0) | (g << 10) | (b << 20) | (a << 30); + }; + uint32_t redBits[] = { pack1010102(0x3FF, 0x000, 0x000, 0x3), + pack1010102(0x2ff, 0x000, 0x000, 0x3), + pack1010102(0x1ff, 0x000, 0x000, 0x3), + pack1010102(0x0ff, 0x000, 0x000, 0x3) }; + uint32_t blueBits[] = { pack1010102(0x000, 0x000, 0x3FF, 0x3), + pack1010102(0x000, 0x000, 0x2ff, 0x3), + pack1010102(0x000, 0x000, 0x1ff, 0x3), + pack1010102(0x000, 0x000, 0x0ff, 0x3) }; + if (bitmap.installPixels(imageInfo, (void*) redBits, imageInfo.minRowBytes())) { + canvas->drawBitmap(bitmap, 2, 2); + } + SkPixmap bluePixmap(imageInfo, &blueBits, imageInfo.minRowBytes()); + if (bitmap.installPixels(imageInfo, (void*) blueBits, imageInfo.minRowBytes())) { + canvas->drawBitmap(bitmap, 4, 4); + } +## +## + +#Subtopic RGB_101010x + +#Illustration + +#Example +#Bug 7645 +#Height 96 +#Platform cpu + canvas->scale(16, 16); + SkBitmap bitmap; + SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_101010x_SkColorType, kOpaque_SkAlphaType); + bitmap.allocPixels(imageInfo); + SkCanvas offscreen(bitmap); + offscreen.clear(SK_ColorGREEN); + canvas->drawBitmap(bitmap, 0, 0); + auto pack101010x = [](unsigned r, unsigned g, unsigned b) -> uint32_t { + return (r << 0) | (g << 10) | (b << 20); + }; + uint32_t redBits[] = { pack101010x(0x3FF, 0x000, 0x000), pack101010x(0x2ff, 0x000, 0x000), + pack101010x(0x1ff, 0x000, 0x000), pack101010x(0x0ff, 0x000, 0x000) }; + uint32_t blueBits[] = { pack101010x(0x000, 0x000, 0x3FF), pack101010x(0x000, 0x000, 0x2ff), + pack101010x(0x000, 0x000, 0x1ff), pack101010x(0x000, 0x000, 0x0ff) }; + if (bitmap.installPixels(imageInfo, (void*) redBits, imageInfo.minRowBytes())) { + canvas->drawBitmap(bitmap, 2, 2); + } + SkPixmap bluePixmap(imageInfo, &blueBits, imageInfo.minRowBytes()); + if (bitmap.installPixels(imageInfo, (void*) blueBits, imageInfo.minRowBytes())) { + canvas->drawBitmap(bitmap, 4, 4); + } +## +## + +#Subtopic Gray_8 + +#Example +#Height 64 + canvas->scale(16, 16); + SkBitmap bitmap; + SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kGray_8_SkColorType, kOpaque_SkAlphaType); + bitmap.allocPixels(imageInfo); + SkCanvas offscreen(bitmap); + offscreen.clear(SK_ColorGREEN); + canvas->drawBitmap(bitmap, 0, 0); + uint8_t gray8[] = { 0xFF, 0xBB, 0x77, 0x33 }; + SkPixmap grayPixmap(imageInfo, &gray8, imageInfo.minRowBytes()); + if (bitmap.writePixels(grayPixmap, 0, 0)) { + canvas->drawBitmap(bitmap, 2, 2); + } +## +## + +#Subtopic RGBA_F16 + +#Illustration + +#ToDo +FloatToHalf should be replaced with SkFloatToHalf if/when that's made public +## + +#Example +#Height 96 +#Function +union FloatUIntUnion { + uint32_t fUInt; + float fFloat; +}; + +uint16_t FloatToHalf(float f) { + static const FloatUIntUnion magic = { 15 << 23 }; + static const uint32_t round_mask = ~0xfffu; + FloatUIntUnion floatUnion; + floatUnion.fFloat = f; + uint32_t sign = floatUnion.fUInt & 0x80000000u; + floatUnion.fUInt ^= sign; + floatUnion.fUInt &= round_mask; + floatUnion.fFloat *= magic.fFloat; + floatUnion.fUInt -= round_mask; + return (floatUnion.fUInt >> 13) | (sign >> 16); +} +## + +void draw(SkCanvas* canvas) { + canvas->scale(16, 16); + SkBitmap bitmap; + SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_F16_SkColorType, kPremul_SkAlphaType); + bitmap.allocPixels(imageInfo); + SkCanvas offscreen(bitmap); + offscreen.clear(SK_ColorGREEN); + canvas->drawBitmap(bitmap, 0, 0); + auto H = [](float c) -> uint16_t { + return FloatToHalf(c); + }; + // R G B A + uint16_t red_f16[][4] = { { H(1.0f), H(0.0f), H(0.0f), H(1.0f) }, + { H(.75f), H(0.0f), H(0.0f), H(1.0f) }, + { H(.50f), H(0.0f), H(0.0f), H(1.0f) }, + { H(.25f), H(0.0f), H(0.0f), H(1.0f) } }; + uint16_t blue_f16[][4] = { { H(0.0f), H(0.0f), H(1.0f), H(1.0f) }, + { H(0.0f), H(0.0f), H(.75f), H(1.0f) }, + { H(0.0f), H(0.0f), H(.50f), H(1.0f) }, + { H(0.0f), H(0.0f), H(.25f), H(1.0f) } }; + SkPixmap redPixmap(imageInfo, red_f16, imageInfo.minRowBytes()); + if (bitmap.writePixels(redPixmap, 0, 0)) { + canvas->drawBitmap(bitmap, 2, 2); + } + SkPixmap bluePixmap(imageInfo, blue_f16, imageInfo.minRowBytes()); + if (bitmap.writePixels(bluePixmap, 0, 0)) { + canvas->drawBitmap(bitmap, 4, 4); + } +} +## +## + #Subtopic Color_Type ## # ------------------------------------------------------------------------------ diff --git a/docs/SkImage_Reference.bmh b/docs/SkImage_Reference.bmh index fa08509d9b..7f5832f241 100644 --- a/docs/SkImage_Reference.bmh +++ b/docs/SkImage_Reference.bmh @@ -381,7 +381,8 @@ for (int quality : { 100, 50, 10, 1} ) { SkColorType colorType, SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace) - +#In Constructor +#Line # creates Image from GPU_Texture ## Creates Image from GPU_Texture associated with context. Caller is responsible for managing the lifetime of GPU_Texture. diff --git a/docs/SkPaint_Reference.bmh b/docs/SkPaint_Reference.bmh index b92fa4b0b4..6a40f752cc 100644 --- a/docs/SkPaint_Reference.bmh +++ b/docs/SkPaint_Reference.bmh @@ -814,7 +814,7 @@ at compile time. ## -#Subtopic Antialias ## +#Subtopic Anti-alias ## # ------------------------------------------------------------------------------ #Subtopic Dither #Line # distributing color error ## diff --git a/docs/illustrations.bmh b/docs/illustrations.bmh new file mode 100644 index 0000000000..a7b5068cc4 --- /dev/null +++ b/docs/illustrations.bmh @@ -0,0 +1,452 @@ +#Topic Illustrations
+
+#Subtopic Image_Info_Color_Type_BGR_565
+#Example
+#Width 415
+#Height 250
+void draw(SkCanvas* canvas) {
+ canvas->scale(1.25f, 1.25f);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setTextSize(10);
+ paint.setTextAlign(SkPaint::kCenter_Align);
+ canvas->drawString("16-bit word", 5 + 20 * 8, 20, paint);
+ canvas->drawString("little endian byte order", 5 + 20 * 4, 85, paint);
+ canvas->drawString("(low bits)", 5 + 20 * 1.5f, 137, paint);
+ canvas->drawString("(high bits)", 5 + 20 * 6.5f, 187, paint);
+ auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {
+ SkPaint p(paint);
+ p.setColor(SK_ColorRED);
+ SkScalar xPos = 15;
+ int width = n % 32 + 1;
+ int lastN = n > 32 ? 32 : 0;
+ for (; n >= lastN; --n) {
+ for (int i = 0; i <= count; ++i) {
+ int a = width - e[i];
+ if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {
+ char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'};
+ canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);
+ break;
+ }
+ }
+ xPos += 20;
+ }
+ p.setColor(SK_ColorBLACK);
+ for (int i = 0; i < count; ++i) {
+ canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);
+ }
+ p.setStyle(SkPaint::kStroke_Style);
+ for (int i = 0; i <= count; ++i) {
+ canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);
+ }
+ for (int i = 0; i < 2; ++i) {
+ canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);
+ }
+ };
+ SkScalar edges[] = { 0, 5, 11, 16,
+ 0, 3, 8,
+ 0, 5, 8 };
+ const char* labels[] = { "red", "green", "blue" };
+ drawBoxText(&edges[0], &labels[0], 3, 15, 45);
+ drawBoxText(&edges[4], &labels[1], 2, 7, 110);
+ drawBoxText(&edges[7], &labels[0], 2, 7, 160);
+}
+##
+##
+
+#Subtopic Image_Info_Color_Type_ABGR_4444
+#Example
+#Width 415
+#Height 250
+void draw(SkCanvas* canvas) {
+ canvas->scale(1.25f, 1.25f);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setTextSize(10);
+ paint.setTextAlign(SkPaint::kCenter_Align);
+ canvas->drawString("16-bit word", 5 + 20 * 8, 20, paint);
+ canvas->drawString("little endian byte order", 5 + 20 * 4, 85, paint);
+ auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {
+ SkPaint p(paint);
+ p.setColor(SK_ColorRED);
+ SkScalar xPos = 15;
+ int width = n % 32 + 1;
+ int lastN = n > 32 ? 32 : 0;
+ for (; n >= lastN; --n) {
+ for (int i = 0; i <= count; ++i) {
+ int a = width - e[i];
+ if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {
+ char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'};
+ canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);
+ break;
+ }
+ }
+ xPos += 20;
+ }
+ p.setColor(SK_ColorBLACK);
+ for (int i = 0; i < count; ++i) {
+ canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);
+ }
+ p.setStyle(SkPaint::kStroke_Style);
+ for (int i = 0; i <= count; ++i) {
+ canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);
+ }
+ for (int i = 0; i < 2; ++i) {
+ canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);
+ }
+ };
+ SkScalar edges[] = { 0, 4, 8, 12, 16 };
+ const char* labels[] = { "red", "green", "blue", "alpha" };
+ drawBoxText(&edges[0], &labels[0], 4, 15, 45);
+ drawBoxText(&edges[0], &labels[2], 2, 7, 110);
+ drawBoxText(&edges[0], &labels[0], 2, 7, 160);
+}
+##
+##
+
+#Subtopic Image_Info_Color_Type_RGBA_8888
+#Example
+#Width 812
+#Height 365
+void draw(SkCanvas* canvas) {
+ canvas->scale(1.25f, 1.25f);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setTextSize(10);
+ paint.setTextAlign(SkPaint::kCenter_Align);
+ canvas->drawString("32-bit word", 5 + 20 * 16, 20, paint);
+ canvas->drawString("little endian byte order", 5 + 20 * 4, 85, paint);
+ auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {
+ SkPaint p(paint);
+ p.setColor(SK_ColorRED);
+ SkScalar xPos = 15;
+ int width = n % 32 + 1;
+ int lastN = n > 32 ? 32 : 0;
+ for (; n >= lastN; --n) {
+ for (int i = 0; i <= count; ++i) {
+ int a = width - e[i];
+ if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {
+ char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'};
+ canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);
+ break;
+ }
+ }
+ xPos += 20;
+ }
+ p.setColor(SK_ColorBLACK);
+ for (int i = 0; i < count; ++i) {
+ canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);
+ }
+ p.setStyle(SkPaint::kStroke_Style);
+ for (int i = 0; i <= count; ++i) {
+ canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);
+ }
+ for (int i = 0; i < 2; ++i) {
+ canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);
+ }
+ };
+ SkScalar edges[] = { 0, 8, 16, 24, 32 };
+ const char* labels[] = { "alpha", "blue", "green", "red" };
+ drawBoxText(edges, &labels[0], 4, 31, 45);
+ drawBoxText(edges, &labels[3], 1, 7, 110);
+ drawBoxText(edges, &labels[2], 1, 7, 160);
+ drawBoxText(edges, &labels[1], 1, 7, 210);
+ drawBoxText(edges, &labels[0], 1, 7, 260);
+}
+##
+##
+
+#Subtopic Image_Info_Color_Type_RGB_888x
+#Example
+#Width 812
+#Height 365
+void draw(SkCanvas* canvas) {
+ canvas->scale(1.25f, 1.25f);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setTextSize(10);
+ paint.setTextAlign(SkPaint::kCenter_Align);
+ canvas->drawString("32-bit word", 5 + 20 * 16, 20, paint);
+ canvas->drawString("little endian byte order", 5 + 20 * 4, 85, paint);
+ auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {
+ SkPaint p(paint);
+ p.setColor(SK_ColorRED);
+ SkScalar xPos = 15;
+ int width = n % 32 + 1;
+ int lastN = n > 32 ? 32 : 0;
+ for (; n >= lastN; --n) {
+ for (int i = 0; i <= count; ++i) {
+ int a = width - e[i];
+ if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {
+ char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'};
+ canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);
+ break;
+ }
+ }
+ xPos += 20;
+ }
+ p.setColor(SK_ColorBLACK);
+ for (int i = 0; i < count; ++i) {
+ canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);
+ }
+ p.setStyle(SkPaint::kStroke_Style);
+ for (int i = 0; i <= count; ++i) {
+ canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);
+ }
+ for (int i = 0; i < 2; ++i) {
+ canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);
+ }
+ };
+ SkScalar edges[] = { 0, 8, 16, 24, 32 };
+ const char* labels[] = { "(unused)", "blue", "green", "red" };
+ drawBoxText(edges, &labels[0], 4, 31, 45);
+ drawBoxText(edges, &labels[3], 1, 7, 110);
+ drawBoxText(edges, &labels[2], 1, 7, 160);
+ drawBoxText(edges, &labels[1], 1, 7, 210);
+ drawBoxText(edges, &labels[0], 1, 7, 260);
+}
+##
+##
+
+#Subtopic Image_Info_Color_Type_BGRA_8888
+#Example
+#Width 812
+#Height 365
+void draw(SkCanvas* canvas) {
+ canvas->scale(1.25f, 1.25f);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setTextSize(10);
+ paint.setTextAlign(SkPaint::kCenter_Align);
+ canvas->drawString("32-bit word", 5 + 20 * 16, 20, paint);
+ canvas->drawString("little endian byte order", 5 + 20 * 4, 85, paint);
+ auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {
+ SkPaint p(paint);
+ p.setColor(SK_ColorRED);
+ SkScalar xPos = 15;
+ int width = n % 32 + 1;
+ int lastN = n > 32 ? 32 : 0;
+ for (; n >= lastN; --n) {
+ for (int i = 0; i <= count; ++i) {
+ int a = width - e[i];
+ if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {
+ char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'};
+ canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);
+ break;
+ }
+ }
+ xPos += 20;
+ }
+ p.setColor(SK_ColorBLACK);
+ for (int i = 0; i < count; ++i) {
+ canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);
+ }
+ p.setStyle(SkPaint::kStroke_Style);
+ for (int i = 0; i <= count; ++i) {
+ canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);
+ }
+ for (int i = 0; i < 2; ++i) {
+ canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);
+ }
+ };
+ SkScalar edges[] = { 0, 8, 16, 24, 32 };
+ const char* labels[] = { "alpha", "red", "green", "blue" };
+ drawBoxText(edges, &labels[0], 4, 31, 45);
+ drawBoxText(edges, &labels[3], 1, 7, 110);
+ drawBoxText(edges, &labels[2], 1, 7, 160);
+ drawBoxText(edges, &labels[1], 1, 7, 210);
+ drawBoxText(edges, &labels[0], 1, 7, 260);
+}
+##
+##
+
+#Subtopic Image_Info_Color_Type_RGBA_1010102
+#Example
+#Width 812
+#Height 380
+void draw(SkCanvas* canvas) {
+ canvas->scale(1.25f, 1.25f);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setTextSize(10);
+ paint.setTextAlign(SkPaint::kCenter_Align);
+ canvas->drawString("32-bit word", 5 + 20 * 16, 20, paint);
+ canvas->drawString("little endian byte order", 5 + 20 * 4, 85, paint);
+ canvas->drawString("(low bits)", 5 + 20 * 4, 137, paint);
+ canvas->drawString("(low bits)", 5 + 20 * 3, 187, paint);
+ canvas->drawString("(high bits)", 5 + 20 * 7, 187, paint);
+ canvas->drawString("(low bits)", 5 + 20 * 2, 237, paint);
+ canvas->drawString("(high bits)", 5 + 20 * 6, 237, paint);
+ canvas->drawString("(high bits)", 5 + 20 * 5, 287, paint);
+ auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {
+ SkPaint p(paint);
+ p.setColor(SK_ColorRED);
+ SkScalar xPos = 15;
+ int width = n % 32 + 1;
+ int lastN = n > 32 ? 32 : 0;
+ for (; n >= lastN; --n) {
+ for (int i = 0; i <= count; ++i) {
+ int a = width - e[i];
+ if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {
+ char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'};
+ canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);
+ break;
+ }
+ }
+ xPos += 20;
+ }
+ p.setColor(SK_ColorBLACK);
+ for (int i = 0; i < count; ++i) {
+ canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);
+ }
+ p.setStyle(SkPaint::kStroke_Style);
+ for (int i = 0; i <= count; ++i) {
+ canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);
+ }
+ for (int i = 0; i < 2; ++i) {
+ canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);
+ }
+ };
+ SkScalar edges[] = { 0, 2, 12, 22, 32,
+ 0, 8,
+ 0, 6, 8,
+ 0, 4, 8,
+ 0, 2, 8
+ };
+ const char* labels[] = { "alpha", "blue", "green", "red" };
+ drawBoxText(&edges[0], &labels[0], 4, 31, 45);
+ drawBoxText(&edges[5], &labels[3], 1, 7, 110);
+ drawBoxText(&edges[7], &labels[2], 2, 7, 160);
+ drawBoxText(&edges[10], &labels[1], 2, 7, 210);
+ drawBoxText(&edges[13], &labels[0], 2, 7, 260);
+}
+##
+##
+
+#Subtopic Image_Info_Color_Type_RGB_101010x
+#Example
+#Width 812
+#Height 380
+void draw(SkCanvas* canvas) {
+ canvas->scale(1.25f, 1.25f);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setTextSize(10);
+ paint.setTextAlign(SkPaint::kCenter_Align);
+ canvas->drawString("32-bit word", 5 + 20 * 16, 20, paint);
+ canvas->drawString("little endian byte order", 5 + 20 * 4, 85, paint);
+ canvas->drawString("(low bits)", 5 + 20 * 4, 137, paint);
+ canvas->drawString("(low bits)", 5 + 20 * 3, 187, paint);
+ canvas->drawString("(high bits)", 5 + 20 * 7, 187, paint);
+ canvas->drawString("(low bits)", 5 + 20 * 2, 237, paint);
+ canvas->drawString("(high bits)", 5 + 20 * 6, 237, paint);
+ canvas->drawString("(high bits)", 5 + 20 * 5, 287, paint);
+ auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {
+ SkPaint p(paint);
+ p.setColor(SK_ColorRED);
+ SkScalar xPos = 15;
+ int width = n % 32 + 1;
+ int lastN = n > 32 ? 32 : 0;
+ for (; n >= lastN; --n) {
+ for (int i = 0; i <= count; ++i) {
+ int a = width - e[i];
+ if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {
+ char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'};
+ canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);
+ break;
+ }
+ }
+ xPos += 20;
+ }
+ p.setColor(SK_ColorBLACK);
+ for (int i = 0; i < count; ++i) {
+ canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);
+ }
+ p.setStyle(SkPaint::kStroke_Style);
+ for (int i = 0; i <= count; ++i) {
+ canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);
+ }
+ for (int i = 0; i < 2; ++i) {
+ canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);
+ }
+ };
+ SkScalar edges[] = { 0, 2, 12, 22, 32,
+ 0, 8,
+ 0, 6, 8,
+ 0, 4, 8,
+ 0, 2, 8
+ };
+ const char* labels[] = { "unused", "blue", "green", "red" };
+ drawBoxText(&edges[0], &labels[0], 4, 31, 45);
+ drawBoxText(&edges[5], &labels[3], 1, 7, 110);
+ drawBoxText(&edges[7], &labels[2], 2, 7, 160);
+ drawBoxText(&edges[10], &labels[1], 2, 7, 210);
+ drawBoxText(&edges[13], &labels[0], 2, 7, 260);
+}
+##
+##
+
+#Subtopic Image_Info_Color_Type_RGBA_F16
+#Example
+#Width 812
+#Height 685
+void draw(SkCanvas* canvas) {
+ canvas->scale(1.25f, 1.25f);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setTextSize(10);
+ paint.setTextAlign(SkPaint::kCenter_Align);
+ canvas->drawString("64-bit word", 5 + 20 * 16, 20, paint);
+ canvas->drawString("little endian byte order", 5 + 20 * 4, 135, paint);
+ for (int i = 0; i < 4; ++i) {
+ canvas->drawString("(low bits)", 5 + 20 * 4, 187 + i * 100, paint);
+ canvas->drawString("(high bits)", 5 + 20 * 4, 237 + i * 100, paint);
+ }
+ auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {
+ SkPaint p(paint);
+ p.setColor(SK_ColorRED);
+ SkScalar xPos = 15;
+ int width = n % 32 + 1;
+ int lastN = n > 32 ? 32 : 0;
+ for (; n >= lastN; --n) {
+ for (int i = 0; i <= count; ++i) {
+ int a = width - e[i];
+ if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {
+ char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'};
+ canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);
+ break;
+ }
+ }
+ xPos += 20;
+ }
+ p.setColor(SK_ColorBLACK);
+ for (int i = 0; i < count; ++i) {
+ canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);
+ }
+ p.setStyle(SkPaint::kStroke_Style);
+ for (int i = 0; i <= count; ++i) {
+ canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);
+ }
+ for (int i = 0; i < 2; ++i) {
+ canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);
+ }
+ };
+ SkScalar edges[] = { 0, 16, 32,
+ 0, 8
+ };
+ const char* labels[] = { "alpha", "blue", "green", "red" };
+ drawBoxText(&edges[0], &labels[0], 2, 63, 45);
+ drawBoxText(&edges[0], &labels[2], 2, 31, 95);
+ drawBoxText(&edges[3], &labels[3], 1, 7, 160);
+ drawBoxText(&edges[3], &labels[3], 1, 7, 210);
+ drawBoxText(&edges[3], &labels[2], 1, 7, 260);
+ drawBoxText(&edges[3], &labels[2], 1, 7, 310);
+ drawBoxText(&edges[3], &labels[1], 1, 7, 360);
+ drawBoxText(&edges[3], &labels[1], 1, 7, 410);
+ drawBoxText(&edges[3], &labels[0], 1, 7, 460);
+ drawBoxText(&edges[3], &labels[0], 1, 7, 510);
+}
+##
+##
+
+#Topic Illustrations ##
diff --git a/docs/status.json b/docs/status.json index 7b8b7f7175..a8888020dd 100644 --- a/docs/status.json +++ b/docs/status.json @@ -29,6 +29,7 @@ "SkMatrix_Reference.bmh",
"SkPixmap_Reference.bmh",
"SkSurface_Reference.bmh",
+ "illustrations.bmh",
"undocumented.bmh"
]
},
diff --git a/docs/undocumented.bmh b/docs/undocumented.bmh index 5f0d2fa6d6..70a26dec80 100644 --- a/docs/undocumented.bmh +++ b/docs/undocumented.bmh @@ -111,6 +111,8 @@ FT_Load_Glyph ## #Method int SkColorSetARGB(a, r, g, b) ## + #Method SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) + ## #Const SK_ColorBLACK 0xFF000000 ## @@ -149,6 +151,9 @@ FT_Load_Glyph #Substitute RGB-565 #Alias Color_RGB-565 # quit changing - to _ ! #Subtopic ## + + #Subtopic Gray + ## #Topic ## #Topic Color_Filter @@ -377,31 +382,11 @@ FT_Load_Glyph ## ## -#Topic Mask -#Class SkMask - #Enum Format - #Const kBW_Format 0 - ## - #Const kA8_Format 1 - ## - #Const k3D_Format 2 - ## - #Const kARGB32_Format 3 - ## - k#Const LCD16_Format 4 - ## - ## -## -#Topic ## - #Topic Mask_Alpha #Topic ## #Topic Mask_Filter #Class SkMaskFilter -#Method virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, - SkIPoint* margin) const -## #Method void toString(SkString* str) const ## #Class ## diff --git a/site/user/api/SkBitmap_Reference.md b/site/user/api/SkBitmap_Reference.md index bd407fe7d1..54a2db3172 100644 --- a/site/user/api/SkBitmap_Reference.md +++ b/site/user/api/SkBitmap_Reference.md @@ -3464,7 +3464,7 @@ bool extractAlpha(SkBitmap* dst, const SkPaint* paint, SkIPoint* offset) const Sets <a href="#SkBitmap_extractAlpha_2_dst">dst</a> to <a href="undocumented#Alpha">Alpha</a> described by pixels. Returns false if <a href="#SkBitmap_extractAlpha_2_dst">dst</a> cannot be written to or <a href="#SkBitmap_extractAlpha_2_dst">dst</a> pixels cannot be allocated. -If <a href="#SkBitmap_extractAlpha_2_paint">paint</a> is not nullptr and contains <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#SkMaskFilter_filterMask">SkMaskFilter::filterMask</a> +If <a href="#SkBitmap_extractAlpha_2_paint">paint</a> is not nullptr and contains <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#SkMaskFilter">SkMaskFilter</a> generates <a href="undocumented#Mask_Alpha">Mask Alpha</a> from <a href="#Bitmap">Bitmap</a>. Uses <a href="#SkBitmap_HeapAllocator">HeapAllocator</a> to reserve memory for <a href="#SkBitmap_extractAlpha_2_dst">dst</a> <a href="undocumented#Pixel_Ref">Pixel Ref</a>. Sets <a href="#SkBitmap_extractAlpha_2_offset">offset</a> to top-left position for <a href="#SkBitmap_extractAlpha_2_dst">dst</a> for alignment with <a href="#Bitmap">Bitmap</a>; (0, 0) unless <a href="undocumented#SkMaskFilter">SkMaskFilter</a> generates mask. @@ -3503,7 +3503,7 @@ bool extractAlpha(SkBitmap* dst, const SkPaint* paint, Allocator* allocator, SkI Sets <a href="#SkBitmap_extractAlpha_3_dst">dst</a> to <a href="undocumented#Alpha">Alpha</a> described by pixels. Returns false if <a href="#SkBitmap_extractAlpha_3_dst">dst</a> cannot be written to or <a href="#SkBitmap_extractAlpha_3_dst">dst</a> pixels cannot be allocated. -If <a href="#SkBitmap_extractAlpha_3_paint">paint</a> is not nullptr and contains <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#SkMaskFilter_filterMask">SkMaskFilter::filterMask</a> +If <a href="#SkBitmap_extractAlpha_3_paint">paint</a> is not nullptr and contains <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#SkMaskFilter">SkMaskFilter</a> generates <a href="undocumented#Mask_Alpha">Mask Alpha</a> from <a href="#Bitmap">Bitmap</a>. <a href="#SkBitmap_extractAlpha_3_allocator">allocator</a> may reference a custom allocation class or be set to nullptr to use <a href="#SkBitmap_HeapAllocator">HeapAllocator</a>. Sets <a href="#SkBitmap_extractAlpha_3_offset">offset</a> to top-left position for <a href="#SkBitmap_extractAlpha_3_dst">dst</a> for alignment with <a href="#Bitmap">Bitmap</a>; (0, 0) unless <a href="undocumented#SkMaskFilter">SkMaskFilter</a> generates diff --git a/site/user/api/SkImageInfo_Reference.md b/site/user/api/SkImageInfo_Reference.md index c71dbab526..2584d0ecd8 100644 --- a/site/user/api/SkImageInfo_Reference.md +++ b/site/user/api/SkImageInfo_Reference.md @@ -2,6 +2,15 @@ SkImageInfo Reference === # <a name="Image_Info"></a> Image Info +<a href="#Image_Info">Image Info</a> specifies the dimensions and encoding of the pixels in a <a href="SkBitmap_Reference#Bitmap">Bitmap</a>. +The dimensions are integral width and height. The encoding is how pixel +bits describe <a href="undocumented#Alpha">Color Alpha</a>, transparency; <a href="undocumented#Color">Color</a> components red, blue, +and green; and <a href="undocumented#Color_Space">Color Space</a>, the range and linearity of colors. + +<a href="#Image_Info">Image Info</a> describes an uncompressed raster pixels. In contrast, <a href="SkImage_Reference#Image">Image</a> +additionally describes compressed pixels like PNG, and <a href="SkSurface_Reference#Surface">Surface</a> describes +destinations on the GPU. <a href="SkImage_Reference#Image">Image</a> and <a href="SkSurface_Reference#Surface">Surface</a> may be specified by <a href="#Image_Info">Image Info</a>, +but <a href="SkImage_Reference#Image">Image</a> and <a href="SkSurface_Reference#Surface">Surface</a> may not contain <a href="#Image_Info">Image Info</a>. ## <a name="Overview"></a> Overview @@ -32,38 +41,92 @@ enum <a href="#SkAlphaType">SkAlphaType</a> { kLastEnum_SkAlphaType = <a href="#kUnpremul_SkAlphaType">kUnpremul_SkAlphaType</a>, };</pre> -Describes how to interpret the alpha component of a pixel. +Describes how to interpret the alpha component of a pixel. A pixel may +be opaque, or <a href="undocumented#Alpha">Color Alpha</a>, describing multiple levels of transparency. + +In simple blending, <a href="undocumented#Alpha">Color Alpha</a> weights the draw color and the destination +color to create a new color. If alpha describes a weight from zero to one: + +new color = draw color * alpha + destination color * (1 - alpha)In practice alpha is encoded in two or more bits, where 1.0 equals all bits set. + +<a href="undocumented#RGB">Color RGB</a> may have <a href="undocumented#Alpha">Color Alpha</a> included in each component value; the stored +value is the original <a href="undocumented#RGB">Color RGB</a> multiplied by <a href="undocumented#Alpha">Color Alpha</a>. <a href="undocumented#Premultiply">Premultiplied</a> color +components improve performance. ### Constants <table> <tr> - <td><a name="kUnknown_SkAlphaType"> <code><strong>kUnknown_SkAlphaType </strong></code> </a></td><td>0</td><td></td> + <td><a name="kUnknown_SkAlphaType"> <code><strong>kUnknown_SkAlphaType </strong></code> </a></td><td>0</td><td><a href="#Alpha_Type">Alpha Type</a> is uninitialized.</td> </tr> <tr> - <td><a name="kOpaque_SkAlphaType"> <code><strong>kOpaque_SkAlphaType </strong></code> </a></td><td>1</td><td>All pixels are stored as opaque.</td> + <td><a name="kOpaque_SkAlphaType"> <code><strong>kOpaque_SkAlphaType </strong></code> </a></td><td>1</td><td>Pixels are opaque. The <a href="#Color_Type">Color Type</a> must have no explicit alpha +component, or all alpha components must be set to their maximum value.</td> </tr> <tr> - <td><a name="kPremul_SkAlphaType"> <code><strong>kPremul_SkAlphaType </strong></code> </a></td><td>2</td><td>All pixels have their alpha premultiplied in their color components. -This is the natural format for the rendering target pixels.</td> + <td><a name="kPremul_SkAlphaType"> <code><strong>kPremul_SkAlphaType </strong></code> </a></td><td>2</td><td>Pixels have alpha premultiplied into color components. +<a href="SkSurface_Reference#Surface">Surface</a> pixels must be premultiplied.</td> </tr> <tr> - <td><a name="kUnpremul_SkAlphaType"> <code><strong>kUnpremul_SkAlphaType </strong></code> </a></td><td>3</td><td>All pixels have their color components stored without any regard to the -alpha. e.g. this is the default configuration for PNG images. -<a href="#kUnpremul_SkAlphaType">kUnpremul_SkAlphaType</a> is supported only for input images. Rendering cannot -generate this on output.</td> + <td><a name="kUnpremul_SkAlphaType"> <code><strong>kUnpremul_SkAlphaType </strong></code> </a></td><td>3</td><td><a href="undocumented#Pixel">Pixel</a> color component values are independent of alpha value. +Images generated from encoded data like PNG do not premultiply pixel color +components. <a href="#kUnpremul_SkAlphaType">kUnpremul_SkAlphaType</a> is supported for <a href="SkImage_Reference#Image">Image</a> pixels, but not for +<a href="SkSurface_Reference#Surface">Surface</a> pixels.</td> </tr> </table> +### See Also + +<a href="#SkColorType">SkColorType</a> <a href="undocumented#SkColorSpace">SkColorSpace</a> + + + +## <a name="Alpha_Type_Opaque"></a> Alpha Type Opaque + +Use <a href="#Alpha_Type_Opaque">Opaque</a> as a hint to optimize drawing when alpha component +of all pixel is set to its maximum value of 1.0; all alpha component bits are set. +If <a href="#Image_Info">Image Info</a> is set to <a href="#Alpha_Type_Opaque">Opaque</a> but all alpha values are not 1.0, results are +undefined. + ### Example -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> +<div><fiddle-embed name="79146a1a41d58d22582fdc567c6ffe4e"><div><a href="undocumented#SkPreMultiplyARGB">SkPreMultiplyARGB</a> parameter a is set to 255, its maximum value, and is interpreted +as <a href="undocumented#Alpha">Color Alpha</a> of 1.0. <a href="#kOpaque_SkAlphaType">kOpaque_SkAlphaType</a> may be set to improve performance. +If <a href="undocumented#SkPreMultiplyARGB">SkPreMultiplyARGB</a> parameter a is set to a value smaller than 255, +<a href="#kPremul_SkAlphaType">kPremul_SkAlphaType</a> must be used instead to avoid undefined results. +The four displayed values are the original component values, though not necessarily +in the same order.</div></fiddle-embed></div> -### See Also +## <a name="Alpha_Type_Premul"></a> Alpha Type Premul -incomplete +Use <a href="#Alpha_Type_Premul">Premul</a> when stored color components are the original color multiplied by the +alpha component. The alpha component range of 0.0 to 1.0 is achieved by dividing +the integer bit value by the maximum bit value. + +stored color = original color * alpha / max alphaThe color component must be equal to or smaller than the alpha component, +or the results are undefined. + +### Example + +<div><fiddle-embed name="ad696b39c915803d566e96896ec3a36c"><div><a href="undocumented#SkPreMultiplyARGB">SkPreMultiplyARGB</a> parameter a is set to 150, less than its maximum value, and is +interpreted as <a href="undocumented#Alpha">Color Alpha</a> of about 0.6. <a href="#kPremul_SkAlphaType">kPremul_SkAlphaType</a> must be set, since +<a href="undocumented#SkPreMultiplyARGB">SkPreMultiplyARGB</a> parameter a is set to a value smaller than 255, +to avoid undefined results. +The four displayed values reflect that the alpha component has been multiplied +by the original color.</div></fiddle-embed></div> +## <a name="Alpha_Type_Unpremul"></a> Alpha Type Unpremul +Use <a href="#Alpha_Type_Unpremul">Unpremul</a> if stored color components are not divided by the alpha component. +Some drawing destinations may not support <a href="#Alpha_Type_Unpremul">Unpremul</a>. + +### Example + +<div><fiddle-embed name="46e528e0c6b3f3e296d0d0930d638629"><div><a href="undocumented#SkColorSetARGB">SkColorSetARGB</a> parameter a is set to 150, less than its maximum value, and is +interpreted as <a href="undocumented#Alpha">Color Alpha</a> of about 0.6. color is not premultiplied; +color components may have values greater than color alpha. +The four displayed values are the original component values, though not necessarily +in the same order.</div></fiddle-embed></div> ## <a name="Color_Type"></a> Color Type @@ -89,7 +152,8 @@ kLastEnum_SkColorType = <a href="#kRGBA_F16_SkColorType">kRGBA_F16_SkColorType</ <a href="#kN32_SkColorType">kN32_SkColorType</a> = <a href="#kRGBA_8888_SkColorType">kRGBA_8888_SkColorType</a>, };</pre> -Describes how to interpret the components of a pixel. +Describes how pixel bits encode color. A pixel may be an alpha mask, a +gray level, <a href="undocumented#RGB">Color RGB</a>, or <a href="undocumented#ARGB">Color ARGB</a>. <a href="#kN32_SkColorType">kN32_SkColorType</a> selects the native 32-bit <a href="undocumented#ARGB">Color ARGB</a> format. On Little_Endian processors, pixels containing 8-bit <a href="undocumented#ARGB">Color ARGB</a> components pack into 32-bit @@ -103,34 +167,34 @@ processors, pixels containing 8-bit <a href="undocumented#ARGB">Color ARGB</a> c <td><a name="kUnknown_SkColorType"> <code><strong>kUnknown_SkColorType </strong></code> </a></td><td>0</td><td></td> </tr> <tr> - <td><a name="kAlpha_8_SkColorType"> <code><strong>kAlpha_8_SkColorType </strong></code> </a></td><td>1</td><td></td> + <td><a name="kAlpha_8_SkColorType"> <code><strong>kAlpha_8_SkColorType </strong></code> </a></td><td>1</td><td>Encodes <a href="undocumented#Alpha">Color Alpha</a> as <a href="#Color_Type_Alpha_8">Alpha 8</a> pixel in an 8-bit byte.</td> </tr> <tr> - <td><a name="kRGB_565_SkColorType"> <code><strong>kRGB_565_SkColorType </strong></code> </a></td><td>2</td><td></td> + <td><a name="kRGB_565_SkColorType"> <code><strong>kRGB_565_SkColorType </strong></code> </a></td><td>2</td><td>Encodes <a href="undocumented#RGB">Color RGB</a> as <a href="#Color_Type_BGR_565">BGR 565</a> pixel in a 16-bit word.</td> </tr> <tr> - <td><a name="kARGB_4444_SkColorType"> <code><strong>kARGB_4444_SkColorType </strong></code> </a></td><td>3</td><td></td> + <td><a name="kARGB_4444_SkColorType"> <code><strong>kARGB_4444_SkColorType </strong></code> </a></td><td>3</td><td>Encodes <a href="undocumented#ARGB">Color ARGB</a> as <a href="#Color_Type_ABGR_4444">ABGR 4444</a> pixel in a 16-bit word.</td> </tr> <tr> - <td><a name="kRGBA_8888_SkColorType"> <code><strong>kRGBA_8888_SkColorType </strong></code> </a></td><td>4</td><td></td> + <td><a name="kRGBA_8888_SkColorType"> <code><strong>kRGBA_8888_SkColorType </strong></code> </a></td><td>4</td><td>Encodes <a href="undocumented#ARGB">Color ARGB</a> as <a href="#Color_Type_RGBA_8888">RGBA 8888</a> pixel in a 32-bit word.</td> </tr> <tr> - <td><a name="kRGB_888x_SkColorType"> <code><strong>kRGB_888x_SkColorType </strong></code> </a></td><td>5</td><td></td> + <td><a name="kRGB_888x_SkColorType"> <code><strong>kRGB_888x_SkColorType </strong></code> </a></td><td>5</td><td>Encodes <a href="undocumented#RGB">Color RGB</a> as <a href="#Color_Type_RGB_888x">RGB 888x</a> pixel in a 32-bit word.</td> </tr> <tr> - <td><a name="kBGRA_8888_SkColorType"> <code><strong>kBGRA_8888_SkColorType </strong></code> </a></td><td>6</td><td></td> + <td><a name="kBGRA_8888_SkColorType"> <code><strong>kBGRA_8888_SkColorType </strong></code> </a></td><td>6</td><td>Encodes <a href="undocumented#ARGB">Color ARGB</a> as <a href="#Color_Type_BGRA_8888">BGRA 8888</a> pixel in a 32-bit word.</td> </tr> <tr> - <td><a name="kRGBA_1010102_SkColorType"> <code><strong>kRGBA_1010102_SkColorType </strong></code> </a></td><td>7</td><td></td> + <td><a name="kRGBA_1010102_SkColorType"> <code><strong>kRGBA_1010102_SkColorType </strong></code> </a></td><td>7</td><td>Encodes <a href="undocumented#ARGB">Color ARGB</a> as <a href="#Color_Type_RGBA_1010102">RGBA 1010102</a> pixel in a 32-bit word.</td> </tr> <tr> - <td><a name="kRGB_101010x_SkColorType"> <code><strong>kRGB_101010x_SkColorType </strong></code> </a></td><td>8</td><td></td> + <td><a name="kRGB_101010x_SkColorType"> <code><strong>kRGB_101010x_SkColorType </strong></code> </a></td><td>8</td><td>Encodes <a href="undocumented#RGB">Color RGB</a> as <a href="#Color_Type_RGB_101010x">RGB 101010x</a> pixel in a 32-bit word.</td> </tr> <tr> - <td><a name="kGray_8_SkColorType"> <code><strong>kGray_8_SkColorType </strong></code> </a></td><td>9</td><td></td> + <td><a name="kGray_8_SkColorType"> <code><strong>kGray_8_SkColorType </strong></code> </a></td><td>9</td><td>Encodes <a href="undocumented#Gray">Color Gray</a> as <a href="#Color_Type_Gray_8">Gray 8</a> in an 8-bit byte.</td> </tr> <tr> - <td><a name="kRGBA_F16_SkColorType"> <code><strong>kRGBA_F16_SkColorType </strong></code> </a></td><td>10</td><td></td> + <td><a name="kRGBA_F16_SkColorType"> <code><strong>kRGBA_F16_SkColorType </strong></code> </a></td><td>10</td><td>Encodes <a href="undocumented#ARGB">Color ARGB</a> as <a href="#Color_Type_RGBA_F16">RGBA F16</a> in a 64-bit word.</td> </tr> </table> @@ -138,19 +202,177 @@ processors, pixels containing 8-bit <a href="undocumented#ARGB">Color ARGB</a> c <table> <tr> - <td><a name="kN32_SkColorType"> <code><strong>kN32_SkColorType </strong></code> </a></td><td>4</td><td></td> + <td><a name="kN32_SkColorType"> <code><strong>kN32_SkColorType </strong></code> </a></td><td>4</td><td>Encodes <a href="undocumented#ARGB">Color ARGB</a> as either <a href="#Color_Type_RGBA_8888">RGBA 8888</a> or <a href="#Color_Type_BGRA_8888">BGRA 8888</a>, whichever +is native to the platform.</td> </tr> </table> +### See Also + +<a href="#SkAlphaType">SkAlphaType</a> <a href="undocumented#SkColorSpace">SkColorSpace</a> + + + +## <a name="Color_Type_Alpha_8"></a> Color Type Alpha 8 + +<a href="#Color_Type_Alpha_8">Alpha 8</a> is an 8-bit byte pixel encoding that represents transparency. A value of zero is +completely transparent; a value of 255 is completely opaque. <a href="SkBitmap_Reference#Bitmap">Bitmap</a> with <a href="#Color_Type_Alpha_8">Alpha 8</a> +pixels does not visibly draw, because its pixels have no color information. +The paired <a href="#SkAlphaType">SkAlphaType</a> is ignored. + ### Example -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> +<div><fiddle-embed name="21ae21e4ce53d2018e042dd457997300"><div><a href="#Color_Type_Alpha_8">Alpha 8</a> pixels can modify another draw. orangePaint fills the bounds of bitmap, +with its transparency set to alpha8 pixel value.</div></fiddle-embed></div> -### See Also +## <a name="Color_Type_BGR_565"></a> Color Type BGR 565 -incomplete +<a href="#Color_Type_BGR_565">BGR 565</a> is a 16-bit word pixel encoding that contains five bits of blue, +six bits of green, and five bits of red. <a href="#Color_Type_BGR_565">BGR 565</a> is fully opaque as if its +<a href="undocumented#Alpha">Color Alpha</a> was set to one, and should always be paired with <a href="#kOpaque_SkAlphaType">kOpaque_SkAlphaType</a>. + +![Color_Type_BGR_565](https://fiddle.skia.org/i/b674a54eb4188d5ce66c04cebdb61089_raster.png "") + +### Example + +<div><fiddle-embed name="54e4c690d64d73ba028c5b250c0d09f0"></fiddle-embed></div> + +## <a name="Color_Type_ABGR_4444"></a> Color Type ABGR 4444 + +<a href="#Color_Type_ABGR_4444">ABGR 4444</a> is a 16-bit word pixel encoding that contains four bits of alpha, +four bits of blue, four bits of green, and four bits of red. + +![Color_Type_ABGR_4444](https://fiddle.skia.org/i/0441bdba65a19aa72b75b7fa62d22121_raster.png "") + +If paired with <a href="#kPremul_SkAlphaType">kPremul_SkAlphaType</a>: blue, green, and red components are +premultiplied by the alpha value. If blue, green, or red is greater than alpha, +the drawn result is undefined. + +If paired with <a href="#kUnpremul_SkAlphaType">kUnpremul_SkAlphaType</a>: alpha, blue, green, and red components +may have any value. There may be a performance penalty with unpremultipled +pixels. + +If paired with <a href="#kOpaque_SkAlphaType">kOpaque_SkAlphaType</a>: all alpha component values are at the maximum; +blue, green, and red components are fully opaque. If any alpha component is +less than 15, the drawn result is undefined. + +### Example + +<div><fiddle-embed name="f89e8200d225ccb839e50a1481db48e9"></fiddle-embed></div> + +## <a name="Color_Type_RGBA_8888"></a> Color Type RGBA 8888 + +<a href="#Color_Type_RGBA_8888">RGBA 8888</a> is a 32-bit word pixel encoding that contains eight bits of red, +eight bits of green, eight bits of blue, and eight bits of alpha. +![Color_Type_RGBA_8888](https://fiddle.skia.org/i/4ccd35f27fe73dce8cce8c75e18df23c_raster.png "") + +If paired with <a href="#kPremul_SkAlphaType">kPremul_SkAlphaType</a>: red, green, and blue components are +premultiplied by the alpha value. If red, green, or blue is greater than alpha, +the drawn result is undefined. + +If paired with <a href="#kUnpremul_SkAlphaType">kUnpremul_SkAlphaType</a>: alpha, red, green, and blue components +may have any value. There may be a performance penalty with unpremultipled +pixels. + +If paired with <a href="#kOpaque_SkAlphaType">kOpaque_SkAlphaType</a>: all alpha component values are at the maximum; +red, green, and blue components are fully opaque. If any alpha component is +less than 255, the drawn result is undefined. + +On Big_Endian platforms, <a href="#Color_Type_RGBA_8888">RGBA 8888</a> is the native <a href="#Color_Type">Color Type</a>, and will have +the best performance. Use <a href="#kN32_SkColorType">kN32_SkColorType</a> to choose the best <a href="#Color_Type">Color Type</a> for +the platform at compile time. + +### Example + +<div><fiddle-embed name="f3b9effa700b1b95ce10caf422b020cd"></fiddle-embed></div> + +## <a name="Color_Type_RGB_888x"></a> Color Type RGB 888x + +<a href="#Color_Type_RGB_888x">RGB 888x</a> is a 32-bit word pixel encoding that contains eight bits of red, +eight bits of green, eight bits of blue, and eight unused bits. <a href="#Color_Type_RGB_888x">RGB 888x</a> is fully +opaque as if its <a href="undocumented#Alpha">Color Alpha</a> was set to one, and should always be paired with +<a href="#kOpaque_SkAlphaType">kOpaque_SkAlphaType</a>. + +![Color_Type_RGB_888x](https://fiddle.skia.org/i/fecfe58c25cfc1b1e411e5eb50f7d8d1_raster.png "") + +### Example + +<div><fiddle-embed name="1e236c4c9ce0597c22186589fee9dc1e"></fiddle-embed></div> + +## <a name="Color_Type_BGRA_8888"></a> Color Type BGRA 8888 + +<a href="#Color_Type_BGRA_8888">BGRA 8888</a> is a 32-bit word pixel encoding that contains eight bits of blue, +eight bits of green, eight bits of red, and eight bits of alpha. + +![Color_Type_BGRA_8888](https://fiddle.skia.org/i/babd0e12db21a88c74d4e88aa40268ab_raster.png "") + +If paired with <a href="#kPremul_SkAlphaType">kPremul_SkAlphaType</a>: blue, green, and red components are +premultiplied by the alpha value. If blue, green, or red is greater than alpha, +the drawn result is undefined. + +If paired with <a href="#kUnpremul_SkAlphaType">kUnpremul_SkAlphaType</a>: blue, green, red, and alpha components +may have any value. There may be a performance penalty with unpremultipled +pixels. + +If paired with <a href="#kOpaque_SkAlphaType">kOpaque_SkAlphaType</a>: all alpha component values are at the maximum; +blue, green, and red components are fully opaque. If any alpha component is +less than 255, the drawn result is undefined. + +On Little_Endian platforms, <a href="#Color_Type_BGRA_8888">BGRA 8888</a> is the native <a href="#Color_Type">Color Type</a>, and will have +the best performance. Use <a href="#kN32_SkColorType">kN32_SkColorType</a> to choose the best <a href="#Color_Type">Color Type</a> for +the platform at compile time. + +### Example + +<div><fiddle-embed name="fcadba68a4fe7253b1726487e12b1eeb"></fiddle-embed></div> + +## <a name="Color_Type_RGBA_1010102"></a> Color Type RGBA 1010102 + +<a href="#Color_Type_RGBA_1010102">RGBA 1010102</a> is a 32-bit word pixel encoding that contains ten bits of red, +ten bits of green, ten bits of blue, and two bits of alpha. Possible alpha +values are zero: fully transparent; one: 33% opaque; two: 67% opaque; +three: fully opaque. + +![Color_Type_RGBA_1010102](https://fiddle.skia.org/i/6c470410001ad8f1ee9f58204c66f1bb_raster.png "") + +If paired with <a href="#kPremul_SkAlphaType">kPremul_SkAlphaType</a>: red, green, and blue components are +premultiplied by the alpha value. If red, green, or blue is greater than the +alpha replicated to ten bits, the drawn result is undefined. + +If paired with <a href="#kUnpremul_SkAlphaType">kUnpremul_SkAlphaType</a>: alpha, red, green, and blue components +may have any value. There may be a performance penalty with unpremultipled +pixels. + +If paired with <a href="#kOpaque_SkAlphaType">kOpaque_SkAlphaType</a>: all alpha component values are at the maximum; +red, green, and blue components are fully opaque. If any alpha component is +less than 3, the drawn result is undefined. + +### Example + +<div><fiddle-embed name="1bf1a6f087b4f2f93962960902061a7a"></fiddle-embed></div> + +## <a name="Color_Type_RGB_101010x"></a> Color Type RGB 101010x + +![Color_Type_RGB_101010x](https://fiddle.skia.org/i/c22477b11dabaa3e3a0b5bb33a7733cd_raster.png "") + +### Example + +<div><fiddle-embed name="d975ec17354b1297841e4a31d3f6a5d5"></fiddle-embed></div> + +## <a name="Color_Type_Gray_8"></a> Color Type Gray 8 + +### Example + +<div><fiddle-embed name="93da0eb0b6722a4f33dc7dae094abf0b"></fiddle-embed></div> + +## <a name="Color_Type_RGBA_F16"></a> Color Type RGBA F16 + +![Color_Type_RGBA_F16](https://fiddle.skia.org/i/9344796c059ff5e4f057595e781905b3_raster.png "") + +### Example +<div><fiddle-embed name="1795410dffea303b08ba98ee78dc1556"></fiddle-embed></div> ## <a name="YUV_ColorSpace"></a> YUV ColorSpace diff --git a/site/user/api/SkImage_Reference.md b/site/user/api/SkImage_Reference.md index 9888b75790..78105422cc 100644 --- a/site/user/api/SkImage_Reference.md +++ b/site/user/api/SkImage_Reference.md @@ -73,6 +73,7 @@ drawing. | <a href="#SkImage_MakeCrossContextFromEncoded">MakeCrossContextFromEncoded</a> | creates <a href="#Image">Image</a> from encoded data, and uploads to GPU | | <a href="#SkImage_MakeCrossContextFromPixmap">MakeCrossContextFromPixmap</a> | creates <a href="#Image">Image</a> from <a href="SkPixmap_Reference#Pixmap">Pixmap</a>, and uploads to GPU | | <a href="#SkImage_MakeFromAHardwareBuffer">MakeFromAHardwareBuffer</a> | creates <a href="#Image">Image</a> from Android hardware buffer | +| <a href="#SkImage_MakeFromAdoptedTexture_2">MakeFromAdoptedTexture 2</a> | creates <a href="#Image">Image</a> from <a href="undocumented#GPU_Texture">GPU Texture</a>, managed internally | | <a href="#SkImage_MakeFromBitmap">MakeFromBitmap</a> | creates <a href="#Image">Image</a> from <a href="SkBitmap_Reference#Bitmap">Bitmap</a>, sharing or copying pixels | | <a href="#SkImage_MakeFromEncoded">MakeFromEncoded</a> | creates <a href="#Image">Image</a> from encoded data | | <a href="#SkImage_MakeFromGenerator">MakeFromGenerator</a> | creates <a href="#Image">Image</a> from a stream of data | @@ -81,6 +82,8 @@ drawing. | | <a href="#SkImage_MakeFromNV12TexturesCopy_2">MakeFromNV12TexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace, const GrBackendTexture nv12TextureHandles[2], const SkISize nv12Sizes[2], GrSurfaceOrigin surfaceOrigin, sk sp<SkColorSpace> colorSpace = nullptr)</a> | | <a href="#SkImage_MakeFromPicture">MakeFromPicture</a> | creates <a href="#Image">Image</a> from <a href="undocumented#Picture">Picture</a> | | <a href="#SkImage_MakeFromRaster">MakeFromRaster</a> | creates <a href="#Image">Image</a> from <a href="SkPixmap_Reference#Pixmap">Pixmap</a>, with release | +| <a href="#SkImage_MakeFromTexture_3">MakeFromTexture 3</a> | creates <a href="#Image">Image</a> from <a href="undocumented#GPU_Texture">GPU Texture</a> | +| | static <a href="undocumented#sk_sp">sk sp</a><<a href="#SkImage">SkImage</a>> <a href="#SkImage_MakeFromTexture_3">MakeFromTexture(GrContext* context, const GrBackendTexture& backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk sp<SkColorSpace> colorSpace)</a> | | <a href="#SkImage_MakeFromYUVTexturesCopy">MakeFromYUVTexturesCopy</a> | creates <a href="#Image">Image</a> from <a href="SkImageInfo_Reference#YUV_ColorSpace">YUV ColorSpace</a> data in three planes | | | <a href="#SkImage_MakeFromYUVTexturesCopy">MakeFromYUVTexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace, const GrBackendObject yuvTextureHandles[3], const SkISize yuvSizes[3], GrSurfaceOrigin surfaceOrigin, sk sp<SkColorSpace> colorSpace = nullptr)</a> | | | <a href="#SkImage_MakeFromYUVTexturesCopy_2">MakeFromYUVTexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace, const GrBackendTexture yuvTextureHandles[3], const SkISize yuvSizes[3], GrSurfaceOrigin surfaceOrigin, sk sp<SkColorSpace> colorSpace = nullptr)</a> | @@ -105,12 +108,14 @@ drawing. | <a href="#SkImage_MakeCrossContextFromEncoded">MakeCrossContextFromEncoded</a> | creates <a href="#Image">Image</a> from encoded data, and uploads to GPU | | <a href="#SkImage_MakeCrossContextFromPixmap">MakeCrossContextFromPixmap</a> | creates <a href="#Image">Image</a> from <a href="SkPixmap_Reference#Pixmap">Pixmap</a>, and uploads to GPU | | <a href="#SkImage_MakeFromAHardwareBuffer">MakeFromAHardwareBuffer</a> | creates <a href="#Image">Image</a> from Android hardware buffer | +| <a href="#SkImage_MakeFromAdoptedTexture_2">MakeFromAdoptedTexture 2</a> | creates <a href="#Image">Image</a> from <a href="undocumented#GPU_Texture">GPU Texture</a>, managed internally | | <a href="#SkImage_MakeFromBitmap">MakeFromBitmap</a> | creates <a href="#Image">Image</a> from <a href="SkBitmap_Reference#Bitmap">Bitmap</a>, sharing or copying pixels | | <a href="#SkImage_MakeFromEncoded">MakeFromEncoded</a> | creates <a href="#Image">Image</a> from encoded data | | <a href="#SkImage_MakeFromGenerator">MakeFromGenerator</a> | creates <a href="#Image">Image</a> from a stream of data | | <a href="#SkImage_MakeFromNV12TexturesCopy">MakeFromNV12TexturesCopy</a> | creates <a href="#Image">Image</a> from <a href="SkImageInfo_Reference#YUV_ColorSpace">YUV ColorSpace</a> data in two planes | | <a href="#SkImage_MakeFromPicture">MakeFromPicture</a> | creates <a href="#Image">Image</a> from <a href="undocumented#Picture">Picture</a> | | <a href="#SkImage_MakeFromRaster">MakeFromRaster</a> | creates <a href="#Image">Image</a> from <a href="SkPixmap_Reference#Pixmap">Pixmap</a>, with release | +| <a href="#SkImage_MakeFromTexture_3">MakeFromTexture 3</a> | creates <a href="#Image">Image</a> from <a href="undocumented#GPU_Texture">GPU Texture</a> | | <a href="#SkImage_MakeFromYUVTexturesCopy">MakeFromYUVTexturesCopy</a> | creates <a href="#Image">Image</a> from <a href="SkImageInfo_Reference#YUV_ColorSpace">YUV ColorSpace</a> data in three planes | | <a href="#SkImage_MakeRasterCopy">MakeRasterCopy</a> | creates <a href="#Image">Image</a> from <a href="SkPixmap_Reference#Pixmap">Pixmap</a> and copied pixels | | <a href="#SkImage_MakeRasterData">MakeRasterData</a> | creates <a href="#Image">Image</a> from <a href="SkImageInfo_Reference#Image_Info">Image Info</a> and shared pixels | @@ -416,7 +421,6 @@ created <a href="#Image">Image</a>, or nullptr --- <a name="SkImage_MakeFromTexture"></a> -## MakeFromTexture <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> static sk_sp<SkImage> MakeFromTexture(GrContext* context, const GrBackendTexture& backendTexture, @@ -439,6 +443,7 @@ static sk_sp<SkImage> MakeFromTexture(GrContext* context, const GrBackendT --- <a name="SkImage_MakeFromTexture_3"></a> +## MakeFromTexture_3 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> static sk_sp<SkImage> MakeFromTexture(GrContext* context, const GrBackendTexture& backendTexture, @@ -483,7 +488,7 @@ created <a href="#Image">Image</a>, or nullptr ### See Also -<a href="#SkImage_MakeFromAdoptedTexture">MakeFromAdoptedTexture</a><sup><a href="#SkImage_MakeFromAdoptedTexture_2">[2]</a></sup> <a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture">SkSurface::MakeFromBackendTexture</a><sup><a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture_2">[2]</a></sup> +<a href="#SkImage_MakeFromAdoptedTexture">MakeFromAdoptedTexture</a> <a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture">SkSurface::MakeFromBackendTexture</a><sup><a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture_2">[2]</a></sup> --- @@ -539,7 +544,7 @@ created <a href="#Image">Image</a>, or nullptr ### See Also -<a href="#SkImage_MakeFromAdoptedTexture">MakeFromAdoptedTexture</a><sup><a href="#SkImage_MakeFromAdoptedTexture_2">[2]</a></sup> <a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture">SkSurface::MakeFromBackendTexture</a><sup><a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture_2">[2]</a></sup> +<a href="#SkImage_MakeFromAdoptedTexture">MakeFromAdoptedTexture</a> <a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture">SkSurface::MakeFromBackendTexture</a><sup><a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture_2">[2]</a></sup> --- @@ -650,7 +655,6 @@ created <a href="#Image">Image</a>, or nullptr --- <a name="SkImage_MakeFromAdoptedTexture"></a> -## MakeFromAdoptedTexture <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext* context, @@ -663,13 +667,14 @@ static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext* context, --- <a name="SkImage_MakeFromAdoptedTexture_2"></a> +## MakeFromAdoptedTexture_2 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext* context, - const GrBackendTexture& backendTexture, - GrSurfaceOrigin surfaceOrigin, SkColorType colorType, - SkAlphaType alphaType = kPremul_SkAlphaType, - sk_sp<SkColorSpace> colorSpace = nullptr) + const GrBackendTexture& backendTexture, + GrSurfaceOrigin surfaceOrigin, SkColorType colorType, + SkAlphaType alphaType = kPremul_SkAlphaType, + sk_sp<SkColorSpace> colorSpace = nullptr) </pre> Creates <a href="#Image">Image</a> from <a href="#SkImage_MakeFromAdoptedTexture_2_backendTexture">backendTexture</a> associated with <a href="#SkImage_MakeFromAdoptedTexture_2_context">context</a>. <a href="#SkImage_MakeFromAdoptedTexture_2_backendTexture">backendTexture</a> and @@ -709,7 +714,7 @@ created <a href="#Image">Image</a>, or nullptr ### See Also -<a href="#SkImage_MakeFromTexture">MakeFromTexture</a><sup><a href="#SkImage_MakeFromTexture_2">[2]</a></sup><sup><a href="#SkImage_MakeFromTexture_3">[3]</a></sup><sup><a href="#SkImage_MakeFromTexture_4">[4]</a></sup> <a href="#SkImage_MakeFromYUVTexturesCopy">MakeFromYUVTexturesCopy</a><sup><a href="#SkImage_MakeFromYUVTexturesCopy_2">[2]</a></sup> +<a href="#SkImage_MakeFromTexture">MakeFromTexture</a> <a href="#SkImage_MakeFromYUVTexturesCopy">MakeFromYUVTexturesCopy</a><sup><a href="#SkImage_MakeFromYUVTexturesCopy_2">[2]</a></sup> --- @@ -1448,7 +1453,7 @@ true if <a href="#Image">Image</a> is a <a href="undocumented#GPU_Texture">GPU T ### See Also -<a href="#SkImage_MakeFromTexture">MakeFromTexture</a><sup><a href="#SkImage_MakeFromTexture_2">[2]</a></sup><sup><a href="#SkImage_MakeFromTexture_3">[3]</a></sup><sup><a href="#SkImage_MakeFromTexture_4">[4]</a></sup> <a href="#SkImage_isValid">isValid</a> +<a href="#SkImage_MakeFromTexture">MakeFromTexture</a> <a href="#SkImage_isValid">isValid</a> --- @@ -1524,7 +1529,7 @@ back-end API texture handle, or nullptr ### See Also -<a href="#SkImage_MakeFromTexture">MakeFromTexture</a><sup><a href="#SkImage_MakeFromTexture_2">[2]</a></sup><sup><a href="#SkImage_MakeFromTexture_3">[3]</a></sup><sup><a href="#SkImage_MakeFromTexture_4">[4]</a></sup> <a href="#SkImage_isTextureBacked">isTextureBacked</a> +<a href="#SkImage_MakeFromTexture">MakeFromTexture</a> <a href="#SkImage_isTextureBacked">isTextureBacked</a> --- @@ -1956,7 +1961,7 @@ created <a href="#Image">Image</a>, or nullptr ### See Also -<a href="#SkImage_MakeFromTexture">MakeFromTexture</a><sup><a href="#SkImage_MakeFromTexture_2">[2]</a></sup><sup><a href="#SkImage_MakeFromTexture_3">[3]</a></sup><sup><a href="#SkImage_MakeFromTexture_4">[4]</a></sup> +<a href="#SkImage_MakeFromTexture">MakeFromTexture</a> --- @@ -2116,7 +2121,7 @@ true if backend texture was created ### See Also -<a href="#SkImage_MakeFromTexture">MakeFromTexture</a><sup><a href="#SkImage_MakeFromTexture_2">[2]</a></sup><sup><a href="#SkImage_MakeFromTexture_3">[3]</a></sup><sup><a href="#SkImage_MakeFromTexture_4">[4]</a></sup> <a href="#SkImage_makeTextureImage">makeTextureImage</a> +<a href="#SkImage_MakeFromTexture">MakeFromTexture</a> <a href="#SkImage_makeTextureImage">makeTextureImage</a> --- @@ -2245,7 +2250,7 @@ created <a href="#Image">Image</a> in <a href="#SkImage_makeColorSpace_target">t ### See Also -MakeFromPixture <a href="#SkImage_MakeFromTexture">MakeFromTexture</a><sup><a href="#SkImage_MakeFromTexture_2">[2]</a></sup><sup><a href="#SkImage_MakeFromTexture_3">[3]</a></sup><sup><a href="#SkImage_MakeFromTexture_4">[4]</a></sup> +MakeFromPixture <a href="#SkImage_MakeFromTexture">MakeFromTexture</a> --- diff --git a/site/user/api/SkPaint_Reference.md b/site/user/api/SkPaint_Reference.md index 07460cb8d2..e909e17cdc 100644 --- a/site/user/api/SkPaint_Reference.md +++ b/site/user/api/SkPaint_Reference.md @@ -3186,7 +3186,7 @@ replace <a href="SkPath_Reference#Path">Path</a> with a modification when drawn< ## <a name="Mask_Filter_Methods"></a> Mask Filter Methods <a href="undocumented#Mask_Filter">Mask Filter</a> uses coverage of the shape drawn to create <a href="undocumented#Mask_Alpha">Mask Alpha</a>. -<a href="undocumented#Mask_Filter">Mask Filter</a> takes a <a href="undocumented#Mask">Mask</a>, and returns a <a href="undocumented#Mask">Mask</a>. +<a href="undocumented#Mask_Filter">Mask Filter</a> takes a Mask, and returns a Mask. <a href="undocumented#Mask_Filter">Mask Filter</a> may change the geometry and transparency of the shape, such as creating a blur effect. Set <a href="undocumented#Mask_Filter">Mask Filter</a> to nullptr to prevent <a href="undocumented#Mask_Filter">Mask Filter</a> from diff --git a/site/user/api/catalog.htm b/site/user/api/catalog.htm index 07e8a6e5cd..d25fe7774b 100644 --- a/site/user/api/catalog.htm +++ b/site/user/api/catalog.htm @@ -3197,6 +3197,174 @@ "file": "SkCanvas_Reference", "name": "State_Stack_2" }, + "Illustrations_Image_Info_Color_Type_ABGR_4444": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"16-bit word\", 5 + 20 * 8, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 85, paint);\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 4, 8, 12, 16 };\n const char* labels[] = { \"red\", \"green\", \"blue\", \"alpha\" };\n drawBoxText(&edges[0], &labels[0], 4, 15, 45);\n drawBoxText(&edges[0], &labels[2], 2, 7, 110);\n drawBoxText(&edges[0], &labels[0], 2, 7, 160);\n}\n", + "width": 415, + "height": 250, + "hash": "0441bdba65a19aa72b75b7fa62d22121", + "file": "illustrations", + "name": "Image_Info_Color_Type_ABGR_4444" +}, + "Illustrations_Image_Info_Color_Type_BGRA_8888": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"32-bit word\", 5 + 20 * 16, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 85, paint);\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 8, 16, 24, 32 };\n const char* labels[] = { \"alpha\", \"red\", \"green\", \"blue\" };\n drawBoxText(edges, &labels[0], 4, 31, 45);\n drawBoxText(edges, &labels[3], 1, 7, 110);\n drawBoxText(edges, &labels[2], 1, 7, 160);\n drawBoxText(edges, &labels[1], 1, 7, 210);\n drawBoxText(edges, &labels[0], 1, 7, 260);\n}\n", + "width": 812, + "height": 365, + "hash": "babd0e12db21a88c74d4e88aa40268ab", + "file": "illustrations", + "name": "Image_Info_Color_Type_BGRA_8888" +}, + "Illustrations_Image_Info_Color_Type_BGR_565": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"16-bit word\", 5 + 20 * 8, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 85, paint);\n canvas->drawString(\"(low bits)\", 5 + 20 * 1.5f, 137, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 6.5f, 187, paint);\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 5, 11, 16, \n 0, 3, 8,\n 0, 5, 8 };\n const char* labels[] = { \"red\", \"green\", \"blue\" };\n drawBoxText(&edges[0], &labels[0], 3, 15, 45);\n drawBoxText(&edges[4], &labels[1], 2, 7, 110);\n drawBoxText(&edges[7], &labels[0], 2, 7, 160);\n}\n", + "width": 415, + "height": 250, + "hash": "b674a54eb4188d5ce66c04cebdb61089", + "file": "illustrations", + "name": "Image_Info_Color_Type_BGR_565" +}, + "Illustrations_Image_Info_Color_Type_RGBA_1010102": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"32-bit word\", 5 + 20 * 16, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 85, paint);\n canvas->drawString(\"(low bits)\", 5 + 20 * 4, 137, paint);\n canvas->drawString(\"(low bits)\", 5 + 20 * 3, 187, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 7, 187, paint);\n canvas->drawString(\"(low bits)\", 5 + 20 * 2, 237, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 6, 237, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 5, 287, paint);\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 2, 12, 22, 32,\n 0, 8,\n 0, 6, 8,\n 0, 4, 8,\n 0, 2, 8\n };\n const char* labels[] = { \"alpha\", \"blue\", \"green\", \"red\" };\n drawBoxText(&edges[0], &labels[0], 4, 31, 45);\n drawBoxText(&edges[5], &labels[3], 1, 7, 110);\n drawBoxText(&edges[7], &labels[2], 2, 7, 160);\n drawBoxText(&edges[10], &labels[1], 2, 7, 210);\n drawBoxText(&edges[13], &labels[0], 2, 7, 260);\n}\n", + "width": 812, + "height": 380, + "hash": "6c470410001ad8f1ee9f58204c66f1bb", + "file": "illustrations", + "name": "Image_Info_Color_Type_RGBA_1010102" +}, + "Illustrations_Image_Info_Color_Type_RGBA_8888": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"32-bit word\", 5 + 20 * 16, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 85, paint);\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 8, 16, 24, 32 };\n const char* labels[] = { \"alpha\", \"blue\", \"green\", \"red\" };\n drawBoxText(edges, &labels[0], 4, 31, 45);\n drawBoxText(edges, &labels[3], 1, 7, 110);\n drawBoxText(edges, &labels[2], 1, 7, 160);\n drawBoxText(edges, &labels[1], 1, 7, 210);\n drawBoxText(edges, &labels[0], 1, 7, 260);\n}\n", + "width": 812, + "height": 365, + "hash": "4ccd35f27fe73dce8cce8c75e18df23c", + "file": "illustrations", + "name": "Image_Info_Color_Type_RGBA_8888" +}, + "Illustrations_Image_Info_Color_Type_RGBA_F16": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"64-bit word\", 5 + 20 * 16, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 135, paint);\n for (int i = 0; i < 4; ++i) {\n canvas->drawString(\"(low bits)\", 5 + 20 * 4, 187 + i * 100, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 4, 237 + i * 100, paint);\n }\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 16, 32,\n 0, 8\n };\n const char* labels[] = { \"alpha\", \"blue\", \"green\", \"red\" };\n drawBoxText(&edges[0], &labels[0], 2, 63, 45);\n drawBoxText(&edges[0], &labels[2], 2, 31, 95);\n drawBoxText(&edges[3], &labels[3], 1, 7, 160);\n drawBoxText(&edges[3], &labels[3], 1, 7, 210);\n drawBoxText(&edges[3], &labels[2], 1, 7, 260);\n drawBoxText(&edges[3], &labels[2], 1, 7, 310);\n drawBoxText(&edges[3], &labels[1], 1, 7, 360);\n drawBoxText(&edges[3], &labels[1], 1, 7, 410);\n drawBoxText(&edges[3], &labels[0], 1, 7, 460);\n drawBoxText(&edges[3], &labels[0], 1, 7, 510);\n}\n", + "width": 812, + "height": 685, + "hash": "9344796c059ff5e4f057595e781905b3", + "file": "illustrations", + "name": "Image_Info_Color_Type_RGBA_F16" +}, + "Illustrations_Image_Info_Color_Type_RGB_101010x": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"32-bit word\", 5 + 20 * 16, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 85, paint);\n canvas->drawString(\"(low bits)\", 5 + 20 * 4, 137, paint);\n canvas->drawString(\"(low bits)\", 5 + 20 * 3, 187, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 7, 187, paint);\n canvas->drawString(\"(low bits)\", 5 + 20 * 2, 237, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 6, 237, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 5, 287, paint);\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 2, 12, 22, 32,\n 0, 8,\n 0, 6, 8,\n 0, 4, 8,\n 0, 2, 8\n };\n const char* labels[] = { \"unused\", \"blue\", \"green\", \"red\" };\n drawBoxText(&edges[0], &labels[0], 4, 31, 45);\n drawBoxText(&edges[5], &labels[3], 1, 7, 110);\n drawBoxText(&edges[7], &labels[2], 2, 7, 160);\n drawBoxText(&edges[10], &labels[1], 2, 7, 210);\n drawBoxText(&edges[13], &labels[0], 2, 7, 260);\n}\n", + "width": 812, + "height": 380, + "hash": "c22477b11dabaa3e3a0b5bb33a7733cd", + "file": "illustrations", + "name": "Image_Info_Color_Type_RGB_101010x" +}, + "Illustrations_Image_Info_Color_Type_RGB_888x": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"32-bit word\", 5 + 20 * 16, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 85, paint);\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 8, 16, 24, 32 };\n const char* labels[] = { \"(unused)\", \"blue\", \"green\", \"red\" };\n drawBoxText(edges, &labels[0], 4, 31, 45);\n drawBoxText(edges, &labels[3], 1, 7, 110);\n drawBoxText(edges, &labels[2], 1, 7, 160);\n drawBoxText(edges, &labels[1], 1, 7, 210);\n drawBoxText(edges, &labels[0], 1, 7, 260);\n}\n", + "width": 812, + "height": 365, + "hash": "fecfe58c25cfc1b1e411e5eb50f7d8d1", + "file": "illustrations", + "name": "Image_Info_Color_Type_RGB_888x" +}, + "Image_Info_Alpha_Type_Opaque": { + "code": "void draw(SkCanvas* canvas) {\n SkPMColor color = SkPreMultiplyARGB(255, 50, 100, 150);\n SkString s;\n s.printf(\"%u %u %u %u\", SkColorGetA(color), SkColorGetR(color),\n SkColorGetG(color), SkColorGetB(color));\n SkPaint paint;\n paint.setAntiAlias(true);\n canvas->drawString(s, 10, 62, paint);\n canvas->scale(50, 50);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kOpaque_SkAlphaType);\n if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 0, 0);\n }\n}", + "width": 256, + "height": 64, + "hash": "79146a1a41d58d22582fdc567c6ffe4e", + "file": "SkImageInfo_Reference", + "name": "Alpha_Type_Opaque" +}, + "Image_Info_Alpha_Type_Premul": { + "code": "void draw(SkCanvas* canvas) {\n SkPMColor color = SkPreMultiplyARGB(150, 50, 100, 150);\n SkString s;\n s.printf(\"%u %u %u %u\", SkColorGetA(color), SkColorGetR(color),\n SkColorGetG(color), SkColorGetB(color));\n SkPaint paint;\n paint.setAntiAlias(true);\n canvas->drawString(s, 10, 62, paint);\n canvas->scale(50, 50);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kPremul_SkAlphaType);\n if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 0, 0);\n }\n}", + "width": 256, + "height": 64, + "hash": "ad696b39c915803d566e96896ec3a36c", + "file": "SkImageInfo_Reference", + "name": "Alpha_Type_Premul" +}, + "Image_Info_Alpha_Type_Unpremul": { + "code": "void draw(SkCanvas* canvas) {\n SkColor color = SkColorSetARGB(150, 50, 100, 255);\n SkString s;\n s.printf(\"%u %u %u %u\", SkColorGetA(color), SkColorGetR(color),\n SkColorGetG(color), SkColorGetB(color));\n SkPaint paint;\n paint.setAntiAlias(true);\n canvas->drawString(s, 10, 62, paint);\n canvas->scale(50, 50);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kUnpremul_SkAlphaType);\n if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 0, 0);\n }\n}", + "width": 256, + "height": 256, + "hash": "46e528e0c6b3f3e296d0d0930d638629", + "file": "SkImageInfo_Reference", + "name": "Alpha_Type_Unpremul" +}, + "Image_Info_Color_Type_ABGR_4444": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kARGB_4444_SkColorType, kPremul_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto pack4444 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint16_t {\n return (a << 0) | (b << 4) | (g << 8) | (r << 12);\n };\n uint16_t red4444[] = { pack4444(0xF, 0xF, 0x0, 0x0), pack4444(0xF, 0xb, 0x0, 0x0), \n pack4444(0xF, 0x7, 0x0, 0x0), pack4444(0xF, 0x3, 0x0, 0x0) };\n uint16_t blue4444[] = { pack4444(0xF, 0x0, 0x0, 0xF), pack4444(0xF, 0x0, 0x0, 0xb),\n pack4444(0xF, 0x0, 0x0, 0x7), pack4444(0xF, 0x0, 0x0, 0x3) };\n SkPixmap redPixmap(imageInfo, &red4444, imageInfo.minRowBytes());\n if (bitmap.writePixels(redPixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n SkPixmap bluePixmap(imageInfo, &blue4444, imageInfo.minRowBytes());\n if (bitmap.writePixels(bluePixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}", + "width": 256, + "height": 96, + "hash": "f89e8200d225ccb839e50a1481db48e9", + "file": "SkImageInfo_Reference", + "name": "Color_Type_ABGR_4444" +}, + "Image_Info_Color_Type_Alpha_8": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kAlpha_8_SkColorType, kOpaque_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n SkPaint orangePaint;\n orangePaint.setARGB(0xFF, 0xFF, 0xA5, 0x00);\n canvas->drawBitmap(bitmap, 0, 0, &orangePaint);\n uint8_t alpha8[] = { 0xFF, 0xBB, 0x77, 0x33 };\n SkPixmap alphaPixmap(imageInfo, &alpha8, imageInfo.minRowBytes());\n if (bitmap.writePixels(alphaPixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 2, 2, &orangePaint);\n }\n}", + "width": 256, + "height": 64, + "hash": "21ae21e4ce53d2018e042dd457997300", + "file": "SkImageInfo_Reference", + "name": "Color_Type_Alpha_8" +}, + "Image_Info_Color_Type_BGRA_8888": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kBGRA_8888_SkColorType, kPremul_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto pack8888 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint32_t {\n return (b << 0) | (g << 8) | (r << 16) | (a << 24);\n };\n uint32_t red8888[] = { pack8888(0xFF, 0xFF, 0x0, 0x0), pack8888(0xFF, 0xbb, 0x0, 0x0), \n pack8888(0xFF, 0x99, 0x0, 0x0), pack8888(0xFF, 0x55, 0x0, 0x0) };\n uint32_t blue8888[] = { pack8888(0xFF, 0x0, 0x0, 0x0FF), pack8888(0xFF, 0x0, 0x0, 0x0bb),\n pack8888(0xFF, 0x0, 0x0, 0x099), pack8888(0xFF, 0x0, 0x0, 0x055) };\n SkPixmap redPixmap(imageInfo, &red8888, imageInfo.minRowBytes());\n if (bitmap.writePixels(redPixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n SkPixmap bluePixmap(imageInfo, &blue8888, imageInfo.minRowBytes());\n if (bitmap.writePixels(bluePixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}", + "width": 256, + "height": 96, + "hash": "fcadba68a4fe7253b1726487e12b1eeb", + "file": "SkImageInfo_Reference", + "name": "Color_Type_BGRA_8888" +}, + "Image_Info_Color_Type_BGR_565": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_565_SkColorType, kOpaque_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto pack565 = [](unsigned r, unsigned g, unsigned b) -> uint16_t {\n return (b << 0) | (g << 5) | (r << 11);\n };\n uint16_t red565[] = { pack565(0x1F, 0x00, 0x00), pack565(0x17, 0x00, 0x00), \n pack565(0x0F, 0x00, 0x00), pack565(0x07, 0x00, 0x00) };\n uint16_t blue565[] = { pack565(0x00, 0x00, 0x1F), pack565(0x00, 0x00, 0x17),\n pack565(0x00, 0x00, 0x0F), pack565(0x00, 0x00, 0x07) };\n SkPixmap redPixmap(imageInfo, &red565, imageInfo.minRowBytes());\n if (bitmap.writePixels(redPixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n SkPixmap bluePixmap(imageInfo, &blue565, imageInfo.minRowBytes());\n if (bitmap.writePixels(bluePixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}", + "width": 256, + "height": 96, + "hash": "54e4c690d64d73ba028c5b250c0d09f0", + "file": "SkImageInfo_Reference", + "name": "Color_Type_BGR_565" +}, + "Image_Info_Color_Type_Gray_8": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kGray_8_SkColorType, kOpaque_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n uint8_t gray8[] = { 0xFF, 0xBB, 0x77, 0x33 };\n SkPixmap grayPixmap(imageInfo, &gray8, imageInfo.minRowBytes());\n if (bitmap.writePixels(grayPixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n}", + "width": 256, + "height": 64, + "hash": "93da0eb0b6722a4f33dc7dae094abf0b", + "file": "SkImageInfo_Reference", + "name": "Color_Type_Gray_8" +}, + "Image_Info_Color_Type_RGBA_1010102": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_1010102_SkColorType, kOpaque_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto pack1010102 = [](unsigned r, unsigned g, unsigned b, unsigned a) -> uint32_t {\n return (r << 0) | (g << 10) | (b << 20) | (a << 30);\n };\n uint32_t redBits[] = { pack1010102(0x3FF, 0x000, 0x000, 0x3), \n pack1010102(0x2ff, 0x000, 0x000, 0x3), \n pack1010102(0x1ff, 0x000, 0x000, 0x3), \n pack1010102(0x0ff, 0x000, 0x000, 0x3) };\n uint32_t blueBits[] = { pack1010102(0x000, 0x000, 0x3FF, 0x3), \n pack1010102(0x000, 0x000, 0x2ff, 0x3),\n pack1010102(0x000, 0x000, 0x1ff, 0x3), \n pack1010102(0x000, 0x000, 0x0ff, 0x3) };\n if (bitmap.installPixels(imageInfo, (void*) redBits, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n SkPixmap bluePixmap(imageInfo, &blueBits, imageInfo.minRowBytes());\n if (bitmap.installPixels(imageInfo, (void*) blueBits, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}", + "width": 256, + "height": 96, + "hash": "1bf1a6f087b4f2f93962960902061a7a", + "file": "SkImageInfo_Reference", + "name": "Color_Type_RGBA_1010102" +}, + "Image_Info_Color_Type_RGBA_8888": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_8888_SkColorType, kPremul_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto pack8888 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint32_t {\n return (r << 0) | (g << 8) | (b << 16) | (a << 24);\n };\n uint32_t red8888[] = { pack8888(0xFF, 0xFF, 0x0, 0x0), pack8888(0xFF, 0xbb, 0x0, 0x0), \n pack8888(0xFF, 0x77, 0x0, 0x0), pack8888(0xFF, 0x33, 0x0, 0x0) };\n uint32_t blue8888[] = { pack8888(0xFF, 0x0, 0x0, 0x0FF), pack8888(0xFF, 0x0, 0x0, 0x0bb),\n pack8888(0xFF, 0x0, 0x0, 0x077), pack8888(0xFF, 0x0, 0x0, 0x033) };\n SkPixmap redPixmap(imageInfo, &red8888, imageInfo.minRowBytes());\n if (bitmap.writePixels(redPixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n SkPixmap bluePixmap(imageInfo, &blue8888, imageInfo.minRowBytes());\n if (bitmap.writePixels(bluePixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}", + "width": 256, + "height": 96, + "hash": "f3b9effa700b1b95ce10caf422b020cd", + "file": "SkImageInfo_Reference", + "name": "Color_Type_RGBA_8888" +}, + "Image_Info_Color_Type_RGBA_F16": { + "code": "union FloatUIntUnion {\n uint32_t fUInt;\n float fFloat;\n};\nuint16_t FloatToHalf(float f) {\n static const FloatUIntUnion magic = { 15 << 23 };\n static const uint32_t round_mask = ~0xfffu;\n FloatUIntUnion floatUnion;\n floatUnion.fFloat = f;\n uint32_t sign = floatUnion.fUInt & 0x80000000u;\n floatUnion.fUInt ^= sign;\n floatUnion.fUInt &= round_mask;\n floatUnion.fFloat *= magic.fFloat;\n floatUnion.fUInt -= round_mask;\n return (floatUnion.fUInt >> 13) | (sign >> 16);\n}\n\nvoid draw(SkCanvas* canvas) { \n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_F16_SkColorType, kPremul_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto H = [](float c) -> uint16_t {\n return FloatToHalf(c);\n };\n // R G B A\n uint16_t red_f16[][4] = { { H(1.0f), H(0.0f), H(0.0f), H(1.0f) },\n { H(.75f), H(0.0f), H(0.0f), H(1.0f) }, \n { H(.50f), H(0.0f), H(0.0f), H(1.0f) },\n { H(.25f), H(0.0f), H(0.0f), H(1.0f) } };\n uint16_t blue_f16[][4] = { { H(0.0f), H(0.0f), H(1.0f), H(1.0f) },\n { H(0.0f), H(0.0f), H(.75f), H(1.0f) }, \n { H(0.0f), H(0.0f), H(.50f), H(1.0f) },\n { H(0.0f), H(0.0f), H(.25f), H(1.0f) } };\n SkPixmap redPixmap(imageInfo, red_f16, imageInfo.minRowBytes());\n if (bitmap.writePixels(redPixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n SkPixmap bluePixmap(imageInfo, blue_f16, imageInfo.minRowBytes());\n if (bitmap.writePixels(bluePixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}\n", + "width": 256, + "height": 96, + "hash": "1795410dffea303b08ba98ee78dc1556", + "file": "SkImageInfo_Reference", + "name": "Color_Type_RGBA_F16" +}, + "Image_Info_Color_Type_RGB_101010x": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_101010x_SkColorType, kOpaque_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto pack101010x = [](unsigned r, unsigned g, unsigned b) -> uint32_t {\n return (r << 0) | (g << 10) | (b << 20);\n };\n uint32_t redBits[] = { pack101010x(0x3FF, 0x000, 0x000), pack101010x(0x2ff, 0x000, 0x000), \n pack101010x(0x1ff, 0x000, 0x000), pack101010x(0x0ff, 0x000, 0x000) };\n uint32_t blueBits[] = { pack101010x(0x000, 0x000, 0x3FF), pack101010x(0x000, 0x000, 0x2ff),\n pack101010x(0x000, 0x000, 0x1ff), pack101010x(0x000, 0x000, 0x0ff) };\n if (bitmap.installPixels(imageInfo, (void*) redBits, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n SkPixmap bluePixmap(imageInfo, &blueBits, imageInfo.minRowBytes());\n if (bitmap.installPixels(imageInfo, (void*) blueBits, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}", + "width": 256, + "height": 96, + "hash": "d975ec17354b1297841e4a31d3f6a5d5", + "file": "SkImageInfo_Reference", + "name": "Color_Type_RGB_101010x" +}, + "Image_Info_Color_Type_RGB_888x": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_888x_SkColorType, kOpaque_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto pack888 = [](unsigned r, unsigned g, unsigned b) -> uint32_t {\n return (r << 0) | (g << 8) | (b << 16);\n };\n uint32_t red888[] = { pack888(0xFF, 0x00, 0x00), pack888(0xbb, 0x00, 0x00), \n pack888(0x77, 0x00, 0x00), pack888(0x33, 0x00, 0x00) };\n uint32_t blue888[] = { pack888(0x00, 0x00, 0xFF), pack888(0x00, 0x00, 0xbb),\n pack888(0x00, 0x00, 0x77), pack888(0x00, 0x00, 0x33) };\n if (bitmap.installPixels(imageInfo, (void*) red888, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n if (bitmap.installPixels(imageInfo, (void*) blue888, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}", + "width": 256, + "height": 96, + "hash": "1e236c4c9ce0597c22186589fee9dc1e", + "file": "SkImageInfo_Reference", + "name": "Color_Type_RGB_888x" +}, "Paint_Anti_alias": { "code": "void draw(SkCanvas* canvas) {\n SkBitmap bitmap;\n bitmap.allocN32Pixels(50, 50);\n SkCanvas offscreen(bitmap);\n SkPaint paint;\n paint.setStyle(SkPaint::kStroke_Style);\n paint.setStrokeWidth(10);\n for (bool antialias : { false, true }) {\n paint.setColor(antialias ? SK_ColorRED : SK_ColorBLUE);\n paint.setAntiAlias(antialias);\n bitmap.eraseColor(0);\n offscreen.drawLine(5, 5, 15, 30, paint);\n canvas->drawLine(5, 5, 15, 30, paint);\n canvas->save();\n canvas->scale(10, 10);\n canvas->drawBitmap(bitmap, antialias ? 12 : 0, 0);\n canvas->restore();\n canvas->translate(15, 0);\n }\n}\n", "width": 512, @@ -3501,14 +3669,6 @@ "file": "SkPath_Reference", "name": "Path_2" }, - "SkAlphaType": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImageInfo_Reference", - "name": "SkAlphaType" -}, "SkAutoCanvasRestore_SkCanvas_star": { "code": "void draw(SkCanvas* canvas) {\n SkPaint p;\n p.setAntiAlias(true);\n p.setTextSize(64);\n for (SkScalar sx : { -1, 1 } ) {\n for (SkScalar sy : { -1, 1 } ) {\n SkAutoCanvasRestore autoRestore(canvas, true);\n SkMatrix m = SkMatrix::MakeAll(sx, 1, 96, 0, sy, 64, 0, 0, 1);\n canvas->concat(m);\n canvas->drawString(\"R\", 0, 0, p);\n }\n }\n}", "width": 256, @@ -4597,14 +4757,6 @@ "file": "SkCanvas_Reference", "name": "SkCanvas::writePixels_2" }, - "SkColorType": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImageInfo_Reference", - "name": "SkColorType" -}, "SkDestinationSurfaceColorMode": { "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", "width": 256, diff --git a/site/user/api/undocumented.md b/site/user/api/undocumented.md index 01bb9ce5bb..88ac21c4dd 100644 --- a/site/user/api/undocumented.md +++ b/site/user/api/undocumented.md @@ -99,6 +99,15 @@ int SkColorSetARGB(a, r, g, b) --- +<a name="SkPreMultiplyARGB"></a> +## SkPreMultiplyARGB + +<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> +SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) +</pre> + +--- + ### Constants <table> @@ -135,6 +144,8 @@ int SkColorSetARGB(a, r, g, b) ## <a name="RGB-565"></a> RGB-565 +## <a name="Gray"></a> Gray + # <a name="Color_Filter"></a> Color Filter # <a name="SkColorFilter"></a> Class SkColorFilter @@ -421,48 +432,12 @@ static sk_sp<SkPixelRef> MakeAllocate(const SkImageInfo&, size_t rowBytes) --- -# <a name="Mask"></a> Mask - -# <a name="SkMask"></a> Class SkMask - -## <a name="SkMask_Format"></a> Enum SkMask::Format - -### Constants - -<table> - <tr> - <td><a name="SkMask_kBW_Format"> <code><strong>SkMask::kBW_Format </strong></code> </a></td><td>0</td><td></td> - </tr> - <tr> - <td><a name="SkMask_kA8_Format"> <code><strong>SkMask::kA8_Format </strong></code> </a></td><td>1</td><td></td> - </tr> - <tr> - <td><a name="SkMask_k3D_Format"> <code><strong>SkMask::k3D_Format </strong></code> </a></td><td>2</td><td></td> - </tr> - <tr> - <td><a name="SkMask_kARGB32_Format"> <code><strong>SkMask::kARGB32_Format </strong></code> </a></td><td>3</td><td></td> - </tr> -k <tr> - <td><a name="SkMask_LCD16_Format"> <code><strong>SkMask::LCD16_Format </strong></code> </a></td><td>4</td><td></td> - </tr> - -</table> - # <a name="Mask_Alpha"></a> Mask Alpha # <a name="Mask_Filter"></a> Mask Filter # <a name="SkMaskFilter"></a> Class SkMaskFilter -<a name="SkMaskFilter_filterMask"></a> -## filterMask - -<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> -virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, SkIPoint* margin) const -</pre> - ---- - <a name="SkMaskFilter_toString"></a> ## toString diff --git a/tools/bookmaker/bookmaker.cpp b/tools/bookmaker/bookmaker.cpp index f3641a92d5..02dbbc1961 100644 --- a/tools/bookmaker/bookmaker.cpp +++ b/tools/bookmaker/bookmaker.cpp @@ -48,6 +48,7 @@ enum comments should be disallowed unless after #Enum and before first #Const trouble with aliases, plurals need to keep first letter of includeWriter @param / @return lowercase Quad -> quad, Quads -> quads +deprecated methods should be sorted down in md out, and show include "Deprecated." text body. see head of selfCheck.cpp for additional todos */ @@ -60,7 +61,7 @@ see head of selfCheck.cpp for additional todos */ bool BmhParser::addDefinition(const char* defStart, bool hasEnd, MarkType markType, - const vector<string>& typeNameBuilder) { + const vector<string>& typeNameBuilder, HasTag hasTag) { Definition* definition = nullptr; switch (markType) { case MarkType::kComment: @@ -144,6 +145,11 @@ bool BmhParser::addDefinition(const char* defStart, bool hasEnd, MarkType markTy return false; } } + if (HasTag::kYes == hasTag) { + if (!this->checkEndMarker(markType, definition->fName)) { + return false; + } + } if (!this->popParentStack(definition)) { return false; } @@ -221,6 +227,9 @@ bool BmhParser::addDefinition(const char* defStart, bool hasEnd, MarkType markTy string fullTopic = hasEnd ? fParent->fFiddle : definition->fFiddle; Definition* defPtr = fTopicMap[fullTopic]; if (hasEnd) { + if (HasTag::kYes == hasTag && !this->checkEndMarker(markType, fullTopic)) { + return false; + } if (!definition) { definition = defPtr; } else if (definition != defPtr) { @@ -366,6 +375,7 @@ bool BmhParser::addDefinition(const char* defStart, bool hasEnd, MarkType markTy case MarkType::kDuration: case MarkType::kFile: case MarkType::kHeight: + case MarkType::kIllustration: case MarkType::kImage: case MarkType::kIn: case MarkType::kLine: @@ -469,6 +479,33 @@ void BmhParser::reportDuplicates(const Definition& def, const string& dup) const } } + +static Definition* find_fiddle(Definition* def, string name) { + if (MarkType::kExample == def->fMarkType && name == def->fFiddle) { + return def; + } + for (auto& child : def->fChildren) { + Definition* result = find_fiddle(child, name); + if (result) { + return result; + } + } + return nullptr; +} + +Definition* BmhParser::findExample(string name) const { + for (const auto& topic : fTopicMap) { + if (topic.second->fParent) { + continue; + } + Definition* def = find_fiddle(topic.second, name); + if (def) { + return def; + } + } + return nullptr; +} + static void find_examples(const Definition& def, vector<string>* exampleNames) { if (MarkType::kExample == def.fMarkType) { exampleNames->push_back(def.fFiddle); @@ -478,6 +515,39 @@ static void find_examples(const Definition& def, vector<string>* exampleNames) { } } +bool BmhParser::checkEndMarker(MarkType markType, string match) const { + TextParser tp(fFileName, fLine, fChar, fLineCount); + tp.skipSpace(); + if (fMC != tp.next()) { + return this->reportError<bool>("mismatched end marker expect #"); + } + const char* nameStart = tp.fChar; + tp.skipToNonAlphaNum(); + string markName(nameStart, tp.fChar - nameStart); + if (fMaps[(int) markType].fName != markName) { + return this->reportError<bool>("expected #XXX ## to match"); + } + tp.skipSpace(); + nameStart = tp.fChar; + tp.skipToNonAlphaNum(); + markName = string(nameStart, tp.fChar - nameStart); + if ("" == markName) { + if (fMC != tp.next() || fMC != tp.next()) { + return this->reportError<bool>("expected ##"); + } + return true; + } + std::replace(markName.begin(), markName.end(), '-', '_'); + auto defPos = match.rfind(markName); + if (string::npos == defPos) { + return this->reportError<bool>("mismatched end marker v1"); + } + if (markName.size() != match.size() - defPos) { + return this->reportError<bool>("mismatched end marker v2"); + } + return true; +} + bool BmhParser::checkExamples() const { vector<string> exampleNames; for (const auto& topic : fTopicMap) { @@ -731,7 +801,8 @@ bool BmhParser::findDefinitions() { } else { vector<string> parentName; parentName.push_back(fParent->fName); - if (!this->addDefinition(fChar - 1, true, fParent->fMarkType, parentName)) { + if (!this->addDefinition(fChar - 1, true, fParent->fMarkType, parentName, + HasTag::kNo)) { return false; } } @@ -775,7 +846,8 @@ bool BmhParser::findDefinitions() { if (hasEnd && expectEnd) { SkASSERT(fMC != this->peek()); } - if (!this->addDefinition(defStart, hasEnd, markType, typeNameBuilder)) { + if (!this->addDefinition(defStart, hasEnd, markType, typeNameBuilder, + HasTag::kYes)) { return false; } continue; @@ -1527,6 +1599,7 @@ vector<string> BmhParser::typeName(MarkType markType, bool* checkEnd) { case MarkType::kDuration: case MarkType::kFile: case MarkType::kHeight: + case MarkType::kIllustration: case MarkType::kImage: case MarkType::kIn: case MarkType::kLiteral: @@ -1613,10 +1686,14 @@ string BmhParser::uniqueName(const string& base, MarkType markType) { int number = 2; string numBuilder(builder); do { - for (const auto& iter : fParent->fChildren) { + for (auto& iter : fParent->fChildren) { if (markType == iter->fMarkType) { if (iter->fName == numBuilder) { - fCloned = true; + if (iter->fDeprecated) { + iter->fClone = true; + } else { + fCloned = true; + } numBuilder = builder + '_' + to_string(number); goto tryNext; } @@ -1669,8 +1746,14 @@ tryNext: ; } if (MarkType::kMethod == markType) { cloned->fCloned = true; + if (cloned->fDeprecated) { + cloned->fClone = true; + } else { + fCloned = true; + } + } else { + fCloned = true; } - fCloned = true; numBuilder = builder + '_' + to_string(number); } while (++number); return numBuilder; diff --git a/tools/bookmaker/bookmaker.h b/tools/bookmaker/bookmaker.h index bc7e0a1b21..7bb743c9cb 100644 --- a/tools/bookmaker/bookmaker.h +++ b/tools/bookmaker/bookmaker.h @@ -106,6 +106,7 @@ enum class MarkType { kFormula, kFunction, kHeight, + kIllustration, kImage, kIn, kLegend, @@ -1216,6 +1217,11 @@ public: kColumnEnd, }; + enum class HasTag { + kNo, + kYes, + }; + #define M(mt) (1LL << (int) MarkType::k##mt) #define M_D M(Description) #define M_CS M(Class) | M(Struct) @@ -1247,7 +1253,7 @@ public: , { "Code", nullptr, MarkType::kCode, R_O, E_N, M_CSST | M_E | M(Method) } , { "", nullptr, MarkType::kColumn, R_Y, E_N, M(Row) } , { "", nullptr, MarkType::kComment, R_N, E_N, 0 } -, { "Const", &fConstMap, MarkType::kConst, R_Y, E_N, M_E | M_ST } +, { "Const", &fConstMap, MarkType::kConst, R_Y, E_O, M_E | M_ST } , { "Define", nullptr, MarkType::kDefine, R_O, E_N, M_ST } , { "DefinedBy", nullptr, MarkType::kDefinedBy, R_N, E_N, M(Method) } , { "Deprecated", nullptr, MarkType::kDeprecated, R_Y, E_N, 0 } @@ -1256,14 +1262,16 @@ public: , { "Duration", nullptr, MarkType::kDuration, R_N, E_N, M(Example) | M(NoExample) } , { "Enum", &fEnumMap, MarkType::kEnum, R_Y, E_O, M_CSST | M(Root) } , { "EnumClass", &fClassMap, MarkType::kEnumClass, R_Y, E_O, M_CSST | M(Root) } -, { "Example", nullptr, MarkType::kExample, R_O, E_N, M_CSST | M_E | M(Method) } +, { "Example", nullptr, MarkType::kExample, + R_O, E_N, M_CSST | M_E | M(Method) | M(Const) } , { "Experimental", nullptr, MarkType::kExperimental, R_Y, E_N, 0 } , { "External", nullptr, MarkType::kExternal, R_Y, E_N, M(Root) } , { "File", nullptr, MarkType::kFile, R_N, E_N, M(Track) } , { "Formula", nullptr, MarkType::kFormula, R_O, E_N, - M(Column) | M_ST | M(Member) | M(Method) | M_D } + M(Column) | M_E | M_ST | M(Member) | M(Method) | M_D } , { "Function", nullptr, MarkType::kFunction, R_O, E_N, M(Example) | M(NoExample) } , { "Height", nullptr, MarkType::kHeight, R_N, E_N, M(Example) | M(NoExample) } +, { "Illustration", nullptr, MarkType::kIllustration, R_N, E_N, M(Subtopic) } , { "Image", nullptr, MarkType::kImage, R_N, E_N, M(Example) | M(NoExample) } , { "In", nullptr, MarkType::kIn, R_N, E_N, M_CSST | M_E | M(Method) | M(Typedef) } @@ -1322,7 +1330,8 @@ public: ~BmhParser() override {} bool addDefinition(const char* defStart, bool hasEnd, MarkType markType, - const vector<string>& typeNameBuilder); + const vector<string>& typeNameBuilder, HasTag hasTag); + bool checkEndMarker(MarkType markType, string name) const; bool checkExamples() const; bool checkParamReturn(const Definition* definition) const; bool dumpExamples(const char* fiddleJsonFileName) const; @@ -1341,6 +1350,7 @@ public: } bool findDefinitions(); + Definition* findExample(string name) const; MarkType getMarkType(MarkLookup lookup) const; bool hasEndToken() const; string memberName(); @@ -1461,6 +1471,7 @@ public: , { nullptr, MarkType::kFormula } , { nullptr, MarkType::kFunction } , { nullptr, MarkType::kHeight } + , { nullptr, MarkType::kIllustration } , { nullptr, MarkType::kImage } , { nullptr, MarkType::kIn } , { nullptr, MarkType::kLegend } @@ -1954,7 +1965,7 @@ protected: INHERITED::resetCommon(); } - Definition* findExample(const string& name) const; + Definition* findExample(string name) const { return fBmhParser->findExample(name); } bool parseFiddles(); virtual bool pngOut(Definition* example) = 0; virtual bool textOut(Definition* example, const char* stdOutStart, diff --git a/tools/bookmaker/fiddleParser.cpp b/tools/bookmaker/fiddleParser.cpp index faf551006f..682c87c845 100644 --- a/tools/bookmaker/fiddleParser.cpp +++ b/tools/bookmaker/fiddleParser.cpp @@ -7,32 +7,6 @@ #include "bookmaker.h" -static Definition* find_fiddle(Definition* def, const string& name) { - if (MarkType::kExample == def->fMarkType && name == def->fFiddle) { - return def; - } - for (auto& child : def->fChildren) { - Definition* result = find_fiddle(child, name); - if (result) { - return result; - } - } - return nullptr; -} - -Definition* FiddleBase::findExample(const string& name) const { - for (const auto& topic : fBmhParser->fTopicMap) { - if (topic.second->fParent) { - continue; - } - Definition* def = find_fiddle(topic.second, name); - if (def) { - return def; - } - } - return nullptr; -} - bool FiddleBase::parseFiddles() { if (!this->skipExact("{\n")) { return false; diff --git a/tools/bookmaker/includeWriter.cpp b/tools/bookmaker/includeWriter.cpp index 0b77cface0..328e9412cb 100644 --- a/tools/bookmaker/includeWriter.cpp +++ b/tools/bookmaker/includeWriter.cpp @@ -1234,9 +1234,6 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti case KeyWord::kStruct: case KeyWord::kClass: fStructMemberTab = 0; - if ("FontMetrics" == child.fName) { - SkDebugf(""); - } // if struct contains members, compute their name and comment tabs if (child.fChildren.size() > 0) { const ParentPair* testPair = &pair; @@ -1407,9 +1404,6 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti return false; } } else { - if ("FontMetrics" == child.fName) { - SkDebugf(""); - } if (!this->populate(&child, &pair, root)) { return false; } @@ -1660,9 +1654,6 @@ string IncludeWriter::resolveRef(const char* start, const char* end, bool first, RefType* refType) { // look up Xxx_Xxx string undername(start, end - start); - if ("Paint_Stroke_Width" == undername) { - SkDebugf(""); - } for (const auto& external : fBmhParser->fExternals) { if (external.fName == undername) { *refType = RefType::kExternal; diff --git a/tools/bookmaker/mdOut.cpp b/tools/bookmaker/mdOut.cpp index 61692aa69c..f74853b470 100644 --- a/tools/bookmaker/mdOut.cpp +++ b/tools/bookmaker/mdOut.cpp @@ -257,6 +257,8 @@ string MdOut::addReferences(const char* refStart, const char* refEnd, return result; } + + bool MdOut::buildReferences(const char* docDir, const char* mdFileOrPath) { if (!sk_isdir(mdFileOrPath)) { SkString mdFile = SkOSPath::Basename(mdFileOrPath); @@ -272,15 +274,8 @@ bool MdOut::buildReferences(const char* docDir, const char* mdFileOrPath) { SkOSFile::Iter it(docDir, ".bmh"); for (SkString file; it.next(&file); ) { SkString p = SkOSPath::Join(docDir, file.c_str()); - const char* hunk = p.c_str(); - if (!SkStrEndsWith(hunk, ".bmh")) { - continue; - } - if (SkStrEndsWith(hunk, "markup.bmh")) { // don't look inside this for now - continue; - } - if (!this->buildRefFromFile(hunk, mdFileOrPath)) { - SkDebugf("failed to parse %s\n", hunk); + if (!this->buildRefFromFile(p.c_str(), mdFileOrPath)) { + SkDebugf("failed to parse %s\n", p.c_str()); return false; } } @@ -302,6 +297,15 @@ bool MdOut::buildStatus(const char* statusFile, const char* outDir) { } bool MdOut::buildRefFromFile(const char* name, const char* outDir) { + if (!SkStrEndsWith(name, ".bmh")) { + return true; + } + if (SkStrEndsWith(name, "markup.bmh")) { // don't look inside this for now + return true; + } + if (SkStrEndsWith(name, "illustrations.bmh")) { // don't look inside this for now + return true; + } fFileName = string(name); string filename(name); if (filename.substr(filename.length() - 4) == ".bmh") { @@ -882,6 +886,23 @@ void MdOut::markTypeOut(Definition* def) { break; case MarkType::kHeight: break; + case MarkType::kIllustration: { + string illustName = "Illustrations_" + def->fParent->fFiddle; + auto illustIter = fBmhParser.fTopicMap.find(illustName); + SkASSERT(fBmhParser.fTopicMap.end() != illustIter); + Definition* illustDef = illustIter->second; + SkASSERT(MarkType::kSubtopic == illustDef->fMarkType); + SkASSERT(1 == illustDef->fChildren.size()); + Definition* illustExample = illustDef->fChildren[0]; + SkASSERT(MarkType::kExample == illustExample->fMarkType); + string hash = illustExample->fHash; + SkASSERT("" != hash); + string title; + this->writePending(); + FPRINTF("![%s](https://fiddle.skia.org/i/%s_raster.png \"%s\")", + def->fName.c_str(), hash.c_str(), title.c_str()); + this->lf(2); + } break; case MarkType::kImage: break; case MarkType::kIn: diff --git a/tools/bookmaker/spellCheck.cpp b/tools/bookmaker/spellCheck.cpp index 3cb62be3ef..e5ad746379 100644 --- a/tools/bookmaker/spellCheck.cpp +++ b/tools/bookmaker/spellCheck.cpp @@ -191,6 +191,8 @@ bool SpellCheck::check(Definition* def) { break; case MarkType::kHeight: break; + case MarkType::kIllustration: + break; case MarkType::kImage: break; case MarkType::kIn: |