diff options
-rw-r--r-- | docs/SkSurface_Reference.bmh | 179 | ||||
-rw-r--r-- | include/core/SkSurface.h | 2 | ||||
-rw-r--r-- | site/user/api/SkSurface_Reference.md | 220 | ||||
-rw-r--r-- | tools/bookmaker/bookmaker.h | 2 | ||||
-rw-r--r-- | tools/bookmaker/includeParser.cpp | 15 | ||||
-rw-r--r-- | tools/bookmaker/includeWriter.cpp | 2 |
6 files changed, 416 insertions, 4 deletions
diff --git a/docs/SkSurface_Reference.bmh b/docs/SkSurface_Reference.bmh index acbc191bfd..036b9b25cb 100644 --- a/docs/SkSurface_Reference.bmh +++ b/docs/SkSurface_Reference.bmh @@ -424,6 +424,68 @@ If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. # ------------------------------------------------------------------------------ +#Method static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* context, + const GrBackendTexture& backendTexture, + GrSurfaceOrigin origin, int sampleCnt, + SkColorType colorType, + sk_sp<SkColorSpace> colorSpace, + const SkSurfaceProps* surfaceProps) + +Wraps a GPU-backed texture into Surface. Caller must ensure the texture is +valid for the lifetime of returned Surface. If sampleCnt greater than zero, +creates an intermediate MSAA Surface which is used for drawing backendTexture. + +Surface is returned if all parameters are valid. backendTexture is valid if +its pixel configuration agrees with colorSpace and context; for instance, if +backendTexture has an sRGB configuration, then context must support sRGB, +and colorSpace must be present. Further, backendTexture width and height must +not exceed context capabilities, and the context must be able to support +back-end textures. + +If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. + +#Param context GPU_Context ## +#Param backendTexture texture residing on GPU ## +#Param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin ## +#Param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing ## +#Param colorType one of: kUnknown_SkColorType, kAlpha_8_SkColorType, + kRGB_565_SkColorType, kARGB_4444_SkColorType, + kRGBA_8888_SkColorType, kBGRA_8888_SkColorType, + kGray_8_SkColorType, kRGBA_F16_SkColorType +## +#Param colorSpace range of colors ## +#Param surfaceProps LCD striping orientation and setting for device independent + fonts; may be nullptr +## + +#Return Surface if all parameters are valid; otherwise, nullptr ## + +#Example +#ToDo remove !fiddle below once backEndTextureRenderTarget is available ## +#Platform !fiddle gpu cpu + 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); +## + +#SeeAlso GrBackendTexture MakeFromBackendRenderTarget MakeRenderTarget + +#Method ## + +# ------------------------------------------------------------------------------ + #Method static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext* context, const GrBackendRenderTarget& backendRenderTarget, GrSurfaceOrigin origin, @@ -477,6 +539,66 @@ If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. # ------------------------------------------------------------------------------ +#Method static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext* context, + const GrBackendRenderTarget& backendRenderTarget, + GrSurfaceOrigin origin, + SkColorType colorType, + sk_sp<SkColorSpace> colorSpace, + const SkSurfaceProps* surfaceProps) + +Wraps a GPU-backed buffer into Surface. Caller must ensure render target is +valid for the lifetime of returned Surface. + +Surface is returned if all parameters are valid. backendRenderTarget is valid if +its pixel configuration agrees with colorSpace and context; for instance, if +backendRenderTarget has an sRGB configuration, then context must support sRGB, +and colorSpace must be present. Further, backendRenderTarget width and height must +not exceed context capabilities, and the context must be able to support +back-end render targets. + +If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. + +#Param context GPU_Context ## +#Param backendRenderTarget GPU intermediate memory buffer ## +#Param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin ## +#Param colorType one of: kUnknown_SkColorType, kAlpha_8_SkColorType, + kRGB_565_SkColorType, kARGB_4444_SkColorType, + kRGBA_8888_SkColorType, kBGRA_8888_SkColorType, + kGray_8_SkColorType, kRGBA_F16_SkColorType +## +#Param colorSpace range of colors ## +#Param surfaceProps LCD striping orientation and setting for device independent + fonts; may be nullptr +## + +#Return Surface if all parameters are valid; otherwise, nullptr ## + +#Example +#ToDo remove !fiddle below once backEndTextureRenderTarget is available ## +#Platform !fiddle gpu + SkPaint paint; + paint.setTextSize(32); + GrContext* context = canvas->getGrContext(); + if (!context) { + canvas->drawString("GPU only!", 20, 40, paint); + return; + } + sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendRenderTarget(context, + 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); +## + +#SeeAlso MakeFromBackendTexture MakeRenderTarget + +#Method ## + +# ------------------------------------------------------------------------------ + #Method static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(GrContext* context, const GrBackendTexture& backendTexture, GrSurfaceOrigin origin, @@ -528,6 +650,63 @@ If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. # ------------------------------------------------------------------------------ +#Method static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(GrContext* context, + const GrBackendTexture& backendTexture, + GrSurfaceOrigin origin, + int sampleCnt, + SkColorType colorType, + sk_sp<SkColorSpace> colorSpace, + const SkSurfaceProps* surfaceProps) + +Used to wrap a GPU-backed texture as a SkSurface. 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 SkSurface. + +If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. + +#Param context GPU_Context ## +#Param backendTexture texture residing on GPU ## +#Param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin ## +#Param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing ## +#Param colorType one of: kUnknown_SkColorType, kAlpha_8_SkColorType, + kRGB_565_SkColorType, kARGB_4444_SkColorType, + kRGBA_8888_SkColorType, kBGRA_8888_SkColorType, + kGray_8_SkColorType, kRGBA_F16_SkColorType +## +#Param colorSpace range of colors ## +#Param surfaceProps LCD striping orientation and setting for device independent + fonts; may be nullptr +## + +#Return Surface if all parameters are valid; otherwise, nullptr ## + +#Example +#Platform !fiddle gpu + SkPaint paint; + paint.setTextSize(32); + GrContext* context = canvas->getGrContext(); + if (!context) { + canvas->drawString("GPU only!", 20, 40, paint); + return; + } + sk_sp<SkSurface> gpuSurface = SkSurface::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); +## + +#SeeAlso MakeFromBackendRenderTarget MakeRenderTarget + +#Method ## + +# ------------------------------------------------------------------------------ + #Method static sk_sp<SkSurface> MakeRenderTarget(GrContext* context, SkBudgeted budgeted, const SkImageInfo& imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h index b4df88c8cf..1f2c4b7f07 100644 --- a/include/core/SkSurface.h +++ b/include/core/SkSurface.h @@ -169,7 +169,7 @@ public: const GrBackendTexture& backendTexture, GrSurfaceOrigin origin, int sampleCnt, - SkColorType, + SkColorType colorType, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* surfaceProps); diff --git a/site/user/api/SkSurface_Reference.md b/site/user/api/SkSurface_Reference.md index 3cc78cf1b1..f108880ff4 100644 --- a/site/user/api/SkSurface_Reference.md +++ b/site/user/api/SkSurface_Reference.md @@ -406,6 +406,83 @@ void draw(SkCanvas* canvas) { --- +<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 <a href="undocumented#GPU">GPU</a>-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 <a href="undocumented#MSAA">MSAA</a> <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 <a href="undocumented#sRGB">sRGB</a> configuration, then <a href="#SkSurface_MakeFromBackendTexture_2_context">context</a> must support <a href="undocumented#sRGB">sRGB</a>, +and <a href="#SkSurface_MakeFromBackendTexture_2_colorSpace">colorSpace</a> must be present. Further, <a href="#SkSurface_MakeFromBackendTexture_2_backendTexture">backendTexture</a> <a href="#SkSurface_width">width</a> and <a href="#SkSurface_height">height</a> 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 <a href="undocumented#SK_SUPPORT_GPU">SK SUPPORT GPU</a> 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 <a href="undocumented#GPU">GPU</a></td> + </tr> <tr> <td><a name="SkSurface_MakeFromBackendTexture_2_origin"> <code><strong>origin </strong></code> </a></td> <td> +one of: <a href="undocumented#GrSurfaceOrigin">kBottomLeft GrSurfaceOrigin</a>, <a href="undocumented#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> +one of: <a href="undocumented#SkColorType">kUnknown SkColorType</a>, <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, +<a href="undocumented#SkColorType">kRGB 565 SkColorType</a>, <a href="undocumented#SkColorType">kARGB 4444 SkColorType</a>, +<a href="undocumented#SkColorType">kRGBA 8888 SkColorType</a>, <a href="undocumented#SkColorType">kBGRA 8888 SkColorType</a>, +<a href="undocumented#SkColorType">kGray 8 SkColorType</a>, <a href="undocumented#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> +<a href="undocumented#LCD">LCD</a> 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"> +void draw(SkCanvas* canvas) { + 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> + +### See Also + +<a href="undocumented#GrBackendTexture">GrBackendTexture</a> <a href="#SkSurface_MakeFromBackendRenderTarget">MakeFromBackendRenderTarget</a> <a href="#SkSurface_MakeRenderTarget">MakeRenderTarget</a> + +--- + <a name="SkSurface_MakeFromBackendRenderTarget"></a> ## MakeFromBackendRenderTarget @@ -476,6 +553,79 @@ void draw(SkCanvas* canvas) { --- +<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> +static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext* context, + const GrBackendRenderTarget& backendRenderTarget, + GrSurfaceOrigin origin, SkColorType colorType, + sk_sp<SkColorSpace> colorSpace, + const SkSurfaceProps* surfaceProps) +</pre> + +Wraps a <a href="undocumented#GPU">GPU</a>-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>. + +<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 +<a href="#SkSurface_MakeFromBackendRenderTarget_2_backendRenderTarget">backendRenderTarget</a> has an <a href="undocumented#sRGB">sRGB</a> configuration, then <a href="#SkSurface_MakeFromBackendRenderTarget_2_context">context</a> must support <a href="undocumented#sRGB">sRGB</a>, +and <a href="#SkSurface_MakeFromBackendRenderTarget_2_colorSpace">colorSpace</a> must be present. Further, <a href="#SkSurface_MakeFromBackendRenderTarget_2_backendRenderTarget">backendRenderTarget</a> <a href="#SkSurface_width">width</a> and <a href="#SkSurface_height">height</a> must +not exceed <a href="#SkSurface_MakeFromBackendRenderTarget_2_context">context</a> capabilities, and the <a href="#SkSurface_MakeFromBackendRenderTarget_2_context">context</a> must be able to support +back-end render targets. + +If <a href="undocumented#SK_SUPPORT_GPU">SK SUPPORT GPU</a> is defined as zero, has no effect and returns nullptr. + +### Parameters + +<table> <tr> <td><a name="SkSurface_MakeFromBackendRenderTarget_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_MakeFromBackendRenderTarget_2_backendRenderTarget"> <code><strong>backendRenderTarget </strong></code> </a></td> <td> +<a href="undocumented#GPU">GPU</a> intermediate memory buffer</td> + </tr> <tr> <td><a name="SkSurface_MakeFromBackendRenderTarget_2_origin"> <code><strong>origin </strong></code> </a></td> <td> +one of: <a href="undocumented#GrSurfaceOrigin">kBottomLeft GrSurfaceOrigin</a>, <a href="undocumented#GrSurfaceOrigin">kTopLeft GrSurfaceOrigin</a></td> + </tr> <tr> <td><a name="SkSurface_MakeFromBackendRenderTarget_2_colorType"> <code><strong>colorType </strong></code> </a></td> <td> +one of: <a href="undocumented#SkColorType">kUnknown SkColorType</a>, <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, +<a href="undocumented#SkColorType">kRGB 565 SkColorType</a>, <a href="undocumented#SkColorType">kARGB 4444 SkColorType</a>, +<a href="undocumented#SkColorType">kRGBA 8888 SkColorType</a>, <a href="undocumented#SkColorType">kBGRA 8888 SkColorType</a>, +<a href="undocumented#SkColorType">kGray 8 SkColorType</a>, <a href="undocumented#SkColorType">kRGBA F16 SkColorType</a></td> + </tr> <tr> <td><a name="SkSurface_MakeFromBackendRenderTarget_2_colorSpace"> <code><strong>colorSpace </strong></code> </a></td> <td> +range of colors</td> + </tr> <tr> <td><a name="SkSurface_MakeFromBackendRenderTarget_2_surfaceProps"> <code><strong>surfaceProps </strong></code> </a></td> <td> +<a href="undocumented#LCD">LCD</a> 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"> +void draw(SkCanvas* canvas) { + SkPaint paint; + paint.setTextSize(32); + GrContext* context = canvas->getGrContext(); + if (!context) { + canvas->drawString("GPU only!", 20, 40, paint); + return; + } + sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendRenderTarget(context, + 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); +} +</pre> + +### See Also + +<a href="#SkSurface_MakeFromBackendTexture">MakeFromBackendTexture</a> <a href="#SkSurface_MakeRenderTarget">MakeRenderTarget</a> + +--- + <a name="SkSurface_MakeFromBackendTextureAsRenderTarget"></a> ## MakeFromBackendTextureAsRenderTarget @@ -544,6 +694,76 @@ void draw(SkCanvas* canvas) {SkPaint paint; --- +<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 <a href="undocumented#GPU">GPU</a>-backed texture as a <a href="#SkSurface">SkSurface</a>. <a href="undocumented#Skia">Skia</a> will treat the texture as +a rendering target only, but unlike NewFromBackendRenderTarget, <a href="undocumented#Skia">Skia</a> will manage and own +the associated render target objects (but not the provided texture). <a href="undocumented#Skia">Skia</a> 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 <a href="undocumented#SK_SUPPORT_GPU">SK SUPPORT GPU</a> 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 <a href="undocumented#GPU">GPU</a></td> + </tr> <tr> <td><a name="SkSurface_MakeFromBackendTextureAsRenderTarget_2_origin"> <code><strong>origin </strong></code> </a></td> <td> +one of: <a href="undocumented#GrSurfaceOrigin">kBottomLeft GrSurfaceOrigin</a>, <a href="undocumented#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> +one of: <a href="undocumented#SkColorType">kUnknown SkColorType</a>, <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, +<a href="undocumented#SkColorType">kRGB 565 SkColorType</a>, <a href="undocumented#SkColorType">kARGB 4444 SkColorType</a>, +<a href="undocumented#SkColorType">kRGBA 8888 SkColorType</a>, <a href="undocumented#SkColorType">kBGRA 8888 SkColorType</a>, +<a href="undocumented#SkColorType">kGray 8 SkColorType</a>, <a href="undocumented#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> +<a href="undocumented#LCD">LCD</a> 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"> +void draw(SkCanvas* canvas) {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> + +### See Also + +<a href="#SkSurface_MakeFromBackendRenderTarget">MakeFromBackendRenderTarget</a> <a href="#SkSurface_MakeRenderTarget">MakeRenderTarget</a> + +--- + <a name="SkSurface_MakeRenderTarget"></a> ## MakeRenderTarget diff --git a/tools/bookmaker/bookmaker.h b/tools/bookmaker/bookmaker.h index d4126cebd4..cb0e8dab16 100644 --- a/tools/bookmaker/bookmaker.h +++ b/tools/bookmaker/bookmaker.h @@ -1552,6 +1552,7 @@ public: fInEnum = false; fInFunction = false; fInString = false; + fFailed = false; } void setBracketShortCuts(Bracket bracket) { @@ -1728,6 +1729,7 @@ protected: bool fInEnum; bool fInFunction; bool fInString; + bool fFailed; typedef ParserCommon INHERITED; }; diff --git a/tools/bookmaker/includeParser.cpp b/tools/bookmaker/includeParser.cpp index cd6e9e3914..2846614d44 100644 --- a/tools/bookmaker/includeParser.cpp +++ b/tools/bookmaker/includeParser.cpp @@ -301,11 +301,13 @@ bool IncludeParser::crossCheck(BmhParser& bmhParser) { def->fVisited = true; } else { SkDebugf("missing toString bmh: %s\n", fullName.c_str()); + fFailed = true; } } break; } else { SkDebugf("method macro differs from bmh: %s\n", fullName.c_str()); + fFailed = true; } } } @@ -337,6 +339,7 @@ bool IncludeParser::crossCheck(BmhParser& bmhParser) { } if (!def) { SkDebugf("method missing from bmh: %s\n", fullName.c_str()); + fFailed = true; break; } if (def->crossCheck2(token)) { @@ -346,6 +349,7 @@ bool IncludeParser::crossCheck(BmhParser& bmhParser) { } } else { SkDebugf("method differs from bmh: %s\n", fullName.c_str()); + fFailed = true; } } break; case MarkType::kComment: @@ -382,6 +386,7 @@ bool IncludeParser::crossCheck(BmhParser& bmhParser) { } if (!def) { SkDebugf("enum missing from bmh: %s\n", fullName.c_str()); + fFailed = true; break; } } @@ -394,12 +399,14 @@ bool IncludeParser::crossCheck(BmhParser& bmhParser) { } if (MarkType::kCode != def->fMarkType) { SkDebugf("enum code missing from bmh: %s\n", fullName.c_str()); + fFailed = true; break; } if (def->crossCheck(token)) { def->fVisited = true; } else { - SkDebugf("enum differs from bmh: %s\n", def->fName.c_str()); + SkDebugf("enum differs from bmh: %s\n", def->fName.c_str()); + fFailed = true; } for (auto& child : token.fChildren) { string constName = MarkType::kEnumClass == token.fMarkType ? @@ -413,6 +420,7 @@ bool IncludeParser::crossCheck(BmhParser& bmhParser) { if (!def) { if (string::npos == child->fName.find("Legacy_")) { SkDebugf("const missing from bmh: %s\n", constName.c_str()); + fFailed = true; } } else { def->fVisited = true; @@ -424,6 +432,7 @@ bool IncludeParser::crossCheck(BmhParser& bmhParser) { def->fVisited = true; } else { SkDebugf("member missing from bmh: %s\n", fullName.c_str()); + fFailed = true; } break; case MarkType::kTypedef: @@ -431,6 +440,7 @@ bool IncludeParser::crossCheck(BmhParser& bmhParser) { def->fVisited = true; } else { SkDebugf("typedef missing from bmh: %s\n", fullName.c_str()); + fFailed = true; } break; default: @@ -448,11 +458,12 @@ bool IncludeParser::crossCheck(BmhParser& bmhParser) { RootDefinition* root = &finder->second; if (!root->dumpUnVisited(bmhParser.fSkip)) { SkDebugf("some struct elements not found; struct finding in includeParser is missing\n"); + fFailed = true; } SkDebugf("cross-checked %s\n", className.c_str()); } bmhParser.fWroteOut = true; - return true; + return !fFailed; } IClassDefinition* IncludeParser::defineClass(const Definition& includeDef, diff --git a/tools/bookmaker/includeWriter.cpp b/tools/bookmaker/includeWriter.cpp index b18585f4bf..e8d86f0916 100644 --- a/tools/bookmaker/includeWriter.cpp +++ b/tools/bookmaker/includeWriter.cpp @@ -633,7 +633,7 @@ void IncludeWriter::methodOut(const Definition* method, const Definition& child) this->indentToColumn(column); int partLen = (int) (partEnd - partStart); // FIXME : detect this earlier; assert if #Return is empty - SkASSERT(partLen > 0 && partLen < 200); + SkASSERT(partLen > 0 && partLen < 300); // may assert if param desc is especially long fIndent = column; this->rewriteBlock(partLen, partStart, Phrase::kYes); fIndent = saveIndent; |