From 06c20f356ddfcf95385c5d5ca9bf4428a7a16b81 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Tue, 20 Mar 2018 15:53:27 -0400 Subject: more SkImageInfo docs fix a couple of fiddles with changed output rewrite some SkSurface image makers move towards replacing SkImageInfo.h R=caryclark@google.com Docs-Preview: https://skia.org/?cl=115163 Bug: skia:6898 Change-Id: Id9895b051cd457336c30250a69cf95359d1d34d7 Reviewed-on: https://skia-review.googlesource.com/115163 Commit-Queue: Cary Clark Reviewed-by: Cary Clark --- site/user/api/SkBitmap_Reference.md | 2 +- site/user/api/SkCanvas_Reference.md | 6 +- site/user/api/SkIRect_Reference.md | 2 +- site/user/api/SkImageInfo_Reference.md | 290 +++++++++++++++++++-------------- site/user/api/SkImage_Reference.md | 40 +---- site/user/api/SkPaint_Reference.md | 26 +-- site/user/api/SkPath_Reference.md | 4 +- site/user/api/SkSurface_Reference.md | 239 ++++----------------------- site/user/api/catalog.htm | 151 ++++++++--------- site/user/api/undocumented.md | 30 ++-- 10 files changed, 316 insertions(+), 474 deletions(-) (limited to 'site') diff --git a/site/user/api/SkBitmap_Reference.md b/site/user/api/SkBitmap_Reference.md index 9038a34ba8..864ed54e70 100644 --- a/site/user/api/SkBitmap_Reference.md +++ b/site/user/api/SkBitmap_Reference.md @@ -3629,7 +3629,7 @@ SK_DEBUG is defined at compile time. ### See Also -SkImageInfo::validate() +SkImageInfo::validate --- diff --git a/site/user/api/SkCanvas_Reference.md b/site/user/api/SkCanvas_Reference.md index f318040a8a..2253b3756a 100644 --- a/site/user/api/SkCanvas_Reference.md +++ b/site/user/api/SkCanvas_Reference.md @@ -470,7 +470,7 @@ enum class ColorBehavior { - + ## SkCanvas @@ -2462,8 +2462,6 @@ maximum allowed clip in device coordinates --- - - ## clipRRect @@ -4600,7 +4598,7 @@ or to fill the grid entry with a color. - + const int* fXDivs diff --git a/site/user/api/SkIRect_Reference.md b/site/user/api/SkIRect_Reference.md index ecbd43eeea..049c2b6da1 100644 --- a/site/user/api/SkIRect_Reference.md +++ b/site/user/api/SkIRect_Reference.md @@ -775,7 +775,7 @@ midpoint in y #### Example Output ~~~~ -left: 1073741824 right: 1073741826 centerX: -1073741823 safe mid x: 1073741825 +left: 1073741824 right: 1073741826 centerX: 1073741825 safe mid x: 1073741825 ~~~~ diff --git a/site/user/api/SkImageInfo_Reference.md b/site/user/api/SkImageInfo_Reference.md index 464fed988e..10e1272361 100644 --- a/site/user/api/SkImageInfo_Reference.md +++ b/site/user/api/SkImageInfo_Reference.md @@ -140,6 +140,27 @@ The four displayed values are the original component values, though not necessar in the same order. + +## SkAlphaTypeIsOpaque + +
+static inline bool SkAlphaTypeIsOpaque(SkAlphaType at)
+
+ +### Parameters + + + +
at +one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType, +kUnpremul_SkAlphaType
+ +### Return Value + +true if at equals kOpaque_SkAlphaType + +--- + ## Color Type kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType, @@ -164,11 +185,15 @@ enum SkColorType { kRGB_101010x_SkColorType, kGray_8_SkColorType, kRGBA_F16_SkColorType, + kLastEnum_SkColorType = kRGBA_F16_SkColorType, + +#if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) kN32_SkColorType = kBGRA_8888_SkColorType, +#elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) kN32_SkColorType = kRGBA_8888_SkColorType, -}; - +#else +#error " Describes how pixel bits encode color. A pixel may be an alpha mask, a gray level, Color RGB, or Color ARGB. @@ -578,34 +603,44 @@ kLastEnum_SkYUVColorSpace = kRec709_SkYUVColo }; -Describes the color space a YUV pixel. +Describes color range of YUV pixels. The color mapping from YUV to RGB varies +depending on the source. YUV pixels may be generated by JPEG images, standard +video streams, or high definition video streams. Each has its own mapping from +YUV and RGB. + +JPEG YUV values encode the full range of 0 to 255 for all three components. +Video YUV values range from 16 to 235 for all three components. Details of +encoding and conversion to RGB are described in YCbCr color space . ### Constants -
kJPEG_SkYUVColorSpace 0Standard JPEG color space. + kJPEG_SkYUVColorSpace 0Describes standard JPEG color space; +CCIR 601
+ + with full range of 0 to 255 for components. - kRec601_SkYUVColorSpace 1SDTV standard Rec. 601 color space. Uses "studio swing" [16, 235] color -range. See http://en.wikipedia.org/wiki/Rec._601 for details. + kRec601_SkYUVColorSpace 1Describes standard used by SDTV; +CCIR 601 + + with studio range of 16 to 235 range for components. - kRec709_SkYUVColorSpace 2HDTV standard Rec. 709 color space. Uses "studio swing" [16, 235] color -range. See http://en.wikipedia.org/wiki/Rec._709 for details. + kRec709_SkYUVColorSpace 2Describes standard used by HDTV; +Rec. 709 + + with studio range of 16 to 235 range for components. -### Example - -
- ### See Also -incomplete +SkImage::MakeFromYUVTexturesCopy SkImage::MakeFromNV12TexturesCopy @@ -623,7 +658,7 @@ and green; and Color Space, the range and | name | description | | --- | --- | -| ByteSizeOverflowed | incomplete | +| ByteSizeOverflowed | checks result of computeByteSize and computeMinByteSize | | Make | creates Image Info from dimensions, Color Type, Alpha Type, Color Space | | MakeA8 | creates Image Info with kAlpha_8_SkColorType, kPremul_SkAlphaType | | MakeN32 | creates Image Info with Native Color Type | @@ -635,11 +670,10 @@ and green; and Color Space, the range and | bytesPerPixel | returns number of bytes in pixel based on Color Type | | colorSpace | returns Color Space | | colorType | returns Color Type | -| computeByteSize | incomplete | -| computeMinByteSize | incomplete | +| computeByteSize | memory required by pixel buffer with given row bytes | +| computeMinByteSize | least memory required by pixel buffer | | computeOffset | returns byte offset within pixel array | | dimensions | returns width and height | -| flatten | incomplete | | gammaCloseToSRGB | Returns if Color Space gamma is approximately the same as sRGB | | height | returns pixel row count | | isEmpty | returns if dimensions contain pixels | @@ -651,11 +685,10 @@ and green; and Color Space, the range and | minRowBytes | returns width times bytesPerPixel in 32 bits | | minRowBytes64 | returns width times bytesPerPixel in 64 bits | | refColorSpace | returns Color Space | -| reset | incomplete | +| reset | sets zero dimensions, kUnknown_SkColorType, kUnknown_SkAlphaType | | shiftPerPixel | returns bit shift from pixels to bytes | -| unflatten | incomplete | -| validRowBytes | incomplete | -| validate | incomplete | +| validRowBytes | checks if row bytes is large enough to contain pixel row | +| validate | asserts if Image Info is invalid (debug only) | | width | returns pixel column count | ## Related Function @@ -684,7 +717,7 @@ and green; and Color Space, the range and | makeColorSpace | creates Image Info with changed Color Space | | makeColorType | creates Image Info with changed Color Type | | makeWH | creates Image Info with changed dimensions | -| reset | incomplete | +| reset | sets zero dimensions, kUnknown_SkColorType, kUnknown_SkAlphaType | ## SkImageInfo @@ -693,7 +726,7 @@ and green; and Color Space, the range and SkImageInfo() -Creates an empty Image Info with kUnknown_SkColorType, kUnknown_SkAlphaType, +Creates an empty Image Info with kUnknown_SkColorType, kUnknown_SkAlphaType, a width and height of zero, and no Color Space. ### Return Value @@ -884,7 +917,7 @@ created Image Info ### Example -
+
### See Also @@ -920,7 +953,7 @@ created Image Info ### Example -
+
### See Also @@ -1588,7 +1621,7 @@ color: kRGBA_F16_SkColorType shiftPerPixel: 3 ### See Also -incomplete +bytesPerPixel minRowBytes SkBitmap::shiftPerPixel SkPixmap::shiftPerPixel --- @@ -1701,11 +1734,11 @@ offset within pixel array ### Example -
+
### See Also -incomplete +height width minRowBytes computeByteSize --- @@ -1713,8 +1746,8 @@ incomplete | name | description | | --- | --- | -| operator!=(const SkImageInfo& other) const | incomplete | -| operator==(const SkImageInfo& other) const | incomplete | +| operator!=(const SkImageInfo& other) const | compares Image Info for inequality | +| operator==(const SkImageInfo& other) const | compares Image Info for equality | ## operator== @@ -1723,24 +1756,38 @@ incomplete bool operator==(const SkImageInfo& other) _const +Compares Image Info with other, and returns true if width, height, Color Type, +Alpha Type, and Color Space are equivalent. + ### Parameters +Image Info to compare
other -incomplete
### Return Value -incomplete +true if Image Info equals other ### Example -
+
+ +#### Example Output + +~~~~ +info1 != info2 +info1 != info2 +info1 != info2 +info1 == info2 +~~~~ + +
### See Also -incomplete +operator!=(const SkImageInfo& other) const SkColorSpace::Equals --- @@ -1751,72 +1798,38 @@ incomplete bool operator!=(const SkImageInfo& other) _const +Compares Image Info with other, and returns true if width, height, Color Type, +Alpha Type, and Color Space are equivalent. + ### Parameters +Image Info to compare
other -incomplete
### Return Value -incomplete - -### Example - -
- -### See Also - -incomplete - ---- - - -## unflatten - -
-void unflatten(SkReadBuffer& buffer)
-
- -### Parameters - - - -
buffer -incomplete
+true if Image Info is not equal to other ### Example -
+
-### See Also - -incomplete - ---- - - -## flatten - -
-void flatten(SkWriteBuffer& buffer) const
-
- -### Parameters - - - -
buffer -incomplete
+#### Example Output -### Example +~~~~ +info1 != info2 +info1 != info2 +info1 != info2 +info1 == info2 +~~~~ -
+
### See Also -incomplete +operator==(const SkImageInfo& other) const SkColorSpace::Equals --- @@ -1827,33 +1840,30 @@ incomplete size_t computeByteSize(size_t rowBytes) const -Returns the size (in bytes) of the image buffer that this info needs, given the specified -rowBytes. The rowBytes must be >= this->minRowBytes. -if (height == 0) { -return 0; -} else { -return (height - 1) * rowBytes + width * bytes_per_pixel. +Returns storage required by pixel array, given Image Info dimensions, Color Type, +and rowBytes. rowBytes is assumed to be at least as large as minRowBytes. -If the calculation overflows this returns SK MaxSizeT. +Returns zero if height is zero. +Returns SK MaxSizeT if answer exceeds the range of size_t. ### Parameters +size of pixel row or larger
rowBytes -incomplete
### Return Value -incomplete +memory required by pixel buffer ### Example -
+
### See Also -incomplete +computeMinByteSize validRowBytes --- @@ -1864,20 +1874,23 @@ incomplete size_t computeMinByteSize() const -Returns the minimum size (in bytes) of the image buffer that this info needs. -If the calculation overflows, or if the height is 0, this returns 0. +Returns storage required by pixel array, given Image Info dimensions, and +Color Type. Uses minRowBytes to compute bytes for pixel row. + +Returns zero if height is zero. +Returns SK MaxSizeT if answer exceeds the range of size_t. ### Return Value -incomplete +least memory required by pixel buffer ### Example -
+
### See Also -incomplete +computeByteSize validRowBytes --- @@ -1888,26 +1901,39 @@ incomplete static bool ByteSizeOverflowed(size_t byteSize) -Returns true if the result of computeByteSize (or computeMinByteSize) overflowed +Returns true if byteSize equals SK MaxSizeT. computeByteSize and +computeMinByteSize return SK MaxSizeT if size_t can not hold buffer size. ### Parameters +result of computeByteSize or computeMinByteSize
byteSize -incomplete
### Return Value -incomplete +true if computeByteSize or computeMinByteSize result exceeds size_t ### Example -
+
+ +#### Example Output + +~~~~ +rowBytes:100000000 size:99999999900000008 overflowed:false +rowBytes:1000000000 size:999999999000000008 overflowed:false +rowBytes:10000000000 size:9999999990000000008 overflowed:false +rowBytes:100000000000 size:18446744073709551615 overflowed:true +rowBytes:1000000000000 size:18446744073709551615 overflowed:true +~~~~ + +
### See Also -incomplete +computeByteSize computeMinByteSize validRowBytes --- @@ -1918,24 +1944,36 @@ incomplete bool validRowBytes(size_t rowBytes) const +Returns true if rowBytes is smaller than width times pixel size. + ### Parameters +size of pixel row or larger
rowBytes -incomplete
### Return Value -incomplete +true if rowBytes is large enough to contain pixel row ### Example -
+
+ +#### Example Output + +~~~~ +validRowBytes(60): false +validRowBytes(64): true +validRowBytes(68): true +~~~~ + +
### See Also -incomplete +ByteSizeOverflowed computeByteSize computeMinByteSize --- @@ -1946,13 +1984,26 @@ incomplete void reset() +Creates an empty Image Info with kUnknown_SkColorType, kUnknown_SkAlphaType, +a width and height of zero, and no Color Space. + ### Example -
+
+ +#### Example Output + +~~~~ +info == copy +info != reset copy +SkImageInfo() == reset copy +~~~~ + +
### See Also -incomplete +SkImageInfo() --- @@ -1960,14 +2011,12 @@ incomplete | name | description | | --- | --- | -| ByteSizeOverflowed | incomplete | -| computeByteSize | incomplete | -| computeMinByteSize | incomplete | +| ByteSizeOverflowed | checks result of computeByteSize and computeMinByteSize | +| computeByteSize | memory required by pixel buffer with given row bytes | +| computeMinByteSize | least memory required by pixel buffer | | computeOffset | returns byte offset within pixel array | -| flatten | incomplete | -| unflatten | incomplete | -| validRowBytes | incomplete | -| validate | incomplete | +| validRowBytes | checks if row bytes is large enough to contain pixel row | +| validate | asserts if Image Info is invalid (debug only) | ## validate @@ -1976,13 +2025,12 @@ incomplete void validate() const -### Example - -
+Asserts if internal values are illegal or inconsistent. Only available if +SK_DEBUG is defined at compile time. ### See Also -incomplete +validRowBytes SkBitmap::validate --- diff --git a/site/user/api/SkImage_Reference.md b/site/user/api/SkImage_Reference.md index c40598f150..e9faca9c7c 100644 --- a/site/user/api/SkImage_Reference.md +++ b/site/user/api/SkImage_Reference.md @@ -78,15 +78,11 @@ drawing. | MakeFromEncoded | creates Image from encoded data | | MakeFromGenerator | creates Image from a stream of data | | MakeFromNV12TexturesCopy | creates Image from YUV ColorSpace data in three planes | -| | MakeFromNV12TexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace, const GrBackendTexture nv12Textures[2], GrSurfaceOrigin surfaceOrigin, sk sp<SkColorSpace> colorSpace = nullptr) | -| | MakeFromNV12TexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace, const GrBackendTexture nv12Textures[2], const SkISize nv12Sizes[2], GrSurfaceOrigin surfaceOrigin, sk sp<SkColorSpace> colorSpace = nullptr) | | MakeFromPicture | creates Image from Picture | | MakeFromRaster | creates Image from Pixmap, with release | | MakeFromTexture 3 | creates Image from GPU Texture | | | static sk sp<SkImage> MakeFromTexture(GrContext* context, const GrBackendTexture& backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk sp<SkColorSpace> colorSpace) | | MakeFromYUVTexturesCopy | creates Image from YUV ColorSpace data in three planes | -| | MakeFromYUVTexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace, const GrBackendTexture yuvTextures[3], GrSurfaceOrigin surfaceOrigin, sk sp<SkColorSpace> colorSpace = nullptr) | -| | MakeFromYUVTexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace, const GrBackendTexture yuvTextures[3], const SkISize yuvSizes[3], GrSurfaceOrigin surfaceOrigin, sk sp<SkColorSpace> colorSpace = nullptr) | | MakeRasterCopy | creates Image from Pixmap and copied pixels | | MakeRasterData | creates Image from Image Info and shared pixels | | asLegacyBitmap | returns as Raster Bitmap | @@ -493,7 +489,7 @@ created Image, or nullptr ### See Also -MakeFromAdoptedTexture SkSurface::MakeFromBackendTexture[2] +MakeFromAdoptedTexture SkSurface::MakeFromBackendTexture --- @@ -549,7 +545,7 @@ created Image, or nullptr ### See Also -MakeFromAdoptedTexture SkSurface::MakeFromBackendTexture[2] +MakeFromAdoptedTexture SkSurface::MakeFromBackendTexture --- @@ -719,7 +715,7 @@ created Image, or nullptr ### See Also -MakeFromTexture MakeFromYUVTexturesCopy[2] +MakeFromTexture MakeFromYUVTexturesCopy --- @@ -759,19 +755,7 @@ created Image, or nullptr ### See Also -MakeFromNV12TexturesCopy[2] - ---- - - - -
-static sk_sp<SkImage> MakeFromYUVTexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace,
-                                              const GrBackendTexture yuvTextures[3],
-                                              const SkISize yuvSizes[3],
-                                              GrSurfaceOrigin surfaceOrigin,
-                                              sk_sp<SkColorSpace> colorSpace = nullptr)
-
+MakeFromNV12TexturesCopy --- @@ -814,19 +798,7 @@ created Image, or nullptr ### See Also -MakeFromYUVTexturesCopy[2] - ---- - - - -
-static sk_sp<SkImage> MakeFromNV12TexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace,
-                                               const GrBackendTexture nv12Textures[2],
-                                               const SkISize nv12Sizes[2],
-                                               GrSurfaceOrigin surfaceOrigin,
-                                               sk_sp<SkColorSpace> colorSpace = nullptr)
-
+MakeFromYUVTexturesCopy --- @@ -2110,7 +2082,7 @@ enum LegacyBitmapMode { - + ## asLegacyBitmap diff --git a/site/user/api/SkPaint_Reference.md b/site/user/api/SkPaint_Reference.md index 23c582b0a2..88a100b978 100644 --- a/site/user/api/SkPaint_Reference.md +++ b/site/user/api/SkPaint_Reference.md @@ -531,6 +531,10 @@ paint1 != paint2 +### See Also + +operator!=(const SkPaint& a, const SkPaint& b) + --- @@ -570,6 +574,10 @@ paint1 == paint2 +### See Also + +operator==(const SkPaint& a, const SkPaint& b) + --- @@ -806,7 +814,7 @@ multiple settings at once. Flags default to all flags clear, disabling the associated feature. - + ## Enum SkPaint::ReserveFlags @@ -829,7 +837,7 @@ enum ReserveFlags { SkPaint::kStrikeThruText_ReserveFlag 0x0010soon - + ## getFlags @@ -2109,7 +2117,7 @@ and the set Path Fill Type is ignored. - + ## Enum SkPaint::_anonymous @@ -2128,7 +2136,7 @@ May be used to verify that Style is a legal value. - + ## getStyle @@ -2448,8 +2456,6 @@ at the contour point. Stroke Cap is kButt Cap by default. - - ### Example
@@ -3617,7 +3623,7 @@ and by its height if Flags has Enum SkPaint::_anonymous_2 @@ -3635,7 +3641,7 @@ enum { - + ### Example @@ -3914,7 +3920,7 @@ A glyph index is a 16-bit word. - + ### Example @@ -4088,7 +4094,7 @@ Fonts with embedded bitmaps may not have valid underline or strikeout metrics. - + uint32_t fFlags diff --git a/site/user/api/SkPath_Reference.md b/site/user/api/SkPath_Reference.md index 240bea423c..527a245da5 100644 --- a/site/user/api/SkPath_Reference.md +++ b/site/user/api/SkPath_Reference.md @@ -4669,8 +4669,8 @@ number of bytes read, or zero on failure #### Example Output ~~~~ -length = 60; returned by readFromMemory = 0 -length = 68; returned by readFromMemory = 64 +length = 32; returned by readFromMemory = 0 +length = 40; returned by readFromMemory = 36 ~~~~ diff --git a/site/user/api/SkSurface_Reference.md b/site/user/api/SkSurface_Reference.md index dda2c3c80e..1b01fe5f58 100644 --- a/site/user/api/SkSurface_Reference.md +++ b/site/user/api/SkSurface_Reference.md @@ -36,8 +36,8 @@ of the requested dimensions are zero, then nullptr will be returned. | name | description | | --- | --- | | MakeFromBackendRenderTarget | creates Surface from GPU memory buffer | -| MakeFromBackendTexture | creates Surface from GPU-backed texture | -| MakeFromBackendTextureAsRenderTarget | creates Surface from GPU-backed texture | +| MakeFromBackendTexture | creates Surface from GPU texture | +| MakeFromBackendTextureAsRenderTarget | creates Surface from GPU back-end render target | | MakeNull | creates Surface without backing pixels | | MakeRaster | creates Surface from SkImageInfo | | MakeRasterDirect | creates Surface from SkImageInfo and Pixel Storage | @@ -68,8 +68,8 @@ of the requested dimensions are zero, then nullptr will be returned. | name | description | | --- | --- | | MakeFromBackendRenderTarget | creates Surface from GPU memory buffer | -| MakeFromBackendTexture | creates Surface from GPU-backed texture | -| MakeFromBackendTextureAsRenderTarget | creates Surface from GPU-backed texture | +| MakeFromBackendTexture | creates Surface from GPU texture | +| MakeFromBackendTextureAsRenderTarget | creates Surface from GPU back-end render target | | MakeNull | creates Surface without backing pixels | | MakeRaster | creates Surface from SkImageInfo | | MakeRasterDirect | creates Surface from SkImageInfo and Pixel Storage | @@ -371,6 +371,7 @@ fonts; may be nullptr static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* context, const GrBackendTexture& backendTexture, GrSurfaceOrigin origin, int sampleCnt, + SkColorType colorType, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* surfaceProps) @@ -398,87 +399,14 @@ texture residing on GPU one of: kBottomLeft GrSurfaceOrigin, kTopLeft GrSurfaceOrigin sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing - colorSpace -range of colors - surfaceProps -LCD striping orientation and setting for device independent -fonts; may be nullptr - - - -### Return Value - -Surface if all parameters are valid; otherwise, nullptr - -### Example - -
-
-    SkPaint paint;
-    paint.setTextSize(32);
-    GrContext* context = canvas->getGrContext();
-    if (!context) {
-         canvas->drawString("GPU only!", 20, 40, paint);
-         return;
-    }
-    sk_sp gpuSurface = SkSurface::MakeFromBackendTexture(context,
-            backEndTextureRenderTarget, kTopLeft_GrSurfaceOrigin, 0, nullptr, nullptr);
-    auto surfaceCanvas = gpuSurface->getCanvas();
-    surfaceCanvas->clear(SK_ColorWHITE);
-    surfaceCanvas->drawString("GPU rocks!", 20, 40, paint);
-    sk_sp image(gpuSurface->makeImageSnapshot());
-    canvas->drawImage(image, 0, 0);
-
-
- -### See Also - -GrBackendTexture MakeFromBackendRenderTarget[2] MakeRenderTarget[2][3] - ---- - - - -
-static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* context,
-                                               const GrBackendTexture& backendTexture,
-                                               GrSurfaceOrigin origin, int sampleCnt,
-                                               SkColorType colorType,
-                                               sk_sp<SkColorSpace> colorSpace,
-                                               const SkSurfaceProps* surfaceProps)
-
- -Wraps a GPU-backed texture into Surface. Caller must ensure the texture is -valid for the lifetime of returned Surface. If sampleCnt greater than zero, -creates an intermediate MSAA Surface which is used for drawing backendTexture. - -Surface is returned if all parameters are valid. backendTexture is valid if -its pixel configuration agrees with colorSpace and context; for instance, if -backendTexture has an sRGB configuration, then context must support sRGB, -and colorSpace must be present. Further, backendTexture width and height must -not exceed context capabilities, and the context must be able to support -back-end textures. - -If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. - -### Parameters - - - - - - - - + @@ -490,25 +418,7 @@ fonts; may be nullptr ### Example -
-
-    SkPaint paint;
-    paint.setTextSize(32);
-    GrContext* context = canvas->getGrContext();
-    if (!context) {
-         canvas->drawString("GPU only!", 20, 40, paint);
-         return;
-    }
-    sk_sp gpuSurface = SkSurface::MakeFromBackendTexture(context,
-            backEndTextureRenderTarget, kTopLeft_GrSurfaceOrigin,
-            kRGBA_8888_SkColorType, 0, nullptr, nullptr);
-    auto surfaceCanvas = gpuSurface->getCanvas();
-    surfaceCanvas->clear(SK_ColorWHITE);
-    surfaceCanvas->drawString("GPU rocks!", 20, 40, paint);
-    sk_sp image(gpuSurface->makeImageSnapshot());
-    canvas->drawImage(image, 0, 0);
-
-
+
### See Also @@ -573,7 +483,6 @@ fonts; may be nullptr sk_sp gpuSurface = SkSurface::MakeFromBackendRenderTarget(context, backEndRenderTarget, kTopLeft_GrSurfaceOrigin, nullptr, nullptr); auto surfaceCanvas = gpuSurface->getCanvas(); - surfaceCanvas->clear(SK_ColorWHITE); surfaceCanvas->drawString("GPU rocks!", 20, 40, paint); sk_sp image(gpuSurface->makeImageSnapshot()); canvas->drawImage(image, 0, 0); @@ -582,7 +491,7 @@ fonts; may be nullptr ### See Also -MakeFromBackendTexture[2] MakeRenderTarget[2][3] +MakeFromBackendTexture MakeRenderTarget[2][3] --- @@ -596,8 +505,8 @@ static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext* context, const SkSurfaceProps* surfaceProps) -Wraps a GPU-backed buffer into Surface. Caller must ensure render target is -valid for the lifetime of returned Surface. +Wraps a GPU-backed buffer into Surface. Caller must ensure backendRenderTarget +is valid for the lifetime of returned Surface. Surface is returned if all parameters are valid. backendRenderTarget is valid if its pixel configuration agrees with colorSpace and context; for instance, if @@ -648,7 +557,6 @@ fonts; may be nullptr backEndRenderTarget, kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, nullptr, nullptr); auto surfaceCanvas = gpuSurface->getCanvas(); - surfaceCanvas->clear(SK_ColorWHITE); surfaceCanvas->drawString("GPU rocks!", 20, 40, paint); sk_sp image(gpuSurface->makeImageSnapshot()); canvas->drawImage(image, 0, 0); @@ -657,7 +565,7 @@ fonts; may be nullptr ### See Also -MakeFromBackendTexture[2] MakeRenderTarget[2][3] +MakeFromBackendTexture MakeRenderTarget[2][3] --- @@ -668,15 +576,22 @@ fonts; may be nullptr static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(GrContext* context, const GrBackendTexture& backendTexture, GrSurfaceOrigin origin, int sampleCnt, - sk_sp<SkColorSpace> colorSpace, + SkColorType colorType, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* surfaceProps) -Used to wrap a GPU-backed texture as a SkSurface. Skia will treat the texture as -a rendering target only, but unlike NewFromBackendRenderTarget, Skia will manage and own -the associated render target objects (but not the provided texture). Skia will not assume -ownership of the texture and the client must ensure the texture is valid for the lifetime -of the SkSurface. +Wraps a GPU-backed texture into Surface. Caller must ensure backendTexture is +valid for the lifetime of returned Surface. If sampleCnt greater than zero, +creates an intermediate MSAA Surface which is used for drawing backendTexture. + +Surface is returned if all parameters are valid. backendTexture is valid if +its pixel configuration agrees with colorSpace and context; for instance, if +backendTexture has an sRGB configuration, then context must support sRGB, +and colorSpace must be present. Further, backendTexture width and height must +not exceed context capabilities. + +Returned Surface is available only for drawing into, and cannot generate an +Image. If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. @@ -690,81 +605,14 @@ texture residing on GPU one of: kBottomLeft GrSurfaceOrigin, kTopLeft GrSurfaceOrigin - - - -
context -GPU Context
backendTexture -texture residing on GPU
origin -one of: kBottomLeft GrSurfaceOrigin, kTopLeft GrSurfaceOrigin
sampleCnt -samples per pixel, or 0 to disable full scene anti-aliasing
colorType +
colorType one of: kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType, kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType, kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType, kGray_8_SkColorType, kRGBA_F16_SkColorType
colorSpace -range of colors
surfaceProps +
colorSpace +range of colors; may be nullptr
surfaceProps LCD striping orientation and setting for device independent fonts; may be nullptr
sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing
colorSpace -range of colors
surfaceProps -LCD striping orientation and setting for device independent -fonts; may be nullptr
- -### Return Value - -Surface if all parameters are valid; otherwise, nullptr - -### Example - -
-SkPaint paint;
-    paint.setTextSize(32);
-    GrContext* context = canvas->getGrContext();
-    if (!context) {
-         canvas->drawString("GPU only!", 20, 40, paint);
-         return;
-    }
-    sk_sp gpuSurface = SkSurface::MakeFromBackendTextureAsRenderTarget(
-            context, backEndTextureRenderTarget, kTopLeft_GrSurfaceOrigin, 0,
-            nullptr, nullptr);
-    auto surfaceCanvas = gpuSurface->getCanvas();
-    surfaceCanvas->clear(SK_ColorWHITE);
-    surfaceCanvas->drawString("GPU rocks!", 20, 40, paint);
-    sk_sp image(gpuSurface->makeImageSnapshot());
-    canvas->drawImage(image, 0, 0);
-
-
- -### See Also - -MakeFromBackendRenderTarget[2] MakeRenderTarget[2][3] - ---- - - - -
-static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(GrContext* context,
-                                            const GrBackendTexture& backendTexture,
-                                            GrSurfaceOrigin origin, int sampleCnt,
-                                            SkColorType colorType, sk_sp<SkColorSpace> colorSpace,
-                                            const SkSurfaceProps* surfaceProps)
-
- -Used to wrap a GPU-backed texture as a SkSurface. Skia will treat the texture as -a rendering target only, but unlike NewFromBackendRenderTarget, Skia will manage and own -the associated render target objects (but not the provided texture). Skia will not assume -ownership of the texture and the client must ensure the texture is valid for the lifetime -of the SkSurface. - -If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. - -### Parameters - - - - - - - - + @@ -776,24 +624,7 @@ fonts; may be nullptr ### Example -
-SkPaint paint;
-    paint.setTextSize(32);
-    GrContext* context = canvas->getGrContext();
-    if (!context) {
-         canvas->drawString("GPU only!", 20, 40, paint);
-         return;
-    }
-    sk_sp gpuSurface = SkSurface::MakeFromBackendTextureAsRenderTarget(
-            context, backEndTextureRenderTarget, kTopLeft_GrSurfaceOrigin, 0,
-            kRGBA_8888_SkColorType, nullptr, nullptr);
-    auto surfaceCanvas = gpuSurface->getCanvas();
-    surfaceCanvas->clear(SK_ColorWHITE);
-    surfaceCanvas->drawString("GPU rocks!", 20, 40, paint);
-    sk_sp image(gpuSurface->makeImageSnapshot());
-    canvas->drawImage(image, 0, 0);
-
-
+
### See Also @@ -860,7 +691,7 @@ hint that Surface will host Mip_Map images ### See Also -MakeFromBackendRenderTarget[2]MakeFromBackendTextureAsRenderTarget[2] +MakeFromBackendRenderTarget[2]MakeFromBackendTextureAsRenderTarget --- @@ -916,7 +747,7 @@ or red green blue. ### See Also -MakeFromBackendRenderTarget[2]MakeFromBackendTextureAsRenderTarget[2] +MakeFromBackendRenderTarget[2]MakeFromBackendTextureAsRenderTarget --- @@ -957,7 +788,7 @@ of Raster Surface; width, or height, o ### See Also -MakeFromBackendRenderTarget[2]MakeFromBackendTextureAsRenderTarget[2] +MakeFromBackendRenderTarget[2]MakeFromBackendTextureAsRenderTarget --- diff --git a/site/user/api/catalog.htm b/site/user/api/catalog.htm index 6906dc95c9..0399831702 100644 --- a/site/user/api/catalog.htm +++ b/site/user/api/catalog.htm @@ -740,7 +740,7 @@ "hash": "687d833b042fb018f8948764e73a37b1", "file": "SkIRect_Reference", "name": "SkIRect::centerY", - "stdout": "left: 1073741824 right: 1073741826 centerX: -1073741823 safe mid x: 1073741825\\n" + "stdout": "left: 1073741824 right: 1073741826 centerX: 1073741825 safe mid x: 1073741825\\n" }, "SkIRect_contains": { "code": "void draw(SkCanvas* canvas) {\n SkIRect rect = { 30, 50, 40, 60 };\n SkIPoint pts[] = { { 30, 50}, { 40, 50}, { 30, 60} };\n for (auto pt : pts) {\n SkDebugf(\"rect: (%d, %d, %d, %d) %s (%d, %d)\\n\",\n rect.left(), rect.top(), rect.right(), rect.bottom(),\n rect.contains(pt.x(), pt.y()) ? \"contains\" : \"does not contain\", pt.x(), pt.y());\n }\n}", @@ -1014,6 +1014,13 @@ "file": "SkIRect_Reference", "name": "SkIRect::y()", "stdout": "unsorted.fTop: 25 unsorted.y(): 25\\nsorted.fTop: 5 sorted.y(): 5\\n" + }, + "SkImageInfo_ByteSizeOverflowed": { + "code": "void draw(SkCanvas* canvas) {\n SkImageInfo info = SkImageInfo::MakeN32Premul(2, 1000000000);\n for (size_t rowBytes = 100000000; rowBytes < 10000000000000LL; rowBytes *= 10) {\n const size_t size = info.computeByteSize(rowBytes);\n SkDebugf(\"rowBytes:%llu size:%llu overflowed:%s\\n\", rowBytes, size,\n SkImageInfo::ByteSizeOverflowed(size) ? \"true\" : \"false\");\n }\n}", + "hash": "6a63dfdd62ab77ff57783af8c33d7b78", + "file": "SkImageInfo_Reference", + "name": "SkImageInfo::ByteSizeOverflowed", + "stdout": "rowBytes:100000000 size:99999999900000008 overflowed:false\\nrowBytes:1000000000 size:999999999000000008 overflowed:false\\nrowBytes:10000000000 size:9999999990000000008 overflowed:false\\nrowBytes:100000000000 size:18446744073709551615 overflowed:true\\nrowBytes:1000000000000 size:18446744073709551615 overflowed:true\\n" }, "SkImageInfo_alphaType": { "code": "void draw(SkCanvas* canvas) {\n const char* alphas[] = {\"Unknown\", \"Opaque\", \"Premul\", \"Unpremul\"};\n SkImageInfo info = SkImageInfo::MakeA8(16, 32);\n SkDebugf(\"alpha type: k\" \"%s\" \"_SkAlphaType\\n\", alphas[info.alphaType()]);\n}", @@ -1049,6 +1056,13 @@ "file": "SkImageInfo_Reference", "name": "SkImageInfo::dimensions()", "stdout": "dimensionsAsBounds == bounds\\n" + }, + "SkImageInfo_equal1_operator": { + "code": "void draw(SkCanvas* canvas) {\n SkImageInfo info1 = SkImageInfo::Make(10, 20, kGray_8_SkColorType, kPremul_SkAlphaType);\n SkImageInfo info2 = SkImageInfo::Make(20, 10, kAlpha_8_SkColorType, kUnpremul_SkAlphaType);\n SkDebugf(\"info1 %c= info2\\n\", info1 == info2 ? '=' : '!');\n info2 = info2.makeWH(10, 20);\n SkDebugf(\"info1 %c= info2\\n\", info1 == info2 ? '=' : '!');\n info2 = info2.makeColorType(kGray_8_SkColorType);\n SkDebugf(\"info1 %c= info2\\n\", info1 == info2 ? '=' : '!');\n info2 = info2.makeAlphaType(kPremul_SkAlphaType);\n SkDebugf(\"info1 %c= info2\\n\", info1 == info2 ? '=' : '!');\n}", + "hash": "53c212c4f2449df0b0eedbc6227b6ab7", + "file": "SkImageInfo_Reference", + "name": "SkImageInfo::operator==(const SkImageInfo& other)_const", + "stdout": "info1 != info2\\ninfo1 != info2\\ninfo1 != info2\\ninfo1 == info2\\n" }, "SkImageInfo_isEmpty": { "code": "void draw(SkCanvas* canvas) {\n for (int width : { 0, 2 } ) {\n for (int height : { 0, 2 } ) {\n SkImageInfo imageInfo= SkImageInfo::MakeA8(width, height);\n SkDebugf(\"width: %d height: %d empty: %s\\n\", width, height,\n imageInfo.isEmpty() ? \"true\" : \"false\");\n }\n }\n}", @@ -1077,6 +1091,13 @@ "file": "SkImageInfo_Reference", "name": "SkImageInfo::minRowBytes64", "stdout": "RGBA_F16 width 16777216 (0x01000000) OK\\nRGBA_F16 width 33554432 (0x02000000) OK\\nRGBA_F16 width 67108864 (0x04000000) OK\\nRGBA_F16 width 134217728 (0x08000000) OK\\nRGBA_F16 width 268435456 (0x10000000) too large\\nRGBA_F16 width 536870912 (0x20000000) too large\\nRGBA_F16 width 1073741824 (0x40000000) too large\\nRGBA_F16 width -2147483648 (0x80000000) too large\\n" + }, + "SkImageInfo_notequal1_operator": { + "code": "void draw(SkCanvas* canvas) {\n SkImageInfo info1 = SkImageInfo::Make(10, 20, kGray_8_SkColorType, kPremul_SkAlphaType);\n SkImageInfo info2 = SkImageInfo::Make(20, 10, kAlpha_8_SkColorType, kUnpremul_SkAlphaType);\n SkDebugf(\"info1 %c= info2\\n\", info1 != info2 ? '!' : '=');\n info2 = info2.makeWH(10, 20);\n SkDebugf(\"info1 %c= info2\\n\", info1 != info2 ? '!' : '=');\n info2 = info2.makeColorType(kGray_8_SkColorType);\n SkDebugf(\"info1 %c= info2\\n\", info1 != info2 ? '!' : '=');\n info2 = info2.makeAlphaType(kPremul_SkAlphaType);\n SkDebugf(\"info1 %c= info2\\n\", info1 != info2 ? '!' : '=');\n}", + "hash": "8c039fde0a476ac1aa62bf9de5d61c77", + "file": "SkImageInfo_Reference", + "name": "SkImageInfo::operator!=(const SkImageInfo& other)_const", + "stdout": "info1 != info2\\ninfo1 != info2\\ninfo1 != info2\\ninfo1 == info2\\n" }, "SkImageInfo_refColorSpace": { "code": "void draw(SkCanvas* canvas) {\n SkImageInfo info1 = SkImageInfo::MakeN32(16, 32, kPremul_SkAlphaType, \n SkColorSpace::MakeSRGBLinear());\n SkImageInfo info2 = SkImageInfo::MakeN32(16, 32, kPremul_SkAlphaType,\n info1.refColorSpace());\n SkColorSpace* colorSpace = info2.colorSpace();\n SkDebugf(\"gammaCloseToSRGB: %s gammaIsLinear: %s isSRGB: %s\\n\",\n colorSpace->gammaCloseToSRGB() ? \"true\" : \"false\",\n colorSpace->gammaIsLinear() ? \"true\" : \"false\",\n colorSpace->isSRGB() ? \"true\" : \"false\");\n}", @@ -1084,6 +1105,13 @@ "file": "SkImageInfo_Reference", "name": "SkImageInfo::refColorSpace", "stdout": "gammaCloseToSRGB: false gammaIsLinear: true isSRGB: false\\n" + }, + "SkImageInfo_reset": { + "code": "void draw(SkCanvas* canvas) {\n SkImageInfo info = SkImageInfo::MakeN32Premul(16, 8);\n SkImageInfo copy = info;\n SkDebugf(\"info %c= copy\\n\", info == copy ? '=' : '!');\n copy.reset();\n SkDebugf(\"info %c= reset copy\\n\", info == copy ? '=' : '!');\n SkDebugf(\"SkImageInfo() %c= reset copy\\n\", SkImageInfo() == copy ? '=' : '!');\n}", + "hash": "ab7e73786805c936de386b6c1ebe1f13", + "file": "SkImageInfo_Reference", + "name": "SkImageInfo::reset()", + "stdout": "info == copy\\ninfo != reset copy\\nSkImageInfo() == reset copy\\n" }, "SkImageInfo_shiftPerPixel": { "code": "void draw(SkCanvas* canvas) {\n const char* colors[] = {\"Unknown\", \"Alpha_8\", \"RGB_565\", \"ARGB_4444\", \"RGBA_8888\", \"RGB_888x\",\n \"BGRA_8888\", \"RGBA_1010102\", \"RGB_101010x\", \"Gray_8\", \"RGBA_F16\"};\n for (SkColorType colorType : {\n kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType,\n kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType,\n kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType,\n kGray_8_SkColorType, kRGBA_F16_SkColorType\n } ) {\n SkImageInfo info = SkImageInfo::Make(1, 1, colorType, kOpaque_SkAlphaType);\n SkDebugf(\"color: k\" \"%s\" \"_SkColorType\" \"%*s\" \"shiftPerPixel: %d\\n\",\n colors[colorType], 14 - strlen(colors[colorType]), \" \",\n info.shiftPerPixel());\n }\n}", @@ -1091,6 +1119,13 @@ "file": "SkImageInfo_Reference", "name": "SkImageInfo::shiftPerPixel", "stdout": "color: kUnknown_SkColorType shiftPerPixel: 0\\ncolor: kAlpha_8_SkColorType shiftPerPixel: 0\\ncolor: kRGB_565_SkColorType shiftPerPixel: 1\\ncolor: kARGB_4444_SkColorType shiftPerPixel: 1\\ncolor: kRGBA_8888_SkColorType shiftPerPixel: 2\\ncolor: kRGB_888x_SkColorType shiftPerPixel: 2\\ncolor: kBGRA_8888_SkColorType shiftPerPixel: 2\\ncolor: kRGBA_1010102_SkColorType shiftPerPixel: 2\\ncolor: kRGB_101010x_SkColorType shiftPerPixel: 2\\ncolor: kGray_8_SkColorType shiftPerPixel: 0\\ncolor: kRGBA_F16_SkColorType shiftPerPixel: 3\\n" + }, + "SkImageInfo_validRowBytes": { + "code": "void draw(SkCanvas* canvas) {\n SkImageInfo info = SkImageInfo::MakeN32Premul(16, 8);\n for (size_t rowBytes = 60; rowBytes < 72; rowBytes += sizeof(SkPMColor)) {\n SkDebugf(\"validRowBytes(%llu): %s\\n\", rowBytes, info.validRowBytes(rowBytes) ?\n \"true\" : \"false\");\n }\n}", + "hash": "c6b0f6a3f493cb08d9abcdefe12de245", + "file": "SkImageInfo_Reference", + "name": "SkImageInfo::validRowBytes", + "stdout": "validRowBytes(60): false\\nvalidRowBytes(64): true\\nvalidRowBytes(68): true\\n" }, "SkImage_MakeFromRaster": { "code": "static void releaseProc(const void* pixels, SkImage::ReleaseContext context) {\n int* countPtr = static_cast(context);\n *countPtr += 1;\n}\n\nvoid draw(SkCanvas* canvas) {\n SkColor color = 0;\n SkPixmap pixmap(SkImageInfo::MakeN32(1, 1, kPremul_SkAlphaType), &color, 4);\n int releaseCount = 0;\n sk_sp image(SkImage::MakeFromRaster(pixmap, releaseProc, &releaseCount));\n SkDebugf(\"before reset: %d\\n\", releaseCount);\n image.reset();\n SkDebugf(\"after reset: %d\\n\", releaseCount);\n}\n", @@ -2308,7 +2343,7 @@ "hash": "9c6edd836c573a0fd232d2b8aa11a678", "file": "SkPath_Reference", "name": "SkPath::readFromMemory", - "stdout": "length = 60; returned by readFromMemory = 0\\nlength = 68; returned by readFromMemory = 64\\n" + "stdout": "length = 32; returned by readFromMemory = 0\\nlength = 40; returned by readFromMemory = 36\\n" }, "SkPath_reset": { "code": "void draw(SkCanvas* canvas) {\n SkPath path1, path2;\n path1.setFillType(SkPath::kInverseWinding_FillType);\n path1.addRect({10, 20, 30, 40});\n SkDebugf(\"path1 %c= path2\\n\", path1 == path2 ? '=' : '!');\n path1.reset();\n SkDebugf(\"path1 %c= path2\\n\", path1 == path2 ? '=' : '!');\n}", @@ -4882,14 +4917,6 @@ "hash": "a01e533dc7ab34ed728dc4e7a5f1f0ee", "file": "SkIPoint_Reference", "name": "SkIPoint::operator-=(const SkIVector& v)" -}, - "SkImageInfo_ByteSizeOverflowed": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImageInfo_Reference", - "name": "SkImageInfo::ByteSizeOverflowed" }, "SkImageInfo_Make": { "code": "void draw(SkCanvas* canvas) {\n uint8_t storage[][5] = {{ 0xCA, 0xDA, 0xCA, 0xC9, 0xA3 },\n { 0xAC, 0xA8, 0x89, 0xA7, 0x87 },\n { 0x9B, 0xB5, 0xE5, 0x95, 0x46 },\n { 0x90, 0x81, 0xC5, 0x71, 0x33 },\n { 0x75, 0x55, 0x44, 0x40, 0x30 }};\n SkImageInfo imageInfo = SkImageInfo::Make(5, 5, kGray_8_SkColorType, kOpaque_SkAlphaType);\n SkPixmap pixmap(imageInfo, storage[0], sizeof(storage) / 5);\n SkBitmap bitmap;\n bitmap.installPixels(pixmap);\n canvas->scale(8, 8);\n canvas->drawBitmap(bitmap, 0, 0);\n}", @@ -4918,16 +4945,16 @@ "SkImageInfo_MakeN32Premul": { "code": "void draw(SkCanvas* canvas) {\n SkBitmap bitmap;\n bitmap.allocPixels(SkImageInfo::MakeN32Premul(18, 18));\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorWHITE);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(15);\n offscreen.drawString(\"\\xF0\\x9F\\x98\\xB8\", 1, 15, paint);\n canvas->scale(6, 6);\n canvas->drawBitmap(bitmap, 0, 0);\n}", "width": 256, - "height": 256, - "hash": "077084c05471d6bbd54338d92ea799e3", + "height": 128, + "hash": "525650a67e19fdd8ca9f72b7eda65174", "file": "SkImageInfo_Reference", "name": "SkImageInfo::MakeN32Premul" }, "SkImageInfo_MakeN32Premul_2": { "code": "void draw(SkCanvas* canvas) {\n SkBitmap bitmap;\n bitmap.allocPixels(SkImageInfo::MakeN32Premul({18, 18}));\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorWHITE);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(15);\n offscreen.drawString(\"\\xF0\\x9F\\x98\\xB9\", 1, 15, paint);\n canvas->scale(6, 6);\n canvas->drawBitmap(bitmap, 0, 0);\n}", "width": 256, - "height": 256, - "hash": "897f42eb3b27d749ec792435fb389a07", + "height": 128, + "hash": "b9026d7f39029756bd7cab9542c64f4e", "file": "SkImageInfo_Reference", "name": "SkImageInfo::MakeN32Premul_2" }, @@ -4964,26 +4991,26 @@ "name": "SkImageInfo::bounds()" }, "SkImageInfo_computeByteSize": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", + "code": "void draw(SkCanvas* canvas) {\n SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2);\n const size_t size = info.computeByteSize(100000);\n SkAutoTMalloc storage(size);\n SkPMColor* pixels = storage.get();\n SkBitmap bitmap;\n bitmap.setInfo(info);\n bitmap.setPixels(pixels);\n bitmap.eraseColor(SK_ColorRED);\n canvas->scale(50, 50);\n canvas->rotate(8);\n canvas->drawBitmap(bitmap, 2, 0);\n}", "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "height": 130, + "hash": "9def507d2295f7051effd0c83bb04436", "file": "SkImageInfo_Reference", "name": "SkImageInfo::computeByteSize" }, "SkImageInfo_computeMinByteSize": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", + "code": "void draw(SkCanvas* canvas) {\n SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2);\n const size_t size = info.computeMinByteSize();\n SkAutoTMalloc storage(size);\n SkPMColor* pixels = storage.get();\n SkBitmap bitmap;\n bitmap.setInfo(info);\n bitmap.setPixels(pixels);\n bitmap.eraseColor(SK_ColorRED);\n canvas->scale(50, 50);\n canvas->rotate(8);\n canvas->drawBitmap(bitmap, 2, 0);\n}", "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "height": 130, + "hash": "fc18640fdde437cb35338aed7c68d399", "file": "SkImageInfo_Reference", "name": "SkImageInfo::computeMinByteSize" }, "SkImageInfo_computeOffset": { "code": "void draw(SkCanvas* canvas) {\n uint8_t pixels[][12] = { { 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00},\n { 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00},\n { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00},\n { 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF},\n { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},\n { 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00},\n { 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00},\n { 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00} };\n SkImageInfo imageInfo = SkImageInfo::MakeA8(8, 8);\n SkBitmap bitmap;\n bitmap.installPixels(imageInfo, (void*) pixels, sizeof(pixels[0]));\n SkPaint paint;\n paint.setColor(SK_ColorRED);\n canvas->drawBitmapRect(bitmap, SkRect::MakeWH(8, 8), SkRect::MakeWH(32, 32), &paint);\n size_t offset = imageInfo.computeOffset(2, 3, sizeof(pixels[0]));\n pixels[0][offset] = 0x7F;\n offset = imageInfo.computeOffset(5, 3, sizeof(pixels[0]));\n pixels[0][offset] = 0x7F;\n bitmap.installPixels(imageInfo, (void*) pixels, sizeof(pixels[0]));\n canvas->drawBitmapRect(bitmap, SkRect::MakeWH(8, 8), SkRect::MakeWH(128, 128), &paint);\n}", "width": 256, - "height": 256, - "hash": "0a1ddddfe4f01c025e893ae826cb4ece", + "height": 128, + "hash": "818e4e1191e39d2a642902cbf253b399", "file": "SkImageInfo_Reference", "name": "SkImageInfo::computeOffset" }, @@ -4994,22 +5021,6 @@ "hash": "f206f698e7a8db3d84334c26b1a702dc", "file": "SkImageInfo_Reference", "name": "SkImageInfo::SkImageInfo()" -}, - "SkImageInfo_equal1_operator": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImageInfo_Reference", - "name": "SkImageInfo::operator==(const SkImageInfo& other)_const" -}, - "SkImageInfo_flatten": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImageInfo_Reference", - "name": "SkImageInfo::flatten()" }, "SkImageInfo_gammaCloseToSRGB": { "code": "void draw(SkCanvas* canvas) {\n const int width = 256;\n const int height = 64;\n auto drawLabel = [=](const char* what, bool closeToSRGB) -> void {\n SkString string;\n string.printf(\"%s gamma is %s\" \"close to sRGB\", what, closeToSRGB ? \"\" : \"not \");\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(string, width / 2, 56, paint);\n };\n SkColor gradColors[] = { 0xFFFF7F00, 0xFF00FF7F, 0xFF0000FF, 0xFF7F7FFF };\n SkPoint gradPoints[] = { { 0, 0 }, { width, 0 }, { width * 2, 0 }, { width * 3, 0 } };\n SkPaint gradPaint;\n gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr,\n SK_ARRAY_COUNT(gradColors), SkShader::kClamp_TileMode));\n canvas->drawRect(SkRect::MakeWH(width, height), gradPaint);\n drawLabel(\"canvas\", canvas->imageInfo().gammaCloseToSRGB());\n SkBitmap bitmap;\n SkImageInfo offscreenInfo = SkImageInfo::MakeS32(width, height, kPremul_SkAlphaType);\n bitmap.allocPixels(offscreenInfo);\n SkCanvas sRGBOffscreen(bitmap);\n sRGBOffscreen.drawRect(SkRect::MakeWH(width, height), gradPaint);\n canvas->translate(0, 80);\n canvas->drawBitmap(bitmap, 0, 0);\n drawLabel(\"offscreen\", offscreenInfo.gammaCloseToSRGB());\n}", @@ -5058,46 +5069,6 @@ "hash": "26827898b6b199d6c4b5e4d2c6e6bac8", "file": "SkImageInfo_Reference", "name": "SkImageInfo::makeWH" -}, - "SkImageInfo_notequal1_operator": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImageInfo_Reference", - "name": "SkImageInfo::operator!=(const SkImageInfo& other)_const" -}, - "SkImageInfo_reset": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImageInfo_Reference", - "name": "SkImageInfo::reset()" -}, - "SkImageInfo_unflatten": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImageInfo_Reference", - "name": "SkImageInfo::unflatten()" -}, - "SkImageInfo_validRowBytes": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImageInfo_Reference", - "name": "SkImageInfo::validRowBytes" -}, - "SkImageInfo_validate": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImageInfo_Reference", - "name": "SkImageInfo::validate()" }, "SkImageInfo_width": { "code": "void draw(SkCanvas* canvas) {\n canvas->translate(10, 10);\n canvas->drawBitmap(source, 0, 0);\n SkImageInfo imageInfo = source.info();\n canvas->translate(0, imageInfo.height());\n SkPaint paint;\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawLine(0, 10, imageInfo.width(), 10, paint);\n canvas->drawString(\"width\", imageInfo.width() / 2, 25, paint);\n}", @@ -7042,6 +7013,22 @@ "hash": "260a5ba014b00eeb5a74b3c6b8d31be4", "file": "SkSurface_Reference", "name": "SkSurface::BackendHandleAccess" +}, + "SkSurface_MakeFromBackendTexture": { + "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n paint.setTextSize(32);\n GrContext* context = canvas->getGrContext();\n if (!context) {\n canvas->drawString(\"GPU only!\", 20, 40, paint);\n return;\n }\n sk_sp gpuSurface = SkSurface::MakeFromBackendTexture(context,\n backEndTexture, kTopLeft_GrSurfaceOrigin, 0,\n kRGBA_8888_SkColorType, nullptr, nullptr);\n auto surfaceCanvas = gpuSurface->getCanvas();\n surfaceCanvas->drawString(\"GPU rocks!\", 20, 40, paint);\n sk_sp image(gpuSurface->makeImageSnapshot());\n canvas->drawImage(image, 0, 0);\n}", + "width": 256, + "height": 256, + "hash": "d3aec071998f871809f515e58abb1b0e", + "file": "SkSurface_Reference", + "name": "SkSurface::MakeFromBackendTexture" +}, + "SkSurface_MakeFromBackendTextureAsRenderTarget": { + "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n paint.setTextSize(32);\n GrContext* context = canvas->getGrContext();\n if (!context) {\n canvas->drawString(\"GPU only!\", 20, 40, paint);\n return;\n }\n sk_sp gpuSurface = SkSurface::MakeFromBackendTextureAsRenderTarget(\n context, backEndTexture, kTopLeft_GrSurfaceOrigin, 0,\n kRGBA_8888_SkColorType, nullptr, nullptr);\n auto surfaceCanvas = gpuSurface->getCanvas();\n surfaceCanvas->drawString(\"GPU rocks!\", 20, 40, paint);\n sk_sp image(gpuSurface->makeImageSnapshot());\n canvas->drawImage(image, 0, 0);\n}", + "width": 256, + "height": 256, + "hash": "5e87093b9cbe95124ae14cbe77091eb7", + "file": "SkSurface_Reference", + "name": "SkSurface::MakeFromBackendTextureAsRenderTarget" }, "SkSurface_MakeRenderTarget": { "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n paint.setTextSize(32);\n GrContext* context = canvas->getGrContext();\n if (!context) {\n canvas->drawString(\"GPU only!\", 20, 40, paint);\n return;\n }\n SkImageInfo info = SkImageInfo::MakeN32(256, 64, kOpaque_SkAlphaType);\n for (auto surfaceOrigin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin } ) {\n auto gpuSurface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0,\n surfaceOrigin, nullptr));\n auto surfaceCanvas = gpuSurface->getCanvas();\n surfaceCanvas->clear(SK_ColorWHITE);\n surfaceCanvas->drawString(\"GPU rocks!\", 20, 40, paint);\n sk_sp image(gpuSurface->makeImageSnapshot());\n canvas->drawImage(image, 0, 0);\n canvas->translate(0, 128);\n }\n}", @@ -7178,14 +7165,6 @@ "hash": "882e8e0103048009a25cfc20400492f7", "file": "SkSurface_Reference", "name": "SkSurface::writePixels_2" -}, - "SkYUVColorSpace": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImageInfo_Reference", - "name": "SkYUVColorSpace" } } var canvas diff --git a/site/user/api/undocumented.md b/site/user/api/undocumented.md index 86aae54dbe..c667925ea7 100644 --- a/site/user/api/undocumented.md +++ b/site/user/api/undocumented.md @@ -32,7 +32,7 @@ undocumented -
context -GPU Context
backendTexture -texture residing on GPU
origin -one of: kBottomLeft GrSurfaceOrigin, kTopLeft GrSurfaceOrigin
sampleCnt -samples per pixel, or 0 to disable full scene anti-aliasing
colorType +
colorType one of: kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType, kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType, kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType, kGray_8_SkColorType, kRGBA_F16_SkColorType
colorSpace -range of colors
surfaceProps +
colorSpace +range of colors; may be nullptr
surfaceProps LCD striping orientation and setting for device independent fonts; may be nullptr
SkBlendMode::kPlus 12
+ # Circle @@ -50,7 +50,7 @@ undocumented SkClipOp::kIntersect 1 - + # Color @@ -181,6 +181,15 @@ bool gammaCloseToSRGB() const --- + +## Equals + +
+static bool Equals(const SkColorSpace* src, const SkColorSpace* dst)
+
+ +--- + ## Enum SkTransferFunctionBehavior ### Constants @@ -193,7 +202,7 @@ bool gammaCloseToSRGB() const SkTransferFunctionBehavior::kIgnore 1 - + # Core Graphics @@ -329,7 +338,7 @@ void draw(SkCanvas*, const SkMatrix* = NULL) SkEncodedImageFormat::kHEIF 12 - + # Filter Quality @@ -351,7 +360,7 @@ void draw(SkCanvas*, const SkMatrix* = NULL) kHigh_SkFilterQuality 3 - + ## Nearest Neighbor @@ -616,7 +625,6 @@ template <typename D, typename S> inline bool SkTFitsIn(S s) SkPaintDefaults_MiterLimit 4 - # Patch @@ -837,7 +845,7 @@ void dumpHex() const SkShader::kMirror_TileMode 2 - + ## MakeBitmapShader @@ -887,7 +895,7 @@ static sk_sp<SkShader> MakeBitmapShader(const SkBitmap& src, TileMode tmx, # -Topic +Topic # Text @@ -919,7 +927,7 @@ Topic kTopLeft_GrSurfaceOrigin 1 - + ## Budgeted @@ -935,7 +943,7 @@ Topic SkBudgeted::kYes 1 - + ## Enum GrSemaphoresSubmitted @@ -949,7 +957,7 @@ Topic GrSemaphoresSubmitted::kYes 1 - + # Unpremultiply -- cgit v1.2.3