diff options
author | Cary Clark <caryclark@skia.org> | 2017-12-11 16:03:17 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-11 21:47:38 +0000 |
commit | 2f466242c7289b246d7ef665aa50006cfd11aa36 (patch) | |
tree | f41d3ac2559c624a132fa74e3334ccbc5cfd1ceb | |
parent | bb091a08d1c60ccf3d014d94490c5b4134586ee2 (diff) |
working on image and nightly housekeeping bot
Add more examples and docs for SkImage; still a ways to go.
Fix bit-rotted examples.
Add typedef support.
Add json driver to pick files to work on; remove special-casing.
Fix unordered map traversal that made md output unreliable.
TBR=rmistry@google.com
Docs-Preview: https://skia.org/?cl=80060
Bug: skia:6898
Change-Id: Ib8eb9fdfa5a9db61c8332e657fa2e2f4b96a665f
Reviewed-on: https://skia-review.googlesource.com/80060
Reviewed-by: Cary Clark <caryclark@skia.org>
Commit-Queue: Cary Clark <caryclark@skia.org>
-rw-r--r-- | BUILD.gn | 1 | ||||
-rw-r--r-- | docs/SkBitmap_Reference.bmh | 32 | ||||
-rw-r--r-- | docs/SkCanvas_Reference.bmh | 98 | ||||
-rw-r--r-- | docs/SkImage_Reference.bmh | 343 | ||||
-rw-r--r-- | docs/SkSurface_Reference.bmh | 10 | ||||
-rw-r--r-- | docs/status.json | 44 | ||||
-rw-r--r-- | docs/undocumented.bmh | 7 | ||||
-rw-r--r-- | site/user/api/SkBitmap_Reference.md | 2 | ||||
-rw-r--r-- | site/user/api/SkCanvas_Reference.md | 66 | ||||
-rw-r--r-- | site/user/api/SkIPoint_Reference.md | 3 | ||||
-rw-r--r-- | site/user/api/SkImage_Reference.md | 315 | ||||
-rw-r--r-- | site/user/api/SkPaint_Reference.md | 2 | ||||
-rw-r--r-- | site/user/api/SkSurface_Reference.md | 28 | ||||
-rw-r--r-- | site/user/api/catalog.htm | 76 | ||||
-rw-r--r-- | site/user/api/undocumented.md | 60 | ||||
-rw-r--r-- | tools/bookmaker/bookmaker.cpp | 263 | ||||
-rw-r--r-- | tools/bookmaker/bookmaker.h | 51 | ||||
-rw-r--r-- | tools/bookmaker/cataloger.cpp | 11 | ||||
-rw-r--r-- | tools/bookmaker/definition.cpp | 12 | ||||
-rw-r--r-- | tools/bookmaker/includeParser.cpp | 43 | ||||
-rw-r--r-- | tools/bookmaker/includeWriter.cpp | 13 | ||||
-rw-r--r-- | tools/bookmaker/mdOut.cpp | 42 | ||||
-rw-r--r-- | tools/bookmaker/parserCommon.cpp | 119 | ||||
-rw-r--r-- | tools/bookmaker/spellCheck.cpp | 8 |
24 files changed, 877 insertions, 772 deletions
@@ -1395,6 +1395,7 @@ if (skia_enable_tools) { ":flags", ":skia", ":tool_utils", + "//third_party/jsoncpp", ] } diff --git a/docs/SkBitmap_Reference.bmh b/docs/SkBitmap_Reference.bmh index 6f65688d2d..4e0525e85f 100644 --- a/docs/SkBitmap_Reference.bmh +++ b/docs/SkBitmap_Reference.bmh @@ -85,14 +85,14 @@ is useful to position one or more Bitmaps within a shared pixel array. # allocPixels # Allocates pixels from Image_Info, or aborts. ## # allocPixelsFlags # Allocates pixels from Image_Info with options, or aborts. ## # alphaType # Returns Image_Info Alpha_Type. ## -# bounds() # Returns width and height as Rectangle. ## +# bounds() # Returns width() and height() as Rectangle. ## # bytesPerPixel # Returns number of bytes in pixel based on Color_Type. ## # colorSpace # Returns Image_Info Color_Space. ## # colorType # Returns Image_Info Color_Type. ## # computeByteSize # Returns size required for pixels. ## -# dimensions # Returns width and height. ## -# drawsNothing # Returns true if no width, no height, or no Pixel_Ref. ## -# empty() # Returns true if Image_Info has zero width or height. ## +# dimensions() # Returns width() and height(). ## +# drawsNothing # Returns true if no width(), no height(), or no Pixel_Ref. ## +# empty() # Returns true if Image_Info has zero width() or height(). ## # erase() # Writes Color to rectangle of pixels. ## # eraseARGB # Writes Color to pixels. ## # eraseArea # Deprecated ## @@ -104,7 +104,7 @@ is useful to position one or more Bitmaps within a shared pixel array. # getAddr16 # Returns readable pixel address as 16-bit pointer. ## # getAddr32 # Returns readable pixel address as 32-bit pointer. ## # getAddr8 # Returns readable pixel address as 8-bit pointer. ## -# getBounds # Returns width and height as Rectangle. ## +# getBounds # Returns width() and height() as Rectangle. ## # getColor # Returns one pixel as Unpremultiplied Color. ## # getGenerationID # Returns unique ID. ## # getPixels # Returns address of pixels. ## @@ -583,7 +583,7 @@ Returns Color_Space, the range of colors, associated with Image_Info. The reference count of Color_Space is unchanged. The returned Color_Space is immutable. -#Return Color_Space in Image_Info ## +#Return Color_Space in Image_Info, or nullptr ## #Example #Description @@ -3387,16 +3387,16 @@ pixmap contents become invalid on any future change to Bitmap. } } #StdOut -------
--xxx--
-x---x-
-----x-
----x--
---x---
---x---
-------
---x---
---x---
+------ +-xxx-- +x---x- +----x- +---x-- +--x--- +--x--- +------ +--x--- +--x--- ------ #StdOut ## ## diff --git a/docs/SkCanvas_Reference.bmh b/docs/SkCanvas_Reference.bmh index b2c70f5477..8979b87581 100644 --- a/docs/SkCanvas_Reference.bmh +++ b/docs/SkCanvas_Reference.bmh @@ -4711,14 +4711,15 @@ void draw(SkCanvas* canvas) { #Code struct Lattice { - enum Flags {... - - const int* fXDivs; - const int* fYDivs; - const Flags* fFlags; - int fXCount; - int fYCount; - const SkIRect* fBounds; + enum RectType ... + + const int* fXDivs; + const int* fYDivs; + const RectType* fRectTypes; + int fXCount; + int fYCount; + const SkIRect* fBounds; + const SkColor* fColors; }; ## @@ -4730,17 +4731,28 @@ void draw(SkCanvas* canvas) { The grid entries not on even columns and rows are scaled to fit the remaining space, if any. - #Enum Flags + #Enum RectType #Code - enum Flags : uint8_t { - kTransparent_Flags = 1 << 0, + enum RectType : uint8_t { + kDefault = 0, + kTransparent, + kFixedColor, }; ## - Optional setting per rectangular grid entry to make it transparent. + Optional setting per rectangular grid entry to make it transparent, + or to fill the grid entry with a color. - #Const kTransparent_Flags 1 - Set to skip lattice rectangle by making it transparent. + #Const kDefault 0 + Draws Bitmap into lattice rectangle. + ## + + #Const kTransparent 1 + Skips lattice rectangle by making it transparent. + ## + + #Const kFixedColor 2 + Draws one of fColors into lattice rectangle. ## ## @@ -4760,14 +4772,16 @@ void draw(SkCanvas* canvas) { grid entries. ## - #Member const Flags* fFlags - Optional array of Flags, one per rectangular grid entry: + #Member const RectType* fRectTypes + Optional array of fill types, one per rectangular grid entry: array length must be #Formula (fXCount + 1) * (fYCount + 1) ## . + Each RectType is one of: kDefault, kTransparent, kFixedColor. + Array entries correspond to the rectangular grid entries, ascending left to right and then top to bottom. ## @@ -4787,6 +4801,18 @@ void draw(SkCanvas* canvas) { If nullptr, source bounds is dimensions of Bitmap or Image. ## + #Member const SkColor* fColors + Optional array of colors, one per rectangular grid entry. + Array length must be + #Formula + (fXCount + 1) * (fYCount + 1) + ## + . + + Array entries correspond to the rectangular grid entries, ascending + left to right, then top to bottom. + ## + #Struct Lattice ## #Method void drawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattice, const SkRect& dst, @@ -5329,26 +5355,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);
+ 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();
+ 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); } ## @@ -5390,7 +5416,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);
+ 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 22ba343b64..d0cb2fa0d8 100644 --- a/docs/SkImage_Reference.bmh +++ b/docs/SkImage_Reference.bmh @@ -25,15 +25,6 @@ are zero, then nullptr will be returned. #Table ## ## -#Subtopic Structs -#Table -#Legend -# description # struct ## -#Legend ## -# DeferredTextureImageUsageParams # ## -#Table ## -#Subtopic ## - #Subtopic Member_Functions #Table #Legend @@ -44,7 +35,6 @@ are zero, then nullptr will be returned. # 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. ## @@ -55,79 +45,38 @@ are zero, then nullptr will be returned. # 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 # ## -# encodeToData # ## -# getDeferredTextureImageData # ## -# getTexture # ## -# getTextureHandle # ## -# height # ## -# isAlphaOnly # ## -# isLazyGenerated # ## -# isOpaque # ## -# isTextureBacked # ## -# isValid # ## -# makeColorSpace # ## -# makeNonTextureImage # ## -# makeShader # ## -# makeSubset # ## -# makeTextureImage # ## -# makeWithFilter # ## -# peekPixels # ## -# readPixels # ## -# refColorSpace # ## -# refEncodedData # ## -# scalePixels # ## -# toString # ## -# uniqueID # ## -# width # ## +# asLegacyBitmap # Returns as Raster_Bitmap ## +# bounds() # Returns width() and height() as Rectangle. ## +# colorSpace # Returns Color_Space. ## +# dimensions() # Returns width() and height(). ## +# encodeToData # Returns encoded Image as SkData. ## +# getTexture # Deprecated. ## +# getTextureHandle # Returns GPU reference to Image as texture. ## +# height() # Returns pixel row count. ## +# isAlphaOnly # Returns if pixels represent a transparency mask. ## +# isLazyGenerated # Returns if Image is created as needed. ## +# isOpaque # Returns if Alpha_Type is kOpaque_SkAlphaType. ## +# isTextureBacked # Returns if Image was created from GPU texture. ## +# isValid # Returns if Image can draw to Raster_Surface or GPU_Context. ## +# makeColorSpace # Creates Image matching Color_Space if possible. ## +# makeNonTextureImage # Creates Raster_Image if possible. ## +# makeShader # Creates Shader, Paint element that can tile Image. ## +# makeSubset # Creates Image containing part of original. ## +# makeTextureImage # Creates Image matching Color_Space if possible. ## +# makeWithFilter # Creates filtered, clipped Image. ## +# peekPixels # Returns Pixmap if possible. ## +# readPixels # Copies and converts pixels. ## +# refColorSpace # Returns Image_Info Color_Space. ## +# refEncodedData # Returns Image encoded in SkData if present. ## +# scalePixels # Scales and converts one Image to another. ## +# toString # Converts Image to machine readable form. ## +# uniqueID # Identifier for Image. ## +# width() # Returns pixel column count. ## #Table ## #Subtopic ## #Topic ## -# ------------------------------------------------------------------------------ - -#Struct DeferredTextureImageUsageParams - -#Code -#ToDo fill this in manually ## -## - -Drawing parameters for which a deferred texture image data should be optimized. */ - -# ------------------------------------------------------------------------------ - -#Method DeferredTextureImageUsageParams(const SkMatrix matrix, const SkFilterQuality quality, - int preScaleMipLevel) - -#Param matrix incomplete ## -#Param quality incomplete ## -#Param preScaleMipLevel incomplete ## - -#Return incomplete ## - -#Example -// incomplete -## - -#SeeAlso incomplete - -#Method ## - -#Member SkMatrix fMatrix -## - -#Member SkFilterQuality fQuality -## - -#Member int fPreScaleMipLevel -## - -#Struct DeferredTextureImageUsageParams ## - #Typedef SkImageInfo Info ## @@ -136,7 +85,8 @@ Drawing parameters for which a deferred texture image data should be optimized. #Method static sk_sp<SkImage> MakeRasterCopy(const SkPixmap& pixmap) -Creates Image from Pixmap and copy of pixels. +Creates Image from Pixmap and copy of pixels. Since pixels are copied, Pixmap +pixels may be modified or deleted without affecting Image. Image is returned if Pixmap is valid. Valid Pixmap parameters include: dimensions are greater than zero; @@ -150,7 +100,26 @@ pixel address is not nullptr. #Return copy of Pixmap pixels, or nullptr ## #Example -// incomplete +#Height 50 +#Description +Draw a five by five bitmap, and draw a copy in an Image. Editing the pixmap +alters the bitmap draw, but does not alter the Image draw since the Image +contains a copy of the pixels. +## + uint8_t storage[][5] = {{ 0xCA, 0xDA, 0xCA, 0xC9, 0xA3 }, + { 0xAC, 0xA8, 0x89, 0xA7, 0x87 }, + { 0x9B, 0xB5, 0xE5, 0x95, 0x46 }, + { 0x90, 0x81, 0xC5, 0x71, 0x33 }, + { 0x75, 0x55, 0x44, 0x40, 0x30 }}; + SkImageInfo imageInfo = SkImageInfo::Make(5, 5, kGray_8_SkColorType, kOpaque_SkAlphaType); + SkPixmap pixmap(imageInfo, storage[0], sizeof(storage) / 5); + SkBitmap bitmap; + bitmap.installPixels(pixmap); + sk_sp<SkImage> image = SkImage::MakeRasterCopy(pixmap); + *pixmap.writable_addr8(2, 2) = 0x00; + canvas->scale(10, 10); + canvas->drawBitmap(bitmap, 0, 0); + canvas->drawImage(image, 10, 0); ## #SeeAlso MakeRasterData MakeFromGenerator @@ -664,6 +633,8 @@ The new image takes a reference on the buffer. #Method int height() const +Returns pixel row count. + #Return incomplete ## #Example @@ -678,13 +649,15 @@ The new image takes a reference on the buffer. #Method SkISize dimensions() const -#Return incomplete ## +Returns ISize { width(), height() }. + +#Return integral size of width() and height() ## #Example // incomplete ## -#SeeAlso incomplete +#SeeAlso height() width() #Method ## @@ -692,7 +665,9 @@ The new image takes a reference on the buffer. #Method SkIRect bounds() const -#Return incomplete ## +Returns IRect { 0, 0, width(), height() }. + +#Return integral rectangle from origin to width() and height() ## #Example // incomplete @@ -734,12 +709,15 @@ The new image takes a reference on the buffer. #Method SkColorSpace* colorSpace() const -Returns Color_Space of Image. Color_Space may have been a parameter when -Image was created, or may have been parsed from encoded data. Skia may not be -able to draw image respecting returned Color_Space or draw into Surface with -returned Color_Space. +Returns Color_Space, the range of colors, associated with Image. The +reference count of Color_Space is unchanged. The returned Color_Space is +immutable. + +Color_Space returned was a parameter to an Image constructor, +or was parsed from encoded data. Color_Space may be ignored when +drawing Image, and when drawing into Surface constructed with Color_Space. -#Return Color_Space Image was created with, or nullptr ## +#Return Color_Space in Image, or nullptr ## #Example // incomplete @@ -767,9 +745,10 @@ returned Color_Space. #Method bool isAlphaOnly() const -Returns true fi the image will be drawn as a mask, with no intrinsic color of its own. +Returns true if Image pixels represent transparency only. If true, each pixel +is packed in 8 bits as defined by kAlpha_8_SkColorType. -#Return incomplete ## +#Return true if pixels represent a transparency mask ## #Example // incomplete @@ -783,7 +762,9 @@ Returns true fi the image will be drawn as a mask, with no intrinsic color of it #Method bool isOpaque() const -#Return incomplete ## +Returns if all pixels ignore any Alpha value and are treated as fully opaque. + +#Return true if Alpha_Type is kOpaque_SkAlphaType ## #Example // incomplete @@ -855,19 +836,15 @@ On failure, return false and ignore the pixmap parameter. #Method GrTexture* getTexture() const -DEPRECATED - -#Private -currently used by Canvas2DLayerBridge in Chromium. +Deprecated. + +#Deprecated ## -#Return incomplete ## - -#Example -// incomplete +#Private +currently used by Canvas2DLayerBridge in Chromium. ## -#SeeAlso incomplete - #Method ## # ------------------------------------------------------------------------------ @@ -914,19 +891,39 @@ generator-backed images may be invalid for CPU and/or GPU. #Method GrBackendObject getTextureHandle(bool flushPendingGrContextIO, GrSurfaceOrigin* origin = nullptr) const -Retrieves the back-end API handle of the texture. If flushPendingGrContextIO then the -GrContext will issue to the back-end API any deferred I/O operations on the texture before -returning. -If 'origin' is supplied it will be filled in with the origin of the content drawn -into the image. +Retrieves the back-end API handle of texture. If flushPendingGrContextIO is true, +complete deferred I/O operations. -#Param flushPendingGrContextIO incomplete ## -#Param origin incomplete ## +If origin in not nullptr, copies location of content drawn into Image. -#Return incomplete ## +#Param flushPendingGrContextIO flag to flush outstanding requests ## +#Param origin storage for one of: kTopLeft_GrSurfaceOrigin, + kBottomLeft_GrSurfaceOrigin; or nullptr +## + +#Return back-end API texture handle ## #Example -// incomplete +#Image 3 +#Platform gpu +GrContext* context = canvas->getGrContext(); +if (!context) { + return; +} +SkPaint paint; +paint.setAntiAlias(true); +SkString str; +int y = 0; +for (auto origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin } ) { + sk_sp<SkImage> srcImage(SkImage::MakeFromTexture(context, + backEndTexture, origin, kPremul_SkAlphaType, nullptr)); + GrSurfaceOrigin readBackOrigin; + GrBackendObject readBackHandle = srcImage->getTextureHandle(false, &readBackOrigin); + str.printf("readBackHandle: %x", readBackHandle); + canvas->drawString(str, 5, y += 20, paint); + str.printf("origin: k%s_GrSurfaceOrigin", readBackOrigin ? "BottomLeft" : "TopLeft"); + canvas->drawString(str, 5, y += 20, paint); +} ## #SeeAlso incomplete @@ -1048,14 +1045,14 @@ filterQuality. #Method sk_sp<SkData> encodeToData(SkEncodedImageFormat encodedImageFormat, int quality) const -Encode the image's pixels and return the result as SkData. -If the image type cannot be encoded, or the requested encoder format is -not supported, this will return nullptr. +Encodes Image pixels, returning result as SkData. + +Returns nullptr if encoding fails, or encodedImageFormat is not supported. #Param encodedImageFormat incomplete ## #Param quality incomplete ## -#Return incomplete ## +#Return encoded Image, or nullptr ## #Example // incomplete @@ -1221,94 +1218,6 @@ caller. # ------------------------------------------------------------------------------ -#Method size_t getDeferredTextureImageData(const GrContextThreadSafeProxy& contextThreadSafeProxy, - const DeferredTextureImageUsageParams deferredTextureImageUsageParams[], - int paramCnt, - void* buffer, - SkColorSpace* dstColorSpace = nullptr, - SkColorType dstColorType = kN32_SkColorType) const - -This method allows clients to capture the data necessary to turn a SkImage into a texture- -backed image. If the original image is codec-backed this will decode into a format optimized -for the context represented by the proxy. This method is thread safe with respect to the -GrContext whence the proxy came. Clients allocate and manage the storage of the deferred -texture data and control its lifetime. No cleanup is required, thus it is safe to simply free -the memory out from under the data. - -The same method is used both for getting the size necessary for uploading -and retrieving texture data. The deferredTextureImageUsageParams array represents the set of -draws over which to optimize the texture data prior to uploading. - -When called with a null buffer this returns the size that the client must allocate in order -to create deferred texture data for this image (or zero if this is an inappropriate -candidate). The buffer allocated by the client should be 8 byte aligned. -When buffer is not null this fills in the deferred texture data for this image in the -provided buffer (assuming this is an appropriate candidate image and the buffer is -appropriately aligned). Upon success the size written is returned, otherwise 0. -dstColorSpace is the color space of the surface where this texture will ultimately be used. -If the method determines that Mip_Maps are needed, this helps determine the correct strategy -for building them (gamma-correct or not). - -dstColorType is the color type of the surface where this texture will ultimately be used. -This determines the format with which the image will be uploaded to the GPU. If dstColorType -does not support color spaces (low bit depth types such as kARGB_4444_SkColorType), then dstColorSpace -must be null. - -#Param contextThreadSafeProxy incomplete ## -#Param deferredTextureImageUsageParams incomplete ## -#Param paramCnt incomplete ## -#Param buffer incomplete ## -#Param dstColorSpace incomplete ## -#Param dstColorType incomplete ## - -#Return incomplete ## - -#Example -// incomplete -## - -#SeeAlso incomplete - -#Method ## - -# ------------------------------------------------------------------------------ - -#Method static sk_sp<SkImage> MakeFromDeferredTextureImageData(GrContext* context, const void* data, - SkBudgeted budgeted) - -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 GPU_Context ## -#Param data buffer filled by getDeferredTextureImageData ## -#Param budgeted one of: SkBudgeted::kNo, SkBudgeted::kYes ## - -#Return incomplete ## - -#Example -#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 - -#Method ## - #Typedef std::function<void(GrBackendTexture)> BackendTextureReleaseProc ## @@ -1404,10 +1313,38 @@ write did not succeed. Returns true if Image is backed by an image-generator or other service that creates and caches its pixels or texture on-demand. -#Return incomplete ## +#Return true if Image is created as needed ## #Example -// incomplete +#Height 80 +#Function +class TestImageGenerator : public SkImageGenerator { +public: + TestImageGenerator() : SkImageGenerator(SkImageInfo::MakeN32Premul(10, 10)) {} + ~TestImageGenerator() override {} +protected: + bool onGetPixels(const SkImageInfo& info, void* pixelPtr, size_t rowBytes, + const Options& options) override { + SkPMColor* pixels = static_cast<SkPMColor*>(pixelPtr); + for (int y = 0; y < info.height(); ++y) { + for (int x = 0; x < info.width(); ++x) { + pixels[y * info.width() + x] = 0xff223344 + y * 0x000C0811; + } + } + return true; + } +}; +## +void draw(SkCanvas* canvas) { + auto gen = std::unique_ptr<TestImageGenerator>(new TestImageGenerator()); + sk_sp<SkImage> image(SkImage::MakeFromGenerator(std::move(gen))); + SkString lazy(image->isLazyGenerated() ? "is lazy" : "not lazy"); + canvas->scale(8, 8); + canvas->drawImage(image, 0, 0, nullptr); + SkPaint paint; + paint.setTextSize(4); + canvas->drawString(lazy, 2, 5, paint); +} ## #SeeAlso incomplete diff --git a/docs/SkSurface_Reference.bmh b/docs/SkSurface_Reference.bmh index f13134fa46..acbc191bfd 100644 --- a/docs/SkSurface_Reference.bmh +++ b/docs/SkSurface_Reference.bmh @@ -1558,14 +1558,18 @@ Return true if Surface supports characterization. Raster_Surface returns false. # ------------------------------------------------------------------------------ -#Method void draw(SkDeferredDisplayList* deferredDisplayList) +#Method bool draw(SkDeferredDisplayList* deferredDisplayList) Draws deferred display list created using SkDeferredDisplayListRecorder. -The draw has no effect if Surface_Characterization stored in deferredDisplayList -is not compatible with Surface. +Has no effect and returns false if Surface_Characterization stored in +deferredDisplayList is not compatible with Surface. + +Raster_Surface returns false. #Param deferredDisplayList drawing commands ## +#Return false if deferredDisplayList is not compatible ## + #Example #Height 64 #Platform gpu cpu diff --git a/docs/status.json b/docs/status.json new file mode 100644 index 0000000000..43be98cdf3 --- /dev/null +++ b/docs/status.json @@ -0,0 +1,44 @@ +{
+ "Completed": {
+ "include": {
+ "core": [
+ "SkBitmap.h",
+ "SkCanvas.h",
+ "SkMatrix.h",
+ "SkPaint.h",
+ "SkPath.h",
+ "SkPixmap.h",
+ "SkPoint.h",
+ "SkRect.h",
+ "SkSurface.h"
+ ]
+ },
+ "docs": [
+ "SkCanvas_Reference.bmh",
+ "SkIPoint16_Reference.bmh",
+ "SkPaint_Reference.bmh",
+ "SkPoint_Reference.bmh",
+ "SkIRect_Reference.bmh",
+ "SkPath_Reference.bmh",
+ "SkRect_Reference.bmh",
+ "SkBitmap_Reference.bmh",
+ "SkIPoint_Reference.bmh",
+ "SkMatrix_Reference.bmh",
+ "SkPixmap_Reference.bmh",
+ "SkSurface_Reference.bmh",
+ "undocumented.bmh"
+ ]
+ },
+ "InProgress": {
+ "include": {
+ "core": [
+ "SkImage.h"
+ ]
+ },
+ "docs": [
+ "SkImage_Reference.bmh",
+ "overview.bmh",
+ "usingBookmaker.bmh"
+ ]
+ }
+}
diff --git a/docs/undocumented.bmh b/docs/undocumented.bmh index 014251258f..b6987528e2 100644 --- a/docs/undocumented.bmh +++ b/docs/undocumented.bmh @@ -474,7 +474,6 @@ FT_Load_Glyph ## #Topic Mip_Map -#Alias Mip_Maps ## #Topic Nine_Patch @@ -636,6 +635,12 @@ FT_Load_Glyph ## ## +#Topic Raster_Bitmap +## + +#Topic Raster_Image +## + #Topic Raster_Surface ## diff --git a/site/user/api/SkBitmap_Reference.md b/site/user/api/SkBitmap_Reference.md index e3c194bc43..bf0d99dda3 100644 --- a/site/user/api/SkBitmap_Reference.md +++ b/site/user/api/SkBitmap_Reference.md @@ -654,7 +654,7 @@ immutable. ### Return Value -<a href="undocumented#Color_Space">Color Space</a> in <a href="undocumented#Image_Info">Image Info</a> +<a href="undocumented#Color_Space">Color Space</a> in <a href="undocumented#Image_Info">Image Info</a>, or nullptr ### Example diff --git a/site/user/api/SkCanvas_Reference.md b/site/user/api/SkCanvas_Reference.md index 0ef379e3e0..2ac3e730e3 100644 --- a/site/user/api/SkCanvas_Reference.md +++ b/site/user/api/SkCanvas_Reference.md @@ -36,9 +36,9 @@ This approach may be deprecated in the future. | constants | description | | --- | --- | -| <a href="#SkCanvas_Lattice_Flags">Lattice::Flags</a> | Controls <a href="#SkCanvas_Lattice">Lattice</a> transparency. | +| Lattice::Flags | Controls <a href="#SkCanvas_Lattice">Lattice</a> transparency. | | <a href="#SkCanvas_PointMode">PointMode</a> | Sets <a href="#SkCanvas_drawPoints">drawPoints</a> options. | -| SaveLayerFlags | Sets <a href="#SkCanvas_SaveLayerRec">SaveLayerRec</a> options. | +| <a href="#SkCanvas_SaveLayerFlags">SaveLayerFlags</a> | Sets <a href="#SkCanvas_SaveLayerRec">SaveLayerRec</a> options. | | <a href="#SkCanvas_SrcRectConstraint">SrcRectConstraint</a> | Sets <a href="#SkCanvas_drawImageRect">drawImageRect</a> options. | ## <a name="Structs"></a> Structs @@ -385,7 +385,8 @@ specifies a <a href="#SkCanvas_copy_SkBaseDevice_star_device">device</a> for the ### Example -<div><fiddle-embed name=""></fiddle-embed></div> +<pre style="padding: 1em 1em 1em 1em; font-size: 13px width: 62.5em; background-color: #f0f0f0"> +void draw(SkCanvas* canvas) {</fiddle-embed></div> ### See Also @@ -686,7 +687,8 @@ operations are never deferred. ### Example -<div><fiddle-embed name=""></fiddle-embed></div> +<pre style="padding: 1em 1em 1em 1em; font-size: 13px width: 62.5em; background-color: #f0f0f0"> +void draw(SkCanvas* canvas) {</fiddle-embed></div> ### See Also @@ -1657,7 +1659,7 @@ enum { <a href="#SkCanvas_kDontClipToLayer_Legacy_SaveLayerFlag">kDontClipToLayer Legacy SaveLayerFlag</a> = kDontClipToLayer_PrivateSaveLayerFlag, };</pre> -SaveLayerFlags provides options that may be used in any combination in <a href="#SkCanvas_SaveLayerRec">SaveLayerRec</a>, +<a href="#SkCanvas_SaveLayerFlags">SaveLayerFlags</a> provides options that may be used in any combination in <a href="#SkCanvas_SaveLayerRec">SaveLayerRec</a>, defining how <a href="#Layer">Layer</a> allocated by <a href="#SkCanvas_saveLayer">saveLayer</a> operates. ### Constants @@ -1700,7 +1702,7 @@ struct <a href="#SkCanvas_SaveLayerRec_SaveLayerRec">SaveLayerRec</a> { const <a href="SkRect_Reference#SkRect">SkRect</a>* <a href="#SkCanvas_SaveLayerRec_fBounds">fBounds</a>; const <a href="SkPaint_Reference#SkPaint">SkPaint</a>* <a href="#SkCanvas_SaveLayerRec_fPaint">fPaint</a>; const <a href="undocumented#SkImageFilter">SkImageFilter</a>* <a href="#SkCanvas_SaveLayerRec_fBackdrop">fBackdrop</a>; -<a href="#SkCanvas_SaveLayerRec_fSaveLayerFlags">fSaveLayerFlags</a>; +<a href="#SkCanvas_SaveLayerFlags">SaveLayerFlags</a> <a href="#SkCanvas_SaveLayerRec_fSaveLayerFlags">fSaveLayerFlags</a>; };</pre> <a href="#SkCanvas_SaveLayerRec_SaveLayerRec">SaveLayerRec</a> contains the state used to create the <a href="#Layer">Layer</a>. @@ -1931,7 +1933,7 @@ depth of <a href="#SkCanvas_save">save</a> state stack ### Example -<div><fiddle-embed name="0da8c199f1d9ec4d1b9c5d1114d6cbd6"><div>The example draws an image, and saves it into a <a href="#Layer">Layer</a> with <a href="#SkCanvas_kInitWithPrevious_SaveLayerFlag">kInitWithPrevious SaveLayerFlag</a>. +<div><fiddle-embed name="7d3751e82d1b6ec328ffa3d6f48ca831"><div>The example draws an image, and saves it into a <a href="#Layer">Layer</a> with <a href="#SkCanvas_kInitWithPrevious_SaveLayerFlag">kInitWithPrevious SaveLayerFlag</a>. Next it punches a hole in <a href="#Layer">Layer</a> and <a href="#SkCanvas_restore">restore</a> with <a href="#SkBlendMode_kPlus">SkBlendMode::kPlus</a>. Where <a href="#Layer">Layer</a> was cleared, the original image will draw unchanged. Outside of the circle the mandrill is brightened.</div></fiddle-embed></div> @@ -4356,14 +4358,15 @@ and below <a href="#SkCanvas_drawBitmapNine_center">center</a> to fill the remai <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> struct <a href="#SkCanvas_Lattice">Lattice</a> { -enum <a href="#SkCanvas_Lattice_Flags">Flags</a> {... - -const int* <a href="#SkCanvas_Lattice_fXDivs">fXDivs</a>; -const int* <a href="#SkCanvas_Lattice_fYDivs">fYDivs</a>; -const <a href="#SkCanvas_Lattice_Flags">Flags</a>* <a href="#SkCanvas_Lattice_fFlags">fFlags</a>; -int <a href="#SkCanvas_Lattice_fXCount">fXCount</a>; -int <a href="#SkCanvas_Lattice_fYCount">fYCount</a>; -const <a href="SkIRect_Reference#SkIRect">SkIRect</a>* <a href="#SkCanvas_Lattice_fBounds">fBounds</a>; +enum <a href="#SkCanvas_Lattice_RectType">RectType</a> ... + +const int* <a href="#SkCanvas_Lattice_fXDivs">fXDivs</a>; +const int* <a href="#SkCanvas_Lattice_fYDivs">fYDivs</a>; +const <a href="#SkCanvas_Lattice_RectType">RectType</a>* <a href="#SkCanvas_Lattice_fRectTypes">fRectTypes</a>; +int <a href="#SkCanvas_Lattice_fXCount">fXCount</a>; +int <a href="#SkCanvas_Lattice_fYCount">fYCount</a>; +const <a href="SkIRect_Reference#SkIRect">SkIRect</a>* <a href="#SkCanvas_Lattice_fBounds">fBounds</a>; +const <a href="undocumented#SkColor">SkColor</a>* <a href="#SkCanvas_Lattice_fColors">fColors</a>; };</pre> <a href="#SkCanvas_Lattice">Lattice</a> divides <a href="SkBitmap_Reference#Bitmap">Bitmap</a> or <a href="SkImage_Reference#Image">Image</a> into a rectangular grid. @@ -4374,20 +4377,29 @@ entries are proportionately scaled down to fit. The grid entries not on even columns and rows are scaled to fit the remaining space, if any. -## <a name="SkCanvas_Lattice_Flags"></a> Enum SkCanvas::Lattice::Flags +## <a name="SkCanvas_Lattice_RectType"></a> Enum SkCanvas::Lattice::RectType <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> -enum <a href="#SkCanvas_Lattice_Flags">Flags</a> : uint8_t { -<a href="#SkCanvas_Lattice_kTransparent_Flags">kTransparent Flags</a> = 1 << 0, +enum <a href="#SkCanvas_Lattice_RectType">RectType</a> : uint8_t { +<a href="#SkCanvas_Lattice_kDefault">kDefault</a> = 0, +<a href="#SkCanvas_Lattice_kTransparent">kTransparent</a>, +<a href="#SkCanvas_Lattice_kFixedColor">kFixedColor</a>, };</pre> -Optional setting per rectangular grid entry to make it transparent. +Optional setting per rectangular grid entry to make it transparent, +or to fill the grid entry with a color. ### Constants <table> <tr> - <td><a name="SkCanvas_Lattice_kTransparent_Flags"> <code><strong>SkCanvas::Lattice::kTransparent_Flags </strong></code> </a></td><td>1</td><td>Set to skip lattice rectangle by making it transparent.</td> + <td><a name="SkCanvas_Lattice_kDefault"> <code><strong>SkCanvas::Lattice::kDefault </strong></code> </a></td><td>0</td><td>Draws <a href="SkBitmap_Reference#Bitmap">Bitmap</a> into lattice rectangle.</td> + </tr> + <tr> + <td><a name="SkCanvas_Lattice_kTransparent"> <code><strong>SkCanvas::Lattice::kTransparent </strong></code> </a></td><td>1</td><td>Skips lattice rectangle by making it transparent.</td> + </tr> + <tr> + <td><a name="SkCanvas_Lattice_kFixedColor"> <code><strong>SkCanvas::Lattice::kFixedColor </strong></code> </a></td><td>2</td><td>Draws one of <a href="#SkCanvas_Lattice_fColors">fColors</a> into lattice rectangle.</td> </tr> </table> @@ -4408,11 +4420,13 @@ Array entries must be unique, increasing, greater than or equal to Set the first element to <a href="#SkCanvas_Lattice_fBounds">fBounds</a> top to collapse the top row of fixed grid entries. -<a name="SkCanvas_Lattice_fFlags"> <code><strong>const Flags* fFlags</strong></code> </a> +<a name="SkCanvas_Lattice_fRectTypes"> <code><strong>const RectType* fRectTypes</strong></code> </a> -Optional array of <a href="#SkCanvas_Lattice_Flags">Flags</a>, one per rectangular grid entry: +Optional array of fill types, one per rectangular grid entry: array length must be( <a href="#SkCanvas_Lattice_fXCount">fXCount</a> + 1) * (<a href="#SkCanvas_Lattice_fYCount">fYCount</a> + 1). +Each <a href="#SkCanvas_Lattice_RectType">RectType</a> is one of: <a href="#SkCanvas_Lattice_kDefault">kDefault</a>, <a href="#SkCanvas_Lattice_kTransparent">kTransparent</a>, <a href="#SkCanvas_Lattice_kFixedColor">kFixedColor</a>. + Array entries correspond to the rectangular grid entries, ascending left to right and then top to bottom. @@ -4431,6 +4445,14 @@ divisions. Optional subset <a href="SkIRect_Reference#IRect">IRect</a> source to draw from. If nullptr, source bounds is dimensions of <a href="SkBitmap_Reference#Bitmap">Bitmap</a> or <a href="SkImage_Reference#Image">Image</a>. +<a name="SkCanvas_Lattice_fColors"> <code><strong>const SkColor* fColors</strong></code> </a> + +Optional array of colors, one per rectangular grid entry. +Array length must be( <a href="#SkCanvas_Lattice_fXCount">fXCount</a> + 1) * (<a href="#SkCanvas_Lattice_fYCount">fYCount</a> + 1). + +Array entries correspond to the rectangular grid entries, ascending +left to right, then top to bottom. + <a name="SkCanvas_drawBitmapLattice"></a> ## drawBitmapLattice diff --git a/site/user/api/SkIPoint_Reference.md b/site/user/api/SkIPoint_Reference.md index 210104c7bb..fa55436ecc 100644 --- a/site/user/api/SkIPoint_Reference.md +++ b/site/user/api/SkIPoint_Reference.md @@ -1,8 +1,6 @@ SkIPoint Reference === -# <a name="IVector"></a> IVector - # <a name="IPoint"></a> IPoint # <a name="SkIPoint"></a> Struct SkIPoint @@ -501,3 +499,4 @@ Can also be used to add <a href="SkIPoint_Reference#IVector">IVector</a> to <a h --- +# <a name="IVector"></a> IVector diff --git a/site/user/api/SkImage_Reference.md b/site/user/api/SkImage_Reference.md index 019423d231..58cf70d918 100644 --- a/site/user/api/SkImage_Reference.md +++ b/site/user/api/SkImage_Reference.md @@ -22,12 +22,6 @@ are zero, then nullptr will be returned. | topics | description | | --- | --- | -## <a name="Structs"></a> Structs - -| description | struct | -| --- | --- | -| <a href="#SkImage_DeferredTextureImageUsageParams">DeferredTextureImageUsageParams</a> | | - ## <a name="Member_Functions"></a> Member Functions | description | function | @@ -37,7 +31,6 @@ are zero, then nullptr will be returned. | <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. | @@ -48,80 +41,33 @@ are zero, then nullptr will be returned. | <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> | | -| <a href="#SkImage_encodeToData">encodeToData</a> | | -| <a href="#SkImage_getDeferredTextureImageData">getDeferredTextureImageData</a> | | -| <a href="#SkImage_getTexture">getTexture</a> | | -| <a href="#SkImage_getTextureHandle">getTextureHandle</a> | | -| <a href="#SkImage_height">height</a> | | -| <a href="#SkImage_isAlphaOnly">isAlphaOnly</a> | | -| <a href="#SkImage_isLazyGenerated">isLazyGenerated</a> | | -| <a href="#SkImage_isOpaque">isOpaque</a> | | -| <a href="#SkImage_isTextureBacked">isTextureBacked</a> | | -| <a href="#SkImage_isValid">isValid</a> | | -| <a href="#SkImage_makeColorSpace">makeColorSpace</a> | | -| <a href="#SkImage_makeNonTextureImage">makeNonTextureImage</a> | | -| <a href="#SkImage_makeShader">makeShader</a> | | -| <a href="#SkImage_makeSubset">makeSubset</a> | | -| <a href="#SkImage_makeTextureImage">makeTextureImage</a> | | -| <a href="#SkImage_makeWithFilter">makeWithFilter</a> | | -| <a href="#SkImage_peekPixels">peekPixels</a> | | -| <a href="#SkImage_readPixels">readPixels</a> | | -| <a href="#SkImage_refColorSpace">refColorSpace</a> | | -| <a href="#SkImage_refEncodedData">refEncodedData</a> | | -| <a href="#SkImage_scalePixels">scalePixels</a> | | -| <a href="#SkImage_toString">toString</a> | | -| <a href="#SkImage_uniqueID">uniqueID</a> | | -| <a href="#SkImage_width">width</a> | | - -# <a name="SkImage_DeferredTextureImageUsageParams"></a> Struct SkImage::DeferredTextureImageUsageParams - -<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> -</pre> - -Drawing parameters for which a deferred texture image data should be optimized. */ - -<a name="SkImage_DeferredTextureImageUsageParams_DeferredTextureImageUsageParams"></a> -## DeferredTextureImageUsageParams - -<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> -DeferredTextureImageUsageParams(const SkMatrix matrix, const SkFilterQuality quality, - int preScaleMipLevel) -</pre> - -### Parameters - -<table> <tr> <td><a name="SkImage_DeferredTextureImageUsageParams_DeferredTextureImageUsageParams_matrix"> <code><strong>matrix </strong></code> </a></td> <td> -incomplete</td> - </tr> <tr> <td><a name="SkImage_DeferredTextureImageUsageParams_DeferredTextureImageUsageParams_quality"> <code><strong>quality </strong></code> </a></td> <td> -incomplete</td> - </tr> <tr> <td><a name="SkImage_DeferredTextureImageUsageParams_DeferredTextureImageUsageParams_preScaleMipLevel"> <code><strong>preScaleMipLevel </strong></code> </a></td> <td> -incomplete</td> - </tr> -</table> - -### Return Value - -incomplete - -### Example - -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> - -### See Also - -incomplete - ---- - -<a name="SkImage_DeferredTextureImageUsageParams_fMatrix"> <code><strong>SkMatrix fMatrix</strong></code> </a> - -<a name="SkImage_DeferredTextureImageUsageParams_fQuality"> <code><strong>SkFilterQuality fQuality</strong></code> </a> - -<a name="SkImage_DeferredTextureImageUsageParams_fPreScaleMipLevel"> <code><strong>int fPreScaleMipLevel</strong></code> </a> +| <a href="#SkImage_asLegacyBitmap">asLegacyBitmap</a> | Returns as <a href="undocumented#Raster_Bitmap">Raster Bitmap</a> | +| <a href="#SkImage_bounds">bounds</a> | Returns <a href="#SkImage_width">width</a> and <a href="#SkImage_height">height</a> as Rectangle. | +| <a href="#SkImage_colorSpace">colorSpace</a> | Returns <a href="undocumented#Color_Space">Color Space</a>. | +| <a href="#SkImage_dimensions">dimensions</a> | Returns <a href="#SkImage_width">width</a> and <a href="#SkImage_height">height</a>. | +| <a href="#SkImage_encodeToData">encodeToData</a> | Returns encoded <a href="#Image">Image</a> as <a href="undocumented#SkData">SkData</a>. | +| <a href="#SkImage_getTexture">getTexture</a> | Deprecated. | +| <a href="#SkImage_getTextureHandle">getTextureHandle</a> | Returns <a href="undocumented#GPU">GPU</a> reference to <a href="#Image">Image</a> as texture. | +| <a href="#SkImage_height">height</a> | Returns pixel row count. | +| <a href="#SkImage_isAlphaOnly">isAlphaOnly</a> | Returns if pixels represent a transparency mask. | +| <a href="#SkImage_isLazyGenerated">isLazyGenerated</a> | Returns if <a href="#Image">Image</a> is created as needed. | +| <a href="#SkImage_isOpaque">isOpaque</a> | Returns if <a href="#Alpha_Type">Alpha Type</a> is <a href="undocumented#SkAlphaType">kOpaque SkAlphaType</a>. | +| <a href="#SkImage_isTextureBacked">isTextureBacked</a> | Returns if <a href="#Image">Image</a> was created from <a href="undocumented#GPU">GPU</a> texture. | +| <a href="#SkImage_isValid">isValid</a> | Returns if <a href="#Image">Image</a> can draw to <a href="undocumented#Raster_Surface">Raster Surface</a> or <a href="undocumented#GPU_Context">GPU Context</a>. | +| <a href="#SkImage_makeColorSpace">makeColorSpace</a> | Creates <a href="#Image">Image</a> matching <a href="undocumented#Color_Space">Color Space</a> if possible. | +| <a href="#SkImage_makeNonTextureImage">makeNonTextureImage</a> | Creates <a href="undocumented#Raster_Image">Raster Image</a> if possible. | +| <a href="#SkImage_makeShader">makeShader</a> | Creates <a href="undocumented#Shader">Shader</a>, <a href="SkPaint_Reference#Paint">Paint</a> element that can tile <a href="#Image">Image</a>. | +| <a href="#SkImage_makeSubset">makeSubset</a> | Creates <a href="#Image">Image</a> containing part of original. | +| <a href="#SkImage_makeTextureImage">makeTextureImage</a> | Creates <a href="#Image">Image</a> matching <a href="undocumented#Color_Space">Color Space</a> if possible. | +| <a href="#SkImage_makeWithFilter">makeWithFilter</a> | Creates filtered, clipped <a href="#Image">Image</a>. | +| <a href="#SkImage_peekPixels">peekPixels</a> | Returns <a href="SkPixmap_Reference#Pixmap">Pixmap</a> if possible. | +| <a href="#SkImage_readPixels">readPixels</a> | Copies and converts pixels. | +| <a href="#SkImage_refColorSpace">refColorSpace</a> | Returns <a href="#Info">Image Info</a> <a href="undocumented#Color_Space">Color Space</a>. | +| <a href="#SkImage_refEncodedData">refEncodedData</a> | Returns <a href="#Image">Image</a> encoded in <a href="undocumented#SkData">SkData</a> if present. | +| <a href="#SkImage_scalePixels">scalePixels</a> | Scales and converts one <a href="#Image">Image</a> to another. | +| <a href="#SkImage_toString">toString</a> | Converts <a href="#Image">Image</a> to machine readable form. | +| <a href="#SkImage_uniqueID">uniqueID</a> | Identifier for <a href="#Image">Image</a>. | +| <a href="#SkImage_width">width</a> | Returns pixel column count. | <a name="SkImage_MakeRasterCopy"></a> ## MakeRasterCopy @@ -130,7 +76,8 @@ 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. +Creates <a href="#Image">Image</a> from <a href="SkPixmap_Reference#Pixmap">Pixmap</a> and copy of pixels. Since pixels are copied, <a href="SkPixmap_Reference#Pixmap">Pixmap</a> +pixels may be modified or deleted without affecting <a href="#Image">Image</a>. <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; @@ -152,7 +99,9 @@ copy of <a href="SkPixmap_Reference#Pixmap">Pixmap</a> pixels, or nullptr ### Example -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> +<div><fiddle-embed name="513afec5795a9504ebf6af5373d16b6b"><div>Draw a five by five bitmap, and draw a copy in an <a href="#Image">Image</a>. Editing the <a href="#SkImage_MakeRasterCopy_pixmap">pixmap</a> +alters the bitmap draw, but does not alter the <a href="#Image">Image</a> draw since the <a href="#Image">Image</a> +contains a copy of the pixels.</div></fiddle-embed></div> ### See Also @@ -201,18 +150,18 @@ size of pixel row or larger</td> --- -Caller data passed to <a href="SkImage_Reference#RasterReleaseProc">RasterReleaseProc</a>; may be nullptr. +Caller data passed to <a href="#SkImage_RasterReleaseProc">RasterReleaseProc</a>; may be nullptr. ### See Also -<a href="#SkImage_MakeFromRaster">MakeFromRaster</a> <a href="SkImage_Reference#RasterReleaseProc">RasterReleaseProc</a> +<a href="#SkImage_MakeFromRaster">MakeFromRaster</a> <a href="#SkImage_RasterReleaseProc">RasterReleaseProc</a> -Function called when <a href="#Image">Image</a> no longer shares pixels. <a href="SkImage_Reference#ReleaseContext">ReleaseContext</a> is +Function called when <a href="#Image">Image</a> no longer shares pixels. <a href="#SkImage_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 href="#SkImage_ReleaseContext">ReleaseContext</a> <a href="#SkImage_MakeFromRaster">MakeFromRaster</a> <a name="SkImage_MakeFromRaster"></a> ## MakeFromRaster @@ -254,7 +203,7 @@ incomplete ### See Also -<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> +<a href="#SkImage_MakeRasterCopy">MakeRasterCopy</a> <a href="#SkImage_MakeRasterData">MakeRasterData</a> <a href="#SkImage_MakeFromGenerator">MakeFromGenerator</a> <a href="#SkImage_RasterReleaseProc">RasterReleaseProc</a> <a href="#SkImage_ReleaseContext">ReleaseContext</a> --- @@ -881,6 +830,8 @@ incomplete int height() const </pre> +Returns pixel row count. + ### Return Value incomplete @@ -902,9 +853,11 @@ incomplete SkISize dimensions() const </pre> +Returns <a href="undocumented#ISize">ISize</a> { <a href="#SkImage_width">width</a>, <a href="#SkImage_height">height</a> }. + ### Return Value -incomplete +integral size of <a href="#SkImage_width">width</a> and <a href="#SkImage_height">height</a> ### Example @@ -912,7 +865,7 @@ incomplete ### See Also -incomplete +<a href="#SkImage_height">height</a> <a href="#SkImage_width">width</a> --- @@ -923,9 +876,11 @@ incomplete SkIRect bounds() const </pre> +Returns <a href="SkIRect_Reference#IRect">IRect</a> { 0, 0, <a href="#SkImage_width">width</a>, <a href="#SkImage_height">height</a> }. + ### Return Value -incomplete +integral rectangle from origin to <a href="#SkImage_width">width</a> and <a href="#SkImage_height">height</a> ### Example @@ -986,14 +941,17 @@ incomplete SkColorSpace* colorSpace() const </pre> -Returns <a href="undocumented#Color_Space">Color Space</a> of <a href="#Image">Image</a>. <a href="undocumented#Color_Space">Color Space</a> may have been a parameter when -<a href="#Image">Image</a> was created, or may have been parsed from encoded data. <a href="undocumented#Skia">Skia</a> may not be -able to draw image respecting returned <a href="undocumented#Color_Space">Color Space</a> or draw into <a href="SkSurface_Reference#Surface">Surface</a> with -returned <a href="undocumented#Color_Space">Color Space</a>. +Returns <a href="undocumented#Color_Space">Color Space</a>, the range of colors, associated with <a href="#Image">Image</a>. The +reference count of <a href="undocumented#Color_Space">Color Space</a> is unchanged. The returned <a href="undocumented#Color_Space">Color Space</a> is +immutable. + +<a href="undocumented#Color_Space">Color Space</a> returned was a parameter to an <a href="#Image">Image</a> constructor, +or was parsed from encoded data. <a href="undocumented#Color_Space">Color Space</a> may be ignored when +drawing <a href="#Image">Image</a>, and when drawing into <a href="SkSurface_Reference#Surface">Surface</a> constructed with <a href="undocumented#Color_Space">Color Space</a>. ### Return Value -<a href="undocumented#Color_Space">Color Space</a> <a href="#Image">Image</a> was created with, or nullptr +<a href="undocumented#Color_Space">Color Space</a> in <a href="#Image">Image</a>, or nullptr ### Example @@ -1033,11 +991,12 @@ incomplete bool isAlphaOnly() const </pre> -Returns true fi the image will be drawn as a mask, with no intrinsic color of its own. +Returns true if <a href="#Image">Image</a> pixels represent transparency only. If true, each pixel +is packed in 8 bits as defined by <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>. ### Return Value -incomplete +true if pixels represent a transparency mask ### Example @@ -1056,9 +1015,11 @@ incomplete bool isOpaque() const </pre> +Returns if all pixels ignore any <a href="#Alpha">Alpha</a> value and are treated as fully opaque. + ### Return Value -incomplete +true if <a href="#Alpha_Type">Alpha Type</a> is <a href="undocumented#SkAlphaType">kOpaque SkAlphaType</a> ### Example @@ -1170,19 +1131,7 @@ incomplete GrTexture* getTexture() const </pre> -DEPRECATED - - -### Return Value - -incomplete - -### Example - -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> - -### See Also - -incomplete +Deprecated. --- @@ -1251,28 +1200,28 @@ incomplete GrBackendObject getTextureHandle(bool flushPendingGrContextIO, GrSurfaceOrigin* origin = nullptr) const </pre> -Retrieves the back-end <a href="undocumented#API">API</a> handle of the texture. If <a href="#SkImage_getTextureHandle_flushPendingGrContextIO">flushPendingGrContextIO</a> then the -<a href="undocumented#GrContext">GrContext</a> will issue to the back-end <a href="undocumented#API">API</a> any deferred <a href="undocumented#I">I</a>/<a href="undocumented#O">O</a> operations on the texture before -returning. -If '<a href="#SkImage_getTextureHandle_origin">origin</a>' is supplied it will be filled in with the <a href="#SkImage_getTextureHandle_origin">origin</a> of the content drawn -into the image. +Retrieves the back-end <a href="undocumented#API">API</a> handle of texture. If <a href="#SkImage_getTextureHandle_flushPendingGrContextIO">flushPendingGrContextIO</a> is true, +complete deferred <a href="undocumented#I">I</a>/<a href="undocumented#O">O</a> operations. + +If <a href="#SkImage_getTextureHandle_origin">origin</a> in not nullptr, copies location of content drawn into <a href="#Image">Image</a>. ### Parameters <table> <tr> <td><a name="SkImage_getTextureHandle_flushPendingGrContextIO"> <code><strong>flushPendingGrContextIO </strong></code> </a></td> <td> -incomplete</td> +flag to flush outstanding requests</td> </tr> <tr> <td><a name="SkImage_getTextureHandle_origin"> <code><strong>origin </strong></code> </a></td> <td> -incomplete</td> +storage for one of: <a href="undocumented#GrSurfaceOrigin">kTopLeft GrSurfaceOrigin</a>, +<a href="undocumented#GrSurfaceOrigin">kBottomLeft GrSurfaceOrigin</a>; or nullptr</td> </tr> </table> ### Return Value -incomplete +back-end <a href="undocumented#API">API</a> texture handle ### Example -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> +<div><fiddle-embed name="704b914d622fbff24d7a45647380459e" gpu="true"></fiddle-embed></div> ### See Also @@ -1445,9 +1394,9 @@ incomplete sk_sp<SkData> encodeToData(SkEncodedImageFormat encodedImageFormat, int quality) const </pre> -Encode the image's pixels and return the result as <a href="undocumented#SkData">SkData</a>. -If the image type cannot be encoded, or the requested encoder format is -not supported, this will return nullptr. +Encodes <a href="#Image">Image</a> pixels, returning result as <a href="undocumented#SkData">SkData</a>. + +Returns nullptr if encoding fails, or <a href="#SkImage_encodeToData_encodedImageFormat">encodedImageFormat</a> is not supported. ### Parameters @@ -1460,7 +1409,7 @@ incomplete</td> ### Return Value -incomplete +encoded <a href="#Image">Image</a>, or nullptr ### Example @@ -1701,111 +1650,7 @@ incomplete --- -<a name="SkImage_getDeferredTextureImageData"></a> -## getDeferredTextureImageData - -<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> -size_t getDeferredTextureImageData(const GrContextThreadSafeProxy& contextThreadSafeProxy, - const DeferredTextureImageUsageParams deferredTextureImageUsageParams[], - int paramCnt, void* buffer, SkColorSpace* dstColorSpace = nullptr, - SkColorType dstColorType = kN32_SkColorType) const -</pre> - -This method allows clients to capture the data necessary to turn a <a href="#SkImage">SkImage</a> into a texture- -backed image. If the original image is codec-backed this will decode into a format optimized -for the context represented by the proxy. This method is thread safe with respect to the -<a href="undocumented#GrContext">GrContext</a> whence the proxy came. Clients allocate and manage the storage of the deferred -texture data and control its lifetime. No cleanup is required, thus it is safe to simply free -the memory out from under the data. - -The same method is used both for getting the size necessary for uploading -and retrieving texture data. The <a href="#SkImage_getDeferredTextureImageData_deferredTextureImageUsageParams">deferredTextureImageUsageParams</a> array represents the set of -draws over which to optimize the texture data prior to uploading. - -When called with a null <a href="#SkImage_getDeferredTextureImageData_buffer">buffer</a> this returns the size that the client must allocate in order -to create deferred texture data for this image (or zero if this is an inappropriate -candidate). The <a href="#SkImage_getDeferredTextureImageData_buffer">buffer</a> allocated by the client should be 8 byte aligned. -When <a href="#SkImage_getDeferredTextureImageData_buffer">buffer</a> is not null this fills in the deferred texture data for this image in the -provided <a href="#SkImage_getDeferredTextureImageData_buffer">buffer</a> (assuming this is an appropriate candidate image and the <a href="#SkImage_getDeferredTextureImageData_buffer">buffer</a> is -appropriately aligned). Upon success the size written is returned, otherwise 0. -<a href="#SkImage_getDeferredTextureImageData_dstColorSpace">dstColorSpace</a> is the color space of the surface where this texture will ultimately be used. -If the method determines that <a href="undocumented#Mip_Map">Mip Maps</a> are needed, this helps determine the correct strategy -for building them (gamma-correct or not). - -<a href="#SkImage_getDeferredTextureImageData_dstColorType">dstColorType</a> is the color type of the surface where this texture will ultimately be used. -This determines the format with which the image will be uploaded to the <a href="undocumented#GPU">GPU</a>. If <a href="#SkImage_getDeferredTextureImageData_dstColorType">dstColorType</a> -does not support color spaces (low bit depth types such as <a href="undocumented#SkColorType">kARGB 4444 SkColorType</a>), then <a href="#SkImage_getDeferredTextureImageData_dstColorSpace">dstColorSpace</a> -must be null. - -### Parameters - -<table> <tr> <td><a name="SkImage_getDeferredTextureImageData_contextThreadSafeProxy"> <code><strong>contextThreadSafeProxy </strong></code> </a></td> <td> -incomplete</td> - </tr> <tr> <td><a name="SkImage_getDeferredTextureImageData_deferredTextureImageUsageParams"> <code><strong>deferredTextureImageUsageParams </strong></code> </a></td> <td> -incomplete</td> - </tr> <tr> <td><a name="SkImage_getDeferredTextureImageData_paramCnt"> <code><strong>paramCnt </strong></code> </a></td> <td> -incomplete</td> - </tr> <tr> <td><a name="SkImage_getDeferredTextureImageData_buffer"> <code><strong>buffer </strong></code> </a></td> <td> -incomplete</td> - </tr> <tr> <td><a name="SkImage_getDeferredTextureImageData_dstColorSpace"> <code><strong>dstColorSpace </strong></code> </a></td> <td> -incomplete</td> - </tr> <tr> <td><a name="SkImage_getDeferredTextureImageData_dstColorType"> <code><strong>dstColorType </strong></code> </a></td> <td> -incomplete</td> - </tr> -</table> - -### Return Value - -incomplete - -### Example - -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> - -### See Also - -incomplete - ---- - -<a name="SkImage_MakeFromDeferredTextureImageData"></a> -## MakeFromDeferredTextureImageData - -<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> -static sk_sp<SkImage> MakeFromDeferredTextureImageData(GrContext* context, const void* data, - SkBudgeted budgeted) -</pre> - -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> -<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> -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> -one of: <a href="#SkBudgeted_kNo">SkBudgeted::kNo</a>, <a href="#SkBudgeted_kYes">SkBudgeted::kYes</a></td> - </tr> -</table> - -### Return Value - -incomplete - -### Example - -<div><fiddle-embed name="493c3a7c12d9130532971b2a255d1652"gpu="true"></fiddle-embed></div> - -### See Also - -incomplete - ---- - -<a href="SkImage_Reference#BackendTextureReleaseProc">BackendTextureReleaseProc</a> +<a href="#SkImage_BackendTextureReleaseProc">BackendTextureReleaseProc</a> <a name="SkImage_MakeBackendTextureFromSkImage"></a> ## MakeBackendTextureFromSkImage @@ -1817,9 +1662,9 @@ static bool MakeBackendTextureFromSkImage(GrContext* context, sk_sp<SkImage&g </pre> Creates a <a href="undocumented#GrBackendTexture">GrBackendTexture</a> from the provided <a href="#SkImage">SkImage</a>. Returns true on success. The -<a href="undocumented#GrBackendTexture">GrBackendTexture</a> and <a href="SkImage_Reference#BackendTextureReleaseProc">BackendTextureReleaseProc</a> are populated on success. It is the callers -responsibility to call the <a href="SkImage_Reference#BackendTextureReleaseProc">BackendTextureReleaseProc</a> once they have deleted the texture. -Note that the <a href="SkImage_Reference#BackendTextureReleaseProc">BackendTextureReleaseProc</a> allows <a href="undocumented#Skia">Skia</a> to clean up auxiliary data related +<a href="undocumented#GrBackendTexture">GrBackendTexture</a> and <a href="#SkImage_BackendTextureReleaseProc">BackendTextureReleaseProc</a> are populated on success. It is the callers +responsibility to call the <a href="#SkImage_BackendTextureReleaseProc">BackendTextureReleaseProc</a> once they have deleted the texture. +Note that the <a href="#SkImage_BackendTextureReleaseProc">BackendTextureReleaseProc</a> allows <a href="undocumented#Skia">Skia</a> to clean up auxiliary data related to the <a href="undocumented#GrBackendTexture">GrBackendTexture</a>, and is not a substitute for the client deleting the <a href="undocumented#GrBackendTexture">GrBackendTexture</a> themselves. @@ -1935,11 +1780,11 @@ and caches its pixels or texture on-demand. ### Return Value -incomplete +true if <a href="#Image">Image</a> is created as needed ### Example -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> +<div><fiddle-embed name="a8b8bd4bfe968e2c63085f867665227f"></fiddle-embed></div> ### See Also diff --git a/site/user/api/SkPaint_Reference.md b/site/user/api/SkPaint_Reference.md index ecd85e939f..77bb832142 100644 --- a/site/user/api/SkPaint_Reference.md +++ b/site/user/api/SkPaint_Reference.md @@ -2222,7 +2222,7 @@ The default width for the paint is zero. ### Example -<div><fiddle-embed name="01e3e08a3022a351628ff54e84887756"gpu="true"><div>The pixels hit to represent thin lines vary with the angle of the +<div><fiddle-embed name="01e3e08a3022a351628ff54e84887756" gpu="true"><div>The pixels hit to represent thin lines vary with the angle of the line and the platform implementation.</div></fiddle-embed></div> <a name="SkPaint_getStrokeWidth"></a> diff --git a/site/user/api/SkSurface_Reference.md b/site/user/api/SkSurface_Reference.md index c3438918a7..3cc78cf1b1 100644 --- a/site/user/api/SkSurface_Reference.md +++ b/site/user/api/SkSurface_Reference.md @@ -599,7 +599,7 @@ hint that <a href="#Surface">Surface</a> will host <a href="undocumented#Mip_Map ### Example -<div><fiddle-embed name="67b6609471a3f1ed0f4b1657004cdecb"gpu="true"></fiddle-embed></div> +<div><fiddle-embed name="67b6609471a3f1ed0f4b1657004cdecb" gpu="true"></fiddle-embed></div> ### See Also @@ -649,7 +649,7 @@ fonts; may be nullptr</td> ### Example -<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 +<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> @@ -691,7 +691,7 @@ of <a href="undocumented#Raster_Surface">Raster Surface</a>; <a href="#SkSurface ### Example -<div><fiddle-embed name="5c7629c15e9ac93f098335e72560fa2e"gpu="true"></fiddle-embed></div> +<div><fiddle-embed name="5c7629c15e9ac93f098335e72560fa2e" gpu="true"></fiddle-embed></div> ### See Also @@ -919,7 +919,7 @@ enum <a href="#SkSurface_BackendHandleAccess">BackendHandleAccess</a> { ### Example -<div><fiddle-embed name="260a5ba014b00eeb5a74b3c6b8d31be4"gpu="true"></fiddle-embed></div> +<div><fiddle-embed name="260a5ba014b00eeb5a74b3c6b8d31be4" gpu="true"></fiddle-embed></div> ### See Also @@ -954,7 +954,7 @@ one of: <a href="#SkSurface_kFlushRead_BackendHandleAccess">kFlushRead BackendH ### Example -<div><fiddle-embed name="4b5720038daaf65ba1ba546e678ddd6e"gpu="true"></fiddle-embed></div> +<div><fiddle-embed name="4b5720038daaf65ba1ba546e678ddd6e" gpu="true"></fiddle-embed></div> ### See Also @@ -996,7 +996,7 @@ true if <a href="#Surface">Surface</a> is backed by <a href="undocumented#GPU">G ### Example -<div><fiddle-embed name="16e848a4405ce08f8393bba13cc3b8bf"gpu="true"></fiddle-embed></div> +<div><fiddle-embed name="16e848a4405ce08f8393bba13cc3b8bf" gpu="true"></fiddle-embed></div> ### See Also @@ -1506,7 +1506,7 @@ true if supported ### Example -<div><fiddle-embed name="3df4e2fc63483a3fa19589b5388080bc"gpu="true"></fiddle-embed></div> +<div><fiddle-embed name="3df4e2fc63483a3fa19589b5388080bc" gpu="true"></fiddle-embed></div> ### See Also @@ -1515,12 +1515,14 @@ true if supported --- <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> -void draw(SkDeferredDisplayList* deferredDisplayList) +bool draw(SkDeferredDisplayList* deferredDisplayList) </pre> Draws deferred display list created using <a href="undocumented#SkDeferredDisplayListRecorder">SkDeferredDisplayListRecorder</a>. -The <a href="#SkSurface_draw">draw</a> has no effect if <a href="#Characterization">Surface Characterization</a> stored in <a href="#SkSurface_draw_2_deferredDisplayList">deferredDisplayList</a> -is not compatible with <a href="#Surface">Surface</a>. +Has no effect and returns false if <a href="#Characterization">Surface Characterization</a> stored in +<a href="#SkSurface_draw_2_deferredDisplayList">deferredDisplayList</a> is not compatible with <a href="#Surface">Surface</a>. + +<a href="undocumented#Raster_Surface">Raster Surface</a> returns false. ### Parameters @@ -1529,9 +1531,13 @@ drawing commands</td> </tr> </table> +### Return Value + +false if <a href="#SkSurface_draw_2_deferredDisplayList">deferredDisplayList</a> is not compatible + ### Example -<div><fiddle-embed name="3dfa7496268dfb2c7465cda5da39dfbd"gpu="true"cpu="true"></fiddle-embed></div> +<div><fiddle-embed name="3dfa7496268dfb2c7465cda5da39dfbd" gpu="true" cpu="true"></fiddle-embed></div> ### See Also diff --git a/site/user/api/catalog.htm b/site/user/api/catalog.htm index 9926cf52c8..d650805c6c 100644 --- a/site/user/api/catalog.htm +++ b/site/user/api/catalog.htm @@ -47,7 +47,7 @@ "hash": "fe79a9c1ec350264eb9c7b2509dd3638", "file": "SkBitmap_Reference", "name": "SkBitmap::HeapAllocator::allocPixelRef", - "stdout": "pixel address = (nil)\\npixel address = 0x55f1363e3670\\n" + "stdout": "pixel address = (nil)\\npixel address = 0x55b067c54670\\n" }, "SkBitmap_alphaType": { "code": "void draw(SkCanvas* canvas) {\n const char* alphas[] = {\"Unknown\", \"Opaque\", \"Premul\", \"Unpremul\"};\n SkPixmap pixmap(SkImageInfo::MakeA8(16, 32), nullptr, 64);\n SkDebugf(\"alpha type: k\" \"%s\" \"_SkAlphaType\\n\", alphas[pixmap.alphaType()]);\n}", @@ -1352,8 +1352,8 @@ "stdout": "paint1 == paint2\\npaint1 != paint2\\n" }, "SkPaint_flatten": { - "code": "void draw(SkCanvas* canvas) {\n class PaintDumper : public SkWriteBuffer {\n public:\n bool isCrossProcess() const override { return false; };\n void writeByteArray(const void* data, size_t size) override {}\n void writeBool(bool value) override {}\n void writeScalar(SkScalar value) override {}\n void writeScalarArray(const SkScalar* value, uint32_t count) override {}\n void writeInt(int32_t value) override {}\n void writeIntArray(const int32_t* value, uint32_t count) override {}\n void writeUInt(uint32_t value) override {}\n void writeString(const char* value) override {}\n void writeFlattenable(const SkFlattenable* flattenable) override {}\n void writeColorArray(const SkColor* color, uint32_t count) override {}\n void writeColor4f(const SkColor4f& color) override {}\n void writeColor4fArray(const SkColor4f* color, uint32_t count) override {}\n void writePoint(const SkPoint& point) override {}\n void writePointArray(const SkPoint* point, uint32_t count) override {}\n void writeMatrix(const SkMatrix& matrix) override {}\n void writeIRect(const SkIRect& rect) override {}\n void writeRect(const SkRect& rect) override {}\n void writeRegion(const SkRegion& region) override {}\n void writePath(const SkPath& path) override {}\n size_t writeStream(SkStream* stream, size_t length) override { return 0; }\n void writeBitmap(const SkBitmap& bitmap) override {}\n void writeImage(const SkImage*) override {}\n void writeTypeface(SkTypeface* typeface) override {}\n void writePaint(const SkPaint& paint) override {}\n void writeColor(SkColor color) override {\n SkDebugf(\"color = 0x%08x\\n\", color);\n }\n } dumper;\n SkPaint paint;\n paint.setColor(SK_ColorRED);\n paint.flatten(dumper);\n}", - "hash": "670672b146b50eced4d3dd10c701e0a7", + "code": "void draw(SkCanvas* canvas) {\n class PaintDumper : public SkWriteBuffer {\n public:\n bool isCrossProcess() const override { return false; };\n void writeByteArray(const void* data, size_t size) override {}\n void writeBool(bool value) override {}\n void writeScalar(SkScalar value) override {}\n void writeScalarArray(const SkScalar* value, uint32_t count) override {}\n void writeInt(int32_t value) override {}\n void writeIntArray(const int32_t* value, uint32_t count) override {}\n void writeUInt(uint32_t value) override {}\n void writeString(const char* value) override {}\n void writeFlattenable(const SkFlattenable* flattenable) override {}\n void writeColorArray(const SkColor* color, uint32_t count) override {}\n void writeColor4f(const SkColor4f& color) override {}\n void writeColor4fArray(const SkColor4f* color, uint32_t count) override {}\n void writePoint(const SkPoint& point) override {}\n void writePointArray(const SkPoint* point, uint32_t count) override {}\n void writeMatrix(const SkMatrix& matrix) override {}\n void writeIRect(const SkIRect& rect) override {}\n void writeRect(const SkRect& rect) override {}\n void writeRegion(const SkRegion& region) override {}\n void writePath(const SkPath& path) override {}\n size_t writeStream(SkStream* stream, size_t length) override { return 0; }\n void writeImage(const SkImage*) override {}\n void writeTypeface(SkTypeface* typeface) override {}\n void writePaint(const SkPaint& paint) override {}\n void writeColor(SkColor color) override {\n SkDebugf(\"color = 0x%08x\\n\", color);\n }\n } dumper;\n SkPaint paint;\n paint.setColor(SK_ColorRED);\n paint.flatten(dumper);\n}", + "hash": "de31563f11e447dccc988108e9173d28", "file": "SkPaint_Reference", "name": "SkPaint::flatten()", "stdout": "color = 0xffff0000\\n" @@ -2280,7 +2280,7 @@ "hash": "bb761cd858e6d0ca05627262cd22ff5e", "file": "SkPath_Reference", "name": "SkPath::updateBoundsCache", - "stdout": "uncached avg: 0.16768 ms\\ncached avg: 0.163072 ms\\n" + "stdout": "uncached avg: 0.185344 ms\\ncached avg: 0.167168 ms\\n" }, "SkPath_writeToMemory": { "code": "void draw(SkCanvas* canvas) {\n SkPath path, copy;\n path.lineTo(6.f / 7, 2.f / 3);\n size_t size = path.writeToMemory(nullptr);\n SkTDArray<char> storage;\n storage.setCount(size);\n path.writeToMemory(storage.begin());\n copy.readFromMemory(storage.begin(), size);\n SkDebugf(\"path is \" \"%s\" \"equal to copy\\n\", path == copy ? \"\" : \"not \");\n}\n", @@ -2294,7 +2294,7 @@ "hash": "17bcabaaee2dbb7beba562e9ca50b55e", "file": "SkPixmap_Reference", "name": "SkPixmap::addr()", - "stdout": "pixels address: 0x7fe0b7478010\\ninset address: 0x7fe0b74b8210\\n" + "stdout": "pixels address: 0x7ffa37195010\\ninset address: 0x7ffa371d5210\\n" }, "SkPixmap_addr16": { "code": "void draw(SkCanvas* canvas) {\n const int w = 4;\n const int h = 4;\n uint16_t storage[w * h];\n SkPixmap pixmap(SkImageInfo::Make(w, h, kARGB_4444_SkColorType, kPremul_SkAlphaType),\n storage, w * sizeof(storage[0]));\n SkDebugf(\"pixmap.addr16() %c= storage\\n\",\n pixmap.addr16() == storage ? '=' : '!');\n}", @@ -2784,7 +2784,7 @@ "hash": "6dbf21017c60b76cae3379fd9101342a", "file": "SkRect_Reference", "name": "SkRect::growToInclude_3", - "stdout": "rect: 0, 0, 1.04934e+27, 4" + "stdout": "rect: -8.7683e+18, -8.7683e+18, 3.85186e-34, 4" }, "SkRect_height": { "code": "void draw(SkCanvas* canvas) {\n SkRect unsorted = { 15, 25, 10, 20 };\n SkDebugf(\"unsorted height: %g\\n\", unsorted.height());\n SkRect large = { 1, -2147483647.f, 2, 2147483644.f };\n SkDebugf(\"large height: %.0f\\n\", large.height());\n}", @@ -4470,18 +4470,18 @@ "name": "SkCanvas::drawText" }, "SkCanvas_drawTextBlob": { - "code": "void draw(SkCanvas* canvas) {\n SkTextBlobBuilder textBlobBuilder;\n const char bunny[] = \"/(^x^)\\\\\";\n const int len = sizeof(bunny) - 1;\n uint16_t glyphs[len];\n SkPaint paint;\n paint.textToGlyphs(bunny, len, glyphs);\n int runs[] = { 3, 1, 3 };\n SkPoint textPos = { 20, 100 };\n int glyphIndex = 0;\n for (auto runLen : runs) {\n paint.setTextSize(1 == runLen ? 20 : 50);\n const SkTextBlobBuilder::RunBuffer& run = \n textBlobBuilder.allocRun(paint, runLen, textPos.fX, textPos.fY);\n memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);\n textPos.fX += paint.measureText(&bunny[glyphIndex], runLen, nullptr);\n glyphIndex += runLen;\n }\n sk_sp<const SkTextBlob> blob = textBlobBuilder.make();\n paint.reset();\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n}\n", + "code": "void draw(SkCanvas* canvas) {\n SkTextBlobBuilder textBlobBuilder;\n const char bunny[] = \"/(^x^)\\\\\";\n const int len = sizeof(bunny) - 1;\n uint16_t glyphs[len];\n SkPaint paint;\n paint.textToGlyphs(bunny, len, glyphs);\n paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);\n int runs[] = { 3, 1, 3 };\n SkPoint textPos = { 20, 100 };\n int glyphIndex = 0;\n for (auto runLen : runs) {\n paint.setTextSize(1 == runLen ? 20 : 50);\n const SkTextBlobBuilder::RunBuffer& run = \n textBlobBuilder.allocRun(paint, runLen, textPos.fX, textPos.fY);\n memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);\n textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);\n glyphIndex += runLen;\n }\n sk_sp<const SkTextBlob> blob = textBlobBuilder.make();\n paint.reset();\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n}\n", "width": 256, "height": 120, - "hash": "b8c0a748ed5c328f38e00f5f3d12e5e6", + "hash": "2254beaa675e3b329dccddca4eeea735", "file": "SkCanvas_Reference", "name": "SkCanvas::drawTextBlob" }, "SkCanvas_drawTextBlob_2": { - "code": "void draw(SkCanvas* canvas) {\n SkTextBlobBuilder textBlobBuilder;\n SkPaint paint;\n paint.setTextSize(50);\n paint.setColor(SK_ColorRED);\n const SkTextBlobBuilder::RunBuffer& run = \n textBlobBuilder.allocRun(paint, 1, 20, 100);\n run.glyphs[0] = 20;\n sk_sp<const SkTextBlob> blob = textBlobBuilder.make();\n paint.setTextSize(10);\n paint.setColor(SK_ColorBLUE);\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n}\n", + "code": "void draw(SkCanvas* canvas) {\n SkTextBlobBuilder textBlobBuilder;\n SkPaint paint;\n paint.setTextSize(50);\n paint.setColor(SK_ColorRED);\n paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);\n const SkTextBlobBuilder::RunBuffer& run = \n textBlobBuilder.allocRun(paint, 1, 20, 100);\n run.glyphs[0] = 20;\n sk_sp<const SkTextBlob> blob = textBlobBuilder.make();\n paint.setTextSize(10);\n paint.setColor(SK_ColorBLUE);\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n}\n", "width": 256, "height": 120, - "hash": "d313ad4726518f5d44f6433887bb7ce9", + "hash": "d88b17d85fa68c56b3c1ad02b69068bf", "file": "SkCanvas_Reference", "name": "SkCanvas::drawTextBlob_2" }, @@ -4606,10 +4606,10 @@ "name": "SkCanvas::saveLayer_2" }, "SkCanvas_saveLayer_3": { - "code": "void draw(SkCanvas* canvas) {\n // sk_sp<SkImage> image = GetResourceAsImage(\"mandrill_256.png\");\n canvas->drawImage(image, 0, 0, nullptr);\n SkCanvas::SaveLayerRec rec;\n SkPaint paint;\n paint.setBlendMode(SkBlendMode::kPlus);\n rec.fSaveLayerFlags = SkCanvas::kInitWithPrevious_SaveLayerFlag;\n rec.fPaint = &paint;\n canvas->saveLayer(rec);\n paint.setBlendMode(SkBlendMode::kClear);\n canvas->drawCircle(128, 128, 96, paint);\n canvas->restore();\n}", + "code": "void draw(SkCanvas* canvas) {\n // sk_sp<SkImage> image = GetResourceAsImage(\"images/mandrill_256.png\");\n canvas->drawImage(image, 0, 0, nullptr);\n SkCanvas::SaveLayerRec rec;\n SkPaint paint;\n paint.setBlendMode(SkBlendMode::kPlus);\n rec.fSaveLayerFlags = SkCanvas::kInitWithPrevious_SaveLayerFlag;\n rec.fPaint = &paint;\n canvas->saveLayer(rec);\n paint.setBlendMode(SkBlendMode::kClear);\n canvas->drawCircle(128, 128, 96, paint);\n canvas->restore();\n}", "width": 256, "height": 256, - "hash": "0da8c199f1d9ec4d1b9c5d1114d6cbd6", + "hash": "7d3751e82d1b6ec328ffa3d6f48ca831", "file": "SkCanvas_Reference", "name": "SkCanvas::saveLayer_3" }, @@ -4709,14 +4709,6 @@ "file": "SkImage_Reference", "name": "SkImage::CachingHint" }, - "SkImage_DeferredTextureImageUsageParams_DeferredTextureImageUsageParams": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImage_Reference", - "name": "SkImage::DeferredTextureImageUsageParams::DeferredTextureImageUsageParams" -}, "SkImage_LegacyBitmapMode": { "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", "width": 256, @@ -4781,14 +4773,6 @@ "file": "SkImage_Reference", "name": "SkImage::MakeFromBitmap" }, - "SkImage_MakeFromDeferredTextureImageData": { - "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": "493c3a7c12d9130532971b2a255d1652", - "file": "SkImage_Reference", - "name": "SkImage::MakeFromDeferredTextureImageData" -}, "SkImage_MakeFromEncoded": { "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", "width": 256, @@ -4854,10 +4838,10 @@ "name": "SkImage::MakeFromYUVTexturesCopy" }, "SkImage_MakeRasterCopy": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", + "code": "void draw(SkCanvas* canvas) {\n uint8_t storage[][5] = {{ 0xCA, 0xDA, 0xCA, 0xC9, 0xA3 },\n { 0xAC, 0xA8, 0x89, 0xA7, 0x87 },\n { 0x9B, 0xB5, 0xE5, 0x95, 0x46 },\n { 0x90, 0x81, 0xC5, 0x71, 0x33 },\n { 0x75, 0x55, 0x44, 0x40, 0x30 }};\n SkImageInfo imageInfo = SkImageInfo::Make(5, 5, kGray_8_SkColorType, kOpaque_SkAlphaType);\n SkPixmap pixmap(imageInfo, storage[0], sizeof(storage) / 5);\n SkBitmap bitmap;\n bitmap.installPixels(pixmap);\n sk_sp<SkImage> image = SkImage::MakeRasterCopy(pixmap);\n *pixmap.writable_addr8(2, 2) = 0x00;\n canvas->scale(10, 10);\n canvas->drawBitmap(bitmap, 0, 0);\n canvas->drawImage(image, 10, 0);\n}", "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "height": 50, + "hash": "513afec5795a9504ebf6af5373d16b6b", "file": "SkImage_Reference", "name": "SkImage::MakeRasterCopy" }, @@ -4925,27 +4909,11 @@ "file": "SkImage_Reference", "name": "SkImage::encodeToData_2" }, - "SkImage_getDeferredTextureImageData": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImage_Reference", - "name": "SkImage::getDeferredTextureImageData" -}, - "SkImage_getTexture": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImage_Reference", - "name": "SkImage::getTexture" -}, "SkImage_getTextureHandle": { - "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 SkPaint paint;\n paint.setAntiAlias(true);\n SkString str;\n int y = 0;\n for (auto origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin } ) {\n sk_sp<SkImage> srcImage(SkImage::MakeFromTexture(context,\n backEndTexture, origin, kPremul_SkAlphaType, nullptr));\n GrSurfaceOrigin readBackOrigin;\n GrBackendObject readBackHandle = srcImage->getTextureHandle(false, &readBackOrigin);\n str.printf(\"readBackHandle: %x\", readBackHandle);\n canvas->drawString(str, 5, y += 20, paint);\n str.printf(\"origin: k%s_GrSurfaceOrigin\", readBackOrigin ? \"BottomLeft\" : \"TopLeft\");\n canvas->drawString(str, 5, y += 20, paint);\n }\n}", "width": 256, "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "hash": "704b914d622fbff24d7a45647380459e", "file": "SkImage_Reference", "name": "SkImage::getTextureHandle" }, @@ -4966,10 +4934,10 @@ "name": "SkImage::isAlphaOnly" }, "SkImage_isLazyGenerated": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", + "code": "class TestImageGenerator : public SkImageGenerator {\npublic:\n TestImageGenerator() : SkImageGenerator(SkImageInfo::MakeN32Premul(10, 10)) {}\n ~TestImageGenerator() override {}\nprotected:\n bool onGetPixels(const SkImageInfo& info, void* pixelPtr, size_t rowBytes,\n const Options& options) override {\n SkPMColor* pixels = static_cast<SkPMColor*>(pixelPtr);\n for (int y = 0; y < info.height(); ++y) {\n for (int x = 0; x < info.width(); ++x) {\n pixels[y * info.width() + x] = 0xff223344 + y * 0x000C0811;\n }\n }\n return true;\n }\n};\n\nvoid draw(SkCanvas* canvas) {\n auto gen = std::unique_ptr<TestImageGenerator>(new TestImageGenerator());\n sk_sp<SkImage> image(SkImage::MakeFromGenerator(std::move(gen)));\n SkString lazy(image->isLazyGenerated() ? \"is lazy\" : \"not lazy\");\n canvas->scale(8, 8);\n canvas->drawImage(image, 0, 0, nullptr);\n SkPaint paint;\n paint.setTextSize(4);\n canvas->drawString(lazy, 2, 5, paint);\n}\n", "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "height": 80, + "hash": "a8b8bd4bfe968e2c63085f867665227f", "file": "SkImage_Reference", "name": "SkImage::isLazyGenerated" }, @@ -5758,10 +5726,10 @@ "name": "SkPaint::getPosTextPath" }, "SkPaint_getTextBlobIntercepts": { - "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n paint.setTextSize(120);\n SkPoint textPos = { 20, 110 };\n int len = 3;\n SkTextBlobBuilder textBlobBuilder;\n const SkTextBlobBuilder::RunBuffer& run = \n textBlobBuilder.allocRun(paint, len, textPos.fX, textPos.fY);\n run.glyphs[0] = 10;\n run.glyphs[1] = 20;\n run.glyphs[2] = 30; \n sk_sp<const SkTextBlob> blob = textBlobBuilder.make();\n canvas->drawTextBlob(blob.get(), textPos.fX, textPos.fY, paint);\n SkScalar bounds[] = { 116, 134 };\n int count = paint.getTextBlobIntercepts(blob.get(), bounds, nullptr);\n std::vector<SkScalar> intervals;\n intervals.resize(count);\n (void) paint.getTextBlobIntercepts(blob.get(), bounds, &intervals.front());\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n paint.setColor(0xFFFF7777);\n SkScalar x = textPos.fX;\n for (int i = 0; i < count; i+= 2) {\n canvas->drawRect({x, bounds[0], intervals[i], bounds[1]}, paint);\n x = intervals[i + 1];\n }\n canvas->drawRect({intervals[count - 1], bounds[0], 180, bounds[1]}, paint);\n}\n", + "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);\n paint.setTextSize(120);\n SkPoint textPos = { 20, 110 };\n int len = 3;\n SkTextBlobBuilder textBlobBuilder;\n const SkTextBlobBuilder::RunBuffer& run = \n textBlobBuilder.allocRun(paint, len, textPos.fX, textPos.fY);\n run.glyphs[0] = 10;\n run.glyphs[1] = 20;\n run.glyphs[2] = 30; \n sk_sp<const SkTextBlob> blob = textBlobBuilder.make();\n canvas->drawTextBlob(blob.get(), textPos.fX, textPos.fY, paint);\n SkScalar bounds[] = { 116, 134 };\n int count = paint.getTextBlobIntercepts(blob.get(), bounds, nullptr);\n std::vector<SkScalar> intervals;\n intervals.resize(count);\n (void) paint.getTextBlobIntercepts(blob.get(), bounds, &intervals.front());\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n paint.setColor(0xFFFF7777);\n SkScalar x = textPos.fX;\n for (int i = 0; i < count; i+= 2) {\n canvas->drawRect({x, bounds[0], intervals[i], bounds[1]}, paint);\n x = intervals[i + 1];\n }\n canvas->drawRect({intervals[count - 1], bounds[0], 180, bounds[1]}, paint);\n}\n", "width": 256, "height": 143, - "hash": "4961b05f4f26cf270ab4948a57876341", + "hash": "71959a66b2290d70003887c0de339266", "file": "SkPaint_Reference", "name": "SkPaint::getTextBlobIntercepts" }, diff --git a/site/user/api/undocumented.md b/site/user/api/undocumented.md index 13c8e10cd2..aab2c9d94b 100644 --- a/site/user/api/undocumented.md +++ b/site/user/api/undocumented.md @@ -1,7 +1,11 @@ undocumented === -# <a name="Glyph"></a> Glyph +# <a name="Size"></a> Size + +# <a name="SkSize"></a> Struct SkSize + +# <a name="Curve"></a> Curve # <a name="Document"></a> Document @@ -18,22 +22,6 @@ SkCanvas* beginPage(SkScalar width, SkScalar height, const SkRect* content = NUL ## <a name="PDF"></a> PDF -# <a name="PostScript"></a> PostScript - -## <a name="Arct"></a> Arct - -# <a name="Deferred_Display_List"></a> Deferred Display List - -# <a name="SkDeferredDisplayList"></a> Class SkDeferredDisplayList - -## <a name="Recorder"></a> Recorder - -# <a name="SkDeferredDisplayListRecorder"></a> Class SkDeferredDisplayListRecorder - -# <a name="Size"></a> Size - -# <a name="SkSize"></a> Struct SkSize - # <a name="Image_Color_Type"></a> Image Color Type ## <a name="Native_Color_Type"></a> Native Color Type @@ -85,12 +73,6 @@ SkCanvas* beginPage(SkScalar width, SkScalar height, const SkRect* content = NUL # <a name="Line"></a> Line -# <a name="Region"></a> Region - -# <a name="SkRegion"></a> Class SkRegion - -# <a name="Mip_Map"></a> Mip Map - # <a name="Debugging"></a> Debugging <a name="SkDebugf"></a> @@ -102,14 +84,16 @@ SK_API void SkDebugf(const char format[], ...) --- +# <a name="Region"></a> Region + +# <a name="SkRegion"></a> Class SkRegion + # <a name="Device"></a> Device # <a name="SkBaseDevice"></a> Class SkBaseDevice # <a name="Patch"></a> Patch -# <a name="Curve"></a> Curve - # <a name="Typeface"></a> Typeface # <a name="SkTypeface"></a> Class SkTypeface @@ -118,13 +102,29 @@ SK_API void SkDebugf(const char format[], ...) # <a name="SkDumpCanvas"></a> Class SkDumpCanvas +# <a name="ISize"></a> ISize + +# <a name="SkISize"></a> Struct SkISize + +# <a name="PostScript"></a> PostScript + +## <a name="Arct"></a> Arct + +# <a name="Deferred_Display_List"></a> Deferred Display List + +# <a name="SkDeferredDisplayList"></a> Class SkDeferredDisplayList + +## <a name="Recorder"></a> Recorder + +# <a name="SkDeferredDisplayListRecorder"></a> Class SkDeferredDisplayListRecorder + +# <a name="Mip_Map"></a> Mip Map + # <a name="HTML_Canvas"></a> HTML Canvas ## <a name="ArcTo"></a> ArcTo -# <a name="ISize"></a> ISize - -# <a name="SkISize"></a> Struct SkISize +# <a name="Raster_Image"></a> Raster Image # <a name="Left_Side_Bearing"></a> Left Side Bearing @@ -536,6 +536,8 @@ static std::unique_ptr<SkCanvas> MakeCanvas(std::unique_ptr<SkRasterHan # <a name="Font_Manager"></a> Font Manager +# <a name="Glyph"></a> Glyph + # <a name="GPU_Context"></a> GPU Context ## <a name="Resource_Cache_Limits"></a> Resource Cache Limits @@ -944,6 +946,8 @@ void setImmutable() # <a name="Raster_Engine"></a> Raster Engine +# <a name="Raster_Bitmap"></a> Raster Bitmap + # <a name="Raster_Surface"></a> Raster Surface # <a name="Rasterizer"></a> Rasterizer diff --git a/tools/bookmaker/bookmaker.cpp b/tools/bookmaker/bookmaker.cpp index e048375860..b4db36a2e1 100644 --- a/tools/bookmaker/bookmaker.cpp +++ b/tools/bookmaker/bookmaker.cpp @@ -7,6 +7,7 @@ #include "bookmaker.h" +DEFINE_string2(status, a, "", "File containing status of documentation. (Use in place of -b -i)"); DEFINE_string2(bmh, b, "", "Path to a *.bmh file or a directory."); DEFINE_bool2(catalog, c, false, "Write example catalog.htm. (Requires -b -f -r)"); DEFINE_string2(examples, e, "", "File of fiddlecli input, usually fiddle.json (For now, disables -r -f -s)"); @@ -1056,6 +1057,71 @@ void TextParser::reportWarning(const char* errorStr) const { } } +string TextParser::typedefName() { + // look for typedef as one of three forms: + // typedef return-type (*NAME)(params); + // typedef alias NAME; + // typedef std::function<alias> NAME; + string builder; + const char* end = this->doubleLF(); + if (!end) { + end = fEnd; + } + const char* altEnd = this->strnstr("#Typedef ##", end); + if (altEnd) { + end = this->strnchr('\n', end); + } + if (!end) { + return this->reportError<string>("missing typedef std::function end bracket >"); + } + + if (this->startsWith("std::function")) { + if (!this->skipToEndBracket('>')) { + return this->reportError<string>("missing typedef std::function end bracket >"); + } + this->next(); + this->skipWhiteSpace(); + builder += string(fChar, end - fChar); + } else { + const char* paren = this->strnchr('(', end); + if (!paren) { + const char* lastWord = nullptr; + do { + this->skipToWhiteSpace(); + if (fChar < end && isspace(fChar[0])) { + this->skipWhiteSpace(); + lastWord = fChar; + } else { + break; + } + } while (true); + if (!lastWord) { + return this->reportError<string>("missing typedef name"); + } + builder += string(lastWord, end - lastWord); + } else { + this->skipTo(paren); + this->next(); + if ('*' != this->next()) { + return this->reportError<string>("missing typedef function asterisk"); + } + const char* nameStart = fChar; + if (!this->skipToEndBracket(')')) { + return this->reportError<string>("missing typedef function )"); + } + builder += string(nameStart, fChar - nameStart); + if (!this->skipToEndBracket('(')) { + return this->reportError<string>("missing typedef params ("); + } + if (! this->skipToEndBracket(')')) { + return this->reportError<string>("missing typedef params )"); + } + this->skipTo(end); + } + } + return builder; +} + bool BmhParser::skipNoName() { if ('\n' == this->peek()) { this->next(); @@ -1253,67 +1319,12 @@ string BmhParser::typedefName() { SkASSERT(fMC != this->peek()); return fParent->fName; } - // look for typedef as one of three forms: - // typedef return-type (*NAME)(params); - // typedef alias NAME; - // typedef std::function<alias> NAME; string builder; - const char* end = this->doubleLF(); - if (!end) { - end = fEnd; - } - const char* altEnd = this->strnstr("#Typedef ##", end); - if (altEnd) { - end = this->strnchr('\n', end); - } - if (!end) { - return this->reportError<string>("missing typedef std::function end bracket >"); - } - - if (this->startsWith("std::function")) { - if (!this->skipToEndBracket('>')) { - return this->reportError<string>("missing typedef std::function end bracket >"); - } - this->next(); - this->skipWhiteSpace(); - builder = string(fChar, end - fChar); - } else { - const char* paren = this->strnchr('(', end); - if (!paren) { - const char* lastWord = nullptr; - do { - this->skipToWhiteSpace(); - if (fChar < end && isspace(fChar[0])) { - this->skipWhiteSpace(); - lastWord = fChar; - } else { - break; - } - } while (true); - if (!lastWord) { - return this->reportError<string>("missing typedef name"); - } - builder = string(lastWord, end - lastWord); - } else { - this->skipTo(paren); - this->next(); - if ('*' != this->next()) { - return this->reportError<string>("missing typedef function asterisk"); - } - const char* nameStart = fChar; - if (!this->skipToEndBracket(')')) { - return this->reportError<string>("missing typedef function )"); - } - builder = string(nameStart, fChar - nameStart); - if (!this->skipToEndBracket('(')) { - return this->reportError<string>("missing typedef params ("); - } - if (! this->skipToEndBracket(')')) { - return this->reportError<string>("missing typedef params )"); - } - this->skipTo(end); - } + const Definition* parent = this->parentSpace(); + if (parent && parent->fName.length() > 0) { + builder = parent->fName + "::"; } + builder += TextParser::typedefName(); return uniqueRootName(builder, MarkType::kTypedef); } @@ -1348,9 +1359,6 @@ string BmhParser::uniqueRootName(const string& base, MarkType markType) { return markType == def.fMarkType && def.fName == numBuilder; }; - if (string::npos != base.find("SkMatrix::operator")) { - SkDebugf(""); - } string builder(base); if (!builder.length()) { builder = fParent->fName; @@ -1389,9 +1397,6 @@ tryNext: ; cloned->fCloned = true; } fCloned = true; - if (string::npos != builder.find("operator")) { - SkDebugf(""); - } numBuilder = builder + '_' + to_string(number); } while (++number); return numBuilder; @@ -1485,8 +1490,8 @@ int main(int argc, char** const argv) { " bookmaker -b path/to/bmh_files -e fiddle.json\n" " ~/go/bin/fiddlecli --input fiddle.json --output fiddleout.json\n" " bookmaker -b path/to/bmh_files -f fiddleout.json -r path/to/md_files\n" - " bookmaker -b path/to/bmh_files -i path/to/include.h -x\n" - " bookmaker -b path/to/bmh_files -i path/to/include.h -p\n"); + " bookmaker -a path/to/status.json -x\n" + " bookmaker -a path/to/status.json -p\n"); bool help = false; for (int i = 1; i < argc; i++) { if (0 == strcmp("-h", argv[i]) || 0 == strcmp("--help", argv[i])) { @@ -1505,23 +1510,38 @@ int main(int argc, char** const argv) { } else { SkCommandLineFlags::PrintUsage(); const char* const commands[] = { "", "-h", "bmh", "-h", "examples", "-h", "include", "-h", "fiddle", - "-h", "ref", "-h", "tokens", + "-h", "ref", "-h", "status", "-h", "tokens", "-h", "crosscheck", "-h", "populate", "-h", "spellcheck" }; SkCommandLineFlags::Parse(SK_ARRAY_COUNT(commands), commands); return 0; } - if (FLAGS_bmh.isEmpty() && FLAGS_include.isEmpty()) { - SkDebugf("requires -b or -i\n"); + if (FLAGS_bmh.isEmpty() && FLAGS_include.isEmpty() && FLAGS_status.isEmpty()) { + SkDebugf("requires at least one of: -b -i -a\n"); SkCommandLineFlags::PrintUsage(); return 1; } - if ((FLAGS_bmh.isEmpty() || FLAGS_fiddle.isEmpty() || FLAGS_ref.isEmpty()) && FLAGS_catalog) { - SkDebugf("-c requires -b -f -r\n"); + if (!FLAGS_bmh.isEmpty() && !FLAGS_status.isEmpty()) { + SkDebugf("requires -b or -a but not both\n"); SkCommandLineFlags::PrintUsage(); return 1; } - if (FLAGS_bmh.isEmpty() && !FLAGS_examples.isEmpty()) { - SkDebugf("-e requires -b\n"); + if (!FLAGS_include.isEmpty() && !FLAGS_status.isEmpty()) { + SkDebugf("requires -i or -a but not both\n"); + SkCommandLineFlags::PrintUsage(); + return 1; + } + if (FLAGS_bmh.isEmpty() && FLAGS_status.isEmpty() && FLAGS_catalog) { + SkDebugf("-c requires -b or -a\n"); + SkCommandLineFlags::PrintUsage(); + return 1; + } + if ((FLAGS_fiddle.isEmpty() || FLAGS_ref.isEmpty()) && FLAGS_catalog) { + SkDebugf("-c requires -f -r\n"); + SkCommandLineFlags::PrintUsage(); + return 1; + } + if (FLAGS_bmh.isEmpty() && FLAGS_status.isEmpty() && !FLAGS_examples.isEmpty()) { + SkDebugf("-e requires -b or -a\n"); SkCommandLineFlags::PrintUsage(); return 1; } @@ -1538,18 +1558,19 @@ int main(int argc, char** const argv) { } return 0; } - if ((FLAGS_include.isEmpty() || FLAGS_bmh.isEmpty()) && FLAGS_populate) { - SkDebugf("-p requires -b -i\n"); + if ((FLAGS_include.isEmpty() || FLAGS_bmh.isEmpty()) && FLAGS_status.isEmpty() && + FLAGS_populate) { + SkDebugf("-p requires -b -i or -a\n"); SkCommandLineFlags::PrintUsage(); return 1; } - if (FLAGS_bmh.isEmpty() && !FLAGS_ref.isEmpty()) { - SkDebugf("-r requires -b\n"); + if (FLAGS_bmh.isEmpty() && FLAGS_status.isEmpty() && !FLAGS_ref.isEmpty()) { + SkDebugf("-r requires -b or -a\n"); SkCommandLineFlags::PrintUsage(); return 1; } - if (FLAGS_bmh.isEmpty() && !FLAGS_spellcheck.isEmpty()) { - SkDebugf("-s requires -b\n"); + if (FLAGS_bmh.isEmpty() && FLAGS_status.isEmpty() && !FLAGS_spellcheck.isEmpty()) { + SkDebugf("-s requires -b or -a\n"); SkCommandLineFlags::PrintUsage(); return 1; } @@ -1558,8 +1579,9 @@ int main(int argc, char** const argv) { SkCommandLineFlags::PrintUsage(); return 1; } - if ((FLAGS_include.isEmpty() || FLAGS_bmh.isEmpty()) && FLAGS_crosscheck) { - SkDebugf("-x requires -b -i\n"); + if ((FLAGS_include.isEmpty() || FLAGS_bmh.isEmpty()) && FLAGS_status.isEmpty() && + FLAGS_crosscheck) { + SkDebugf("-x requires -b -i or -a\n"); SkCommandLineFlags::PrintUsage(); return 1; } @@ -1568,31 +1590,51 @@ int main(int argc, char** const argv) { if (!bmhParser.parseFile(FLAGS_bmh[0], ".bmh")) { return -1; } + } else if (!FLAGS_status.isEmpty()) { + bmhParser.reset(); + if (!bmhParser.parseStatus(FLAGS_status[0], ".bmh", StatusFilter::kInProgress)) { + return -1; + } } bool done = false; - if (!FLAGS_include.isEmpty()) { - if (FLAGS_tokens || FLAGS_crosscheck) { + if (!FLAGS_include.isEmpty() && FLAGS_tokens) { + IncludeParser includeParser; + includeParser.validate(); + if (!includeParser.parseFile(FLAGS_include[0], ".h")) { + return -1; + } + if (FLAGS_tokens) { + includeParser.fDebugOut = FLAGS_stdout; + if (includeParser.dumpTokens(FLAGS_bmh[0])) { + bmhParser.fWroteOut = true; + } + done = true; + } + } else if (!FLAGS_include.isEmpty() || !FLAGS_status.isEmpty()) { + if (FLAGS_crosscheck) { IncludeParser includeParser; includeParser.validate(); - if (!includeParser.parseFile(FLAGS_include[0], ".h")) { + if (!FLAGS_include.isEmpty() && + !includeParser.parseFile(FLAGS_include[0], ".h")) { return -1; } - if (FLAGS_tokens) { - includeParser.fDebugOut = FLAGS_stdout; - if (includeParser.dumpTokens(FLAGS_bmh[0])) { - bmhParser.fWroteOut = true; - } - done = true; - } else if (FLAGS_crosscheck) { - if (!includeParser.crossCheck(bmhParser)) { - return -1; - } - done = true; + if (!FLAGS_status.isEmpty() && !includeParser.parseStatus(FLAGS_status[0], ".h", + StatusFilter::kCompleted)) { + return -1; } + if (!includeParser.crossCheck(bmhParser)) { + return -1; + } + done = true; } else if (FLAGS_populate) { IncludeWriter includeWriter; includeWriter.validate(); - if (!includeWriter.parseFile(FLAGS_include[0], ".h")) { + if (!FLAGS_include.isEmpty() && + !includeWriter.parseFile(FLAGS_include[0], ".h")) { + return -1; + } + if (!FLAGS_status.isEmpty() && !includeWriter.parseStatus(FLAGS_status[0], ".h", + StatusFilter::kCompleted)) { return -1; } includeWriter.fDebugOut = FLAGS_stdout; @@ -1603,22 +1645,25 @@ int main(int argc, char** const argv) { done = true; } } - if (!done && !FLAGS_catalog && !FLAGS_fiddle.isEmpty() && FLAGS_examples.isEmpty()) { + if (!done && !FLAGS_fiddle.isEmpty() && FLAGS_examples.isEmpty()) { FiddleParser fparser(&bmhParser); if (!fparser.parseFile(FLAGS_fiddle[0], ".txt")) { return -1; } } if (!done && FLAGS_catalog && FLAGS_examples.isEmpty()) { - Catalog fparser(&bmhParser); - fparser.fDebugOut = FLAGS_stdout; - if (!fparser.openCatalog(FLAGS_bmh[0], FLAGS_ref[0])) { + Catalog cparser(&bmhParser); + cparser.fDebugOut = FLAGS_stdout; + if (!FLAGS_bmh.isEmpty() && !cparser.openCatalog(FLAGS_bmh[0], FLAGS_ref[0])) { return -1; } - if (!fparser.parseFile(FLAGS_fiddle[0], ".txt")) { + if (!FLAGS_status.isEmpty() && !cparser.openStatus(FLAGS_status[0], FLAGS_ref[0])) { + return -1; + } + if (!cparser.parseFile(FLAGS_fiddle[0], ".txt")) { return -1; } - if (!fparser.closeCatalog()) { + if (!cparser.closeCatalog()) { return -1; } bmhParser.fWroteOut = true; @@ -1627,12 +1672,20 @@ int main(int argc, char** const argv) { if (!done && !FLAGS_ref.isEmpty() && FLAGS_examples.isEmpty()) { MdOut mdOut(bmhParser); mdOut.fDebugOut = FLAGS_stdout; - if (mdOut.buildReferences(FLAGS_bmh[0], FLAGS_ref[0])) { + if (!FLAGS_bmh.isEmpty() && mdOut.buildReferences(FLAGS_bmh[0], FLAGS_ref[0])) { + bmhParser.fWroteOut = true; + } + if (!FLAGS_status.isEmpty() && mdOut.buildStatus(FLAGS_status[0], FLAGS_ref[0])) { bmhParser.fWroteOut = true; } } if (!done && !FLAGS_spellcheck.isEmpty() && FLAGS_examples.isEmpty()) { - bmhParser.spellCheck(FLAGS_bmh[0], FLAGS_spellcheck); + if (!FLAGS_bmh.isEmpty()) { + bmhParser.spellCheck(FLAGS_bmh[0], FLAGS_spellcheck); + } + if (!FLAGS_status.isEmpty()) { + bmhParser.spellStatus(FLAGS_status[0], FLAGS_spellcheck); + } bmhParser.fWroteOut = true; done = true; } diff --git a/tools/bookmaker/bookmaker.h b/tools/bookmaker/bookmaker.h index 2d0f03cde0..d4126cebd4 100644 --- a/tools/bookmaker/bookmaker.h +++ b/tools/bookmaker/bookmaker.h @@ -10,6 +10,7 @@ #include "SkCommandLineFlags.h" #include "SkData.h" +#include "SkJSONCPP.h" #include <algorithm> #include <cmath> @@ -175,6 +176,12 @@ enum class KeyProperty { kPreprocessor, }; +enum class StatusFilter { + kCompleted, + kInProgress, + kUnknown, +}; + struct IncludeKey { const char* fName; KeyWord fKeyWord; @@ -228,6 +235,7 @@ class TextParser : public NonAssignable { TextParser() {} // only for ParserCommon to call friend class ParserCommon; public: + virtual ~TextParser() {} class Save { public: Save(TextParser* parser) { @@ -636,6 +644,10 @@ public: } } + // FIXME: nothing else in TextParser knows from C++ -- + // there could be a class between TextParser and ParserCommon + virtual string typedefName(); + const char* wordEnd() const { const char* end = fChar; while (isalnum(end[0]) || '_' == end[0] || '-' == end[0]) { @@ -690,7 +702,7 @@ public: fEnd = writer; } - virtual ~EscapeParser() { + ~EscapeParser() override { delete fStorage; } private: @@ -939,6 +951,7 @@ struct IClassDefinition : public Definition { unordered_map<string, Definition*> fMembers; unordered_map<string, Definition*> fMethods; unordered_map<string, Definition*> fStructs; + unordered_map<string, Definition*> fTypedefs; }; struct Reference { @@ -965,7 +978,7 @@ public: { } - virtual ~ParserCommon() { + ~ParserCommon() override { } void addDefinition(Definition* def) { @@ -1018,6 +1031,7 @@ public: } bool parseFile(const char* file, const char* suffix); + bool parseStatus(const char* file, const char* suffix, StatusFilter filter); virtual bool parseFromFile(const char* path) = 0; bool parseSetup(const char* path); @@ -1053,7 +1067,6 @@ public: fMaxLF = 1; } - void writeBlock(int size, const char* data) { SkAssertResult(writeBlockTrim(size, data)); } @@ -1109,7 +1122,28 @@ private: typedef TextParser INHERITED; }; +struct JsonStatus { + const Json::Value& fObject; + Json::Value::iterator fIter; + string fName; +}; +class StatusIter : public ParserCommon { +public: + StatusIter(const char* statusFile, const char* suffix, StatusFilter); + ~StatusIter() override {} + string baseDir(); + bool empty() { return fStack.empty(); } + bool next(string* file); +protected: + bool parseFromFile(const char* path) override; + void reset() override; +private: + vector<JsonStatus> fStack; + Json::Value fRoot; + const char* fSuffix; + StatusFilter fFilter; +}; class BmhParser : public ParserCommon { public: @@ -1290,9 +1324,10 @@ public: bool skipNoName(); bool skipToDefinitionEnd(MarkType markType); void spellCheck(const char* match, SkCommandLineFlags::StringArray report) const; + void spellStatus(const char* match, SkCommandLineFlags::StringArray report) const; vector<string> topicName(); vector<string> typeName(MarkType markType, bool* expectEnd); - string typedefName(); + string typedefName() override; string uniqueName(const string& base, MarkType markType); string uniqueRootName(const string& base, MarkType markType); void validate() const; @@ -1473,6 +1508,7 @@ public: bool parseEnum(Definition* child, Definition* markupDef); bool parseFromFile(const char* path) override { + this->reset(); if (!INHERITED::parseSetup(path)) { return false; } @@ -1486,7 +1522,7 @@ public: bool parseObject(Definition* child, Definition* markupDef); bool parseObjects(Definition* parent, Definition* markupDef); bool parseTemplate(); - bool parseTypedef(); + bool parseTypedef(Definition* child, Definition* markupDef); bool parseUnion(); void popBracket() { @@ -1783,7 +1819,6 @@ public: fMethodDef = nullptr; fBmhStructDef = nullptr; fAttrDeprecated = nullptr; - fAnonymousEnumCount = 1; fInStruct = false; fWroteMethod = false; fIndentNext = false; @@ -1883,6 +1918,7 @@ public: bool appendFile(const string& path); bool closeCatalog(); bool openCatalog(const char* inDir, const char* outDir); + bool openStatus(const char* inDir, const char* outDir); bool parseFromFile(const char* path) override ; private: @@ -1926,6 +1962,7 @@ public: } bool buildReferences(const char* path, const char* outDir); + bool buildStatus(const char* path, const char* outDir); private: enum class TableState { kNone, @@ -2003,6 +2040,8 @@ public: , fClassName(className) { } + ~MethodParser() override {} + void skipToMethodStart() { if (!fClassName.length()) { this->skipToAlphaNum(); diff --git a/tools/bookmaker/cataloger.cpp b/tools/bookmaker/cataloger.cpp index 48e3b48753..c227437c7d 100644 --- a/tools/bookmaker/cataloger.cpp +++ b/tools/bookmaker/cataloger.cpp @@ -50,6 +50,17 @@ bool Catalog::openCatalog(const char* inDir, const char* outDir) { return true; } +bool Catalog::openStatus(const char* statusFile, const char* outDir) { + StatusIter iter(statusFile, ".bmh", StatusFilter::kInProgress); + string unused; + // FIXME: iterate through only chosen files by setting fDocsDir to iter + // read one file to find directory + if (!iter.next(&unused)) { + return false; + } + return openCatalog(iter.baseDir().c_str(), outDir); +} + bool Catalog::closeCatalog() { if (fOut) { this->lf(1); diff --git a/tools/bookmaker/definition.cpp b/tools/bookmaker/definition.cpp index 44da2df268..91592f9dcf 100644 --- a/tools/bookmaker/definition.cpp +++ b/tools/bookmaker/definition.cpp @@ -541,7 +541,7 @@ bool Definition::exampleToScript(string* result, ExampleOptions exampleOptions) break; case MarkType::kFunction: { // emit this, but don't wrap this in draw() - string funcText(iter->fContentStart, iter->fContentEnd - iter->fContentStart - 1); + string funcText(iter->fContentStart, iter->fContentEnd - iter->fContentStart); size_t pos = 0; while (pos < funcText.length() && ' ' > funcText[pos]) { ++pos; @@ -576,9 +576,6 @@ bool Definition::exampleToScript(string* result, ExampleOptions exampleOptions) size_t end = text.length(); size_t outIndent = 0; size_t textIndent = count_indent(text, pos, end); - if ("MakeFromBackendTexture" == fName) { - SkDebugf(""); - } if (fWrapper.length() > 0) { code += fWrapper; code += "\\n"; @@ -899,9 +896,6 @@ string Definition::formatFunction() const { const char* lastStart = methodParser.fChar; const int limit = 100; // todo: allow this to be set by caller or in global or something string name = this->methodName(); - if ("MakeFromBackendTextureAsRenderTarget" == name) { - SkDebugf(""); - } const char* nameInParser = methodParser.strnstr(name.c_str(), methodParser.fEnd); methodParser.skipTo(nameInParser); const char* lastEnd = methodParser.fChar; @@ -1227,10 +1221,6 @@ bool RootDefinition::dumpUnVisited(bool skip) { if ("SkBitmap::validate()" == leaf.first) { continue; } - // typedef uint32_t SaveLayerFlags not seen in SkCanvas.h, don't know why - if ("SaveLayerFlags" == leaf.first) { - continue; - } // SkPath::pathRefIsValid in #ifdef ; prefer to remove chrome dependency to fix if ("SkPath::pathRefIsValid" == leaf.first) { continue; diff --git a/tools/bookmaker/includeParser.cpp b/tools/bookmaker/includeParser.cpp index 955e6ef724..cd6e9e3914 100644 --- a/tools/bookmaker/includeParser.cpp +++ b/tools/bookmaker/includeParser.cpp @@ -426,6 +426,13 @@ bool IncludeParser::crossCheck(BmhParser& bmhParser) { SkDebugf("member missing from bmh: %s\n", fullName.c_str()); } break; + case MarkType::kTypedef: + if (def) { + def->fVisited = true; + } else { + SkDebugf("typedef missing from bmh: %s\n", fullName.c_str()); + } + break; default: SkASSERT(0); // unhandled break; @@ -1474,9 +1481,6 @@ bool IncludeParser::parseMethod(Definition* child, Definition* markupDef) { break; } tokenIter->fName = nameStr; - if ("operator" == nameStr) { - SkDebugf(""); - } tokenIter->fMarkType = MarkType::kMethod; tokenIter->fPrivate = string::npos != nameStr.find("::"); auto testIter = child->fParent->fTokens.begin(); @@ -1538,9 +1542,6 @@ bool IncludeParser::parseMethod(Definition* child, Definition* markupDef) { auto globalFunction = &fIFunctionMap[name]; globalFunction->fContentStart = start; globalFunction->fName = name; - if ("operator+" == name) { - SkDebugf(""); - } globalFunction->fFiddle = name; globalFunction->fContentEnd = end; globalFunction->fMarkType = MarkType::kMethod; @@ -1555,9 +1556,6 @@ bool IncludeParser::parseMethod(Definition* child, Definition* markupDef) { SkASSERT(classDef.fStart); string uniqueName = this->uniqueName(classDef.fMethods, nameStr); markupChild->fName = uniqueName; - if ("operator+" == uniqueName) { - SkDebugf(""); - } if (!this->findComments(*child, markupChild)) { return false; } @@ -1603,7 +1601,7 @@ bool IncludeParser::parseObject(Definition* child, Definition* markupDef) { } break; case KeyWord::kTypedef: - if (!this->parseTypedef()) { + if (!this->parseTypedef(child, markupDef)) { return child->reportError<bool>("failed to parse typedef"); } break; @@ -1720,8 +1718,29 @@ bool IncludeParser::parseTemplate() { return true; } -bool IncludeParser::parseTypedef() { - +bool IncludeParser::parseTypedef(Definition* child, Definition* markupDef) { + TextParser typedefParser(child); + string nameStr = typedefParser.typedefName(); + if (!markupDef) { + Definition& typedefDef = fITypedefMap[nameStr]; + SkASSERT(!typedefDef.fStart); + typedefDef.fStart = child->fContentStart; + typedefDef.fContentStart = child->fContentStart; + typedefDef.fName = nameStr; + typedefDef.fFiddle = nameStr; + typedefDef.fContentEnd = child->fContentEnd; + typedefDef.fTerminator = child->fContentEnd; + typedefDef.fMarkType = MarkType::kTypedef; + typedefDef.fLineCount = child->fLineCount; + return true; + } + markupDef->fTokens.emplace_back(MarkType::kTypedef, child->fContentStart, child->fContentEnd, + child->fLineCount, markupDef); + Definition* markupChild = &markupDef->fTokens.back(); + markupChild->fName = nameStr; + markupChild->fTerminator = markupChild->fContentEnd; + IClassDefinition& classDef = fIClassMap[markupDef->fName]; + classDef.fTypedefs[nameStr] = markupChild; return true; } diff --git a/tools/bookmaker/includeWriter.cpp b/tools/bookmaker/includeWriter.cpp index 8c6d7a938c..b18585f4bf 100644 --- a/tools/bookmaker/includeWriter.cpp +++ b/tools/bookmaker/includeWriter.cpp @@ -8,9 +8,6 @@ #include "bookmaker.h" void IncludeWriter::descriptionOut(const Definition* def) { - if ("SkPoint_length" == def->fFiddle) { - SkDebugf(""); - } const char* commentStart = def->fContentStart; int commentLen = (int) (def->fContentEnd - commentStart); bool breakOut = false; @@ -911,9 +908,6 @@ 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; @@ -1034,9 +1028,6 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti --continueEnd; } methodName += string(fContinuation, continueEnd - fContinuation); - if ("SkIPoint::operator+" == methodName) { - SkDebugf(""); - } method = root->find(methodName, RootDefinition::AllowParens::kNo); if (!method) { fLineCount = child.fLineCount; @@ -1093,9 +1084,6 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti startDef = &child; fStart = child.fContentStart; methodName = root->fName + "::" + child.fName; - if ("SkIPoint::operator+" == methodName) { - SkDebugf(""); - } inConstructor = root->fName == child.fName; fContinuation = child.fContentEnd; method = root->find(methodName, RootDefinition::AllowParens::kNo); @@ -1447,6 +1435,7 @@ bool IncludeWriter::populate(BmhParser& bmhParser) { root->clearVisited(); fStart = includeMapper.second.fContentStart; fEnd = includeMapper.second.fContentEnd; + fAnonymousEnumCount = 1; allPassed &= this->populate(&includeMapper.second, nullptr, root); this->writeBlock((int) (fEnd - fStart), fStart); fIndent = 0; diff --git a/tools/bookmaker/mdOut.cpp b/tools/bookmaker/mdOut.cpp index 6b082ad1de..216a104fd8 100644 --- a/tools/bookmaker/mdOut.cpp +++ b/tools/bookmaker/mdOut.cpp @@ -63,9 +63,6 @@ string MdOut::addReferences(const char* refStart, const char* refEnd, } else { leadingSpaces = string(base, wordStart - base); } - if (!strncmp("SkPoint::operator-()", start, 20)) { - SkDebugf(""); - } t.skipToMethodEnd(); if (base == t.fChar) { break; @@ -77,9 +74,6 @@ string MdOut::addReferences(const char* refStart, const char* refEnd, continue; } ref = string(start, t.fChar - start); - if (412 == t.fLineCount) { - SkDebugf(""); - } if (const Definition* def = this->isDefined(t, ref, BmhParser::Resolvable::kOut != resolvable)) { SkASSERT(def->fFiddle.length()); @@ -218,6 +212,9 @@ string MdOut::addReferences(const char* refStart, const char* refEnd, continue; } } + if ("RasterReleaseProc" == ref) { + SkDebugf(""); + } Definition* test = fRoot; do { if (!test->isRoot()) { @@ -269,6 +266,19 @@ bool MdOut::buildReferences(const char* fileOrPath, const char* outDir) { return true; } +bool MdOut::buildStatus(const char* statusFile, const char* outDir) { + StatusIter iter(statusFile, ".bmh", StatusFilter::kInProgress); + for (string file; iter.next(&file); ) { + SkString p = SkOSPath::Join(iter.baseDir().c_str(), file.c_str()); + const char* hunk = p.c_str(); + if (!this->buildRefFromFile(hunk, outDir)) { + SkDebugf("failed to parse %s\n", hunk); + return false; + } + } + return true; +} + bool MdOut::buildRefFromFile(const char* name, const char* outDir) { fFileName = string(name); string filename(name); @@ -285,8 +295,16 @@ bool MdOut::buildRefFromFile(const char* name, const char* outDir) { match += ".bmh"; fOut = nullptr; string fullName; - for (const auto& topic : fBmhParser.fTopicMap) { - Definition* topicDef = topic.second; + + vector<string> keys; + keys.reserve(fBmhParser.fTopicMap.size()); + for (const auto& it : fBmhParser.fTopicMap) { + keys.push_back(it.first); + } + std::sort(keys.begin(), keys.end()); + for (auto key : keys) { + string s(key); + auto topicDef = fBmhParser.fTopicMap.at(s); if (topicDef->fParent) { continue; } @@ -723,16 +741,18 @@ void MdOut::markTypeOut(Definition* def) { gpuAndCpu = platParse.strnstr("cpu", platParse.fEnd); } } - if (fHasFiddle) { + if (fHasFiddle && !def->hasChild(MarkType::kError)) { + SkASSERT(def->fHash.length() > 0); fprintf(fOut, "<div><fiddle-embed name=\"%s\"", def->fHash.c_str()); if (showGpu) { - fprintf(fOut, "gpu=\"true\""); + fprintf(fOut, " gpu=\"true\""); if (gpuAndCpu) { - fprintf(fOut, "cpu=\"true\""); + fprintf(fOut, " cpu=\"true\""); } } fprintf(fOut, ">"); } else { + SkASSERT(def->fHash.length() == 0); fprintf(fOut, "<pre style=\"padding: 1em 1em 1em 1em; font-size: 13px" " width: 62.5em; background-color: #f0f0f0\">"); this->lfAlways(1); diff --git a/tools/bookmaker/parserCommon.cpp b/tools/bookmaker/parserCommon.cpp index 79503a66b3..af1031ac43 100644 --- a/tools/bookmaker/parserCommon.cpp +++ b/tools/bookmaker/parserCommon.cpp @@ -16,7 +16,6 @@ static void debug_out(int len, const char* data) { } bool ParserCommon::parseFile(const char* fileOrPath, const char* suffix) { -// this->reset(); if (!sk_isdir(fileOrPath)) { if (!this->parseFromFile(fileOrPath)) { SkDebugf("failed to parse %s\n", fileOrPath); @@ -39,9 +38,23 @@ bool ParserCommon::parseFile(const char* fileOrPath, const char* suffix) { return true; } +bool ParserCommon::parseStatus(const char* statusFile, const char* suffix, StatusFilter filter) { + StatusIter iter(statusFile, suffix, filter); + if (iter.empty()) { + return false; + } + for (string file; iter.next(&file); ) { + SkString p = SkOSPath::Join(iter.baseDir().c_str(), file.c_str()); + const char* hunk = p.c_str(); + if (!this->parseFromFile(hunk)) { + SkDebugf("failed to parse %s\n", hunk); + return false; + } + } + return true; +} bool ParserCommon::parseSetup(const char* path) { -// this->reset(); sk_sp<SkData> data = SkData::MakeFromFileName(path); if (nullptr == data.get()) { SkDebugf("%s missing\n", path); @@ -210,3 +223,105 @@ void ParserCommon::writeString(const char* str) { fLinefeeds = 0; fMaxLF = 2; } + +StatusIter::StatusIter(const char* statusFile, const char* suffix, StatusFilter filter) + : fSuffix(suffix) + , fFilter(filter) { + if (!this->parseFromFile(statusFile)) { + return; + } +} + +static const char* block_names[] = { + "Completed", + "InProgress", +}; + +string StatusIter::baseDir() { + SkASSERT(fStack.back().fObject.isArray()); + SkASSERT(fStack.size() > 2); + string dir; + for (unsigned index = 2; index < fStack.size(); ++index) { + dir += fStack[index].fName; + if (index < fStack.size() - 1) { + dir += SkOSPath::SEPARATOR; + } + } + return dir; +} + +// FIXME: need to compare fBlockName against fFilter +// need to compare fSuffix against next value returned +bool StatusIter::next(string* str) { + JsonStatus* status; + do { + do { + if (fStack.empty()) { + return false; + } + status = &fStack.back(); + if (status->fIter != status->fObject.end()) { + break; + } + fStack.pop_back(); + } while (true); + if (1 == fStack.size()) { + do { + StatusFilter blockType = StatusFilter::kUnknown; + for (unsigned index = 0; index < SK_ARRAY_COUNT(block_names); ++index) { + if (status->fIter.key().asString() == block_names[index]) { + blockType = (StatusFilter) index; + break; + } + } + if (blockType <= fFilter) { + break; + } + status->fIter++; + } while (status->fIter != status->fObject.end()); + if (status->fIter == status->fObject.end()) { + continue; + } + } + if (!status->fObject.isArray()) { + SkASSERT(status->fIter != status->fObject.end()); + JsonStatus block = { + *status->fIter, + status->fIter->begin(), + status->fIter.key().asString() + }; + fStack.emplace_back(block); + status = &(&fStack.back())[-1]; + status->fIter++; + status = &fStack.back(); + continue; + } + *str = status->fIter->asString(); + status->fIter++; + if (str->length() - strlen(fSuffix) == str->find(fSuffix)) { + return true; + } + } while (true); + return true; +} + +bool StatusIter::parseFromFile(const char* path) { + sk_sp<SkData> json(SkData::MakeFromFileName(path)); + if (!json) { + SkDebugf("file %s:\n", path); + return this->reportError<bool>("file not readable"); + } + Json::Reader reader; + const char* data = (const char*)json->data(); + if (!reader.parse(data, data+json->size(), fRoot)) { + SkDebugf("file %s:\n", path); + return this->reportError<bool>("file not parsable"); + } + JsonStatus block = { fRoot, fRoot.begin(), "" }; + fStack.emplace_back(block); + return true; +} + +void StatusIter::reset() { + fStack.clear(); +} diff --git a/tools/bookmaker/spellCheck.cpp b/tools/bookmaker/spellCheck.cpp index 6f50cb3bb5..33c0578853 100644 --- a/tools/bookmaker/spellCheck.cpp +++ b/tools/bookmaker/spellCheck.cpp @@ -96,6 +96,14 @@ void BmhParser::spellCheck(const char* match, SkCommandLineFlags::StringArray re checker.report(report); } +void BmhParser::spellStatus(const char* statusFile, SkCommandLineFlags::StringArray report) const { + SpellCheck checker(*this); + StatusIter iter(statusFile, ".bmh", StatusFilter::kInProgress); + string match = iter.baseDir(); + checker.check(match.c_str()); + checker.report(report); +} + bool SpellCheck::check(const char* match) { for (const auto& topic : fBmhParser.fTopicMap) { Definition* topicDef = topic.second; |