diff options
author | Cary Clark <caryclark@skia.org> | 2017-12-15 11:21:51 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-15 16:47:08 +0000 |
commit | 0c5f54663b3080819825bd035979a82d4c5ac902 (patch) | |
tree | 9204af52a6f81b3fcbfa5751de2216292145c517 /site/user | |
parent | 0b1df4b87a6d97d2a590b011e6d748eef3709cb4 (diff) |
working on image docs
some new image work
turn dos into unix linefeeds
add SkBitmap::pixmap()
Docs-Preview: https://skia.org/?cl=83863
TBR=caryclark@google.com
Bug: skia:6898
Change-Id: I06242b4b66464814b753fe37f930baf32f79323a
Reviewed-on: https://skia-review.googlesource.com/83863
Reviewed-by: Cary Clark <caryclark@skia.org>
Commit-Queue: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'site/user')
-rw-r--r-- | site/user/api/SkBitmap_Reference.md | 66 | ||||
-rw-r--r-- | site/user/api/SkImage_Reference.md | 55 | ||||
-rw-r--r-- | site/user/api/SkPaint_Reference.md | 4 | ||||
-rw-r--r-- | site/user/api/catalog.htm | 54 |
4 files changed, 119 insertions, 60 deletions
diff --git a/site/user/api/SkBitmap_Reference.md b/site/user/api/SkBitmap_Reference.md index bf0d99dda3..fc30b242c9 100644 --- a/site/user/api/SkBitmap_Reference.md +++ b/site/user/api/SkBitmap_Reference.md @@ -107,6 +107,7 @@ is useful to position one or more <a href="#Bitmap">Bitmaps</a> within a shared | <a href="#SkBitmap_peekPixels">peekPixels</a> | Returns <a href="SkPixmap_Reference#Pixmap">Pixmap</a> if possible. | | <a href="#SkBitmap_pixelRef">pixelRef</a> | Returns <a href="undocumented#Pixel_Ref">Pixel Ref</a>, or nullptr. | | <a href="#SkBitmap_pixelRefOrigin">pixelRefOrigin</a> | Returns offset within <a href="undocumented#Pixel_Ref">Pixel Ref</a>. | +| <a href="#SkBitmap_pixmap">pixmap</a> | Returns <a href="SkPixmap_Reference#Pixmap">Pixmap</a> if possible. | | <a href="#SkBitmap_readPixels">readPixels</a> | Copies and converts pixels. | | <a href="#SkBitmap_readyToDraw">readyToDraw</a> | Returns true if address of pixels is not nullptr. | | <a href="#SkBitmap_refColorSpace">refColorSpace</a> | Returns <a href="undocumented#Image_Info">Image Info</a> <a href="undocumented#Color_Space">Color Space</a>. | @@ -475,6 +476,51 @@ two width:1 height:1 colorType:kRGBA_8888_SkColorType alphaType:kOpaque_SkAlphaT --- +<a name="SkBitmap_pixmap"></a> +## pixmap + +<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> +SkPixmap pixmap() const +</pre> + +Returns <a href="SkPixmap_Reference#Pixmap">Pixmap</a> with <a href="#Bitmap">Bitmap</a> pixel address, row bytes, and <a href="undocumented#Image_Info">Image Info</a>, if address is available. +If pixel address is not available, returns default constructed <a href="SkPixmap_Reference#Pixmap">Pixmap</a>: nullptr pixels, +<a href="undocumented#SkColorType">kUnknown SkColorType</a>, <a href="undocumented#SkAlphaType">kUnknown SkAlphaType</a>, <a href="#SkBitmap_width">width</a> and <a href="#SkBitmap_height">height</a> of zero. + +Returned <a href="SkPixmap_Reference#Pixmap">Pixmap</a> becomes invalid on any future change to <a href="#Bitmap">Bitmap</a> + +### Return Value + +<a href="SkPixmap_Reference#Pixmap">Pixmap</a> describing <a href="#Bitmap">Bitmap</a>, if pixels are readable; otherwise containing zeroes + +### Example + +<div><fiddle-embed name="4e2da4cff5fa3752b630a63080b44752"> + +#### Example Output + +~~~~ +---------- +---xx----- +--x--x---- +--x------- +--xx------ +--x-x---x- +-x---x--x- +-x----xx-- +-xx---x--- +--xxxx-xx- +---------- +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkBitmap_peekPixels">peekPixels</a> <a href="#SkBitmap_installPixels">installPixels</a> <a href="#SkBitmap_readPixels">readPixels</a> <a href="#SkBitmap_writePixels">writePixels</a> + +--- + <a name="SkBitmap_info"></a> ## info @@ -1982,15 +2028,15 @@ true if <a href="undocumented#Image_Info">Image Info</a> is set to <a href="#SkB bool installPixels(const SkPixmap& pixmap) </pre> -Sets <a href="undocumented#Image_Info">Image Info</a> to <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a>.<a href="#SkBitmap_info">info</a> following the rules in <a href="#SkBitmap_setInfo">setInfo</a>, and creates -<a href="undocumented#Pixel_Ref">Pixel Ref</a> containing <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a>.addr() and <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a>.<a href="#SkBitmap_rowBytes">rowBytes</a>. +Sets <a href="undocumented#Image_Info">Image Info</a> to <a href="#SkBitmap_pixmap">pixmap</a>.<a href="#SkBitmap_info">info</a> following the rules in <a href="#SkBitmap_setInfo">setInfo</a>, and creates +<a href="undocumented#Pixel_Ref">Pixel Ref</a> containing <a href="#SkBitmap_pixmap">pixmap</a>.addr() and <a href="#SkBitmap_pixmap">pixmap</a>.<a href="#SkBitmap_rowBytes">rowBytes</a>. -If <a href="undocumented#Image_Info">Image Info</a> could not be set, or <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a>.<a href="#SkBitmap_rowBytes">rowBytes</a> is less than +If <a href="undocumented#Image_Info">Image Info</a> could not be set, or <a href="#SkBitmap_pixmap">pixmap</a>.<a href="#SkBitmap_rowBytes">rowBytes</a> is less than <a href="#SkImageInfo_minRowBytes">SkImageInfo::minRowBytes</a>: calls <a href="#SkBitmap_reset">reset</a>, and returns false. -Otherwise, if <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a>.addr() equals nullptr: sets <a href="undocumented#Image_Info">Image Info</a>, returns true. +Otherwise, if <a href="#SkBitmap_pixmap">pixmap</a>.addr() equals nullptr: sets <a href="undocumented#Image_Info">Image Info</a>, returns true. -Caller must ensure that <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a> is valid for the lifetime of <a href="#Bitmap">Bitmap</a> and <a href="undocumented#Pixel_Ref">Pixel Ref</a>. +Caller must ensure that <a href="#SkBitmap_pixmap">pixmap</a> is valid for the lifetime of <a href="#Bitmap">Bitmap</a> and <a href="undocumented#Pixel_Ref">Pixel Ref</a>. ### Parameters @@ -2001,7 +2047,7 @@ Caller must ensure that <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a> is ### Return Value -true if <a href="undocumented#Image_Info">Image Info</a> was set to <a href="#SkBitmap_installPixels_3_pixmap">pixmap</a>.<a href="#SkBitmap_info">info</a> +true if <a href="undocumented#Image_Info">Image Info</a> was set to <a href="#SkBitmap_pixmap">pixmap</a>.<a href="#SkBitmap_info">info</a> ### Example @@ -3369,11 +3415,11 @@ true if <a href="#Alpha">Alpha</a> layer was constructed in <a href="#SkBitmap_e bool peekPixels(SkPixmap* pixmap) const </pre> -Copies <a href="#Bitmap">Bitmap</a> pixel address, row bytes, and <a href="undocumented#Image_Info">Image Info</a> to <a href="#SkBitmap_peekPixels_pixmap">pixmap</a>, if address +Copies <a href="#Bitmap">Bitmap</a> pixel address, row bytes, and <a href="undocumented#Image_Info">Image Info</a> to <a href="#SkBitmap_pixmap">pixmap</a>, if address is available, and returns true. If pixel address is not available, return -false and leave <a href="#SkBitmap_peekPixels_pixmap">pixmap</a> unchanged. +false and leave <a href="#SkBitmap_pixmap">pixmap</a> unchanged. -<a href="#SkBitmap_peekPixels_pixmap">pixmap</a> contents become invalid on any future change to <a href="#Bitmap">Bitmap</a>. +<a href="#SkBitmap_pixmap">pixmap</a> contents become invalid on any future change to <a href="#Bitmap">Bitmap</a>. ### Parameters @@ -3410,7 +3456,7 @@ x---x- ### See Also -<a href="#SkBitmap_installPixels">installPixels</a> <a href="#SkBitmap_readPixels">readPixels</a> <a href="#SkBitmap_writePixels">writePixels</a> +<a href="#SkBitmap_pixmap">pixmap</a> <a href="#SkBitmap_installPixels">installPixels</a> <a href="#SkBitmap_readPixels">readPixels</a> <a href="#SkBitmap_writePixels">writePixels</a> --- diff --git a/site/user/api/SkImage_Reference.md b/site/user/api/SkImage_Reference.md index 58cf70d918..1ba1cdd0c3 100644 --- a/site/user/api/SkImage_Reference.md +++ b/site/user/api/SkImage_Reference.md @@ -142,7 +142,7 @@ size of pixel row or larger</td> ### Example -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> +<div><fiddle-embed name="367bdf6ee6ef2482eea95d4a9887c9b0"></fiddle-embed></div> ### See Also @@ -171,10 +171,14 @@ static sk_sp<SkImage> MakeFromRaster(const SkPixmap& pixmap, RasterRelease ReleaseContext releaseContext) </pre> -Creates <a href="#Image">Image</a> from <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a>, sharing <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a> pixels. Pixels must remain valid and +Creates <a href="#Image">Image</a> from <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a>, sharing <a href="SkPixmap_Reference#Pixmap">Pixmap</a> pixels. Pixels must remain valid and unchanged until <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a> is called. <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a> is passed <a href="#SkImage_MakeFromRaster_releaseContext">releaseContext</a> when <a href="#Image">Image</a> is deleted or no longer refers to <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a> pixels. +Pass nullptr for <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a> to share <a href="SkPixmap_Reference#Pixmap">Pixmap</a> without requiring a callback +when <a href="#Image">Image</a> is released. Pass nullptr for <a href="#SkImage_MakeFromRaster_releaseContext">releaseContext</a> if <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a> +does not require state. + <a href="#Image">Image</a> is returned if <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a> is valid. Valid <a href="SkPixmap_Reference#Pixmap">Pixmap</a> parameters include: <a href="#SkImage_dimensions">dimensions</a> are greater than zero; each dimension fits in 29 bits; @@ -187,19 +191,28 @@ pixel address is not nullptr. <table> <tr> <td><a name="SkImage_MakeFromRaster_pixmap"> <code><strong>pixmap </strong></code> </a></td> <td> <a href="#Info">Image Info</a>, pixel address, and row bytes</td> </tr> <tr> <td><a name="SkImage_MakeFromRaster_rasterReleaseProc"> <code><strong>rasterReleaseProc </strong></code> </a></td> <td> -function called when pixels can be released</td> +function called when pixels can be released; or nullptr</td> </tr> <tr> <td><a name="SkImage_MakeFromRaster_releaseContext"> <code><strong>releaseContext </strong></code> </a></td> <td> -state passed to <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a></td> +state passed to <a href="#SkImage_MakeFromRaster_rasterReleaseProc">rasterReleaseProc</a>; or nullptr</td> </tr> </table> ### Return Value -incomplete +<a href="#Image">Image</a> sharing <a href="#SkImage_MakeFromRaster_pixmap">pixmap</a> ### Example -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> +<div><fiddle-embed name="275356b65d18c8868f4434137350cddc"> + +#### Example Output + +~~~~ +before reset: 0 +after reset: 1 +~~~~ + +</fiddle-embed></div> ### See Also @@ -238,7 +251,10 @@ created <a href="#Image">Image</a>, or nullptr ### Example -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> +<div><fiddle-embed name="cf2cf53321e4e6a77c2841bfbc0ef707"><div>The first <a href="SkBitmap_Reference#Bitmap">Bitmap</a> is shared; writing to the pixel memory changes the first +<a href="#Image">Image</a>. +The second <a href="SkBitmap_Reference#Bitmap">Bitmap</a> is marked immutable, and is copied; writing to the pixel +memory does not alter the second <a href="#Image">Image</a>.</div></fiddle-embed></div> ### See Also @@ -254,12 +270,14 @@ static sk_sp<SkImage> MakeFromGenerator(std::unique_ptr<SkImageGenerato const SkIRect* subset = nullptr) </pre> -Creates <a href="#Image">Image</a> based from <a href="#SkImage_MakeFromGenerator_imageGenerator">imageGenerator</a>. -Takes ownership of <a href="#SkImage_MakeFromGenerator_imageGenerator">imageGenerator</a>; it may not be used elsewhere. -If <a href="#SkImage_MakeFromGenerator_subset">subset</a> is not nullptr, it must be contained within <a href="#SkImage_MakeFromGenerator_imageGenerator">imageGenerator</a> data <a href="#SkImage_bounds">bounds</a>. +Creates <a href="#Image">Image</a> from data returned by <a href="#SkImage_MakeFromGenerator_imageGenerator">imageGenerator</a>. Generated data is owned by <a href="#Image">Image</a> and may not +be shared or accessed. -<a href="#Image">Image</a> is returned if generator data is valid. Valid data parameters vary -by type of data and platform. +<a href="#SkImage_MakeFromGenerator_subset">subset</a> allows selecting a portion of the full image. Pass nullptr to select the entire image; +otherwise, <a href="#SkImage_MakeFromGenerator_subset">subset</a> must be contained by image <a href="#SkImage_bounds">bounds</a>. + +<a href="#Image">Image</a> is returned if generator data is valid. Valid data parameters vary by type of data +and platform. <a href="#SkImage_MakeFromGenerator_imageGenerator">imageGenerator</a> may wrap <a href="undocumented#Picture">Picture</a> data, codec data, or custom data. @@ -278,7 +296,7 @@ created <a href="#Image">Image</a>, or nullptr ### Example -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> +<div><fiddle-embed name="ba59d292a18cb0e8a90e1bb143115f1d"><div>The generator returning <a href="undocumented#Picture">Picture</a> cannot be shared; std::move transfers ownership to generated <a href="#Image">Image</a>.</div></fiddle-embed></div> ### See Also @@ -294,7 +312,8 @@ static sk_sp<SkImage> MakeFromEncoded(sk_sp<SkData> encoded, const S </pre> Creates <a href="#Image">Image</a> from <a href="#SkImage_MakeFromEncoded_encoded">encoded</a> data. -If a <a href="#SkImage_MakeFromEncoded_subset">subset</a> is not nullptr, it must be contained within <a href="#SkImage_MakeFromEncoded_encoded">encoded</a> data <a href="#SkImage_bounds">bounds</a>. +<a href="#SkImage_MakeFromEncoded_subset">subset</a> allows selecting a portion of the full image. Pass nullptr to select the entire image; +otherwise, <a href="#SkImage_MakeFromEncoded_subset">subset</a> must be contained by image <a href="#SkImage_bounds">bounds</a>. <a href="#Image">Image</a> is returned if format of the <a href="#SkImage_MakeFromEncoded_encoded">encoded</a> data is recognized and supported. Recognized formats vary by platfrom. @@ -312,10 +331,6 @@ data of <a href="#Image">Image</a> to decode</td> created <a href="#Image">Image</a>, or nullptr -### Example - -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> - ### See Also <a href="#SkImage_MakeFromGenerator">MakeFromGenerator</a> @@ -359,7 +374,7 @@ created <a href="#Image">Image</a>, or nullptr ### Example -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> +<div><fiddle-embed name="2faa98d6a1d578010326af17ee7e4d2a" gpu="true"><div>A back-end texture has been created and uploaded to the <a href="undocumented#GPU">GPU</a> outside of this example.</div></fiddle-embed></div> ### See Also @@ -408,7 +423,7 @@ created <a href="#Image">Image</a>, or nullptr ### Example -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> +<div><fiddle-embed name="dea2835da4be78d1e9ab4be58010d1ad"></fiddle-embed></div> ### See Also diff --git a/site/user/api/SkPaint_Reference.md b/site/user/api/SkPaint_Reference.md index e7b2b49b20..ef8d1afd0d 100644 --- a/site/user/api/SkPaint_Reference.md +++ b/site/user/api/SkPaint_Reference.md @@ -2606,7 +2606,7 @@ May be used to verify that <a href="#Stroke_Join">Stroke Join</a> is a legal val Join getStrokeJoin() const </pre> -The geometry drawn at the corners of strokes. +The geometry drawn at the corners of strokes. ### Return Value @@ -2637,7 +2637,7 @@ kMiter_Join == default stroke join void setStrokeJoin(Join join) </pre> -The geometry drawn at the corners of strokes. +The geometry drawn at the corners of strokes. ### Parameters diff --git a/site/user/api/catalog.htm b/site/user/api/catalog.htm index 4cb0f9f39d..ee48589741 100644 --- a/site/user/api/catalog.htm +++ b/site/user/api/catalog.htm @@ -273,6 +273,13 @@ "name": "SkBitmap::pixelRefOrigin", "stdout": "source origin: 0, 0\\nsubset origin: 32, 64\\n" }, + "SkBitmap_pixmap": { + "code": "void draw(SkCanvas* canvas) {\n SkBitmap bitmap;\n bitmap.allocPixels(SkImageInfo::MakeN32Premul(10, 11));\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorWHITE);\n SkPaint paint;\n offscreen.drawString(\"&\", 0, 10, paint);\n SkPixmap pixmap = bitmap.pixmap();\n if (pixmap.addr()) {\n const SkPMColor* pixels = pixmap.addr32();\n SkPMColor pmWhite = pixels[0];\n for (int y = 0; y < bitmap.height(); ++y) {\n for (int x = 0; x < bitmap.width(); ++x) {\n SkDebugf(\"%c\", *pixels++ == pmWhite ? '-' : 'x');\n }\n SkDebugf(\"\\n\");\n }\n }\n}", + "hash": "4e2da4cff5fa3752b630a63080b44752", + "file": "SkBitmap_Reference", + "name": "SkBitmap::pixmap()", + "stdout": "----------\\n---xx-----\\n--x--x----\\n--x-------\\n--xx------\\n--x-x---x-\\n-x---x--x-\\n-x----xx--\\n-xx---x---\\n--xxxx-xx-\\n----------\\n" + }, "SkBitmap_refColorSpace": { "code": "void draw(SkCanvas* canvas) {\n SkBitmap bitmap1, bitmap2;\n bitmap1.setInfo(SkImageInfo::MakeN32(16, 32, kPremul_SkAlphaType, \n SkColorSpace::MakeSRGBLinear()));\n bitmap2.setInfo(SkImageInfo::MakeN32(16, 32, kPremul_SkAlphaType,\n bitmap1.refColorSpace()));\n SkColorSpace* colorSpace = bitmap2.colorSpace();\n SkDebugf(\"gammaCloseToSRGB: %s gammaIsLinear: %s isSRGB: %s\\n\",\n colorSpace->gammaCloseToSRGB() ? \"true\" : \"false\",\n colorSpace->gammaIsLinear() ? \"true\" : \"false\",\n colorSpace->isSRGB() ? \"true\" : \"false\");\n}", "hash": "972e9bb22c1ce94bb97b2d106168280e", @@ -1029,6 +1036,13 @@ "name": "SkIRect::y()", "stdout": "unsorted.fTop: 25 unsorted.y(): 25\\nsorted.fTop: 5 sorted.y(): 5\\n" }, + "SkImage_MakeFromRaster": { + "code": "static void releaseProc(const void* pixels, SkImage::ReleaseContext context) {\n int* countPtr = static_cast<int*>(context);\n *countPtr += 1;\n}\n\nvoid draw(SkCanvas* canvas) {\n SkColor color = 0;\n SkPixmap pixmap(SkImageInfo::MakeN32(1, 1, kPremul_SkAlphaType), &color, 4);\n int releaseCount = 0;\n sk_sp<SkImage> image(SkImage::MakeFromRaster(pixmap, releaseProc, &releaseCount));\n SkDebugf(\"before reset: %d\\n\", releaseCount);\n image.reset();\n SkDebugf(\"after reset: %d\\n\", releaseCount);\n}\n", + "hash": "275356b65d18c8868f4434137350cddc", + "file": "SkImage_Reference", + "name": "SkImage::MakeFromRaster", + "stdout": "before reset: 0\\nafter reset: 1\\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}", "hash": "d961d91020f19037204a8c3fd8cb1060", @@ -4766,26 +4780,18 @@ "name": "SkImage::MakeFromAdoptedTexture" }, "SkImage_MakeFromBitmap": { - "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> image1 = SkImage::MakeFromBitmap(bitmap);\n bitmap.setImmutable();\n sk_sp<SkImage> image2 = SkImage::MakeFromBitmap(bitmap);\n *pixmap.writable_addr8(2, 2) = 0x00;\n canvas->scale(10, 10);\n canvas->drawImage(image1, 0, 0);\n canvas->drawImage(image2, 10, 0);\n}", "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "height": 50, + "hash": "cf2cf53321e4e6a77c2841bfbc0ef707", "file": "SkImage_Reference", "name": "SkImage::MakeFromBitmap" }, - "SkImage_MakeFromEncoded": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImage_Reference", - "name": "SkImage::MakeFromEncoded" -}, "SkImage_MakeFromGenerator": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", + "code": "void draw(SkCanvas* canvas) {\n SkPictureRecorder recorder;\n recorder.beginRecording(100, 100)->drawColor(SK_ColorRED);\n auto picture = recorder.finishRecordingAsPicture();\n auto gen = SkImageGenerator::MakeFromPicture({100, 100}, picture, nullptr, nullptr,\n SkImage::BitDepth::kU8, SkColorSpace::MakeSRGB());\n sk_sp<SkImage> image = SkImage::MakeFromGenerator(std::move(gen));\n canvas->drawImage(image, 0, 0);\n}", "width": 256, "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "hash": "ba59d292a18cb0e8a90e1bb143115f1d", "file": "SkImage_Reference", "name": "SkImage::MakeFromGenerator" }, @@ -4805,27 +4811,19 @@ "file": "SkImage_Reference", "name": "SkImage::MakeFromPicture" }, - "SkImage_MakeFromRaster": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImage_Reference", - "name": "SkImage::MakeFromRaster" -}, "SkImage_MakeFromTexture": { - "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 canvas->scale(.25f, .25f);\n int x = 0;\n for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin } ) {\n sk_sp<SkImage> image = SkImage::MakeFromTexture(canvas->getGrContext(), backEndTexture,\n origin, kOpaque_SkAlphaType, nullptr);\n canvas->drawImage(image, x, 0);\n x += 512;\n }\n}", "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "height": 128, + "hash": "2faa98d6a1d578010326af17ee7e4d2a", "file": "SkImage_Reference", "name": "SkImage::MakeFromTexture" }, "SkImage_MakeFromTexture_2": { - "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 auto debugster = [](SkImage::ReleaseContext context) -> void {\n *((int *) context) += 128;\n };\n int x = 0;\n for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin } ) {\n sk_sp<SkImage> image = SkImage::MakeFromTexture(canvas->getGrContext(), backEndTexture,\n origin, kOpaque_SkAlphaType, nullptr, debugster, &x);\n canvas->drawImage(image, x, 0);\n x += 128;\n }\n}", "width": 256, "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "hash": "dea2835da4be78d1e9ab4be58010d1ad", "file": "SkImage_Reference", "name": "SkImage::MakeFromTexture_2" }, @@ -4846,10 +4844,10 @@ "name": "SkImage::MakeRasterCopy" }, "SkImage_MakeRasterData": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", + "code": "void draw(SkCanvas* canvas) {\n size_t rowBytes = image->width() * SkColorTypeBytesPerPixel(kRGBA_8888_SkColorType);\n sk_sp<SkData> data = SkData::MakeUninitialized(rowBytes * image->height());\n SkImageInfo dstInfo = SkImageInfo::MakeN32(image->width(), image->height(), \n kPremul_SkAlphaType);\n image->readPixels(dstInfo, data->writable_data(), rowBytes, 0, 0, SkImage::kAllow_CachingHint);\n sk_sp<SkImage> raw = SkImage::MakeRasterData(dstInfo.makeColorType(kRGBA_8888_SkColorType),\n data, rowBytes);\n canvas->drawImage(image, 0, 0);\n canvas->drawImage(raw.get(), 128, 0);\n}", "width": 256, "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", + "hash": "367bdf6ee6ef2482eea95d4a9887c9b0", "file": "SkImage_Reference", "name": "SkImage::MakeRasterData" }, |