diff --git a/docs/SkImage_Reference.bmh b/docs/SkImage_Reference.bmh index 9a2b79e711..1f61db2917 100644 --- a/docs/SkImage_Reference.bmh +++ b/docs/SkImage_Reference.bmh @@ -1142,17 +1142,35 @@ 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. +Color_Space returned was passed to an Image constructor, +or was parsed from encoded data. Color_Space returned may be ignored when Image +is drawn, depending on the capabilities of the Surface receiving the drawing. #Return Color_Space in Image, or nullptr ## #Example -// incomplete +#Image 3 +#Set sRGB + SkPixmap pixmap; + source.peekPixels(&pixmap); + canvas->scale(.25f, .25f); + int y = 0; + for (auto gamma : { SkColorSpace::kLinear_RenderTargetGamma, + SkColorSpace::kSRGB_RenderTargetGamma } ) { + int x = 0; + sk_sp colorSpace = SkColorSpace::MakeRGB(gamma, SkColorSpace::kSRGB_Gamut); + for (int index = 0; index < 2; ++index) { + pixmap.setColorSpace(colorSpace); + sk_sp image = SkImage::MakeRasterCopy(pixmap); + canvas->drawImage(image, x, y); + colorSpace = image->colorSpace()->makeColorSpin(); + x += 512; + } + y += 512; + } ## -#SeeAlso incomplete +#SeeAlso refColorSpace makeColorSpace #Method ## @@ -1160,13 +1178,41 @@ drawing Image, and when drawing into Surface constructed with Color_Space. #Method sk_sp refColorSpace() const -#Return incomplete ## +Returns a smart pointer to Color_Space, the range of colors, associated with +Image. The smart pointer tracks the number of objects sharing this +SkColorSpace reference so the memory is released when the owners destruct. + +The returned SkColorSpace is immutable. + +Color_Space returned was passed to an Image constructor, +or was parsed from encoded data. Color_Space returned may be ignored when Image +is drawn, depending on the capabilities of the Surface receiving the drawing. + +#Return Color_Space in Image, or nullptr, wrapped in a smart pointer ## #Example -// incomplete +#Image 3 +#Set sRGB + SkPixmap pixmap; + source.peekPixels(&pixmap); + canvas->scale(.25f, .25f); + int y = 0; + for (auto gamma : { SkColorSpace::kLinear_RenderTargetGamma, + SkColorSpace::kSRGB_RenderTargetGamma } ) { + int x = 0; + sk_sp colorSpace = SkColorSpace::MakeRGB(gamma, SkColorSpace::kSRGB_Gamut); + for (int index = 0; index < 2; ++index) { + pixmap.setColorSpace(colorSpace); + sk_sp image = SkImage::MakeRasterCopy(pixmap); + canvas->drawImage(image, x, y); + colorSpace = image->refColorSpace()->makeColorSpin(); + x += 512; + } + y += 512; + } ## -#SeeAlso incomplete +#SeeAlso colorSpace makeColorSpace #Method ## @@ -1180,10 +1226,15 @@ is packed in 8 bits as defined by kAlpha_8_SkColorType. #Return true if pixels represent a transparency mask ## #Example -// incomplete + uint8_t pmColors = 0; + sk_sp image = SkImage::MakeRasterCopy({SkImageInfo::MakeA8(1, 1), &pmColors, 1}); + SkDebugf("alphaOnly = %s\n", image->isAlphaOnly() ? "true" : "false"); +#StdOut +alphaOnly = true +## ## -#SeeAlso incomplete +#SeeAlso alphaType isOpaque #Method ## @@ -1191,15 +1242,26 @@ is packed in 8 bits as defined by kAlpha_8_SkColorType. #Method bool isOpaque() const -Returns if all pixels ignore any Alpha value and are treated as fully opaque. +Returns true if pixels ignore their Alpha value and are treated as fully opaque. #Return true if Alpha_Type is kOpaque_SkAlphaType ## #Example -// incomplete + auto check_isopaque = [](const SkImageInfo& imageInfo) -> void { + auto surface(SkSurface::MakeRaster(imageInfo)); + auto image(surface->makeImageSnapshot()); + SkDebugf("isOpaque = %s\n", image->isOpaque() ? "true" : "false"); + }; + + check_isopaque(SkImageInfo::MakeN32Premul(5, 5)); + check_isopaque(SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType)); +#StdOut +isOpaque = false +isOpaque = true +## ## -#SeeAlso incomplete +#SeeAlso alphaType isAlphaOnly #Method ## @@ -1208,17 +1270,31 @@ Returns if all pixels ignore any Alpha value and are treated as fully opaque. #Method sk_sp makeShader(SkShader::TileMode tileMode1, SkShader::TileMode tileMode2, const SkMatrix* localMatrix = nullptr) const -#Param tileMode1 incomplete ## -#Param tileMode2 incomplete ## -#Param localMatrix incomplete ## +Creates Shader from Image. Shader dimensions are taken from Image. Shader uses +SkShader::TileMode rules to fill drawn area outside Image. localMatrix permits +transforming Image before Canvas_Matrix is applied. -#Return incomplete ## +#Param tileMode1 tiling in x, one of: SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, + SkShader::kMirror_TileMode +## +#Param tileMode2 tiling in y, one of: SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, + SkShader::kMirror_TileMode +## +#Param localMatrix Image transformation, or nullptr ## + +#Return Shader containing Image ## #Example -// incomplete +#Image 4 +SkMatrix matrix; +matrix.setRotate(45); +SkPaint paint; +paint.setShader(image->makeShader(SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode, + &matrix)); +canvas->drawPaint(paint); ## -#SeeAlso incomplete +#SeeAlso scalePixels #Method ## @@ -1226,14 +1302,22 @@ Returns if all pixels ignore any Alpha value and are treated as fully opaque. #Method sk_sp makeShader(const SkMatrix* localMatrix = nullptr) const -Helper version of makeShader() that specifies SkShader::kClamp_TileMode. +Creates Shader from Image. Shader dimensions are taken from Image. Shader uses +SkShader::kClamp_TileMode to fill drawn area outside Image. localMatrix permits +transforming Image before Canvas_Matrix is applied. -#Param localMatrix incomplete ## +#Param localMatrix Image transformation, or nullptr ## -#Return incomplete ## +#Return Shader containing Image ## #Example -// incomplete +#Image 5 +SkMatrix matrix; +matrix.setRotate(45); +matrix.postTranslate(125, 30); +SkPaint paint; +paint.setShader(image->makeShader(&matrix)); +canvas->drawPaint(paint); ## #SeeAlso incomplete diff --git a/docs/SkPath_Reference.bmh b/docs/SkPath_Reference.bmh index 83943b0b6c..2626726488 100644 --- a/docs/SkPath_Reference.bmh +++ b/docs/SkPath_Reference.bmh @@ -736,10 +736,9 @@ paths are interpolatable #Method bool interpolate(const SkPath& ending, SkScalar weight, SkPath* out) const -Interpolate between Paths with equal sized Point_Arrays. -Copy Verb_Array and Weights to out, -and set out Point_Array to a weighted average of this Point_Array and ending -Point_Array, using the formula: +Interpolate between Paths with Point_Array of equal size. +Copy Verb_Array and Weights to out, and set out Point_Array to a weighted +average of this Point_Array and ending Point_Array, using the formula: #Formula (this->points * weight) + ending->points * (1 - weight) ## @@ -754,8 +753,8 @@ the same size as ending Point_Array. Call isInterpolatable to check Path compatibility prior to calling interpolate(). #Param ending Point_Array averaged with this Point_Array ## -#Param weight contribution of ending Point_Array, and - one minus contribution of this Point_Array +#Param weight contribution of this Point_Array, and + one minus contribution of ending Point_Array ## #Param out Path replaced by interpolated averages ## @@ -1759,7 +1758,7 @@ second move is not line # ------------------------------------------------------------------------------ #Subtopic Point_Array -#Alias Point_Arrays +#Substitute SkPoint array Point_Array contains Points satisfying the allocated Points for each Verb in Verb_Array. For instance, Path containing one Contour with Line diff --git a/docs/undocumented.bmh b/docs/undocumented.bmh index f99aa2211a..6aff887829 100644 --- a/docs/undocumented.bmh +++ b/docs/undocumented.bmh @@ -694,6 +694,10 @@ FT_Load_Glyph #Enum TileMode #Const kClamp_TileMode 0 ## + #Const kRepeat_TileMode 1 + ## + #Const kMirror_TileMode 2 + ## ## #Method static sk_sp MakeBitmapShader(const SkBitmap& src, TileMode tmx, TileMode tmy, const SkMatrix* localMatrix = nullptr) diff --git a/site/user/api/SkImage_Reference.md b/site/user/api/SkImage_Reference.md index b42e5917c0..033a9c5f51 100644 --- a/site/user/api/SkImage_Reference.md +++ b/site/user/api/SkImage_Reference.md @@ -1176,9 +1176,9 @@ Returns Color Space, the range of colors, 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. +Color Space returned was passed to an Image constructor, +or was parsed from encoded data. Color Space returned may be ignored when Image +is drawn, depending on the capabilities of the Surface receiving the drawing. ### Return Value @@ -1186,11 +1186,11 @@ drawing Image, and when drawing into +
### See Also -incomplete +
refColorSpace makeColorSpace --- @@ -1201,17 +1201,27 @@ incomplete sk_sp<SkColorSpace> refColorSpace() const +Returns a smart pointer to Color Space, the range of colors, associated with +Image. The smart pointer tracks the number of objects sharing this +SkColorSpace reference so the memory is released when the owners destruct. + +The returned SkColorSpace is immutable. + +Color Space returned was passed to an Image constructor, +or was parsed from encoded data. Color Space returned may be ignored when Image +is drawn, depending on the capabilities of the Surface receiving the drawing. + ### Return Value -incomplete +Color Space in Image, or nullptr, wrapped in a smart pointer ### Example -
+
### See Also -incomplete +colorSpace makeColorSpace --- @@ -1231,11 +1241,19 @@ true if pixels represent a transparency mask ### Example -
+
+ +#### Example Output + +~~~~ +alphaOnly = true +~~~~ + +
### See Also -incomplete +alphaType isOpaque --- @@ -1246,7 +1264,7 @@ incomplete bool isOpaque() const -Returns if all pixels ignore any Alpha value and are treated as fully opaque. +Returns true if pixels ignore their Alpha value and are treated as fully opaque. ### Return Value @@ -1254,11 +1272,20 @@ true if Alpha Type is +
+ +#### Example Output + +~~~~ +isOpaque = false +isOpaque = true +~~~~ + +
### See Also -incomplete +
alphaType isAlphaOnly --- @@ -1270,28 +1297,34 @@ sk_sp<SkShader> makeShader(SkShader::TileMode tileMode1, SkShader::TileMod const SkMatrix* localMatrix = nullptr) const +Creates Shader from Image. Shader dimensions are taken from Image. Shader uses +SkShader::TileMode rules to fill drawn area outside Image. localMatrix permits +transforming Image before Canvas Matrix is applied. + ### Parameters +tiling in x, one of: SkShader::kClamp TileMode, SkShader::kRepeat TileMode, +SkShader::kMirror TileMode +tiling in y, one of: SkShader::kClamp TileMode, SkShader::kRepeat TileMode, +SkShader::kMirror TileMode +Image transformation, or nullptr
tileMode1 -incomplete
tileMode2 -incomplete
localMatrix -incomplete
### Return Value -incomplete +Shader containing Image ### Example -
+
### See Also -incomplete +scalePixels --- @@ -1299,22 +1332,24 @@ incomplete sk_sp<SkShader> makeShader(const SkMatrix* localMatrix = nullptr) const -Helper version of +Creates Shader from Image. Shader dimensions are taken from Image. Shader uses +SkShader::kClamp TileMode to fill drawn area outside Image. localMatrix permits +transforming Image before Canvas Matrix is applied. ### Parameters +Image transformation, or nullptr
localMatrix -incomplete
### Return Value -incomplete +Shader containing Image ### Example -
+
### See Also diff --git a/site/user/api/SkPath_Reference.md b/site/user/api/SkPath_Reference.md index 0ac5ae02c9..4b3dc94680 100644 --- a/site/user/api/SkPath_Reference.md +++ b/site/user/api/SkPath_Reference.md @@ -614,10 +614,9 @@ paths are interpolatable bool interpolate(const SkPath& ending, SkScalar weight, SkPath* out) const -Interpolate between Paths with equal sized Point Arrays. -Copy Verb Array and Weights to out, -and set out Point Array to a weighted average of this Point Array and ending -Point Array, using the formula: +Interpolate between Paths with Point Array of equal size. +Copy Verb Array and Weights to out, and set out Point Array to a weighted +average of this Point Array and ending Point Array, using the formula: (this->points * weight) + ending->points * (1 - weight). weight is most useful when between zero (ending Point Array) and @@ -633,8 +632,8 @@ compatibility prior to calling interpolate. +contribution of this Point Array, and +one minus contribution of endingPoint Array diff --git a/site/user/api/catalog.htm b/site/user/api/catalog.htm index 67afa4b989..4265f09294 100644 --- a/site/user/api/catalog.htm +++ b/site/user/api/catalog.htm @@ -1049,6 +1049,20 @@ "file": "SkImage_Reference", "name": "SkImage::dimensions()", "stdout": "dimensionsAsBounds == bounds\\n" + }, + "SkImage_isAlphaOnly": { + "code": "void draw(SkCanvas* canvas) {\n uint8_t pmColors = 0;\n sk_sp image = SkImage::MakeRasterCopy({SkImageInfo::MakeA8(1, 1), &pmColors, 1});\n SkDebugf(\"alphaOnly = %s\\n\", image->isAlphaOnly() ? \"true\" : \"false\");\n}", + "hash": "50762c73b8ea91959c5a7b68fbf1062d", + "file": "SkImage_Reference", + "name": "SkImage::isAlphaOnly", + "stdout": "alphaOnly = true\\n" + }, + "SkImage_isOpaque": { + "code": "void draw(SkCanvas* canvas) {\n auto check_isopaque = [](const SkImageInfo& imageInfo) -> void {\n auto surface(SkSurface::MakeRaster(imageInfo));\n auto image(surface->makeImageSnapshot());\n SkDebugf(\"isOpaque = %s\\n\", image->isOpaque() ? \"true\" : \"false\");\n };\n check_isopaque(SkImageInfo::MakeN32Premul(5, 5));\n check_isopaque(SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType));\n}", + "hash": "e3340460003b74ee286d625e68589d65", + "file": "SkImage_Reference", + "name": "SkImage::isOpaque", + "stdout": "isOpaque = false\\nisOpaque = true\\n" }, "SkMatrix_I": { "code": "void draw(SkCanvas* canvas) {\n SkMatrix m1, m2, m3;\n m1.reset();\n m2.setIdentity();\n m3 = SkMatrix::I();\n SkDebugf(\"m1 %c= m2\\n\", m1 == m2 ? '=' : '!');\n SkDebugf(\"m2 %c= m3\\n\", m1 == m2 ? '=' : '!');\n}", @@ -4868,10 +4882,10 @@ "name": "SkImage::bounds()" }, "SkImage_colorSpace": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", + "code": "void draw(SkCanvas* canvas) {\n SkPixmap pixmap;\n source.peekPixels(&pixmap);\n canvas->scale(.25f, .25f);\n int y = 0;\n for (auto gamma : { SkColorSpace::kLinear_RenderTargetGamma,\n SkColorSpace::kSRGB_RenderTargetGamma } ) {\n int x = 0;\n sk_sp colorSpace = SkColorSpace::MakeRGB(gamma, SkColorSpace::kSRGB_Gamut);\n for (int index = 0; index < 2; ++index) {\n pixmap.setColorSpace(colorSpace);\n sk_sp image = SkImage::MakeRasterCopy(pixmap);\n canvas->drawImage(image, x, y);\n colorSpace = image->colorSpace()->makeColorSpin();\n x += 512;\n }\n y += 512;\n }\n}", "width": 256, "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "hash": "4468d573f42af6f5e234be10a5453bb2", "file": "SkImage_Reference", "name": "SkImage::colorSpace" }, @@ -4914,14 +4928,6 @@ "hash": "96c8202a13068e36432006f75b124eee", "file": "SkImage_Reference", "name": "SkImage::height()" -}, - "SkImage_isAlphaOnly": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImage_Reference", - "name": "SkImage::isAlphaOnly" }, "SkImage_isLazyGenerated": { "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(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(new TestImageGenerator());\n sk_sp 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", @@ -4930,14 +4936,6 @@ "hash": "a8b8bd4bfe968e2c63085f867665227f", "file": "SkImage_Reference", "name": "SkImage::isLazyGenerated" -}, - "SkImage_isOpaque": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImage_Reference", - "name": "SkImage::isOpaque" }, "SkImage_isTextureBacked": { "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", @@ -4980,18 +4978,18 @@ "name": "SkImage::makeRasterImage" }, "SkImage_makeShader": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", + "code": "void draw(SkCanvas* canvas) {\n SkMatrix matrix;\n matrix.setRotate(45);\n SkPaint paint;\n paint.setShader(image->makeShader(SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode,\n &matrix));\n canvas->drawPaint(paint);\n}", "width": 256, "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "hash": "1c6de6fe72b00b5be970f5f718363449", "file": "SkImage_Reference", "name": "SkImage::makeShader" }, "SkImage_makeShader_2": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", + "code": "void draw(SkCanvas* canvas) {\n SkMatrix matrix;\n matrix.setRotate(45);\n matrix.postTranslate(125, 30);\n SkPaint paint;\n paint.setShader(image->makeShader(&matrix));\n canvas->drawPaint(paint);\n}", "width": 256, "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "hash": "10172fca71b9dbdcade772513ffeb27e", "file": "SkImage_Reference", "name": "SkImage::makeShader_2" }, @@ -5044,10 +5042,10 @@ "name": "SkImage::readPixels_2" }, "SkImage_refColorSpace": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", + "code": "void draw(SkCanvas* canvas) {\n SkPixmap pixmap;\n source.peekPixels(&pixmap);\n canvas->scale(.25f, .25f);\n int y = 0;\n for (auto gamma : { SkColorSpace::kLinear_RenderTargetGamma,\n SkColorSpace::kSRGB_RenderTargetGamma } ) {\n int x = 0;\n sk_sp colorSpace = SkColorSpace::MakeRGB(gamma, SkColorSpace::kSRGB_Gamut);\n for (int index = 0; index < 2; ++index) {\n pixmap.setColorSpace(colorSpace);\n sk_sp image = SkImage::MakeRasterCopy(pixmap);\n canvas->drawImage(image, x, y);\n colorSpace = image->refColorSpace()->makeColorSpin();\n x += 512;\n }\n y += 512;\n }\n}", "width": 256, "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "hash": "59b2078ebfbda8736a57c0486ae33332", "file": "SkImage_Reference", "name": "SkImage::refColorSpace" }, diff --git a/site/user/api/undocumented.md b/site/user/api/undocumented.md index 9b4473e453..b0bbeba90f 100644 --- a/site/user/api/undocumented.md +++ b/site/user/api/undocumented.md @@ -1000,6 +1000,12 @@ void dumpHex() const + + + + + +
ending Point Array averaged with this Point Array
weight -contribution of ending Point Array, and -one minus contribution of this Point Array
out Path replaced by interpolated averages
SkShader::kClamp_TileMode 0
SkShader::kRepeat_TileMode 1
SkShader::kMirror_TileMode 2
diff --git a/tools/bookmaker/bookmaker.cpp b/tools/bookmaker/bookmaker.cpp index 2677621ee1..b7aa044885 100644 --- a/tools/bookmaker/bookmaker.cpp +++ b/tools/bookmaker/bookmaker.cpp @@ -342,6 +342,7 @@ bool BmhParser::addDefinition(const char* defStart, bool hasEnd, MarkType markTy case MarkType::kOutdent: case MarkType::kPlatform: case MarkType::kSeeAlso: + case MarkType::kSet: case MarkType::kSubstitute: case MarkType::kTime: case MarkType::kVolatile: @@ -1262,6 +1263,7 @@ vector BmhParser::typeName(MarkType markType, bool* checkEnd) { case MarkType::kPlatform: case MarkType::kReturn: case MarkType::kSeeAlso: + case MarkType::kSet: case MarkType::kSubstitute: case MarkType::kTime: case MarkType::kToDo: diff --git a/tools/bookmaker/bookmaker.h b/tools/bookmaker/bookmaker.h index cb0e8dab16..f309d795c9 100644 --- a/tools/bookmaker/bookmaker.h +++ b/tools/bookmaker/bookmaker.h @@ -122,6 +122,7 @@ enum class MarkType { kRoot, kRow, kSeeAlso, + kSet, kStdOut, kStruct, kSubstitute, @@ -1236,6 +1237,7 @@ public: , { "", nullptr, MarkType::kRow, R_Y, E_N, M(Table) | M(List) } , { "SeeAlso", nullptr, MarkType::kSeeAlso, R_Y, E_N, M_CSST | M_E | M(Method) | M(Typedef) } +, { "Set", nullptr, MarkType::kSet, R_N, E_N, M(Example) } , { "StdOut", nullptr, MarkType::kStdOut, R_N, E_N, M(Example) } , { "Struct", &fClassMap, MarkType::kStruct, R_Y, E_O, M(Class) | M(Root) | M_ST } , { "Substitute", nullptr, MarkType::kSubstitute, R_N, E_N, M_ST } @@ -1425,6 +1427,7 @@ public: , { nullptr, MarkType::kRoot } , { nullptr, MarkType::kRow } , { nullptr, MarkType::kSeeAlso } + , { nullptr, MarkType::kSet } , { nullptr, MarkType::kStdOut } , { &fIStructMap, MarkType::kStruct } , { nullptr, MarkType::kSubstitute } diff --git a/tools/bookmaker/definition.cpp b/tools/bookmaker/definition.cpp index 933ecc6868..77f4446445 100644 --- a/tools/bookmaker/definition.cpp +++ b/tools/bookmaker/definition.cpp @@ -526,6 +526,7 @@ bool Definition::exampleToScript(string* result, ExampleOptions exampleOptions) string normalizedName(fFiddle); string code; string imageStr = "0"; + string srgbStr = "false"; for (auto const& iter : fChildren) { switch (iter->fMarkType) { case MarkType::kError: @@ -562,6 +563,15 @@ bool Definition::exampleToScript(string* result, ExampleOptions exampleOptions) case MarkType::kPlatform: // ignore for now break; + case MarkType::kSet: + if ("sRGB" == string(iter->fContentStart, + iter->fContentEnd - iter->fContentStart)) { + srgbStr = "true"; + } else { + SkASSERT(0); // more work to do + return false; + } + break; case MarkType::kStdOut: textOut = true; break; @@ -609,7 +619,7 @@ bool Definition::exampleToScript(string* result, ExampleOptions exampleOptions) example += " \"width\": " + widthStr + ",\n"; example += " \"height\": " + heightStr + ",\n"; example += " \"source\": " + imageStr + ",\n"; - example += " \"srgb\": false,\n"; + example += " \"srgb\": " + srgbStr + ",\n"; example += " \"f16\": false,\n"; example += " \"textOnly\": " + textOutStr + ",\n"; example += " \"animated\": false,\n"; diff --git a/tools/bookmaker/includeParser.cpp b/tools/bookmaker/includeParser.cpp index da2ee54c2e..363aacc650 100644 --- a/tools/bookmaker/includeParser.cpp +++ b/tools/bookmaker/includeParser.cpp @@ -1493,6 +1493,9 @@ bool IncludeParser::parseMethod(Definition* child, Definition* markupDef) { } tokenIter->fName = nameStr; tokenIter->fMarkType = MarkType::kMethod; + if (string::npos != nameStr.find("defined")) { + SkDebugf(""); + } tokenIter->fPrivate = string::npos != nameStr.find("::"); auto testIter = child->fParent->fTokens.begin(); SkASSERT(child->fParentIndex > 0); @@ -1642,10 +1645,18 @@ bool IncludeParser::parseObject(Definition* child, Definition* markupDef) { auto tokenIter = child->fParent->fTokens.begin(); std::advance(tokenIter, child->fParentIndex); tokenIter = std::prev(tokenIter); - TextParser checkDeprecated(&*tokenIter); - if (checkDeprecated.startsWith("SK_ATTR_DEPRECATED")) { + TextParser previousToken(&*tokenIter); + if (previousToken.startsWith("SK_ATTR_DEPRECATED")) { break; } + if (Bracket::kPound == child->fParent->fBracket && + KeyWord::kIf == child->fParent->fKeyWord) { + // TODO: this will skip methods named defined() -- for the + // moment there aren't any + if (previousToken.startsWith("defined")) { + break; + } + } } if (!this->parseMethod(child, markupDef)) { return child->reportError("failed to parse method"); diff --git a/tools/bookmaker/includeWriter.cpp b/tools/bookmaker/includeWriter.cpp index e8d86f0916..c34fc9391f 100644 --- a/tools/bookmaker/includeWriter.cpp +++ b/tools/bookmaker/includeWriter.cpp @@ -65,6 +65,9 @@ void IncludeWriter::descriptionOut(const Definition* def) { commentLen = (int) (prop->fContentEnd - commentStart); if (commentLen > 0) { this->writeBlockIndent(commentLen, commentStart); + if ('\n' != commentStart[commentLen - 1] && '\n' == commentStart[commentLen]) { + this->lfcr(); + } } commentStart = prop->fTerminator; commentLen = (int) (def->fContentEnd - commentStart); diff --git a/tools/bookmaker/mdOut.cpp b/tools/bookmaker/mdOut.cpp index 0153e49e95..d6069e4b3a 100644 --- a/tools/bookmaker/mdOut.cpp +++ b/tools/bookmaker/mdOut.cpp @@ -883,6 +883,8 @@ void MdOut::markTypeOut(Definition* def) { fprintf(fOut, "See Also"); this->lf(2); break; + case MarkType::kSet: + break; case MarkType::kStdOut: { TextParser code(def); this->mdHeaderOut(4);