diff options
Diffstat (limited to 'site/user/api/SkSurface_Reference.md')
-rw-r--r-- | site/user/api/SkSurface_Reference.md | 239 |
1 files changed, 35 insertions, 204 deletions
diff --git a/site/user/api/SkSurface_Reference.md b/site/user/api/SkSurface_Reference.md index dda2c3c80e..1b01fe5f58 100644 --- a/site/user/api/SkSurface_Reference.md +++ b/site/user/api/SkSurface_Reference.md @@ -36,8 +36,8 @@ of the requested dimensions are zero, then nullptr will be returned. | name | description | | --- | --- | | <a href="#SkSurface_MakeFromBackendRenderTarget">MakeFromBackendRenderTarget</a> | creates <a href="#Surface">Surface</a> from GPU memory buffer | -| <a href="#SkSurface_MakeFromBackendTexture">MakeFromBackendTexture</a> | creates <a href="#Surface">Surface</a> from GPU-backed texture | -| <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget">MakeFromBackendTextureAsRenderTarget</a> | creates <a href="#Surface">Surface</a> from GPU-backed texture | +| <a href="#SkSurface_MakeFromBackendTexture">MakeFromBackendTexture</a> | creates <a href="#Surface">Surface</a> from GPU texture | +| <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget">MakeFromBackendTextureAsRenderTarget</a> | creates <a href="#Surface">Surface</a> from GPU back-end render target | | <a href="#SkSurface_MakeNull">MakeNull</a> | creates <a href="#Surface">Surface</a> without backing pixels | | <a href="#SkSurface_MakeRaster">MakeRaster</a> | creates <a href="#Surface">Surface</a> from <a href="SkImageInfo_Reference#SkImageInfo">SkImageInfo</a> | | <a href="#SkSurface_MakeRasterDirect">MakeRasterDirect</a> | creates <a href="#Surface">Surface</a> from <a href="SkImageInfo_Reference#SkImageInfo">SkImageInfo</a> and <a href="undocumented#Storage">Pixel Storage</a> | @@ -68,8 +68,8 @@ of the requested dimensions are zero, then nullptr will be returned. | name | description | | --- | --- | | <a href="#SkSurface_MakeFromBackendRenderTarget">MakeFromBackendRenderTarget</a> | creates <a href="#Surface">Surface</a> from GPU memory buffer | -| <a href="#SkSurface_MakeFromBackendTexture">MakeFromBackendTexture</a> | creates <a href="#Surface">Surface</a> from GPU-backed texture | -| <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget">MakeFromBackendTextureAsRenderTarget</a> | creates <a href="#Surface">Surface</a> from GPU-backed texture | +| <a href="#SkSurface_MakeFromBackendTexture">MakeFromBackendTexture</a> | creates <a href="#Surface">Surface</a> from GPU texture | +| <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget">MakeFromBackendTextureAsRenderTarget</a> | creates <a href="#Surface">Surface</a> from GPU back-end render target | | <a href="#SkSurface_MakeNull">MakeNull</a> | creates <a href="#Surface">Surface</a> without backing pixels | | <a href="#SkSurface_MakeRaster">MakeRaster</a> | creates <a href="#Surface">Surface</a> from <a href="SkImageInfo_Reference#SkImageInfo">SkImageInfo</a> | | <a href="#SkSurface_MakeRasterDirect">MakeRasterDirect</a> | creates <a href="#Surface">Surface</a> from <a href="SkImageInfo_Reference#SkImageInfo">SkImageInfo</a> and <a href="undocumented#Storage">Pixel Storage</a> | @@ -371,6 +371,7 @@ fonts; may be nullptr</td> static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* context, const GrBackendTexture& backendTexture, GrSurfaceOrigin origin, int sampleCnt, + SkColorType colorType, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* surfaceProps) </pre> @@ -398,87 +399,14 @@ texture residing on GPU</td> one of: <a href="undocumented#kBottomLeft_GrSurfaceOrigin">kBottomLeft GrSurfaceOrigin</a>, <a href="undocumented#kTopLeft_GrSurfaceOrigin">kTopLeft GrSurfaceOrigin</a></td> </tr> <tr> <td><a name="SkSurface_MakeFromBackendTexture_sampleCnt"> <code><strong>sampleCnt </strong></code> </a></td> <td> samples per pixel, or 0 to disable full scene anti-aliasing</td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTexture_colorSpace"> <code><strong>colorSpace </strong></code> </a></td> <td> -range of colors</td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTexture_surfaceProps"> <code><strong>surfaceProps </strong></code> </a></td> <td> -LCD striping orientation and setting for device independent -fonts; may be nullptr</td> - </tr> -</table> - -### Return Value - -<a href="#Surface">Surface</a> if all parameters are valid; otherwise, nullptr - -### Example - -<pre style="padding: 1em 1em 1em 1em; font-size: 13px width: 62.5em; background-color: #f0f0f0"> - - SkPaint paint; - paint.setTextSize(32); - GrContext* context = canvas->getGrContext(); - if (!context) { - canvas->drawString("GPU only!", 20, 40, paint); - return; - } - sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendTexture(context, - backEndTextureRenderTarget, kTopLeft_GrSurfaceOrigin, 0, nullptr, nullptr); - auto surfaceCanvas = gpuSurface->getCanvas(); - surfaceCanvas->clear(SK_ColorWHITE); - surfaceCanvas->drawString("GPU rocks!", 20, 40, paint); - sk_sp<SkImage> image(gpuSurface->makeImageSnapshot()); - canvas->drawImage(image, 0, 0); - -</pre> - -### See Also - -<a href="undocumented#GrBackendTexture">GrBackendTexture</a> <a href="#SkSurface_MakeFromBackendRenderTarget">MakeFromBackendRenderTarget</a><sup><a href="#SkSurface_MakeFromBackendRenderTarget_2">[2]</a></sup> <a href="#SkSurface_MakeRenderTarget">MakeRenderTarget</a><sup><a href="#SkSurface_MakeRenderTarget_2">[2]</a></sup><sup><a href="#SkSurface_MakeRenderTarget_3">[3]</a></sup> - ---- - -<a name="SkSurface_MakeFromBackendTexture_2"></a> - -<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> -static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* context, - const GrBackendTexture& backendTexture, - GrSurfaceOrigin origin, int sampleCnt, - SkColorType colorType, - sk_sp<SkColorSpace> colorSpace, - const SkSurfaceProps* surfaceProps) -</pre> - -Wraps a GPU-backed texture into <a href="#Surface">Surface</a>. Caller must ensure the texture is -valid for the lifetime of returned <a href="#Surface">Surface</a>. If <a href="#SkSurface_MakeFromBackendTexture_2_sampleCnt">sampleCnt</a> greater than zero, -creates an intermediate MSAA <a href="#Surface">Surface</a> which is used for drawing <a href="#SkSurface_MakeFromBackendTexture_2_backendTexture">backendTexture</a>. - -<a href="#Surface">Surface</a> is returned if all parameters are valid. <a href="#SkSurface_MakeFromBackendTexture_2_backendTexture">backendTexture</a> is valid if -its pixel configuration agrees with <a href="#SkSurface_MakeFromBackendTexture_2_colorSpace">colorSpace</a> and <a href="#SkSurface_MakeFromBackendTexture_2_context">context</a>; for instance, if -<a href="#SkSurface_MakeFromBackendTexture_2_backendTexture">backendTexture</a> has an sRGB configuration, then <a href="#SkSurface_MakeFromBackendTexture_2_context">context</a> must support sRGB, -and <a href="#SkSurface_MakeFromBackendTexture_2_colorSpace">colorSpace</a> must be present. Further, <a href="#SkSurface_MakeFromBackendTexture_2_backendTexture">backendTexture</a> width and height must -not exceed <a href="#SkSurface_MakeFromBackendTexture_2_context">context</a> capabilities, and the <a href="#SkSurface_MakeFromBackendTexture_2_context">context</a> must be able to support -back-end textures. - -If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. - -### Parameters - -<table> <tr> <td><a name="SkSurface_MakeFromBackendTexture_2_context"> <code><strong>context </strong></code> </a></td> <td> -<a href="undocumented#GPU_Context">GPU Context</a></td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTexture_2_backendTexture"> <code><strong>backendTexture </strong></code> </a></td> <td> -texture residing on GPU</td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTexture_2_origin"> <code><strong>origin </strong></code> </a></td> <td> -one of: <a href="undocumented#kBottomLeft_GrSurfaceOrigin">kBottomLeft GrSurfaceOrigin</a>, <a href="undocumented#kTopLeft_GrSurfaceOrigin">kTopLeft GrSurfaceOrigin</a></td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTexture_2_sampleCnt"> <code><strong>sampleCnt </strong></code> </a></td> <td> -samples per pixel, or 0 to disable full scene anti-aliasing</td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTexture_2_colorType"> <code><strong>colorType </strong></code> </a></td> <td> + </tr> <tr> <td><a name="SkSurface_MakeFromBackendTexture_colorType"> <code><strong>colorType </strong></code> </a></td> <td> one of: <a href="SkImageInfo_Reference#kUnknown_SkColorType">kUnknown_SkColorType</a>, <a href="SkImageInfo_Reference#kAlpha_8_SkColorType">kAlpha_8_SkColorType</a>, <a href="SkImageInfo_Reference#kRGB_565_SkColorType">kRGB_565_SkColorType</a>, <a href="SkImageInfo_Reference#kARGB_4444_SkColorType">kARGB_4444_SkColorType</a>, <a href="SkImageInfo_Reference#kRGBA_8888_SkColorType">kRGBA_8888_SkColorType</a>, <a href="SkImageInfo_Reference#kRGB_888x_SkColorType">kRGB_888x_SkColorType</a>, <a href="SkImageInfo_Reference#kBGRA_8888_SkColorType">kBGRA_8888_SkColorType</a>, <a href="SkImageInfo_Reference#kRGBA_1010102_SkColorType">kRGBA_1010102_SkColorType</a>, <a href="SkImageInfo_Reference#kRGB_101010x_SkColorType">kRGB_101010x_SkColorType</a>, <a href="SkImageInfo_Reference#kGray_8_SkColorType">kGray_8_SkColorType</a>, <a href="SkImageInfo_Reference#kRGBA_F16_SkColorType">kRGBA_F16_SkColorType</a> </td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTexture_2_colorSpace"> <code><strong>colorSpace </strong></code> </a></td> <td> -range of colors</td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTexture_2_surfaceProps"> <code><strong>surfaceProps </strong></code> </a></td> <td> + </tr> <tr> <td><a name="SkSurface_MakeFromBackendTexture_colorSpace"> <code><strong>colorSpace </strong></code> </a></td> <td> +range of colors; may be nullptr</td> + </tr> <tr> <td><a name="SkSurface_MakeFromBackendTexture_surfaceProps"> <code><strong>surfaceProps </strong></code> </a></td> <td> LCD striping orientation and setting for device independent fonts; may be nullptr</td> </tr> @@ -490,25 +418,7 @@ fonts; may be nullptr</td> ### Example -<pre style="padding: 1em 1em 1em 1em; font-size: 13px width: 62.5em; background-color: #f0f0f0"> - - SkPaint paint; - paint.setTextSize(32); - GrContext* context = canvas->getGrContext(); - if (!context) { - canvas->drawString("GPU only!", 20, 40, paint); - return; - } - sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendTexture(context, - backEndTextureRenderTarget, kTopLeft_GrSurfaceOrigin, - kRGBA_8888_SkColorType, 0, nullptr, nullptr); - auto surfaceCanvas = gpuSurface->getCanvas(); - surfaceCanvas->clear(SK_ColorWHITE); - surfaceCanvas->drawString("GPU rocks!", 20, 40, paint); - sk_sp<SkImage> image(gpuSurface->makeImageSnapshot()); - canvas->drawImage(image, 0, 0); - -</pre> +<div><fiddle-embed name="d3aec071998f871809f515e58abb1b0e" gpu="true" cpu="true"></fiddle-embed></div> ### See Also @@ -573,7 +483,6 @@ fonts; may be nullptr</td> sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendRenderTarget(context, backEndRenderTarget, kTopLeft_GrSurfaceOrigin, nullptr, nullptr); auto surfaceCanvas = gpuSurface->getCanvas(); - surfaceCanvas->clear(SK_ColorWHITE); surfaceCanvas->drawString("GPU rocks!", 20, 40, paint); sk_sp<SkImage> image(gpuSurface->makeImageSnapshot()); canvas->drawImage(image, 0, 0); @@ -582,7 +491,7 @@ fonts; may be nullptr</td> ### See Also -<a href="#SkSurface_MakeFromBackendTexture">MakeFromBackendTexture</a><sup><a href="#SkSurface_MakeFromBackendTexture_2">[2]</a></sup> <a href="#SkSurface_MakeRenderTarget">MakeRenderTarget</a><sup><a href="#SkSurface_MakeRenderTarget_2">[2]</a></sup><sup><a href="#SkSurface_MakeRenderTarget_3">[3]</a></sup> +<a href="#SkSurface_MakeFromBackendTexture">MakeFromBackendTexture</a> <a href="#SkSurface_MakeRenderTarget">MakeRenderTarget</a><sup><a href="#SkSurface_MakeRenderTarget_2">[2]</a></sup><sup><a href="#SkSurface_MakeRenderTarget_3">[3]</a></sup> --- @@ -596,8 +505,8 @@ static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext* context, const SkSurfaceProps* surfaceProps) </pre> -Wraps a GPU-backed buffer into <a href="#Surface">Surface</a>. Caller must ensure render target is -valid for the lifetime of returned <a href="#Surface">Surface</a>. +Wraps a GPU-backed buffer into <a href="#Surface">Surface</a>. Caller must ensure <a href="#SkSurface_MakeFromBackendRenderTarget_2_backendRenderTarget">backendRenderTarget</a> +is valid for the lifetime of returned <a href="#Surface">Surface</a>. <a href="#Surface">Surface</a> is returned if all parameters are valid. <a href="#SkSurface_MakeFromBackendRenderTarget_2_backendRenderTarget">backendRenderTarget</a> is valid if its pixel configuration agrees with <a href="#SkSurface_MakeFromBackendRenderTarget_2_colorSpace">colorSpace</a> and <a href="#SkSurface_MakeFromBackendRenderTarget_2_context">context</a>; for instance, if @@ -648,7 +557,6 @@ fonts; may be nullptr</td> backEndRenderTarget, kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, nullptr, nullptr); auto surfaceCanvas = gpuSurface->getCanvas(); - surfaceCanvas->clear(SK_ColorWHITE); surfaceCanvas->drawString("GPU rocks!", 20, 40, paint); sk_sp<SkImage> image(gpuSurface->makeImageSnapshot()); canvas->drawImage(image, 0, 0); @@ -657,7 +565,7 @@ fonts; may be nullptr</td> ### See Also -<a href="#SkSurface_MakeFromBackendTexture">MakeFromBackendTexture</a><sup><a href="#SkSurface_MakeFromBackendTexture_2">[2]</a></sup> <a href="#SkSurface_MakeRenderTarget">MakeRenderTarget</a><sup><a href="#SkSurface_MakeRenderTarget_2">[2]</a></sup><sup><a href="#SkSurface_MakeRenderTarget_3">[3]</a></sup> +<a href="#SkSurface_MakeFromBackendTexture">MakeFromBackendTexture</a> <a href="#SkSurface_MakeRenderTarget">MakeRenderTarget</a><sup><a href="#SkSurface_MakeRenderTarget_2">[2]</a></sup><sup><a href="#SkSurface_MakeRenderTarget_3">[3]</a></sup> --- @@ -668,15 +576,22 @@ fonts; may be nullptr</td> static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(GrContext* context, const GrBackendTexture& backendTexture, GrSurfaceOrigin origin, int sampleCnt, - sk_sp<SkColorSpace> colorSpace, + SkColorType colorType, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* surfaceProps) </pre> -Used to wrap a GPU-backed texture as a <a href="#SkSurface">SkSurface</a>. Skia will treat the texture as -a rendering target only, but unlike NewFromBackendRenderTarget, Skia will manage and own -the associated render target objects (but not the provided texture). Skia will not assume -ownership of the texture and the client must ensure the texture is valid for the lifetime -of the <a href="#SkSurface">SkSurface</a>. +Wraps a GPU-backed texture into <a href="#Surface">Surface</a>. Caller must ensure <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget_backendTexture">backendTexture</a> is +valid for the lifetime of returned <a href="#Surface">Surface</a>. If <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget_sampleCnt">sampleCnt</a> greater than zero, +creates an intermediate MSAA <a href="#Surface">Surface</a> which is used for drawing <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget_backendTexture">backendTexture</a>. + +<a href="#Surface">Surface</a> is returned if all parameters are valid. <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget_backendTexture">backendTexture</a> is valid if +its pixel configuration agrees with <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget_colorSpace">colorSpace</a> and <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget_context">context</a>; for instance, if +<a href="#SkSurface_MakeFromBackendTextureAsRenderTarget_backendTexture">backendTexture</a> has an sRGB configuration, then <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget_context">context</a> must support sRGB, +and <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget_colorSpace">colorSpace</a> must be present. Further, <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget_backendTexture">backendTexture</a> width and height must +not exceed <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget_context">context</a> capabilities. + +Returned <a href="#Surface">Surface</a> is available only for drawing into, and cannot generate an +<a href="SkImage_Reference#Image">Image</a>. If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. @@ -690,81 +605,14 @@ texture residing on GPU</td> one of: <a href="undocumented#kBottomLeft_GrSurfaceOrigin">kBottomLeft GrSurfaceOrigin</a>, <a href="undocumented#kTopLeft_GrSurfaceOrigin">kTopLeft GrSurfaceOrigin</a></td> </tr> <tr> <td><a name="SkSurface_MakeFromBackendTextureAsRenderTarget_sampleCnt"> <code><strong>sampleCnt </strong></code> </a></td> <td> samples per pixel, or 0 to disable full scene anti-aliasing</td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTextureAsRenderTarget_colorSpace"> <code><strong>colorSpace </strong></code> </a></td> <td> -range of colors</td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTextureAsRenderTarget_surfaceProps"> <code><strong>surfaceProps </strong></code> </a></td> <td> -LCD striping orientation and setting for device independent -fonts; may be nullptr</td> - </tr> -</table> - -### Return Value - -<a href="#Surface">Surface</a> if all parameters are valid; otherwise, nullptr - -### Example - -<pre style="padding: 1em 1em 1em 1em; font-size: 13px width: 62.5em; background-color: #f0f0f0"> -SkPaint paint; - paint.setTextSize(32); - GrContext* context = canvas->getGrContext(); - if (!context) { - canvas->drawString("GPU only!", 20, 40, paint); - return; - } - sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendTextureAsRenderTarget( - context, backEndTextureRenderTarget, kTopLeft_GrSurfaceOrigin, 0, - nullptr, nullptr); - auto surfaceCanvas = gpuSurface->getCanvas(); - surfaceCanvas->clear(SK_ColorWHITE); - surfaceCanvas->drawString("GPU rocks!", 20, 40, paint); - sk_sp<SkImage> image(gpuSurface->makeImageSnapshot()); - canvas->drawImage(image, 0, 0); - -</pre> - -### See Also - -<a href="#SkSurface_MakeFromBackendRenderTarget">MakeFromBackendRenderTarget</a><sup><a href="#SkSurface_MakeFromBackendRenderTarget_2">[2]</a></sup> <a href="#SkSurface_MakeRenderTarget">MakeRenderTarget</a><sup><a href="#SkSurface_MakeRenderTarget_2">[2]</a></sup><sup><a href="#SkSurface_MakeRenderTarget_3">[3]</a></sup> - ---- - -<a name="SkSurface_MakeFromBackendTextureAsRenderTarget_2"></a> - -<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> -static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(GrContext* context, - const GrBackendTexture& backendTexture, - GrSurfaceOrigin origin, int sampleCnt, - SkColorType colorType, sk_sp<SkColorSpace> colorSpace, - const SkSurfaceProps* surfaceProps) -</pre> - -Used to wrap a GPU-backed texture as a <a href="#SkSurface">SkSurface</a>. Skia will treat the texture as -a rendering target only, but unlike NewFromBackendRenderTarget, Skia will manage and own -the associated render target objects (but not the provided texture). Skia will not assume -ownership of the texture and the client must ensure the texture is valid for the lifetime -of the <a href="#SkSurface">SkSurface</a>. - -If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. - -### Parameters - -<table> <tr> <td><a name="SkSurface_MakeFromBackendTextureAsRenderTarget_2_context"> <code><strong>context </strong></code> </a></td> <td> -<a href="undocumented#GPU_Context">GPU Context</a></td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTextureAsRenderTarget_2_backendTexture"> <code><strong>backendTexture </strong></code> </a></td> <td> -texture residing on GPU</td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTextureAsRenderTarget_2_origin"> <code><strong>origin </strong></code> </a></td> <td> -one of: <a href="undocumented#kBottomLeft_GrSurfaceOrigin">kBottomLeft GrSurfaceOrigin</a>, <a href="undocumented#kTopLeft_GrSurfaceOrigin">kTopLeft GrSurfaceOrigin</a></td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTextureAsRenderTarget_2_sampleCnt"> <code><strong>sampleCnt </strong></code> </a></td> <td> -samples per pixel, or 0 to disable full scene anti-aliasing</td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTextureAsRenderTarget_2_colorType"> <code><strong>colorType </strong></code> </a></td> <td> + </tr> <tr> <td><a name="SkSurface_MakeFromBackendTextureAsRenderTarget_colorType"> <code><strong>colorType </strong></code> </a></td> <td> one of: <a href="SkImageInfo_Reference#kUnknown_SkColorType">kUnknown_SkColorType</a>, <a href="SkImageInfo_Reference#kAlpha_8_SkColorType">kAlpha_8_SkColorType</a>, <a href="SkImageInfo_Reference#kRGB_565_SkColorType">kRGB_565_SkColorType</a>, <a href="SkImageInfo_Reference#kARGB_4444_SkColorType">kARGB_4444_SkColorType</a>, <a href="SkImageInfo_Reference#kRGBA_8888_SkColorType">kRGBA_8888_SkColorType</a>, <a href="SkImageInfo_Reference#kRGB_888x_SkColorType">kRGB_888x_SkColorType</a>, <a href="SkImageInfo_Reference#kBGRA_8888_SkColorType">kBGRA_8888_SkColorType</a>, <a href="SkImageInfo_Reference#kRGBA_1010102_SkColorType">kRGBA_1010102_SkColorType</a>, <a href="SkImageInfo_Reference#kRGB_101010x_SkColorType">kRGB_101010x_SkColorType</a>, <a href="SkImageInfo_Reference#kGray_8_SkColorType">kGray_8_SkColorType</a>, <a href="SkImageInfo_Reference#kRGBA_F16_SkColorType">kRGBA_F16_SkColorType</a> </td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTextureAsRenderTarget_2_colorSpace"> <code><strong>colorSpace </strong></code> </a></td> <td> -range of colors</td> - </tr> <tr> <td><a name="SkSurface_MakeFromBackendTextureAsRenderTarget_2_surfaceProps"> <code><strong>surfaceProps </strong></code> </a></td> <td> + </tr> <tr> <td><a name="SkSurface_MakeFromBackendTextureAsRenderTarget_colorSpace"> <code><strong>colorSpace </strong></code> </a></td> <td> +range of colors; may be nullptr</td> + </tr> <tr> <td><a name="SkSurface_MakeFromBackendTextureAsRenderTarget_surfaceProps"> <code><strong>surfaceProps </strong></code> </a></td> <td> LCD striping orientation and setting for device independent fonts; may be nullptr</td> </tr> @@ -776,24 +624,7 @@ fonts; may be nullptr</td> ### Example -<pre style="padding: 1em 1em 1em 1em; font-size: 13px width: 62.5em; background-color: #f0f0f0"> -SkPaint paint; - paint.setTextSize(32); - GrContext* context = canvas->getGrContext(); - if (!context) { - canvas->drawString("GPU only!", 20, 40, paint); - return; - } - sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendTextureAsRenderTarget( - context, backEndTextureRenderTarget, kTopLeft_GrSurfaceOrigin, 0, - kRGBA_8888_SkColorType, nullptr, nullptr); - auto surfaceCanvas = gpuSurface->getCanvas(); - surfaceCanvas->clear(SK_ColorWHITE); - surfaceCanvas->drawString("GPU rocks!", 20, 40, paint); - sk_sp<SkImage> image(gpuSurface->makeImageSnapshot()); - canvas->drawImage(image, 0, 0); - -</pre> +<div><fiddle-embed name="5e87093b9cbe95124ae14cbe77091eb7" gpu="true"></fiddle-embed></div> ### See Also @@ -860,7 +691,7 @@ hint that <a href="#Surface">Surface</a> will host Mip_Map images</td> ### See Also -<a href="#SkSurface_MakeFromBackendRenderTarget">MakeFromBackendRenderTarget</a><sup><a href="#SkSurface_MakeFromBackendRenderTarget_2">[2]</a></sup> <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget">MakeFromBackendTextureAsRenderTarget</a><sup><a href="#SkSurface_MakeFromBackendTextureAsRenderTarget_2">[2]</a></sup> +<a href="#SkSurface_MakeFromBackendRenderTarget">MakeFromBackendRenderTarget</a><sup><a href="#SkSurface_MakeFromBackendRenderTarget_2">[2]</a></sup> <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget">MakeFromBackendTextureAsRenderTarget</a> --- @@ -916,7 +747,7 @@ or red green blue. ### See Also -<a href="#SkSurface_MakeFromBackendRenderTarget">MakeFromBackendRenderTarget</a><sup><a href="#SkSurface_MakeFromBackendRenderTarget_2">[2]</a></sup> <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget">MakeFromBackendTextureAsRenderTarget</a><sup><a href="#SkSurface_MakeFromBackendTextureAsRenderTarget_2">[2]</a></sup> +<a href="#SkSurface_MakeFromBackendRenderTarget">MakeFromBackendRenderTarget</a><sup><a href="#SkSurface_MakeFromBackendRenderTarget_2">[2]</a></sup> <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget">MakeFromBackendTextureAsRenderTarget</a> --- @@ -957,7 +788,7 @@ of <a href="undocumented#Raster_Surface">Raster Surface</a>; width, or height, o ### See Also -<a href="#SkSurface_MakeFromBackendRenderTarget">MakeFromBackendRenderTarget</a><sup><a href="#SkSurface_MakeFromBackendRenderTarget_2">[2]</a></sup> <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget">MakeFromBackendTextureAsRenderTarget</a><sup><a href="#SkSurface_MakeFromBackendTextureAsRenderTarget_2">[2]</a></sup> +<a href="#SkSurface_MakeFromBackendRenderTarget">MakeFromBackendRenderTarget</a><sup><a href="#SkSurface_MakeFromBackendRenderTarget_2">[2]</a></sup> <a href="#SkSurface_MakeFromBackendTextureAsRenderTarget">MakeFromBackendTextureAsRenderTarget</a> --- |