diff options
-rw-r--r-- | docs/SkCanvas_Reference.bmh | 44 | ||||
-rw-r--r-- | docs/SkImage_Reference.bmh | 348 | ||||
-rw-r--r-- | docs/SkPaint_Reference.bmh | 6 | ||||
-rw-r--r-- | docs/SkSurface_Reference.bmh | 266 | ||||
-rw-r--r-- | docs/undocumented.bmh | 4 | ||||
-rw-r--r-- | site/user/api/SkCanvas_Reference.md | 8 | ||||
-rw-r--r-- | site/user/api/SkImage_Reference.md | 340 | ||||
-rw-r--r-- | site/user/api/SkPaint_Reference.md | 8 | ||||
-rw-r--r-- | site/user/api/SkSurface_Reference.md | 8 | ||||
-rw-r--r-- | site/user/api/catalog.htm | 16 | ||||
-rw-r--r-- | tools/bookmaker/bookmaker.h | 3 | ||||
-rw-r--r-- | tools/bookmaker/includeWriter.cpp | 61 |
12 files changed, 685 insertions, 427 deletions
diff --git a/docs/SkCanvas_Reference.bmh b/docs/SkCanvas_Reference.bmh index 55dc86ba35..efbf41f57e 100644 --- a/docs/SkCanvas_Reference.bmh +++ b/docs/SkCanvas_Reference.bmh @@ -5316,6 +5316,8 @@ Paint_Text_Align, Paint_Hinting, Anti-alias, Paint_Fake_Bold, Font_Embedded_Bitmaps, Full_Hinting_Spacing, LCD_Text, Linear_Text, Subpixel_Text, and Paint_Vertical_Text. +Paint_Text_Encoding must be set to SkPaint::kGlyphID_TextEncoding. + Elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader, Color_Filter, Image_Filter, and Draw_Looper; apply to blob. @@ -5327,25 +5329,26 @@ Image_Filter, and Draw_Looper; apply to blob. #Example #Height 120 void draw(SkCanvas* canvas) { - SkTextBlobBuilder textBlobBuilder; - const char bunny[] = "/(^x^)\\"; - const int len = sizeof(bunny) - 1; - uint16_t glyphs[len]; - SkPaint paint; - paint.textToGlyphs(bunny, len, glyphs); - int runs[] = { 3, 1, 3 }; - SkPoint textPos = { 20, 100 }; - int glyphIndex = 0; - for (auto runLen : runs) { - paint.setTextSize(1 == runLen ? 20 : 50); - const SkTextBlobBuilder::RunBuffer& run = - textBlobBuilder.allocRun(paint, runLen, textPos.fX, textPos.fY); - memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen); - textPos.fX += paint.measureText(&bunny[glyphIndex], runLen, nullptr); - glyphIndex += runLen; - } - sk_sp<const SkTextBlob> blob = textBlobBuilder.make(); - paint.reset(); + SkTextBlobBuilder textBlobBuilder;
+ const char bunny[] = "/(^x^)\\";
+ const int len = sizeof(bunny) - 1;
+ uint16_t glyphs[len];
+ SkPaint paint;
+ paint.textToGlyphs(bunny, len, glyphs);
+ paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); + int runs[] = { 3, 1, 3 };
+ SkPoint textPos = { 20, 100 };
+ int glyphIndex = 0;
+ for (auto runLen : runs) {
+ paint.setTextSize(1 == runLen ? 20 : 50);
+ const SkTextBlobBuilder::RunBuffer& run =
+ textBlobBuilder.allocRun(paint, runLen, textPos.fX, textPos.fY);
+ memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);
+ textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);
+ glyphIndex += runLen;
+ }
+ sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
+ paint.reset();
canvas->drawTextBlob(blob.get(), 0, 0, paint); } ## @@ -5366,6 +5369,8 @@ Paint_Text_Align, Paint_Hinting, Anti-alias, Paint_Fake_Bold, Font_Embedded_Bitmaps, Full_Hinting_Spacing, LCD_Text, Linear_Text, Subpixel_Text, and Paint_Vertical_Text. +Paint_Text_Encoding must be set to SkPaint::kGlyphID_TextEncoding. + Elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader, Color_Filter, Image_Filter, and Draw_Looper; apply to blob. @@ -5385,6 +5390,7 @@ Paint attributes related to text, like text size, have no effect on paint passed SkPaint paint; paint.setTextSize(50); paint.setColor(SK_ColorRED); + paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
const SkTextBlobBuilder::RunBuffer& run = textBlobBuilder.allocRun(paint, 1, 20, 100); run.glyphs[0] = 20; diff --git a/docs/SkImage_Reference.bmh b/docs/SkImage_Reference.bmh index 05d38ff522..22ba343b64 100644 --- a/docs/SkImage_Reference.bmh +++ b/docs/SkImage_Reference.bmh @@ -39,24 +39,23 @@ are zero, then nullptr will be returned. #Legend # description # function ## #Legend ## -# MakeFromAHardwareBuffer # ## -# MakeBackendTextureFromSkImage # ## -# MakeCrossContextFromEncoded # ## -# MakeFromAHardwareBuffer # ## -# MakeFromAdoptedTexture # ## -# MakeFromBitmap # ## -# MakeFromDeferredTextureImageData # ## -# MakeFromEncoded # ## -# MakeFromGenerator # ## -# MakeFromNV12TexturesCopy # ## -# MakeFromPicture # ## -# MakeFromRaster # ## -# MakeFromTexture # ## -# MakeFromYUVTexturesCopy # ## -# MakeRasterCopy # ## -# MakeRasterData # ## -# alphaType # ## -# asLegacyBitmap # ## +# MakeBackendTextureFromSkImage # Creates GPU texture from Image. ## +# MakeCrossContextFromEncoded # Creates Image from encoded data, and uploads to GPU. ## +# MakeFromAHardwareBuffer # Creates Image from Android hardware buffer. ## +# MakeFromAdoptedTexture # Creates Image from GPU texture, managed internally. ## +# MakeFromBitmap # Creates Image from Bitmap, sharing or copying pixels. ## +# MakeFromDeferredTextureImageData # Creates Image from GPU texture data retrieved earlier. ## +# MakeFromEncoded # Creates Image from encoded data. ## +# MakeFromGenerator # Creates Image from a stream of data. ## +# MakeFromNV12TexturesCopy # Creates Image from YUV_ColorSpace data in two planes. ## +# MakeFromPicture # Creates Image from Picture. ## +# MakeFromRaster # Creates Image from Pixmap, with release. ## +# MakeFromTexture # Creates Image from GPU texture, managed externally. ## +# MakeFromYUVTexturesCopy # Creates Image from YUV_ColorSpace data in three planes. ## +# MakeRasterCopy # Creates Image from Pixmap and copied pixels. ## +# MakeRasterData # Creates Image from Image_Info and shared pixels. ## +# alphaType # Returns Alpha_Type ## +# asLegacyBitmap # Returns as raster Bitmap ## # bounds # ## # colorSpace # ## # dimensions # ## @@ -133,23 +132,28 @@ Drawing parameters for which a deferred texture image data should be optimized. ## -#Typedef void* ReleaseContext - -## - # ------------------------------------------------------------------------------ #Method static sk_sp<SkImage> MakeRasterCopy(const SkPixmap& pixmap) -#Param pixmap incomplete ## +Creates Image from Pixmap and copy of pixels. -#Return incomplete ## +Image is returned if Pixmap is valid. Valid Pixmap parameters include: +dimensions are greater than zero; +each dimension fits in 29 bits; +Color_Type and Alpha_Type are valid, and Color_Type is not kUnknown_SkColorType; +row bytes are large enough to hold one row of pixels; +pixel address is not nullptr. + +#Param pixmap Image_Info, pixel address, and row bytes ## + +#Return copy of Pixmap pixels, or nullptr ## #Example // incomplete ## -#SeeAlso incomplete +#SeeAlso MakeRasterData MakeFromGenerator #Method ## @@ -157,38 +161,66 @@ Drawing parameters for which a deferred texture image data should be optimized. #Method static sk_sp<SkImage> MakeRasterData(const Info& info, sk_sp<SkData> pixels, size_t rowBytes) -#Param info incomplete ## -#Param pixels incomplete ## -#Param rowBytes incomplete ## +Creates Image from Image_Info, sharing pixels. -#Return incomplete ## +Image is returned if Image_Info is valid. Valid Image_Info parameters include: +dimensions are greater than zero; +each dimension fits in 29 bits; +Color_Type and Alpha_Type are valid, and Color_Type is not kUnknown_SkColorType; +rowBytes are large enough to hold one row of pixels; +pixels is not nullptr, and contains enough data for Image. + +#Param info contains width, height, Alpha_Type, Color_Type, Color_Space ## +#Param pixels address or pixel storage ## +#Param rowBytes size of pixel row or larger ## + +#Return Image sharing pixels, or nullptr ## #Example // incomplete ## -#SeeAlso incomplete +#SeeAlso MakeRasterCopy MakeFromGenerator #Method ## # ------------------------------------------------------------------------------ +#Typedef void* ReleaseContext + +Caller data passed to RasterReleaseProc; may be nullptr. + +#SeeAlso MakeFromRaster RasterReleaseProc + +## + #Typedef void (*RasterReleaseProc)(const void* pixels, ReleaseContext) +Function called when Image no longer shares pixels. ReleaseContext is +provided by caller when Image is created, and may be nullptr. + +#SeeAlso ReleaseContext MakeFromRaster + ## #Method static sk_sp<SkImage> MakeFromRaster(const SkPixmap& pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext) -Return a new Image referencing the specified pixels. These must remain valid and unchanged -until the specified release-proc is called, indicating that Skia no longer has a reference -to the pixels. -Returns nullptr if the requested pixmap info is unsupported. +Creates Image from pixmap, sharing pixmap pixels. Pixels must remain valid and +unchanged until rasterReleaseProc is called. rasterReleaseProc is passed +releaseContext when Image is deleted or no longer refers to pixmap pixels. -#Param pixmap incomplete ## -#Param rasterReleaseProc incomplete ## -#Param releaseContext incomplete ## +Image is returned if pixmap is valid. Valid Pixmap parameters include: +dimensions are greater than zero; +each dimension fits in 29 bits; +Color_Type and Alpha_Type are valid, and Color_Type is not kUnknown_SkColorType; +row bytes are large enough to hold one row of pixels; +pixel address is not nullptr. + +#Param pixmap Image_Info, pixel address, and row bytes ## +#Param rasterReleaseProc function called when pixels can be released ## +#Param releaseContext state passed to rasterReleaseProc ## #Return incomplete ## @@ -196,7 +228,7 @@ Returns nullptr if the requested pixmap info is unsupported. // incomplete ## -#SeeAlso incomplete +#SeeAlso MakeRasterCopy MakeRasterData MakeFromGenerator RasterReleaseProc ReleaseContext #Method ## @@ -204,18 +236,26 @@ Returns nullptr if the requested pixmap info is unsupported. #Method static sk_sp<SkImage> MakeFromBitmap(const SkBitmap& bitmap) -Construct a new image from the specified bitmap. If the bitmap is marked immutable, and -its pixel memory is shareable, it may be shared instead of copied. +Creates Image from bitmap, sharing or copying bitmap pixels. If the bitmap +is marked immutable, and its pixel memory is shareable, it may be shared +instead of copied. -#Param bitmap incomplete ## +Image is returned if bitmap is valid. Valid Bitmap parameters include: +dimensions are greater than zero; +each dimension fits in 29 bits; +Color_Type and Alpha_Type are valid, and Color_Type is not kUnknown_SkColorType; +row bytes are large enough to hold one row of pixels; +pixel address is not nullptr. -#Return incomplete ## +#Param bitmap Image_Info, row bytes, and pixels ## + +#Return created Image, or nullptr ## #Example // incomplete ## -#SeeAlso incomplete +#SeeAlso MakeFromRaster MakeRasterCopy MakeFromGenerator MakeRasterData #Method ## @@ -224,20 +264,25 @@ its pixel memory is shareable, it may be shared instead of copied. #Method static sk_sp<SkImage> MakeFromGenerator(std::unique_ptr<SkImageGenerator> imageGenerator, const SkIRect* subset = nullptr) -Construct a new SkImage based on the given ImageGenerator. Returns nullptr on error. -This function will always take ownership of the passed generator. -If a subset is specified, it must be contained within the generator's bounds. +Creates Image based from imageGenerator. +Takes ownership of imageGenerator; it may not be used elsewhere. +If subset is not nullptr, it must be contained within imageGenerator data bounds. -#Param imageGenerator incomplete ## -#Param subset incomplete ## +Image is returned if generator data is valid. Valid data parameters vary +by type of data and platform. -#Return incomplete ## +imageGenerator may wrap Picture data, codec data, or custom data. + +#Param imageGenerator stock or custom routines to retrieve Image ## +#Param subset bounds of returned Image; may be nullptr ## + +#Return created Image, or nullptr ## #Example // incomplete ## -#SeeAlso incomplete +#SeeAlso MakeFromEncoded #Method ## @@ -245,20 +290,22 @@ If a subset is specified, it must be contained within the generator's bounds. #Method static sk_sp<SkImage> MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect* subset = nullptr) -Construct a new SkImage based on the specified encoded data. Returns nullptr on failure, -which can mean that the format of the encoded data was not recognized/supported. -If a subset is specified, it must be contained within the encoded data's bounds. +Creates Image from encoded data. +If a subset is not nullptr, it must be contained within encoded data bounds. -#Param encoded incomplete ## -#Param subset incomplete ## +Image is returned if format of the encoded data is recognized and supported. +Recognized formats vary by platfrom. -#Return incomplete ## +#Param encoded data of Image to decode ## +#Param subset bounds of returned Image; may be nullptr ## + +#Return created Image, or nullptr ## #Example // incomplete ## -#SeeAlso incomplete +#SeeAlso MakeFromGenerator #Method ## @@ -274,23 +321,27 @@ If a subset is specified, it must be contained within the encoded data's bounds. SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace) -Create a new image from the specified descriptor. Note - the caller is responsible for -managing the lifetime of the underlying platform texture. -Will return nullptr if the specified back-end texture is unsupported. +Creates Image from GPU texture associated with context. Caller is responsible for +managing the lifetime of GPU texture. -#Param context incomplete ## -#Param backendTexture incomplete ## -#Param origin incomplete ## -#Param alphaType incomplete ## -#Param colorSpace incomplete ## +Image is returned if format of backendTexture is recognized and supported. +Recognized formats vary by GPU back-end. -#Return incomplete ## +#Param context GPU_Context ## +#Param backendTexture texture residing on GPU ## +#Param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin ## +#Param alphaType one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType, + kPremul_SkAlphaType, kUnpremul_SkAlphaType +## +#Param colorSpace range of colors ## + +#Return created Image, or nullptr ## #Example // incomplete ## -#SeeAlso incomplete +#SeeAlso MakeFromAdoptedTexture SkSurface::MakeFromBackendTexture #Method ## @@ -304,26 +355,30 @@ Will return nullptr if the specified back-end texture is unsupported. TextureReleaseProc textureReleaseProc, ReleaseContext releaseContext) -Create a new image from the GrBackendTexture. The underlying platform texture must stay -valid and unaltered until the specified release-proc is invoked, indicating that Skia -no longer is holding a reference to it. -Will return nullptr if the specified back-end texture is unsupported. +Creates Image from GPU texture associated with context. GPU texture must stay +valid and unchanged until textureReleaseProc is called. textureReleaseProc is +passed releaseContext when Image is deleted or no longer refers to texture. -#Param context incomplete ## -#Param backendTexture incomplete ## -#Param origin incomplete ## -#Param alphaType incomplete ## -#Param colorSpace incomplete ## -#Param textureReleaseProc incomplete ## -#Param releaseContext incomplete ## +Image is returned if format of backendTexture is recognized and supported. +Recognized formats vary by GPU back-end. -#Return incomplete ## +#Param context GPU_Context ## +#Param backendTexture texture residing on GPU ## +#Param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin ## +#Param alphaType one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType, + kPremul_SkAlphaType, kUnpremul_SkAlphaType +## +#Param colorSpace range of colors ## +#Param textureReleaseProc function called when texture can be released ## +#Param releaseContext state passed to textureReleaseProc ## + +#Return created Image, or nullptr ## #Example // incomplete ## -#SeeAlso incomplete +#SeeAlso MakeFromAdoptedTexture SkSurface::MakeFromBackendTexture #Method ## @@ -333,28 +388,71 @@ Will return nullptr if the specified back-end texture is unsupported. bool buildMips, SkColorSpace* dstColorSpace) -Decodes and uploads the encoded data to a GPU backed image using the supplied GrContext. -That image can be safely used by other GrContexts, across thread boundaries. The GrContext -used here, and the ones used to draw this image later must be in the same OpenGL share group, -or otherwise be able to share resources. -When the image's ref count reaches zero, the original GrContext will destroy the texture, +Creates Image from encoded data. Image is uploaded to GPU back-end using context. + +Created Image is available to other GPU contexts, and is available across thread +boundaries. All contexts must be in the same GPU_Share_Group, or otherwise +share resources. + +When Image is no longer referenced, context releases texture memory asynchronously. -The texture will be decoded and uploaded to be suitable for use with surfaces that have the -supplied destination color space. The color space of the image itself will be determined -from the encoded data. -#Param context incomplete ## -#Param data incomplete ## -#Param buildMips incomplete ## -#Param dstColorSpace incomplete ## +Texture decoded from data is uploaded to match Surface created with +dstColorSpace. Color_Space of Image is determined by encoded data. -#Return incomplete ## +Image is returned if format of data is recognized and supported, and if context +supports moving resources. Recognized formats vary by platform and GPU back-end. + +#Param context GPU_Context ## +#Param data Image to decode ## +#Param buildMips create Image as Mip_Map if true ## +#Param dstColorSpace range of colors of matching Surface on GPU ## + +#Return created Image, or nullptr ## #Example // incomplete ## -#SeeAlso incomplete +#SeeAlso MakeCrossContextFromPixmap + +#Method ## + +# ------------------------------------------------------------------------------ + +#Method static sk_sp<SkImage> MakeCrossContextFromPixmap(GrContext* context, const SkPixmap& pixmap, + bool buildMips, + SkColorSpace* dstColorSpace) + +Creates Image from pixmap. Image is uploaded to GPU back-end using context. + +Created Image is available to other GPU contexts, and is available across thread +boundaries. All contexts must be in the same GPU_Share_Group, or otherwise +share resources. + +When Image is no longer referenced, context releases texture memory +asynchronously. + +Texture created from pixmap is uploaded to match Surface created with +dstColorSpace. Color_Space of Image is determined by pixmap.colorSpace(). + +Image is returned referring to GPU back-end if format of data is recognized and +supported, and if context supports moving resources. Otherwise, pixmap pixel +data is copied and Image as returned in raster format if possible; nullptr may +be returned. Recognized GPU formats vary by platform and GPU back-end. + +#Param context GPU_Context ## +#Param pixmap Image_Info, pixel address, and row bytes ## +#Param buildMips create Image as Mip_Map if true ## +#Param dstColorSpace range of colors of matching Surface on GPU ## + +#Return created Image, or nullptr ## + +#Example +// incomplete +## + +#SeeAlso MakeCrossContextFromEncoded #Method ## @@ -366,17 +464,21 @@ from the encoded data. SkAlphaType alphaType = kPremul_SkAlphaType, sk_sp<SkColorSpace> colorSpace = nullptr) -Create a new image from the specified descriptor. Note - Skia will delete or recycle the -texture when the image is released. -Will return nullptr if the specified back-end texture is unsupported. +Creates Image from backendTexture associated with context. backendTexture and +returned Image are managed internally, and are released when no longer needed. -#Param context incomplete ## -#Param backendTexture incomplete ## -#Param surfaceOrigin incomplete ## -#Param alphaType incomplete ## -#Param colorSpace incomplete ## +Image is returned if format of backendTexture is recognized and supported. +Recognized formats vary by GPU back-end. -#Return incomplete ## +#Param context GPU_Context ## +#Param backendTexture texture residing on GPU ## +#Param surfaceOrigin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin ## +#Param alphaType one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType, + kPremul_SkAlphaType, kUnpremul_SkAlphaType +## +#Param colorSpace range of colors ## + +#Return created Image, or nullptr ## #Example // incomplete @@ -1174,18 +1276,33 @@ must be null. #Method static sk_sp<SkImage> MakeFromDeferredTextureImageData(GrContext* context, const void* data, SkBudgeted budgeted) -Returns a texture-backed image from data produced in SkImage::getDeferredTextureImageData. +Returns a texture-backed image from data produced in getDeferredTextureImageData. The context must be the context that provided the proxy passed to getDeferredTextureImageData. -#Param context incomplete ## -#Param data incomplete ## -#Param budgeted incomplete ## +#Param context GPU_Context ## +#Param data buffer filled by getDeferredTextureImageData ## +#Param budgeted one of: SkBudgeted::kNo, SkBudgeted::kYes ## #Return incomplete ## #Example -// incomplete +#Image 3 +#Platform gpu + GrContext* context = canvas->getGrContext(); + if (!context) { + return; + } + sk_sp<GrContextThreadSafeProxy> proxy = context->threadSafeProxy(); + SkImage::DeferredTextureImageUsageParams params = {SkMatrix::I(), kNone_SkFilterQuality, 0}; + size_t size = image->getDeferredTextureImageData(*proxy, ¶ms, 1, nullptr, + nullptr, kN32_SkColorType); + void* buffer = sk_malloc_throw(size); + if (image->getDeferredTextureImageData(*proxy, ¶ms, 1, buffer, nullptr, kN32_SkColorType)) { + sk_sp<SkImage> newImage( + SkImage::MakeFromDeferredTextureImageData(context, buffer, SkBudgeted::kNo)); + canvas->drawImage(newImage, 0, 0); + } ## #SeeAlso incomplete @@ -1262,16 +1379,15 @@ Helper functions to convert to SkBitmap #Method bool asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode legacyBitmapMode) const -Attempt to create a bitmap with the same pixels as the image. The result will always be -a raster-backed bitmap (texture-backed bitmaps are DEPRECATED, and not supported here). -If the mode is kRO_LegacyBitmapMode (read-only), the resulting bitmap will be marked as immutable. -On success, returns true. On failure, returns false and the bitmap parameter will be reset -to empty. +Creates raster Bitmap with same pixels as Image. If legacyBitmapMode is kRO_LegacyBitmapMode, +returned bitmap is read-only and immutable. +Returns true if Bitmap is stored in bitmap. Returns false and resets bitmap if Bitmap +write did not succeed. -#Param bitmap incomplete ## -#Param legacyBitmapMode incomplete ## +#Param bitmap storage for legacy Bitmap ## +#Param legacyBitmapMode one of: kRO_LegacyBitmapMode, kRW_LegacyBitmapMode ## -#Return incomplete ## +#Return true if Bitmap was created ## #Example // incomplete diff --git a/docs/SkPaint_Reference.bmh b/docs/SkPaint_Reference.bmh index 8d3bd604c1..4a5da73ca4 100644 --- a/docs/SkPaint_Reference.bmh +++ b/docs/SkPaint_Reference.bmh @@ -591,7 +591,6 @@ can reconstitute the paint at a later time. void writeRegion(const SkRegion& region) override {} void writePath(const SkPath& path) override {} size_t writeStream(SkStream* stream, size_t length) override { return 0; } - void writeBitmap(const SkBitmap& bitmap) override {} void writeImage(const SkImage*) override {} void writeTypeface(SkTypeface* typeface) override {} void writePaint(const SkPaint& paint) override {} @@ -5093,10 +5092,12 @@ void draw(SkCanvas* canvas) { bounds describes a pair of lines parallel to the text advance. The return count is zero or a multiple of two, and is at most twice the number of Glyphs in the string. - Uses Text_Encoding to decode text, Typeface to get the glyph paths, + Uses Typeface to get the glyph paths, and Text_Size, Fake_Bold, and Path_Effect to scale and modify the glyph paths. Uses run array and Text_Align to position intervals. + Text_Encoding must be set to SkPaint::kGlyphID_TextEncoding. + Pass nullptr for intervals to determine the size of the interval array. intervals are cached to improve performance for multiple calls. @@ -5111,6 +5112,7 @@ void draw(SkCanvas* canvas) { #Height 143 void draw(SkCanvas* canvas) { SkPaint paint; + paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); paint.setTextSize(120); SkPoint textPos = { 20, 110 }; int len = 3; diff --git a/docs/SkSurface_Reference.bmh b/docs/SkSurface_Reference.bmh index c6cbbbb7aa..f13134fa46 100644 --- a/docs/SkSurface_Reference.bmh +++ b/docs/SkSurface_Reference.bmh @@ -625,6 +625,7 @@ Surface bottom-left corner is pinned to the origin. #Return Surface if all parameters are valid; otherwise, nullptr ## #Example +#Platform cpu gpu #Description LCD text takes advantage of raster striping to improve resolution. Only one of the four combinations is correct, depending on whether the monitor's LCD is @@ -644,23 +645,18 @@ void draw(SkCanvas* canvas) { }; GrContext* context = canvas->getGrContext(); SkImageInfo info = SkImageInfo::MakeN32(128, 64, kOpaque_SkAlphaType); - SkAutoTMalloc<SkPMColor> storage(info.computeMinByteSize()); - SkBitmap bitmap; - bitmap.installPixels(info, storage.get(), info.minRowBytes()); int y = 0; for (auto geometry : { kRGB_H_SkPixelGeometry, kBGR_H_SkPixelGeometry, kRGB_V_SkPixelGeometry, kBGR_V_SkPixelGeometry } ) { SkSurfaceProps props(0, geometry); - std::unique_ptr<SkCanvas> offscreen = SkCanvas::MakeRasterDirect(info, storage.get(), - info.minRowBytes(), &props); sk_sp<SkSurface> surface = context ? SkSurface::MakeRenderTarget( context, SkBudgeted::kNo, info, 0, &props) : SkSurface::MakeRaster(info, &props); test_draw(surface->getCanvas()); surface->draw(canvas, 0, y, nullptr); - surface->draw(offscreen.get(), 0, 0, nullptr); + sk_sp<SkImage> image(surface->makeImageSnapshot()); SkAutoCanvasRestore acr(canvas, true); canvas->scale(8, 8); - canvas->drawBitmap(bitmap, 12, y / 8); + canvas->drawImage(image, 12, y / 8); y += 64; } } @@ -893,43 +889,43 @@ CAN WE DEPRECATE THIS? }; ## -#Const kFlushRead_BackendHandleAccess +#Const kFlushRead_BackendHandleAccess 0 Caller may read from the back-end object. ## -#Const kFlushWrite_BackendHandleAccess +#Const kFlushWrite_BackendHandleAccess 1 Caller may write to the back-end object. ## -#Const kDiscardWrite_BackendHandleAccess +#Const kDiscardWrite_BackendHandleAccess 2 Caller must overwrite the entire back-end object. ## #Example #Platform gpu - SkPaint paint;
- paint.setTextSize(32);
- GrContext* context = canvas->getGrContext();
- if (!context) {
- canvas->drawString("GPU only!", 20, 40, paint);
- return;
- }
- sk_sp<SkSurface> gpuSurface = SkSurface::MakeRenderTarget(
- context, SkBudgeted::kYes, SkImageInfo::MakeN32Premul(10, 10));
- int y = 20;
- SkString str;
- paint.setTextSize(16);
- for (auto access : { SkSurface::kFlushRead_BackendHandleAccess,
- SkSurface::kFlushWrite_BackendHandleAccess,
- SkSurface::kDiscardWrite_BackendHandleAccess } ) {
- sk_sp<SkImage> image(gpuSurface->makeImageSnapshot());
- str.printf("uniqueID=%d", image->uniqueID());
- canvas->drawString(str, 20, y += 20, paint);
- GrBackendObject backendObject = gpuSurface->getTextureHandle(access);
- str.printf("backendObject %c= 0", backendObject != 0 ? '!' : '=');
- canvas->drawString(str, 20, y += 20, paint);
- }
- sk_sp<SkImage> image(gpuSurface->makeImageSnapshot());
- str.printf("final image uniqueID=%d", image->uniqueID());
- canvas->drawString(str, 20, y += 20, paint);
+ SkPaint paint; + paint.setTextSize(32); + GrContext* context = canvas->getGrContext(); + if (!context) { + canvas->drawString("GPU only!", 20, 40, paint); + return; + } + sk_sp<SkSurface> gpuSurface = SkSurface::MakeRenderTarget( + context, SkBudgeted::kYes, SkImageInfo::MakeN32Premul(10, 10)); + int y = 20; + SkString str; + paint.setTextSize(16); + for (auto access : { SkSurface::kFlushRead_BackendHandleAccess, + SkSurface::kFlushWrite_BackendHandleAccess, + SkSurface::kDiscardWrite_BackendHandleAccess } ) { + sk_sp<SkImage> image(gpuSurface->makeImageSnapshot()); + str.printf("uniqueID=%d", image->uniqueID()); + canvas->drawString(str, 20, y += 20, paint); + GrBackendObject backendObject = gpuSurface->getTextureHandle(access); + str.printf("backendObject %c= 0", backendObject != 0 ? '!' : '='); + canvas->drawString(str, 20, y += 20, paint); + } + sk_sp<SkImage> image(gpuSurface->makeImageSnapshot()); + str.printf("final image uniqueID=%d", image->uniqueID()); + canvas->drawString(str, 20, y += 20, paint); ## #SeeAlso getTextureHandle getRenderTargetHandle @@ -955,23 +951,23 @@ or when Surface is deleted. #Example #Platform gpu #Height 64 - SkPaint paint;
- paint.setTextSize(32);
- GrContext* context = canvas->getGrContext();
- if (!context) {
- canvas->drawString("GPU only!", 20, 40, paint);
- return;
- }
- sk_sp<SkSurface> gpuSurface = SkSurface::MakeRenderTarget(
- context, SkBudgeted::kYes, SkImageInfo::MakeN32Premul(10, 10));
- GrBackendObject backendObject = gpuSurface->getTextureHandle(
- SkSurface::kFlushRead_BackendHandleAccess);
- if (backendObject) {
- SkString str;
- str.printf("backendObject=%08x", backendObject);
- paint.setTextSize(16);
- canvas->drawString(str, 20, 40, paint);
- }
+ SkPaint paint; + paint.setTextSize(32); + GrContext* context = canvas->getGrContext(); + if (!context) { + canvas->drawString("GPU only!", 20, 40, paint); + return; + } + sk_sp<SkSurface> gpuSurface = SkSurface::MakeRenderTarget( + context, SkBudgeted::kYes, SkImageInfo::MakeN32Premul(10, 10)); + GrBackendObject backendObject = gpuSurface->getTextureHandle( + SkSurface::kFlushRead_BackendHandleAccess); + if (backendObject) { + SkString str; + str.printf("backendObject=%08x", backendObject); + paint.setTextSize(16); + canvas->drawString(str, 20, 40, paint); + } ## #SeeAlso getRenderTargetHandle GrBackendObject BackendHandleAccess @@ -1004,23 +1000,23 @@ In OpenGL this returns the frame buffer object ID. #Example #Platform gpu #Height 64 - SkPaint paint;
- paint.setTextSize(32);
- GrContext* context = canvas->getGrContext();
- if (!context) {
- canvas->drawString("GPU only!", 20, 40, paint);
- return;
- }
- sk_sp<SkSurface> gpuSurface = SkSurface::MakeRenderTarget(
- context, SkBudgeted::kYes, SkImageInfo::MakeN32Premul(10, 10));
- GrBackendObject backendObject;
- if (gpuSurface->getRenderTargetHandle(&backendObject,
- SkSurface::kFlushRead_BackendHandleAccess)) {
- SkString str;
- str.printf("backendObject=%d", backendObject);
- paint.setTextSize(16);
- canvas->drawString(str, 20, 40, paint);
- }
+ SkPaint paint; + paint.setTextSize(32); + GrContext* context = canvas->getGrContext(); + if (!context) { + canvas->drawString("GPU only!", 20, 40, paint); + return; + } + sk_sp<SkSurface> gpuSurface = SkSurface::MakeRenderTarget( + context, SkBudgeted::kYes, SkImageInfo::MakeN32Premul(10, 10)); + GrBackendObject backendObject; + if (gpuSurface->getRenderTargetHandle(&backendObject, + SkSurface::kFlushRead_BackendHandleAccess)) { + SkString str; + str.printf("backendObject=%d", backendObject); + paint.setTextSize(16); + canvas->drawString(str, 20, 40, paint); + } ## #SeeAlso getTextureHandle GrBackendObject BackendHandleAccess @@ -1349,21 +1345,21 @@ Does not copy, and returns false if: #Return true if pixels were copied ## #Example - sk_sp<SkSurface> surf(SkSurface::MakeRasterN32Premul(64, 64));
- auto surfCanvas = surf->getCanvas();
- surfCanvas->clear(SK_ColorGREEN);
- SkPaint paint;
- surfCanvas->drawOval({2, 10, 58, 54}, paint);
- SkImageInfo info = SkImageInfo::Make(64, 64, kBGRA_8888_SkColorType, kPremul_SkAlphaType);
- SkBitmap bitmap;
- bitmap.setInfo(info);
- bitmap.allocPixels();
- for (int x : { 32, -32 } ) {
- for (int y : { 32, -32 } ) {
- surf->readPixels(bitmap, x, y);
- }
- }
- canvas->drawBitmap(bitmap, 0, 0);
+ sk_sp<SkSurface> surf(SkSurface::MakeRasterN32Premul(64, 64)); + auto surfCanvas = surf->getCanvas(); + surfCanvas->clear(SK_ColorGREEN); + SkPaint paint; + surfCanvas->drawOval({2, 10, 58, 54}, paint); + SkImageInfo info = SkImageInfo::Make(64, 64, kBGRA_8888_SkColorType, kPremul_SkAlphaType); + SkBitmap bitmap; + bitmap.setInfo(info); + bitmap.allocPixels(); + for (int x : { 32, -32 } ) { + for (int y : { 32, -32 } ) { + surf->readPixels(bitmap, x, y); + } + } + canvas->drawBitmap(bitmap, 0, 0); ## #SeeAlso peekPixels @@ -1380,7 +1376,7 @@ Returns Surface_Properties for surface. #Example const char* names[] = { "Unknown", "RGB_H", "BGR_H", "RGB_V", "BGR_V" }; - sk_sp<SkSurface> surf(SkSurface::MakeRasterN32Premul(64, 64));
+ sk_sp<SkSurface> surf(SkSurface::MakeRasterN32Premul(64, 64)); SkDebugf("surf.props(): k%s_SkPixelGeometry\n", names[surf->props().pixelGeometry()]); #StdOut surf.props(): kRGB_H_SkPixelGeometry @@ -1480,16 +1476,16 @@ and the client will still own the semaphores. ## #Platform !fiddle gpu #Height 64 - SkPaint paint;
- paint.setTextSize(32);
- GrContext* context = canvas->getGrContext();
- if (!context) {
- canvas->drawString("GPU only!", 20, 40, paint);
- return;
- }
+ SkPaint paint; + paint.setTextSize(32); + GrContext* context = canvas->getGrContext(); + if (!context) { + canvas->drawString("GPU only!", 20, 40, paint); + return; + } GrBackendSemaphore semaphore; - sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(
- context, SkBudgeted::kYes, SkImageInfo::MakeN32Premul(64, 64));
+ sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget( + context, SkBudgeted::kYes, SkImageInfo::MakeN32Premul(64, 64)); surface->flushAndSignalSemaphores(1, &semaphore); sk_sp<SkImage> image = surface->makeImageSnapshot(); GrBackendObject backendImage = image->getTextureHandle(false); // unused @@ -1506,7 +1502,7 @@ and the client will still own the semaphores. childCanvas->clear(SK_ColorRED); childSurface->wait(1, &semaphore); childCanvas->drawImage(childImage, 32, 0); - childSurface->draw(canvas, 0, 0, nullptr);
+ childSurface->draw(canvas, 0, 0, nullptr); ## #SeeAlso flushAndSignalSemaphores GrBackendSemaphore @@ -1531,29 +1527,29 @@ Return true if Surface supports characterization. Raster_Surface returns false. #Example #Platform gpu #Height 64 - SkPaint paint;
- paint.setTextSize(32);
- GrContext* context = canvas->getGrContext();
- if (!context) {
- canvas->drawString("GPU only!", 20, 40, paint);
- return;
- }
- sk_sp<SkSurface> gpuSurface = SkSurface::MakeRenderTarget(
- context, SkBudgeted::kYes, SkImageInfo::MakeN32Premul(64, 64));
- SkSurfaceCharacterization characterization;
- if (!gpuSurface->characterize(&characterization)) {
- canvas->drawString("characterization unsupported", 20, 40, paint);
- return;
- }
- // start of threadable work
- SkDeferredDisplayListRecorder recorder(characterization);
- SkCanvas* subCanvas = recorder.getCanvas();
- subCanvas->clear(SK_ColorGREEN);
- std::unique_ptr<SkDeferredDisplayList> displayList = recorder.detach();
- // end of threadable work
- gpuSurface->draw(displayList.get());
- sk_sp<SkImage> img = gpuSurface->makeImageSnapshot();
- canvas->drawImage(std::move(img), 0, 0);
+ SkPaint paint; + paint.setTextSize(32); + GrContext* context = canvas->getGrContext(); + if (!context) { + canvas->drawString("GPU only!", 20, 40, paint); + return; + } + sk_sp<SkSurface> gpuSurface = SkSurface::MakeRenderTarget( + context, SkBudgeted::kYes, SkImageInfo::MakeN32Premul(64, 64)); + SkSurfaceCharacterization characterization; + if (!gpuSurface->characterize(&characterization)) { + canvas->drawString("characterization unsupported", 20, 40, paint); + return; + } + // start of threadable work + SkDeferredDisplayListRecorder recorder(characterization); + SkCanvas* subCanvas = recorder.getCanvas(); + subCanvas->clear(SK_ColorGREEN); + std::unique_ptr<SkDeferredDisplayList> displayList = recorder.detach(); + // end of threadable work + gpuSurface->draw(displayList.get()); + sk_sp<SkImage> img = gpuSurface->makeImageSnapshot(); + canvas->drawImage(std::move(img), 0, 0); ## #SeeAlso draw() SkSurfaceCharacterization SkDeferredDisplayList @@ -1573,23 +1569,23 @@ is not compatible with Surface. #Example #Height 64 #Platform gpu cpu - SkPaint paint;
- paint.setTextSize(16);
- sk_sp<SkSurface> gpuSurface = SkSurface::MakeRasterN32Premul(64, 64);
- SkSurfaceCharacterization characterization;
- if (!gpuSurface->characterize(&characterization)) {
- canvas->drawString("characterization unsupported", 20, 40, paint);
- return;
- }
- // start of threadable work
- SkDeferredDisplayListRecorder recorder(characterization);
- SkCanvas* subCanvas = recorder.getCanvas();
- subCanvas->clear(SK_ColorGREEN);
- std::unique_ptr<SkDeferredDisplayList> displayList = recorder.detach();
- // end of threadable work
- gpuSurface->draw(displayList.get());
- sk_sp<SkImage> img = gpuSurface->makeImageSnapshot();
- canvas->drawImage(std::move(img), 0, 0);
+ SkPaint paint; + paint.setTextSize(16); + sk_sp<SkSurface> gpuSurface = SkSurface::MakeRasterN32Premul(64, 64); + SkSurfaceCharacterization characterization; + if (!gpuSurface->characterize(&characterization)) { + canvas->drawString("characterization unsupported", 20, 40, paint); + return; + } + // start of threadable work + SkDeferredDisplayListRecorder recorder(characterization); + SkCanvas* subCanvas = recorder.getCanvas(); + subCanvas->clear(SK_ColorGREEN); + std::unique_ptr<SkDeferredDisplayList> displayList = recorder.detach(); + // end of threadable work + gpuSurface->draw(displayList.get()); + sk_sp<SkImage> img = gpuSurface->makeImageSnapshot(); + canvas->drawImage(std::move(img), 0, 0); ## #SeeAlso characterize() SkSurfaceCharacterization SkDeferredDisplayList diff --git a/docs/undocumented.bmh b/docs/undocumented.bmh index 4163b43e89..014251258f 100644 --- a/docs/undocumented.bmh +++ b/docs/undocumented.bmh @@ -3,11 +3,11 @@ DirectWrite TrueType Windows Linux Android iOS __ANDROID_API__ FreeType FreeType-based Harfbuzz Descenders Kerning Unhinted - LCD RGB sRGB + LCD RGB sRGB YUV_ColorSpace Unicode Unicode5 UTF-8 UTF-16 UTF-32 ASCII Unichar API CPU - GPU GPU-backed OpenGL Vulkan I/O MSAA UV_Mapping Multi_Sample_Anti_Aliasing + GPU GPU-backed OpenGL Vulkan I/O MSAA UV_Mapping Multi_Sample_Anti_Aliasing GPU_Share_Group PDF XPS RFC NaN NaNs diff --git a/site/user/api/SkCanvas_Reference.md b/site/user/api/SkCanvas_Reference.md index d712dc631c..0ef379e3e0 100644 --- a/site/user/api/SkCanvas_Reference.md +++ b/site/user/api/SkCanvas_Reference.md @@ -4938,6 +4938,8 @@ Draw <a href="undocumented#Text_Blob">Text Blob</a> <a href="#SkCanvas_drawTextB <a href="SkPaint_Reference#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a>, <a href="SkPaint_Reference#Full_Hinting_Spacing">Full Hinting Spacing</a>, <a href="SkPaint_Reference#LCD_Text">LCD Text</a>, <a href="SkPaint_Reference#Linear_Text">Linear Text</a>, <a href="SkPaint_Reference#Subpixel_Text">Subpixel Text</a>, and <a href="#Vertical_Text">Paint Vertical Text</a>. +<a href="#Text_Encoding">Paint Text Encoding</a> must be set to <a href="#SkPaint_kGlyphID_TextEncoding">SkPaint::kGlyphID TextEncoding</a>. + Elements of <a href="#SkCanvas_drawTextBlob_paint">paint</a>: <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>; apply to <a href="#SkCanvas_drawTextBlob_blob">blob</a>. @@ -4956,7 +4958,7 @@ blend, color, stroking, and so on, used to draw</td> ### Example -<div><fiddle-embed name="b8c0a748ed5c328f38e00f5f3d12e5e6"></fiddle-embed></div> +<div><fiddle-embed name="2254beaa675e3b329dccddca4eeea735"></fiddle-embed></div> ### See Also @@ -4976,6 +4978,8 @@ Draw <a href="undocumented#Text_Blob">Text Blob</a> <a href="#SkCanvas_drawTextB <a href="SkPaint_Reference#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a>, <a href="SkPaint_Reference#Full_Hinting_Spacing">Full Hinting Spacing</a>, <a href="SkPaint_Reference#LCD_Text">LCD Text</a>, <a href="SkPaint_Reference#Linear_Text">Linear Text</a>, <a href="SkPaint_Reference#Subpixel_Text">Subpixel Text</a>, and <a href="#Vertical_Text">Paint Vertical Text</a>. +<a href="#Text_Encoding">Paint Text Encoding</a> must be set to <a href="#SkPaint_kGlyphID_TextEncoding">SkPaint::kGlyphID TextEncoding</a>. + Elements of <a href="#SkCanvas_drawTextBlob_2_paint">paint</a>: <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>; apply to <a href="#SkCanvas_drawTextBlob_2_blob">blob</a>. @@ -4994,7 +4998,7 @@ blend, color, stroking, and so on, used to draw</td> ### Example -<div><fiddle-embed name="d313ad4726518f5d44f6433887bb7ce9"><div><a href="SkPaint_Reference#Paint">Paint</a> attributes unrelated to text, like color, have no effect on <a href="#SkCanvas_drawTextBlob_2_paint">paint</a> in allocated <a href="undocumented#Text_Blob">Text Blob</a>. +<div><fiddle-embed name="d88b17d85fa68c56b3c1ad02b69068bf"><div><a href="SkPaint_Reference#Paint">Paint</a> attributes unrelated to text, like color, have no effect on <a href="#SkCanvas_drawTextBlob_2_paint">paint</a> in allocated <a href="undocumented#Text_Blob">Text Blob</a>. <a href="SkPaint_Reference#Paint">Paint</a> attributes related to text, like text size, have no effect on <a href="#SkCanvas_drawTextBlob_2_paint">paint</a> passed to <a href="#SkCanvas_drawTextBlob">drawTextBlob</a>.</div></fiddle-embed></div> ### See Also diff --git a/site/user/api/SkImage_Reference.md b/site/user/api/SkImage_Reference.md index 317215073b..019423d231 100644 --- a/site/user/api/SkImage_Reference.md +++ b/site/user/api/SkImage_Reference.md @@ -32,24 +32,23 @@ are zero, then nullptr will be returned. | description | function | | --- | --- | -| <a href="#SkImage_MakeFromAHardwareBuffer">MakeFromAHardwareBuffer</a> | | -| <a href="#SkImage_MakeBackendTextureFromSkImage">MakeBackendTextureFromSkImage</a> | | -| <a href="#SkImage_MakeCrossContextFromEncoded">MakeCrossContextFromEncoded</a> | | -| <a href="#SkImage_MakeFromAHardwareBuffer">MakeFromAHardwareBuffer</a> | | -| <a href="#SkImage_MakeFromAdoptedTexture">MakeFromAdoptedTexture</a> | | -| <a href="#SkImage_MakeFromBitmap">MakeFromBitmap</a> | | -| <a href="#SkImage_MakeFromDeferredTextureImageData">MakeFromDeferredTextureImageData</a> | | -| <a href="#SkImage_MakeFromEncoded">MakeFromEncoded</a> | | -| <a href="#SkImage_MakeFromGenerator">MakeFromGenerator</a> | | -| <a href="#SkImage_MakeFromNV12TexturesCopy">MakeFromNV12TexturesCopy</a> | | -| <a href="#SkImage_MakeFromPicture">MakeFromPicture</a> | | -| <a href="#SkImage_MakeFromRaster">MakeFromRaster</a> | | -| <a href="#SkImage_MakeFromTexture">MakeFromTexture</a> | | -| <a href="#SkImage_MakeFromYUVTexturesCopy">MakeFromYUVTexturesCopy</a> | | -| <a href="#SkImage_MakeRasterCopy">MakeRasterCopy</a> | | -| <a href="#SkImage_MakeRasterData">MakeRasterData</a> | | -| <a href="#SkImage_alphaType">alphaType</a> | | -| <a href="#SkImage_asLegacyBitmap">asLegacyBitmap</a> | | +| <a href="#SkImage_MakeBackendTextureFromSkImage">MakeBackendTextureFromSkImage</a> | Creates <a href="undocumented#GPU">GPU</a> texture from <a href="#Image">Image</a>. | +| <a href="#SkImage_MakeCrossContextFromEncoded">MakeCrossContextFromEncoded</a> | Creates <a href="#Image">Image</a> from encoded data, and uploads to <a href="undocumented#GPU">GPU</a>. | +| <a href="#SkImage_MakeFromAHardwareBuffer">MakeFromAHardwareBuffer</a> | Creates <a href="#Image">Image</a> from <a href="undocumented#Android">Android</a> hardware buffer. | +| <a href="#SkImage_MakeFromAdoptedTexture">MakeFromAdoptedTexture</a> | Creates <a href="#Image">Image</a> from <a href="undocumented#GPU">GPU</a> texture, 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_MakeFromDeferredTextureImageData">MakeFromDeferredTextureImageData</a> | Creates <a href="#Image">Image</a> from <a href="undocumented#GPU">GPU</a> texture data retrieved earlier. | +| <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="undocumented#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">MakeFromTexture</a> | Creates <a href="#Image">Image</a> from <a href="undocumented#GPU">GPU</a> texture, managed externally. | +| <a href="#SkImage_MakeFromYUVTexturesCopy">MakeFromYUVTexturesCopy</a> | Creates <a href="#Image">Image</a> from <a href="undocumented#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="#Info">Image Info</a> and shared pixels. | +| <a href="#SkImage_alphaType">alphaType</a> | Returns <a href="#Alpha_Type">Alpha Type</a> | +| <a href="#SkImage_asLegacyBitmap">asLegacyBitmap</a> | Returns as raster <a href="SkBitmap_Reference#Bitmap">Bitmap</a> | | <a href="#SkImage_bounds">bounds</a> | | | <a href="#SkImage_colorSpace">colorSpace</a> | | | <a href="#SkImage_dimensions">dimensions</a> | | @@ -131,16 +130,25 @@ incomplete static sk_sp<SkImage> MakeRasterCopy(const SkPixmap& pixmap) </pre> +Creates <a href="#Image">Image</a> from <a href="SkPixmap_Reference#Pixmap">Pixmap</a> and copy of pixels. + +<a href="#Image">Image</a> is returned if <a href="SkPixmap_Reference#Pixmap">Pixmap</a> is valid. Valid <a href="SkPixmap_Reference#Pixmap">Pixmap</a> parameters include: +<a href="#SkImage_dimensions">dimensions</a> are greater than zero; +each dimension fits in 29 bits; +<a href="#Color_Type">Color Type</a> and <a href="#Alpha_Type">Alpha Type</a> are valid, and <a href="#Color_Type">Color Type</a> is not <a href="undocumented#SkColorType">kUnknown SkColorType</a>; +row bytes are large enough to hold one row of pixels; +pixel address is not nullptr. + ### Parameters <table> <tr> <td><a name="SkImage_MakeRasterCopy_pixmap"> <code><strong>pixmap </strong></code> </a></td> <td> -incomplete</td> +<a href="#Info">Image Info</a>, pixel address, and row bytes</td> </tr> </table> ### Return Value -incomplete +copy of <a href="SkPixmap_Reference#Pixmap">Pixmap</a> pixels, or nullptr ### Example @@ -148,7 +156,7 @@ incomplete ### See Also -incomplete +<a href="#SkImage_MakeRasterData">MakeRasterData</a> <a href="#SkImage_MakeFromGenerator">MakeFromGenerator</a> --- @@ -159,20 +167,29 @@ incomplete static sk_sp<SkImage> MakeRasterData(const Info& info, sk_sp<SkData> pixels, size_t rowBytes) </pre> +Creates <a href="#Image">Image</a> from <a href="#Info">Image Info</a>, sharing <a href="#SkImage_MakeRasterData_pixels">pixels</a>. + +<a href="#Image">Image</a> is returned if <a href="#Info">Image Info</a> is valid. Valid <a href="#Info">Image Info</a> parameters include: +<a href="#SkImage_dimensions">dimensions</a> are greater than zero; +each dimension fits in 29 bits; +<a href="#Color_Type">Color Type</a> and <a href="#Alpha_Type">Alpha Type</a> are valid, and <a href="#Color_Type">Color Type</a> is not <a href="undocumented#SkColorType">kUnknown SkColorType</a>; +<a href="#SkImage_MakeRasterData_rowBytes">rowBytes</a> are large enough to hold one row of <a href="#SkImage_MakeRasterData_pixels">pixels</a>; +<a href="#SkImage_MakeRasterData_pixels">pixels</a> is not nullptr, and contains enough data for <a href="#Image">Image</a>. + ### Parameters <table> <tr> <td><a name="SkImage_MakeRasterData_info"> <code><strong>info </strong></code> </a></td> <td> -incomplete</td> +contains <a href="#SkImage_width">width</a>, <a href="#SkImage_height">height</a>, <a href="#Alpha_Type">Alpha Type</a>, <a href="#Color_Type">Color Type</a>, <a href="undocumented#Color_Space">Color Space</a></td> </tr> <tr> <td><a name="SkImage_MakeRasterData_pixels"> <code><strong>pixels </strong></code> </a></td> <td> -incomplete</td> +address or pixel storage</td> </tr> <tr> <td><a name="SkImage_MakeRasterData_rowBytes"> <code><strong>rowBytes </strong></code> </a></td> <td> -incomplete</td> +size of pixel row or larger</td> </tr> </table> ### Return Value -incomplete +<a href="#Image">Image</a> sharing <a href="#SkImage_MakeRasterData_pixels">pixels</a>, or nullptr ### Example @@ -180,10 +197,23 @@ incomplete ### See Also -incomplete +<a href="#SkImage_MakeRasterCopy">MakeRasterCopy</a> <a href="#SkImage_MakeFromGenerator">MakeFromGenerator</a> --- +Caller data passed to <a href="SkImage_Reference#RasterReleaseProc">RasterReleaseProc</a>; may be nullptr. + +### See Also + +<a href="#SkImage_MakeFromRaster">MakeFromRaster</a> <a href="SkImage_Reference#RasterReleaseProc">RasterReleaseProc</a> + +Function called when <a href="#Image">Image</a> no longer shares pixels. <a href="SkImage_Reference#ReleaseContext">ReleaseContext</a> is +provided by caller when <a href="#Image">Image</a> is created, and may be nullptr. + +### See Also + +<a href="SkImage_Reference#ReleaseContext">ReleaseContext</a> <a href="#SkImage_MakeFromRaster">MakeFromRaster</a> + <a name="SkImage_MakeFromRaster"></a> ## MakeFromRaster @@ -192,19 +222,25 @@ static sk_sp<SkImage> MakeFromRaster(const SkPixmap& pixmap, RasterRelease ReleaseContext releaseContext) </pre> -Return a new <a href="#Image">Image</a> referencing the specified pixels. These must remain valid and unchanged -until the specified release-proc is called, indicating that <a href="undocumented#Skia">Skia</a> no longer has a reference -to the pixels. -Returns nullptr if the requested <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a> info is unsupported. +Creates <a href="#Image">Image</a> from <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a>, sharing <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a> pixels. Pixels must remain valid and +unchanged until <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a> is called. <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a> is passed +<a href="#SkImage_MakeFromRaster_releaseContext">releaseContext</a> when <a href="#Image">Image</a> is deleted or no longer refers to <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a> pixels. + +<a href="#Image">Image</a> is returned if <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a> is valid. Valid <a href="SkPixmap_Reference#Pixmap">Pixmap</a> parameters include: +<a href="#SkImage_dimensions">dimensions</a> are greater than zero; +each dimension fits in 29 bits; +<a href="#Color_Type">Color Type</a> and <a href="#Alpha_Type">Alpha Type</a> are valid, and <a href="#Color_Type">Color Type</a> is not <a href="undocumented#SkColorType">kUnknown SkColorType</a>; +row bytes are large enough to hold one row of pixels; +pixel address is not nullptr. ### Parameters <table> <tr> <td><a name="SkImage_MakeFromRaster_pixmap"> <code><strong>pixmap </strong></code> </a></td> <td> -incomplete</td> +<a href="#Info">Image Info</a>, pixel address, and row bytes</td> </tr> <tr> <td><a name="SkImage_MakeFromRaster_rasterReleaseProc"> <code><strong>rasterReleaseProc </strong></code> </a></td> <td> -incomplete</td> +function called when pixels can be released</td> </tr> <tr> <td><a name="SkImage_MakeFromRaster_releaseContext"> <code><strong>releaseContext </strong></code> </a></td> <td> -incomplete</td> +state passed to <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a></td> </tr> </table> @@ -218,7 +254,7 @@ incomplete ### See Also -incomplete +<a href="#SkImage_MakeRasterCopy">MakeRasterCopy</a> <a href="#SkImage_MakeRasterData">MakeRasterData</a> <a href="#SkImage_MakeFromGenerator">MakeFromGenerator</a> <a href="SkImage_Reference#RasterReleaseProc">RasterReleaseProc</a> <a href="SkImage_Reference#ReleaseContext">ReleaseContext</a> --- @@ -229,19 +265,27 @@ incomplete static sk_sp<SkImage> MakeFromBitmap(const SkBitmap& bitmap) </pre> -Construct a new image from the specified <a href="#SkImage_MakeFromBitmap_bitmap">bitmap</a>. If the <a href="#SkImage_MakeFromBitmap_bitmap">bitmap</a> is marked immutable, and -its pixel memory is shareable, it may be shared instead of copied. +Creates <a href="#Image">Image</a> from <a href="#SkImage_MakeFromBitmap_bitmap">bitmap</a>, sharing or copying <a href="#SkImage_MakeFromBitmap_bitmap">bitmap</a> pixels. If the <a href="#SkImage_MakeFromBitmap_bitmap">bitmap</a> +is marked immutable, and its pixel memory is shareable, it may be shared +instead of copied. + +<a href="#Image">Image</a> is returned if <a href="#SkImage_MakeFromBitmap_bitmap">bitmap</a> is valid. Valid <a href="SkBitmap_Reference#Bitmap">Bitmap</a> parameters include: +<a href="#SkImage_dimensions">dimensions</a> are greater than zero; +each dimension fits in 29 bits; +<a href="#Color_Type">Color Type</a> and <a href="#Alpha_Type">Alpha Type</a> are valid, and <a href="#Color_Type">Color Type</a> is not <a href="undocumented#SkColorType">kUnknown SkColorType</a>; +row bytes are large enough to hold one row of pixels; +pixel address is not nullptr. ### Parameters <table> <tr> <td><a name="SkImage_MakeFromBitmap_bitmap"> <code><strong>bitmap </strong></code> </a></td> <td> -incomplete</td> +<a href="#Info">Image Info</a>, row bytes, and pixels</td> </tr> </table> ### Return Value -incomplete +created <a href="#Image">Image</a>, or nullptr ### Example @@ -249,7 +293,7 @@ incomplete ### See Also -incomplete +<a href="#SkImage_MakeFromRaster">MakeFromRaster</a> <a href="#SkImage_MakeRasterCopy">MakeRasterCopy</a> <a href="#SkImage_MakeFromGenerator">MakeFromGenerator</a> <a href="#SkImage_MakeRasterData">MakeRasterData</a> --- @@ -261,22 +305,27 @@ static sk_sp<SkImage> MakeFromGenerator(std::unique_ptr<SkImageGenerato const SkIRect* subset = nullptr) </pre> -Construct a new <a href="#SkImage">SkImage</a> based on the given ImageGenerator. Returns nullptr on error. -This function will always take ownership of the passed generator. -If a <a href="#SkImage_MakeFromGenerator_subset">subset</a> is specified, it must be contained within the generator's <a href="#SkImage_bounds">bounds</a>. +Creates <a href="#Image">Image</a> based from <a href="#SkImage_MakeFromGenerator_imageGenerator">imageGenerator</a>. +Takes ownership of <a href="#SkImage_MakeFromGenerator_imageGenerator">imageGenerator</a>; it may not be used elsewhere. +If <a href="#SkImage_MakeFromGenerator_subset">subset</a> is not nullptr, it must be contained within <a href="#SkImage_MakeFromGenerator_imageGenerator">imageGenerator</a> data <a href="#SkImage_bounds">bounds</a>. + +<a href="#Image">Image</a> is returned if generator data is valid. Valid data parameters vary +by type of data and platform. + +<a href="#SkImage_MakeFromGenerator_imageGenerator">imageGenerator</a> may wrap <a href="undocumented#Picture">Picture</a> data, codec data, or custom data. ### Parameters <table> <tr> <td><a name="SkImage_MakeFromGenerator_imageGenerator"> <code><strong>imageGenerator </strong></code> </a></td> <td> -incomplete</td> +stock or custom routines to retrieve <a href="#Image">Image</a></td> </tr> <tr> <td><a name="SkImage_MakeFromGenerator_subset"> <code><strong>subset </strong></code> </a></td> <td> -incomplete</td> +<a href="#SkImage_bounds">bounds</a> of returned <a href="#Image">Image</a>; may be nullptr</td> </tr> </table> ### Return Value -incomplete +created <a href="#Image">Image</a>, or nullptr ### Example @@ -284,7 +333,7 @@ incomplete ### See Also -incomplete +<a href="#SkImage_MakeFromEncoded">MakeFromEncoded</a> --- @@ -295,22 +344,24 @@ incomplete static sk_sp<SkImage> MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect* subset = nullptr) </pre> -Construct a new <a href="#SkImage">SkImage</a> based on the specified <a href="#SkImage_MakeFromEncoded_encoded">encoded</a> data. Returns nullptr on failure, -which can mean that the format of the <a href="#SkImage_MakeFromEncoded_encoded">encoded</a> data was not recognized/supported. -If a <a href="#SkImage_MakeFromEncoded_subset">subset</a> is specified, it must be contained within the <a href="#SkImage_MakeFromEncoded_encoded">encoded</a> data's <a href="#SkImage_bounds">bounds</a>. +Creates <a href="#Image">Image</a> from <a href="#SkImage_MakeFromEncoded_encoded">encoded</a> data. +If a <a href="#SkImage_MakeFromEncoded_subset">subset</a> is not nullptr, it must be contained within <a href="#SkImage_MakeFromEncoded_encoded">encoded</a> data <a href="#SkImage_bounds">bounds</a>. + +<a href="#Image">Image</a> is returned if format of the <a href="#SkImage_MakeFromEncoded_encoded">encoded</a> data is recognized and supported. +Recognized formats vary by platfrom. ### Parameters <table> <tr> <td><a name="SkImage_MakeFromEncoded_encoded"> <code><strong>encoded </strong></code> </a></td> <td> -incomplete</td> +data of <a href="#Image">Image</a> to decode</td> </tr> <tr> <td><a name="SkImage_MakeFromEncoded_subset"> <code><strong>subset </strong></code> </a></td> <td> -incomplete</td> +<a href="#SkImage_bounds">bounds</a> of returned <a href="#Image">Image</a>; may be nullptr</td> </tr> </table> ### Return Value -incomplete +created <a href="#Image">Image</a>, or nullptr ### Example @@ -318,7 +369,7 @@ incomplete ### See Also -incomplete +<a href="#SkImage_MakeFromGenerator">MakeFromGenerator</a> --- @@ -331,28 +382,31 @@ static sk_sp<SkImage> MakeFromTexture(GrContext* context, const GrBackendT sk_sp<SkColorSpace> colorSpace) </pre> -Create a new image from the specified descriptor. Note - the caller is responsible for -managing the lifetime of the underlying platform texture. -Will return nullptr if the specified back-end texture is unsupported. +Creates <a href="#Image">Image</a> from <a href="undocumented#GPU">GPU</a> texture associated with <a href="#SkImage_MakeFromTexture_context">context</a>. Caller is responsible for +managing the lifetime of <a href="undocumented#GPU">GPU</a> texture. + +<a href="#Image">Image</a> is returned if format of <a href="#SkImage_MakeFromTexture_backendTexture">backendTexture</a> is recognized and supported. +Recognized formats vary by <a href="undocumented#GPU">GPU</a> back-end. ### Parameters <table> <tr> <td><a name="SkImage_MakeFromTexture_context"> <code><strong>context </strong></code> </a></td> <td> -incomplete</td> +<a href="undocumented#GPU_Context">GPU Context</a></td> </tr> <tr> <td><a name="SkImage_MakeFromTexture_backendTexture"> <code><strong>backendTexture </strong></code> </a></td> <td> -incomplete</td> +texture residing on <a href="undocumented#GPU">GPU</a></td> </tr> <tr> <td><a name="SkImage_MakeFromTexture_origin"> <code><strong>origin </strong></code> </a></td> <td> -incomplete</td> +one of: <a href="undocumented#GrSurfaceOrigin">kBottomLeft GrSurfaceOrigin</a>, <a href="undocumented#GrSurfaceOrigin">kTopLeft GrSurfaceOrigin</a></td> </tr> <tr> <td><a name="SkImage_MakeFromTexture_alphaType"> <code><strong>alphaType </strong></code> </a></td> <td> -incomplete</td> +one of: <a href="undocumented#SkAlphaType">kUnknown SkAlphaType</a>, <a href="undocumented#SkAlphaType">kOpaque SkAlphaType</a>, +<a href="undocumented#SkAlphaType">kPremul SkAlphaType</a>, <a href="undocumented#SkAlphaType">kUnpremul SkAlphaType</a></td> </tr> <tr> <td><a name="SkImage_MakeFromTexture_colorSpace"> <code><strong>colorSpace </strong></code> </a></td> <td> -incomplete</td> +range of colors</td> </tr> </table> ### Return Value -incomplete +created <a href="#Image">Image</a>, or nullptr ### Example @@ -360,7 +414,7 @@ incomplete ### See Also -incomplete +<a href="#SkImage_MakeFromAdoptedTexture">MakeFromAdoptedTexture</a> <a href="#SkSurface_MakeFromBackendTexture">SkSurface::MakeFromBackendTexture</a> --- @@ -372,33 +426,36 @@ static sk_sp<SkImage> MakeFromTexture(GrContext* context, const GrBackendT ReleaseContext releaseContext) </pre> -Create a new image from the <a href="undocumented#GrBackendTexture">GrBackendTexture</a>. The underlying platform texture must stay -valid and unaltered until the specified release-proc is invoked, indicating that <a href="undocumented#Skia">Skia</a> -no longer is holding a reference to it. -Will return nullptr if the specified back-end texture is unsupported. +Creates <a href="#Image">Image</a> from <a href="undocumented#GPU">GPU</a> texture associated with <a href="#SkImage_MakeFromTexture_2_context">context</a>. <a href="undocumented#GPU">GPU</a> texture must stay +valid and unchanged until <a href="#SkImage_MakeFromTexture_2_textureReleaseProc">textureReleaseProc</a> is called. <a href="#SkImage_MakeFromTexture_2_textureReleaseProc">textureReleaseProc</a> is +passed <a href="#SkImage_MakeFromTexture_2_releaseContext">releaseContext</a> when <a href="#Image">Image</a> is deleted or no longer refers to texture. + +<a href="#Image">Image</a> is returned if format of <a href="#SkImage_MakeFromTexture_2_backendTexture">backendTexture</a> is recognized and supported. +Recognized formats vary by <a href="undocumented#GPU">GPU</a> back-end. ### Parameters <table> <tr> <td><a name="SkImage_MakeFromTexture_2_context"> <code><strong>context </strong></code> </a></td> <td> -incomplete</td> +<a href="undocumented#GPU_Context">GPU Context</a></td> </tr> <tr> <td><a name="SkImage_MakeFromTexture_2_backendTexture"> <code><strong>backendTexture </strong></code> </a></td> <td> -incomplete</td> +texture residing on <a href="undocumented#GPU">GPU</a></td> </tr> <tr> <td><a name="SkImage_MakeFromTexture_2_origin"> <code><strong>origin </strong></code> </a></td> <td> -incomplete</td> +one of: <a href="undocumented#GrSurfaceOrigin">kBottomLeft GrSurfaceOrigin</a>, <a href="undocumented#GrSurfaceOrigin">kTopLeft GrSurfaceOrigin</a></td> </tr> <tr> <td><a name="SkImage_MakeFromTexture_2_alphaType"> <code><strong>alphaType </strong></code> </a></td> <td> -incomplete</td> +one of: <a href="undocumented#SkAlphaType">kUnknown SkAlphaType</a>, <a href="undocumented#SkAlphaType">kOpaque SkAlphaType</a>, +<a href="undocumented#SkAlphaType">kPremul SkAlphaType</a>, <a href="undocumented#SkAlphaType">kUnpremul SkAlphaType</a></td> </tr> <tr> <td><a name="SkImage_MakeFromTexture_2_colorSpace"> <code><strong>colorSpace </strong></code> </a></td> <td> -incomplete</td> +range of colors</td> </tr> <tr> <td><a name="SkImage_MakeFromTexture_2_textureReleaseProc"> <code><strong>textureReleaseProc </strong></code> </a></td> <td> -incomplete</td> +function called when texture can be released</td> </tr> <tr> <td><a name="SkImage_MakeFromTexture_2_releaseContext"> <code><strong>releaseContext </strong></code> </a></td> <td> -incomplete</td> +state passed to <a href="#SkImage_MakeFromTexture_2_textureReleaseProc">textureReleaseProc</a></td> </tr> </table> ### Return Value -incomplete +created <a href="#Image">Image</a>, or nullptr ### Example @@ -406,7 +463,7 @@ incomplete ### See Also -incomplete +<a href="#SkImage_MakeFromAdoptedTexture">MakeFromAdoptedTexture</a> <a href="#SkSurface_MakeFromBackendTexture">SkSurface::MakeFromBackendTexture</a> --- @@ -418,32 +475,37 @@ static sk_sp<SkImage> MakeCrossContextFromEncoded(GrContext* context, sk_s bool buildMips, SkColorSpace* dstColorSpace) </pre> -Decodes and uploads the encoded <a href="#SkImage_MakeCrossContextFromEncoded_data">data</a> to a <a href="undocumented#GPU">GPU</a> backed image using the supplied <a href="undocumented#GrContext">GrContext</a>. -That image can be safely used by other GrContexts, across thread boundaries. The <a href="undocumented#GrContext">GrContext</a> -used here, and the ones used to draw this image later must be in the same <a href="undocumented#OpenGL">OpenGL</a> share group, -or otherwise be able to share resources. -When the image's ref count reaches zero, the original <a href="undocumented#GrContext">GrContext</a> will destroy the texture, +Creates <a href="#Image">Image</a> from encoded <a href="#SkImage_MakeCrossContextFromEncoded_data">data</a>. <a href="#Image">Image</a> is uploaded to <a href="undocumented#GPU">GPU</a> back-end using <a href="#SkImage_MakeCrossContextFromEncoded_context">context</a>. + +Created <a href="#Image">Image</a> is available to other <a href="undocumented#GPU">GPU</a> contexts, and is available across thread +boundaries. All contexts must be in the same <a href="undocumented#GPU_Share_Group">GPU Share Group</a>, or otherwise +share resources. + +When <a href="#Image">Image</a> is no longer referenced, <a href="#SkImage_MakeCrossContextFromEncoded_context">context</a> releases texture memory asynchronously. -The texture will be decoded and uploaded to be suitable for use with surfaces that have the -supplied destination color space. The color space of the image itself will be determined -from the encoded <a href="#SkImage_MakeCrossContextFromEncoded_data">data</a>. + +<a href="undocumented#Texture">Texture</a> decoded from <a href="#SkImage_MakeCrossContextFromEncoded_data">data</a> is uploaded to match <a href="SkSurface_Reference#Surface">Surface</a> created with +<a href="#SkImage_MakeCrossContextFromEncoded_dstColorSpace">dstColorSpace</a>. <a href="undocumented#Color_Space">Color Space</a> of <a href="#Image">Image</a> is determined by encoded <a href="#SkImage_MakeCrossContextFromEncoded_data">data</a>. + +<a href="#Image">Image</a> is returned if format of <a href="#SkImage_MakeCrossContextFromEncoded_data">data</a> is recognized and supported, and if <a href="#SkImage_MakeCrossContextFromEncoded_context">context</a> +supports moving resources. Recognized formats vary by platform and <a href="undocumented#GPU">GPU</a> back-end. ### Parameters <table> <tr> <td><a name="SkImage_MakeCrossContextFromEncoded_context"> <code><strong>context </strong></code> </a></td> <td> -incomplete</td> +<a href="undocumented#GPU_Context">GPU Context</a></td> </tr> <tr> <td><a name="SkImage_MakeCrossContextFromEncoded_data"> <code><strong>data </strong></code> </a></td> <td> -incomplete</td> +<a href="#Image">Image</a> to decode</td> </tr> <tr> <td><a name="SkImage_MakeCrossContextFromEncoded_buildMips"> <code><strong>buildMips </strong></code> </a></td> <td> -incomplete</td> +create <a href="#Image">Image</a> as <a href="undocumented#Mip_Map">Mip Map</a> if true</td> </tr> <tr> <td><a name="SkImage_MakeCrossContextFromEncoded_dstColorSpace"> <code><strong>dstColorSpace </strong></code> </a></td> <td> -incomplete</td> +range of colors of matching <a href="SkSurface_Reference#Surface">Surface</a> on <a href="undocumented#GPU">GPU</a></td> </tr> </table> ### Return Value -incomplete +created <a href="#Image">Image</a>, or nullptr ### Example @@ -451,7 +513,59 @@ incomplete ### See Also -incomplete +<a href="#SkImage_MakeCrossContextFromPixmap">MakeCrossContextFromPixmap</a> + +--- + +<a name="SkImage_MakeCrossContextFromPixmap"></a> +## MakeCrossContextFromPixmap + +<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> +static sk_sp<SkImage> MakeCrossContextFromPixmap(GrContext* context, const SkPixmap& pixmap, + bool buildMips, SkColorSpace* dstColorSpace) +</pre> + +Creates <a href="#Image">Image</a> from <a href="#SkImage_MakeCrossContextFromPixmap_pixmap">pixmap</a>. <a href="#Image">Image</a> is uploaded to <a href="undocumented#GPU">GPU</a> back-end using <a href="#SkImage_MakeCrossContextFromPixmap_context">context</a>. + +Created <a href="#Image">Image</a> is available to other <a href="undocumented#GPU">GPU</a> contexts, and is available across thread +boundaries. All contexts must be in the same <a href="undocumented#GPU_Share_Group">GPU Share Group</a>, or otherwise +share resources. + +When <a href="#Image">Image</a> is no longer referenced, <a href="#SkImage_MakeCrossContextFromPixmap_context">context</a> releases texture memory +asynchronously. + +<a href="undocumented#Texture">Texture</a> created from <a href="#SkImage_MakeCrossContextFromPixmap_pixmap">pixmap</a> is uploaded to match <a href="SkSurface_Reference#Surface">Surface</a> created with +<a href="#SkImage_MakeCrossContextFromPixmap_dstColorSpace">dstColorSpace</a>. <a href="undocumented#Color_Space">Color Space</a> of <a href="#Image">Image</a> is determined by <a href="#SkImage_MakeCrossContextFromPixmap_pixmap">pixmap</a>.<a href="#SkImage_colorSpace">colorSpace</a>. + +<a href="#Image">Image</a> is returned referring to <a href="undocumented#GPU">GPU</a> back-end if format of data is recognized and +supported, and if <a href="#SkImage_MakeCrossContextFromPixmap_context">context</a> supports moving resources. Otherwise, <a href="#SkImage_MakeCrossContextFromPixmap_pixmap">pixmap</a> pixel +data is copied and <a href="#Image">Image</a> as returned in raster format if possible; nullptr may +be returned. Recognized <a href="undocumented#GPU">GPU</a> formats vary by platform and <a href="undocumented#GPU">GPU</a> back-end. + +### Parameters + +<table> <tr> <td><a name="SkImage_MakeCrossContextFromPixmap_context"> <code><strong>context </strong></code> </a></td> <td> +<a href="undocumented#GPU_Context">GPU Context</a></td> + </tr> <tr> <td><a name="SkImage_MakeCrossContextFromPixmap_pixmap"> <code><strong>pixmap </strong></code> </a></td> <td> +<a href="#Info">Image Info</a>, pixel address, and row bytes</td> + </tr> <tr> <td><a name="SkImage_MakeCrossContextFromPixmap_buildMips"> <code><strong>buildMips </strong></code> </a></td> <td> +create <a href="#Image">Image</a> as <a href="undocumented#Mip_Map">Mip Map</a> if true</td> + </tr> <tr> <td><a name="SkImage_MakeCrossContextFromPixmap_dstColorSpace"> <code><strong>dstColorSpace </strong></code> </a></td> <td> +range of colors of matching <a href="SkSurface_Reference#Surface">Surface</a> on <a href="undocumented#GPU">GPU</a></td> + </tr> +</table> + +### Return Value + +created <a href="#Image">Image</a>, or nullptr + +### Example + +<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> + +### See Also + +<a href="#SkImage_MakeCrossContextFromEncoded">MakeCrossContextFromEncoded</a> --- @@ -466,28 +580,31 @@ static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext* context, sk_sp<SkColorSpace> colorSpace = nullptr) </pre> -Create a new image from the specified descriptor. Note - <a href="undocumented#Skia">Skia</a> will delete or recycle the -texture when the image is released. -Will return nullptr if the specified back-end texture is unsupported. +Creates <a href="#Image">Image</a> from <a href="#SkImage_MakeFromAdoptedTexture_backendTexture">backendTexture</a> associated with <a href="#SkImage_MakeFromAdoptedTexture_context">context</a>. <a href="#SkImage_MakeFromAdoptedTexture_backendTexture">backendTexture</a> and +returned <a href="#Image">Image</a> are managed internally, and are released when no longer needed. + +<a href="#Image">Image</a> is returned if format of <a href="#SkImage_MakeFromAdoptedTexture_backendTexture">backendTexture</a> is recognized and supported. +Recognized formats vary by <a href="undocumented#GPU">GPU</a> back-end. ### Parameters <table> <tr> <td><a name="SkImage_MakeFromAdoptedTexture_context"> <code><strong>context </strong></code> </a></td> <td> -incomplete</td> +<a href="undocumented#GPU_Context">GPU Context</a></td> </tr> <tr> <td><a name="SkImage_MakeFromAdoptedTexture_backendTexture"> <code><strong>backendTexture </strong></code> </a></td> <td> -incomplete</td> +texture residing on <a href="undocumented#GPU">GPU</a></td> </tr> <tr> <td><a name="SkImage_MakeFromAdoptedTexture_surfaceOrigin"> <code><strong>surfaceOrigin </strong></code> </a></td> <td> -incomplete</td> +one of: <a href="undocumented#GrSurfaceOrigin">kBottomLeft GrSurfaceOrigin</a>, <a href="undocumented#GrSurfaceOrigin">kTopLeft GrSurfaceOrigin</a></td> </tr> <tr> <td><a name="SkImage_MakeFromAdoptedTexture_alphaType"> <code><strong>alphaType </strong></code> </a></td> <td> -incomplete</td> +one of: <a href="undocumented#SkAlphaType">kUnknown SkAlphaType</a>, <a href="undocumented#SkAlphaType">kOpaque SkAlphaType</a>, +<a href="undocumented#SkAlphaType">kPremul SkAlphaType</a>, <a href="undocumented#SkAlphaType">kUnpremul SkAlphaType</a></td> </tr> <tr> <td><a name="SkImage_MakeFromAdoptedTexture_colorSpace"> <code><strong>colorSpace </strong></code> </a></td> <td> -incomplete</td> +range of colors</td> </tr> </table> ### Return Value -incomplete +created <a href="#Image">Image</a>, or nullptr ### Example @@ -1659,18 +1776,18 @@ static sk_sp<SkImage> MakeFromDeferredTextureImageData(GrContext* context, SkBudgeted budgeted) </pre> -Returns a texture-backed image from <a href="#SkImage_MakeFromDeferredTextureImageData_data">data</a> produced in <a href="#SkImage_getDeferredTextureImageData">SkImage::getDeferredTextureImageData</a>. +Returns a texture-backed image from <a href="#SkImage_MakeFromDeferredTextureImageData_data">data</a> produced in <a href="#SkImage_getDeferredTextureImageData">getDeferredTextureImageData</a>. The <a href="#SkImage_MakeFromDeferredTextureImageData_context">context</a> must be the <a href="#SkImage_MakeFromDeferredTextureImageData_context">context</a> that provided the proxy passed to <a href="#SkImage_getDeferredTextureImageData">getDeferredTextureImageData</a>. ### Parameters <table> <tr> <td><a name="SkImage_MakeFromDeferredTextureImageData_context"> <code><strong>context </strong></code> </a></td> <td> -incomplete</td> +<a href="undocumented#GPU_Context">GPU Context</a></td> </tr> <tr> <td><a name="SkImage_MakeFromDeferredTextureImageData_data"> <code><strong>data </strong></code> </a></td> <td> -incomplete</td> +buffer filled by <a href="#SkImage_getDeferredTextureImageData">getDeferredTextureImageData</a></td> </tr> <tr> <td><a name="SkImage_MakeFromDeferredTextureImageData_budgeted"> <code><strong>budgeted </strong></code> </a></td> <td> -incomplete</td> +one of: <a href="#SkBudgeted_kNo">SkBudgeted::kNo</a>, <a href="#SkBudgeted_kYes">SkBudgeted::kYes</a></td> </tr> </table> @@ -1680,7 +1797,7 @@ incomplete ### Example -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> +<div><fiddle-embed name="493c3a7c12d9130532971b2a255d1652"gpu="true"></fiddle-embed></div> ### See Also @@ -1778,24 +1895,23 @@ incomplete bool asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode legacyBitmapMode) const </pre> -Attempt to create a <a href="#SkImage_asLegacyBitmap_bitmap">bitmap</a> with the same pixels as the image. The result will always be -a raster-backed <a href="#SkImage_asLegacyBitmap_bitmap">bitmap</a> (texture-backed bitmaps are DEPRECATED, and not supported here). -If the mode is <a href="#SkImage_kRO_LegacyBitmapMode">kRO LegacyBitmapMode</a> (read-only), the resulting <a href="#SkImage_asLegacyBitmap_bitmap">bitmap</a> will be marked as immutable. -On success, returns true. On failure, returns false and the <a href="#SkImage_asLegacyBitmap_bitmap">bitmap</a> parameter will be reset -to empty. +Creates raster <a href="SkBitmap_Reference#Bitmap">Bitmap</a> with same pixels as <a href="#Image">Image</a>. If <a href="#SkImage_asLegacyBitmap_legacyBitmapMode">legacyBitmapMode</a> is <a href="#SkImage_kRO_LegacyBitmapMode">kRO LegacyBitmapMode</a>, +returned <a href="#SkImage_asLegacyBitmap_bitmap">bitmap</a> is read-only and immutable. +Returns true if <a href="SkBitmap_Reference#Bitmap">Bitmap</a> is stored in <a href="#SkImage_asLegacyBitmap_bitmap">bitmap</a>. Returns false and resets <a href="#SkImage_asLegacyBitmap_bitmap">bitmap</a> if <a href="SkBitmap_Reference#Bitmap">Bitmap</a> +write did not succeed. ### Parameters <table> <tr> <td><a name="SkImage_asLegacyBitmap_bitmap"> <code><strong>bitmap </strong></code> </a></td> <td> -incomplete</td> +storage for legacy <a href="SkBitmap_Reference#Bitmap">Bitmap</a></td> </tr> <tr> <td><a name="SkImage_asLegacyBitmap_legacyBitmapMode"> <code><strong>legacyBitmapMode </strong></code> </a></td> <td> -incomplete</td> +one of: <a href="#SkImage_kRO_LegacyBitmapMode">kRO LegacyBitmapMode</a>, <a href="#SkImage_kRW_LegacyBitmapMode">kRW LegacyBitmapMode</a></td> </tr> </table> ### Return Value -incomplete +true if <a href="SkBitmap_Reference#Bitmap">Bitmap</a> was created ### Example diff --git a/site/user/api/SkPaint_Reference.md b/site/user/api/SkPaint_Reference.md index 0442705bc1..d2609874cb 100644 --- a/site/user/api/SkPaint_Reference.md +++ b/site/user/api/SkPaint_Reference.md @@ -615,7 +615,7 @@ can reconstitute the paint at a later time. ### Example -<div><fiddle-embed name="670672b146b50eced4d3dd10c701e0a7"> +<div><fiddle-embed name="de31563f11e447dccc988108e9173d28"> #### Example Output @@ -5024,9 +5024,11 @@ Returns the number of <a href="#SkPaint_getTextBlobIntercepts_intervals">interva <a href="#SkPaint_getTextBlobIntercepts_bounds">bounds</a> describes a pair of lines parallel to the text advance. The return count is zero or a multiple of two, and is at most twice the number of <a href="#Glyph">Glyphs</a> in the string. -Uses <a href="#Text_Encoding">Text Encoding</a> to decode text, <a href="undocumented#Typeface">Typeface</a> to get the glyph paths, +Uses <a href="undocumented#Typeface">Typeface</a> to get the glyph paths, and <a href="#Text_Size">Text Size</a>, <a href="#Fake_Bold">Fake Bold</a>, and <a href="undocumented#Path_Effect">Path Effect</a> to scale and modify the glyph paths. Uses run array and <a href="#Text_Align">Text Align</a> to position <a href="#SkPaint_getTextBlobIntercepts_intervals">intervals</a>. +<a href="#Text_Encoding">Text Encoding</a> must be set to <a href="#SkPaint_kGlyphID_TextEncoding">SkPaint::kGlyphID TextEncoding</a>. + Pass nullptr for <a href="#SkPaint_getTextBlobIntercepts_intervals">intervals</a> to determine the size of the interval array. <a href="#SkPaint_getTextBlobIntercepts_intervals">intervals</a> are cached to improve performance for multiple calls. @@ -5047,7 +5049,7 @@ number of intersections; may be zero ### Example -<div><fiddle-embed name="4961b05f4f26cf270ab4948a57876341"></fiddle-embed></div> +<div><fiddle-embed name="71959a66b2290d70003887c0de339266"></fiddle-embed></div> --- diff --git a/site/user/api/SkSurface_Reference.md b/site/user/api/SkSurface_Reference.md index 709e3bfb64..c3438918a7 100644 --- a/site/user/api/SkSurface_Reference.md +++ b/site/user/api/SkSurface_Reference.md @@ -649,7 +649,7 @@ fonts; may be nullptr</td> ### Example -<div><fiddle-embed name="4473daad1b11784a9869431af72c93e0"><div><a href="undocumented#LCD">LCD</a> text takes advantage of raster striping to improve resolution. Only one of +<div><fiddle-embed name="640321e8ecfb3f9329f3bc6e1f02485f"gpu="true"cpu="true"><div><a href="undocumented#LCD">LCD</a> text takes advantage of raster striping to improve resolution. Only one of the four combinations is correct, depending on whether the monitor's <a href="undocumented#LCD">LCD</a> is horizontal or vertical, and whether the order of the stripes is red blue green or red green blue.</div></fiddle-embed></div> @@ -907,13 +907,13 @@ enum <a href="#SkSurface_BackendHandleAccess">BackendHandleAccess</a> { <table> <tr> - <td><a name="SkSurface_kFlushRead_BackendHandleAccess"> <code><strong>SkSurface::kFlushRead_BackendHandleAccess </strong></code> </a></td><td>Caller may read from the back-end object.</td><td></td> + <td><a name="SkSurface_kFlushRead_BackendHandleAccess"> <code><strong>SkSurface::kFlushRead_BackendHandleAccess </strong></code> </a></td><td>0</td><td>Caller may read from the back-end object.</td> </tr> <tr> - <td><a name="SkSurface_kFlushWrite_BackendHandleAccess"> <code><strong>SkSurface::kFlushWrite_BackendHandleAccess </strong></code> </a></td><td>Caller may write to the back-end object.</td><td></td> + <td><a name="SkSurface_kFlushWrite_BackendHandleAccess"> <code><strong>SkSurface::kFlushWrite_BackendHandleAccess </strong></code> </a></td><td>1</td><td>Caller may write to the back-end object.</td> </tr> <tr> - <td><a name="SkSurface_kDiscardWrite_BackendHandleAccess"> <code><strong>SkSurface::kDiscardWrite_BackendHandleAccess </strong></code> </a></td><td>Caller must overwrite the entire back-end object.</td><td></td> + <td><a name="SkSurface_kDiscardWrite_BackendHandleAccess"> <code><strong>SkSurface::kDiscardWrite_BackendHandleAccess </strong></code> </a></td><td>2</td><td>Caller must overwrite the entire back-end object.</td> </tr> </table> diff --git a/site/user/api/catalog.htm b/site/user/api/catalog.htm index 1f6eb77738..9926cf52c8 100644 --- a/site/user/api/catalog.htm +++ b/site/user/api/catalog.htm @@ -4741,6 +4741,14 @@ "file": "SkImage_Reference", "name": "SkImage::MakeCrossContextFromEncoded" }, + "SkImage_MakeCrossContextFromPixmap": { + "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", + "width": 256, + "height": 256, + "hash": "882e8e0103048009a25cfc20400492f7", + "file": "SkImage_Reference", + "name": "SkImage::MakeCrossContextFromPixmap" +}, "SkImage_MakeFromAHardwareBuffer": { "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", "width": 256, @@ -4774,10 +4782,10 @@ "name": "SkImage::MakeFromBitmap" }, "SkImage_MakeFromDeferredTextureImageData": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", + "code": "void draw(SkCanvas* canvas) {\n GrContext* context = canvas->getGrContext();\n if (!context) {\n return;\n }\n sk_sp<GrContextThreadSafeProxy> proxy = context->threadSafeProxy();\n SkImage::DeferredTextureImageUsageParams params = {SkMatrix::I(), kNone_SkFilterQuality, 0};\n size_t size = image->getDeferredTextureImageData(*proxy, ¶ms, 1, nullptr,\n nullptr, kN32_SkColorType);\n void* buffer = sk_malloc_throw(size);\n if (image->getDeferredTextureImageData(*proxy, ¶ms, 1, buffer, nullptr, kN32_SkColorType)) {\n sk_sp<SkImage> newImage(\n SkImage::MakeFromDeferredTextureImageData(context, buffer, SkBudgeted::kNo));\n canvas->drawImage(newImage, 0, 0);\n }\n}", "width": 256, "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "hash": "493c3a7c12d9130532971b2a255d1652", "file": "SkImage_Reference", "name": "SkImage::MakeFromDeferredTextureImageData" }, @@ -6742,10 +6750,10 @@ "name": "SkSurface::MakeRenderTarget" }, "SkSurface_MakeRenderTarget_2": { - "code": "void draw(SkCanvas* canvas) {\n auto test_draw = [](SkCanvas* surfaceCanvas) -> void {\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setLCDRenderText(true);\n paint.setColor(0xFFBBBBBB);\n surfaceCanvas->drawRect(SkRect::MakeWH(128, 64), paint);\n paint.setColor(SK_ColorWHITE);\n paint.setTextSize(32);\n surfaceCanvas->drawString(\"Pest\", 0, 25, paint);\n };\n GrContext* context = canvas->getGrContext();\n SkImageInfo info = SkImageInfo::MakeN32(128, 64, kOpaque_SkAlphaType);\n SkAutoTMalloc<SkPMColor> storage(info.computeMinByteSize());\n SkBitmap bitmap;\n bitmap.installPixels(info, storage.get(), info.minRowBytes());\n int y = 0;\n for (auto geometry : { kRGB_H_SkPixelGeometry, kBGR_H_SkPixelGeometry,\n kRGB_V_SkPixelGeometry, kBGR_V_SkPixelGeometry } ) {\n SkSurfaceProps props(0, geometry);\n std::unique_ptr<SkCanvas> offscreen = SkCanvas::MakeRasterDirect(info, storage.get(),\n info.minRowBytes(), &props);\n sk_sp<SkSurface> surface = context ? SkSurface::MakeRenderTarget(\n context, SkBudgeted::kNo, info, 0, &props) : SkSurface::MakeRaster(info, &props);\n test_draw(surface->getCanvas());\n surface->draw(canvas, 0, y, nullptr);\n surface->draw(offscreen.get(), 0, 0, nullptr);\n SkAutoCanvasRestore acr(canvas, true);\n canvas->scale(8, 8);\n canvas->drawBitmap(bitmap, 12, y / 8);\n y += 64;\n }\n}\n", + "code": "void draw(SkCanvas* canvas) {\n auto test_draw = [](SkCanvas* surfaceCanvas) -> void {\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setLCDRenderText(true);\n paint.setColor(0xFFBBBBBB);\n surfaceCanvas->drawRect(SkRect::MakeWH(128, 64), paint);\n paint.setColor(SK_ColorWHITE);\n paint.setTextSize(32);\n surfaceCanvas->drawString(\"Pest\", 0, 25, paint);\n };\n GrContext* context = canvas->getGrContext();\n SkImageInfo info = SkImageInfo::MakeN32(128, 64, kOpaque_SkAlphaType);\n int y = 0;\n for (auto geometry : { kRGB_H_SkPixelGeometry, kBGR_H_SkPixelGeometry,\n kRGB_V_SkPixelGeometry, kBGR_V_SkPixelGeometry } ) {\n SkSurfaceProps props(0, geometry);\n sk_sp<SkSurface> surface = context ? SkSurface::MakeRenderTarget(\n context, SkBudgeted::kNo, info, 0, &props) : SkSurface::MakeRaster(info, &props);\n test_draw(surface->getCanvas());\n surface->draw(canvas, 0, y, nullptr);\n sk_sp<SkImage> image(surface->makeImageSnapshot());\n SkAutoCanvasRestore acr(canvas, true);\n canvas->scale(8, 8);\n canvas->drawImage(image, 12, y / 8);\n y += 64;\n }\n}\n", "width": 256, "height": 256, - "hash": "4473daad1b11784a9869431af72c93e0", + "hash": "640321e8ecfb3f9329f3bc6e1f02485f", "file": "SkSurface_Reference", "name": "SkSurface::MakeRenderTarget_2" }, diff --git a/tools/bookmaker/bookmaker.h b/tools/bookmaker/bookmaker.h index 8cd128804c..2d0f03cde0 100644 --- a/tools/bookmaker/bookmaker.h +++ b/tools/bookmaker/bookmaker.h @@ -1200,7 +1200,8 @@ public: , { "Return", nullptr, MarkType::kReturn, R_Y, E_N, M(Method) } , { "", nullptr, MarkType::kRoot, R_Y, E_N, 0 } , { "", nullptr, MarkType::kRow, R_Y, E_N, M(Table) | M(List) } -, { "SeeAlso", nullptr, MarkType::kSeeAlso, R_Y, E_N, M_CSST | M_E | M(Method) } +, { "SeeAlso", nullptr, MarkType::kSeeAlso, R_Y, E_N, + M_CSST | M_E | M(Method) | M(Typedef) } , { "StdOut", nullptr, MarkType::kStdOut, R_N, E_N, M(Example) } , { "Struct", &fClassMap, MarkType::kStruct, R_Y, E_O, M(Class) | M(Root) | M_ST } , { "Substitute", nullptr, MarkType::kSubstitute, R_N, E_N, M_ST } diff --git a/tools/bookmaker/includeWriter.cpp b/tools/bookmaker/includeWriter.cpp index c462826f48..8c6d7a938c 100644 --- a/tools/bookmaker/includeWriter.cpp +++ b/tools/bookmaker/includeWriter.cpp @@ -67,9 +67,7 @@ void IncludeWriter::descriptionOut(const Definition* def) { commentStart = prop->fContentStart; commentLen = (int) (prop->fContentEnd - commentStart); if (commentLen > 0) { - if (Wrote::kNone != this->rewriteBlock(commentLen, commentStart, Phrase::kNo)) { - this->lfcr(); - } + this->writeBlockIndent(commentLen, commentStart); } commentStart = prop->fTerminator; commentLen = (int) (def->fContentEnd - commentStart); @@ -913,6 +911,9 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti const Definition* requireDense = nullptr; const Definition* startDef = nullptr; for (auto& child : def->fTokens) { + if (18 == child.fParentIndex) { + SkDebugf(""); + } if (KeyWord::kOperator == child.fKeyWord && method && Definition::MethodType::kOperator == method->fMethodType) { eatOperator = true; @@ -976,34 +977,40 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti continue; } } - if (Definition::Type::kBracket == child.fType && Bracket::kParen == child.fBracket) { - if (!clonedMethod) { - if (inConstructor) { - fContinuation = child.fContentStart; - } + if (Definition::Type::kBracket == child.fType) { + if (Bracket::kAngle == child.fBracket) { continue; } - int alternate = 1; - ptrdiff_t childLen = child.fContentEnd - child.fContentStart; - SkASSERT(')' == child.fContentStart[childLen]); - ++childLen; - do { - TextParser params(clonedMethod->fFileName, clonedMethod->fStart, - clonedMethod->fContentStart, clonedMethod->fLineCount); - params.skipToEndBracket('('); - if (params.startsWith(child.fContentStart, childLen)) { - this->methodOut(clonedMethod, child); - break; + if (Bracket::kParen == child.fBracket) { + if (!clonedMethod) { + if (inConstructor) { + fContinuation = child.fContentStart; + } + continue; } - ++alternate; - string alternateMethod = methodName + '_' + to_string(alternate); - clonedMethod = root->find(alternateMethod, RootDefinition::AllowParens::kNo); - } while (clonedMethod); - if (!clonedMethod) { - return this->reportError<bool>("cloned method not found"); + int alternate = 1; + ptrdiff_t childLen = child.fContentEnd - child.fContentStart; + SkASSERT(')' == child.fContentStart[childLen]); + ++childLen; + do { + TextParser params(clonedMethod->fFileName, clonedMethod->fStart, + clonedMethod->fContentStart, clonedMethod->fLineCount); + params.skipToEndBracket('('); + if (params.startsWith(child.fContentStart, childLen)) { + this->methodOut(clonedMethod, child); + break; + } + ++alternate; + string alternateMethod = methodName + '_' + to_string(alternate); + clonedMethod = root->find(alternateMethod, + RootDefinition::AllowParens::kNo); + } while (clonedMethod); + if (!clonedMethod) { + return this->reportError<bool>("cloned method not found"); + } + clonedMethod = nullptr; + continue; } - clonedMethod = nullptr; - continue; } if (Definition::Type::kWord == child.fType) { if (clonedMethod) { |