• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1SkSurface Reference
2===
3
4
5<a name='SkSurface'></a>
6
7---
8
9<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
10class <a href='SkSurface_Reference#SkSurface'>SkSurface</a> : public <a href='undocumented#SkRefCnt'>SkRefCnt</a> {
11
12    static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkSurface_Reference#SkSurface'>SkSurface</a>> <a href='#SkSurface_MakeRasterDirect'>MakeRasterDirect</a>(const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo, void* pixels,
13                                             size_t rowBytes,
14                                             const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps = nullptr);
15    static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkSurface_Reference#SkSurface'>SkSurface</a>> <a href='#SkSurface_MakeRasterDirectReleaseProc'>MakeRasterDirectReleaseProc</a>(const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo, void* pixels,
16                                    size_t rowBytes,
17                                    void (*releaseProc)(void* pixels, void* context),
18                                    void* context, const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps = nullptr);
19    static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkSurface_Reference#SkSurface'>SkSurface</a>> <a href='#SkSurface_MakeRaster'>MakeRaster</a>(const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo, size_t rowBytes,
20                                       const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps);
21    static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkSurface_Reference#SkSurface'>SkSurface</a>> <a href='#SkSurface_MakeRaster'>MakeRaster</a>(const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo,
22                                       const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* props = nullptr);
23    static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkSurface_Reference#SkSurface'>SkSurface</a>> <a href='#SkSurface_MakeRasterN32Premul'>MakeRasterN32Premul</a>(int width, int height,
24                                                const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps = nullptr);
25    static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkSurface_Reference#SkSurface'>SkSurface</a>> <a href='#SkSurface_MakeFromBackendTexture'>MakeFromBackendTexture</a>(<a href='undocumented#GrContext'>GrContext</a>* context,
26                                                   const <a href='undocumented#GrBackendTexture'>GrBackendTexture</a>& backendTexture,
27                                                   <a href='undocumented#GrSurfaceOrigin'>GrSurfaceOrigin</a> origin, int sampleCnt,
28                                                   <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> colorType,
29                                                   <a href='undocumented#sk_sp'>sk_sp</a><<a href='undocumented#SkColorSpace'>SkColorSpace</a>> colorSpace,
30                                                   const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps);
31    static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkSurface_Reference#SkSurface'>SkSurface</a>> <a href='#SkSurface_MakeFromBackendRenderTarget'>MakeFromBackendRenderTarget</a>(<a href='undocumented#GrContext'>GrContext</a>* context,
32                                                const <a href='undocumented#GrBackendRenderTarget'>GrBackendRenderTarget</a>& backendRenderTarget,
33                                                <a href='undocumented#GrSurfaceOrigin'>GrSurfaceOrigin</a> origin,
34                                                <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> colorType,
35                                                <a href='undocumented#sk_sp'>sk_sp</a><<a href='undocumented#SkColorSpace'>SkColorSpace</a>> colorSpace,
36                                                const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps);
37    static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkSurface_Reference#SkSurface'>SkSurface</a>> <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget'>MakeFromBackendTextureAsRenderTarget</a>(<a href='undocumented#GrContext'>GrContext</a>* context,
38                                                            const <a href='undocumented#GrBackendTexture'>GrBackendTexture</a>& backendTexture,
39                                                            <a href='undocumented#GrSurfaceOrigin'>GrSurfaceOrigin</a> origin,
40                                                            int sampleCnt,
41                                                            <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> colorType,
42                                                            <a href='undocumented#sk_sp'>sk_sp</a><<a href='undocumented#SkColorSpace'>SkColorSpace</a>> colorSpace,
43                                                            const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps);
44    static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkSurface_Reference#SkSurface'>SkSurface</a>> <a href='#SkSurface_MakeRenderTarget'>MakeRenderTarget</a>(<a href='undocumented#GrContext'>GrContext</a>* context, <a href='undocumented#SkBudgeted'>SkBudgeted</a> budgeted,
45                                             const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo,
46                                             int sampleCount, <a href='undocumented#GrSurfaceOrigin'>GrSurfaceOrigin</a> surfaceOrigin,
47                                             const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps,
48                                             bool shouldCreateWithMips = false);
49    static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkSurface_Reference#SkSurface'>SkSurface</a>> <a href='#SkSurface_MakeRenderTarget'>MakeRenderTarget</a>(<a href='undocumented#GrContext'>GrContext</a>* context, <a href='undocumented#SkBudgeted'>SkBudgeted</a> budgeted,
50                                             const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo, int sampleCount,
51                                             const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* props);
52    static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkSurface_Reference#SkSurface'>SkSurface</a>> <a href='#SkSurface_MakeRenderTarget'>MakeRenderTarget</a>(<a href='undocumented#GrContext'>GrContext</a>* context, <a href='undocumented#SkBudgeted'>SkBudgeted</a> budgeted,
53                                             const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo);
54    static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkSurface_Reference#SkSurface'>SkSurface</a>> <a href='#SkSurface_MakeRenderTarget'>MakeRenderTarget</a>(<a href='undocumented#GrContext'>GrContext</a>* context,
55                                             const <a href='undocumented#SkSurfaceCharacterization'>SkSurfaceCharacterization</a>& characterization,
56                                             <a href='undocumented#SkBudgeted'>SkBudgeted</a> budgeted);
57    static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkSurface_Reference#SkSurface'>SkSurface</a>> <a href='#SkSurface_MakeNull'>MakeNull</a>(int width, int height);
58    int <a href='#SkSurface_width'>width()</a> const;
59    int <a href='#SkSurface_height'>height()</a> const;
60    uint32_t <a href='#SkSurface_generationID'>generationID</a>();
61
62    enum <a href='#SkSurface_ContentChangeMode'>ContentChangeMode</a> {
63        <a href='#SkSurface_kDiscard_ContentChangeMode'>kDiscard_ContentChangeMode</a>,
64        <a href='#SkSurface_kRetain_ContentChangeMode'>kRetain_ContentChangeMode</a>,
65    };
66
67    void <a href='#SkSurface_notifyContentWillChange'>notifyContentWillChange</a>(<a href='#SkSurface_ContentChangeMode'>ContentChangeMode</a> mode);
68
69    enum <a href='#SkSurface_BackendHandleAccess'>BackendHandleAccess</a> {
70        <a href='#SkSurface_kFlushRead_BackendHandleAccess'>kFlushRead_BackendHandleAccess</a>,
71        <a href='#SkSurface_kFlushWrite_BackendHandleAccess'>kFlushWrite_BackendHandleAccess</a>,
72        <a href='#SkSurface_kDiscardWrite_BackendHandleAccess'>kDiscardWrite_BackendHandleAccess</a>,
73    };
74
75    <a href='undocumented#GrBackendTexture'>GrBackendTexture</a> <a href='#SkSurface_getBackendTexture'>getBackendTexture</a>(<a href='#SkSurface_BackendHandleAccess'>BackendHandleAccess</a> backendHandleAccess);
76    <a href='undocumented#GrBackendRenderTarget'>GrBackendRenderTarget</a> <a href='#SkSurface_getBackendRenderTarget'>getBackendRenderTarget</a>(<a href='#SkSurface_BackendHandleAccess'>BackendHandleAccess</a> backendHandleAccess);
77    <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>* <a href='#SkSurface_getCanvas'>getCanvas</a>();
78    <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkSurface_Reference#SkSurface'>SkSurface</a>> <a href='#SkSurface_makeSurface'>makeSurface</a>(const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo);
79    <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkImage_Reference#SkImage'>SkImage</a>> <a href='#SkSurface_makeImageSnapshot'>makeImageSnapshot</a>();
80    <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkImage_Reference#SkImage'>SkImage</a>> <a href='#SkSurface_makeImageSnapshot'>makeImageSnapshot</a>(const <a href='SkIRect_Reference#SkIRect'>SkIRect</a>& bounds);
81    void <a href='#SkSurface_draw'>draw</a>(<a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>* <a href='SkCanvas_Reference#Canvas'>canvas</a>, <a href='undocumented#SkScalar'>SkScalar</a> x, <a href='undocumented#SkScalar'>SkScalar</a> y, const <a href='SkPaint_Reference#SkPaint'>SkPaint</a>* <a href='SkPaint_Reference#Paint'>paint</a>);
82    bool <a href='#SkSurface_peekPixels'>peekPixels</a>(<a href='SkPixmap_Reference#SkPixmap'>SkPixmap</a>* <a href='SkPixmap_Reference#Pixmap'>pixmap</a>);
83    bool <a href='#SkSurface_readPixels'>readPixels</a>(const <a href='SkPixmap_Reference#SkPixmap'>SkPixmap</a>& dst, int srcX, int srcY);
84    bool <a href='#SkSurface_readPixels'>readPixels</a>(const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& dstInfo, void* dstPixels, size_t dstRowBytes,
85                    int srcX, int srcY);
86    bool <a href='#SkSurface_readPixels'>readPixels</a>(const <a href='SkBitmap_Reference#SkBitmap'>SkBitmap</a>& dst, int srcX, int srcY);
87    void <a href='#SkSurface_writePixels'>writePixels</a>(const <a href='SkPixmap_Reference#SkPixmap'>SkPixmap</a>& src, int dstX, int dstY);
88    void <a href='#SkSurface_writePixels'>writePixels</a>(const <a href='SkBitmap_Reference#SkBitmap'>SkBitmap</a>& src, int dstX, int dstY);
89    const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>& <a href='#SkSurface_props'>props()</a> const;
90    void <a href='#SkSurface_flush'>flush()</a>;
91    <a href='undocumented#GrSemaphoresSubmitted'>GrSemaphoresSubmitted</a> <a href='#SkSurface_flushAndSignalSemaphores'>flushAndSignalSemaphores</a>(int numSemaphores,
92                                                   <a href='undocumented#GrBackendSemaphore'>GrBackendSemaphore</a> signalSemaphores[]);
93    bool <a href='#SkSurface_wait'>wait</a>(int numSemaphores, const <a href='undocumented#GrBackendSemaphore'>GrBackendSemaphore</a>* waitSemaphores);
94    bool <a href='#SkSurface_characterize'>characterize</a>(<a href='undocumented#SkSurfaceCharacterization'>SkSurfaceCharacterization</a>* characterization) const;
95    bool <a href='#SkSurface_draw'>draw</a>(<a href='undocumented#SkDeferredDisplayList'>SkDeferredDisplayList</a>* deferredDisplayList);
96};
97
98</pre>
99
100<a href='SkSurface_Reference#SkSurface'>SkSurface</a> is responsible for managing the pixels that a <a href='SkCanvas_Reference#Canvas'>canvas</a> draws into. The pixels can be
101allocated either in CPU memory, if a  <a href='undocumented#Raster_Surface'>raster surface</a>; or on the GPU, for a <a href='undocumented#GrRenderTarget'>GrRenderTarget</a> <a href='SkSurface_Reference#Surface'>surface</a>.
102<a href='SkSurface_Reference#SkSurface'>SkSurface</a> takes care of allocating a <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> that will draw into the <a href='SkSurface_Reference#Surface'>surface</a>. Call
103<a href='SkSurface_Reference#Surface'>surface</a>-><a href='#SkSurface_getCanvas'>getCanvas</a>() to use that <a href='SkCanvas_Reference#Canvas'>canvas</a>. The caller should not delete the returned <a href='SkCanvas_Reference#Canvas'>canvas</a>;
104it is owned by <a href='SkSurface_Reference#Surface'>surface</a>.
105
106<a href='SkSurface_Reference#SkSurface'>SkSurface</a> always has non-zero dimensions. If there is a request for a new <a href='SkSurface_Reference#Surface'>surface</a>, and either
107of the requested dimensions are zero, then nullptr will be returned.
108
109<a name='SkSurface_MakeRasterDirect'></a>
110
111---
112
113<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
114static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkSurface_Reference#SkSurface'>SkSurface</a>&gt; <a href='#SkSurface_MakeRasterDirect'>MakeRasterDirect</a>(const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo, void* pixels, size_t rowBytes,
115                                         const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps = nullptr)
116</pre>
117
118Allocates raster <a href='SkSurface_Reference#SkSurface'>SkSurface</a>. <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> returned by <a href='SkSurface_Reference#SkSurface'>SkSurface</a> draws directly into <a href='#SkSurface_MakeRasterDirect_pixels'>pixels</a>.
119
120<a href='SkSurface_Reference#SkSurface'>SkSurface</a> is returned if all parameters are valid.
121Valid parameters include:
122info dimensions are greater than zero;
123info contains <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> and <a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a> supported by  <a href='undocumented#Raster_Surface'>raster surface</a>;
124<a href='#SkSurface_MakeRasterDirect_pixels'>pixels</a> is not nullptr;
125<a href='#SkSurface_MakeRasterDirect_rowBytes'>rowBytes</a> is large enough to contain info width <a href='#SkSurface_MakeRasterDirect_pixels'>pixels</a> of <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a>.
126
127<a href='undocumented#Pixel'>Pixel</a> buffer <a href='undocumented#Size'>size</a> should be info height times computed <a href='#SkSurface_MakeRasterDirect_rowBytes'>rowBytes</a>.
128Pixels are not initialized.
129To access <a href='#SkSurface_MakeRasterDirect_pixels'>pixels</a> after drawing, call <a href='#SkSurface_flush'>flush()</a> or <a href='#SkSurface_peekPixels'>peekPixels</a>().
130
131### Parameters
132
133<table>  <tr>    <td><a name='SkSurface_MakeRasterDirect_imageInfo'><code><strong>imageInfo</strong></code></a></td>
134    <td>width, height, <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a>, <a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a>, <a href='undocumented#SkColorSpace'>SkColorSpace</a>,</td>
135  </tr>
136</table>
137
138of  <a href='undocumented#Raster_Surface'>raster surface</a>; width and height must be greater than zero
139
140### Parameters
141
142<table>  <tr>    <td><a name='SkSurface_MakeRasterDirect_pixels'><code><strong>pixels</strong></code></a></td>
143    <td>pointer to destination <a href='#SkSurface_MakeRasterDirect_pixels'>pixels</a> buffer</td>
144  </tr>
145  <tr>    <td><a name='SkSurface_MakeRasterDirect_rowBytes'><code><strong>rowBytes</strong></code></a></td>
146    <td>interval from one <a href='SkSurface_Reference#SkSurface'>SkSurface</a> row to the next</td>
147  </tr>
148  <tr>    <td><a name='SkSurface_MakeRasterDirect_surfaceProps'><code><strong>surfaceProps</strong></code></a></td>
149    <td>LCD striping orientation and setting for <a href='undocumented#Device'>device</a> independent fonts;</td>
150  </tr>
151</table>
152
153may be nullptr
154
155### Return Value
156
157<a href='SkSurface_Reference#SkSurface'>SkSurface</a> if all parameters are valid; otherwise, nullptr
158
159### Example
160
161<div><fiddle-embed name="3f5aeb870104187643197354a7f1d27a">
162
163#### Example Output
164
165~~~~
166---
167-x-
168---
169~~~~
170
171</fiddle-embed></div>
172
173### See Also
174
175<a href='#SkSurface_MakeRasterDirectReleaseProc'>MakeRasterDirectReleaseProc</a> <a href='#SkSurface_MakeRaster'>MakeRaster</a> <a href='#SkSurface_MakeRasterN32Premul'>MakeRasterN32Premul</a> <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>::<a href='#SkCanvas_MakeRasterDirect'>MakeRasterDirect</a>
176
177<a name='SkSurface_MakeRasterDirectReleaseProc'></a>
178
179---
180
181<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
182static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkSurface_Reference#SkSurface'>SkSurface</a>&gt; <a href='#SkSurface_MakeRasterDirectReleaseProc'>MakeRasterDirectReleaseProc</a>(const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo, void* pixels,
183                                           size_t rowBytes, void (*releaseProc) (void* pixels,
184                                           void* context) , void* context,
185                                           const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps = nullptr)
186</pre>
187
188Allocates raster <a href='SkSurface_Reference#SkSurface'>SkSurface</a>. <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> returned by <a href='SkSurface_Reference#SkSurface'>SkSurface</a> draws directly into <a href='#SkSurface_MakeRasterDirectReleaseProc_pixels'>pixels</a>.
189<a href='#SkSurface_MakeRasterDirectReleaseProc_releaseProc'>releaseProc</a> is called with <a href='#SkSurface_MakeRasterDirectReleaseProc_pixels'>pixels</a> and <a href='#SkSurface_MakeRasterDirectReleaseProc_context'>context</a> when <a href='SkSurface_Reference#SkSurface'>SkSurface</a> is deleted.
190
191<a href='SkSurface_Reference#SkSurface'>SkSurface</a> is returned if all parameters are valid.
192Valid parameters include:
193info dimensions are greater than zero;
194info contains <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> and <a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a> supported by  <a href='undocumented#Raster_Surface'>raster surface</a>;
195<a href='#SkSurface_MakeRasterDirectReleaseProc_pixels'>pixels</a> is not nullptr;
196<a href='#SkSurface_MakeRasterDirectReleaseProc_rowBytes'>rowBytes</a> is large enough to contain info width <a href='#SkSurface_MakeRasterDirectReleaseProc_pixels'>pixels</a> of <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a>.
197
198<a href='undocumented#Pixel'>Pixel</a> buffer <a href='undocumented#Size'>size</a> should be info height times computed <a href='#SkSurface_MakeRasterDirectReleaseProc_rowBytes'>rowBytes</a>.
199Pixels are not initialized.
200To access <a href='#SkSurface_MakeRasterDirectReleaseProc_pixels'>pixels</a> after drawing, call <a href='#SkSurface_flush'>flush()</a> or <a href='#SkSurface_peekPixels'>peekPixels</a>().
201
202### Parameters
203
204<table>  <tr>    <td><a name='SkSurface_MakeRasterDirectReleaseProc_imageInfo'><code><strong>imageInfo</strong></code></a></td>
205    <td>width, height, <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a>, <a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a>, <a href='undocumented#SkColorSpace'>SkColorSpace</a>,</td>
206  </tr>
207</table>
208
209of  <a href='undocumented#Raster_Surface'>raster surface</a>; width and height must be greater than zero
210
211### Parameters
212
213<table>  <tr>    <td><a name='SkSurface_MakeRasterDirectReleaseProc_pixels'><code><strong>pixels</strong></code></a></td>
214    <td>pointer to destination <a href='#SkSurface_MakeRasterDirectReleaseProc_pixels'>pixels</a> buffer</td>
215  </tr>
216  <tr>    <td><a name='SkSurface_MakeRasterDirectReleaseProc_rowBytes'><code><strong>rowBytes</strong></code></a></td>
217    <td>interval from one <a href='SkSurface_Reference#SkSurface'>SkSurface</a> row to the next</td>
218  </tr>
219  <tr>    <td><a name='SkSurface_MakeRasterDirectReleaseProc_releaseProc'><code><strong>releaseProc</strong></code></a></td>
220    <td>called when <a href='SkSurface_Reference#SkSurface'>SkSurface</a> is deleted; may be nullptr</td>
221  </tr>
222  <tr>    <td><a name='SkSurface_MakeRasterDirectReleaseProc_context'><code><strong>context</strong></code></a></td>
223    <td>passed to <a href='#SkSurface_MakeRasterDirectReleaseProc_releaseProc'>releaseProc</a>; may be nullptr</td>
224  </tr>
225  <tr>    <td><a name='SkSurface_MakeRasterDirectReleaseProc_surfaceProps'><code><strong>surfaceProps</strong></code></a></td>
226    <td>LCD striping orientation and setting for <a href='undocumented#Device'>device</a> independent fonts;</td>
227  </tr>
228</table>
229
230may be nullptr
231
232### Return Value
233
234<a href='SkSurface_Reference#SkSurface'>SkSurface</a> if all parameters are valid; otherwise, nullptr
235
236### Example
237
238<div><fiddle-embed name="8e6530b26ab4096a9a91cfaadda1c568">
239
240#### Example Output
241
242~~~~
243---
244-x-
245---
246expected release context
247~~~~
248
249</fiddle-embed></div>
250
251### See Also
252
253<a href='#SkSurface_MakeRasterDirect'>MakeRasterDirect</a> <a href='#SkSurface_MakeRasterN32Premul'>MakeRasterN32Premul</a> <a href='#SkSurface_MakeRaster'>MakeRaster</a>
254
255<a name='SkSurface_MakeRaster'></a>
256
257---
258
259<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
260static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkSurface_Reference#SkSurface'>SkSurface</a>&gt; <a href='#SkSurface_MakeRaster'>MakeRaster</a>(const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo, size_t rowBytes,
261                                   const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps)
262</pre>
263
264Allocates raster <a href='SkSurface_Reference#SkSurface'>SkSurface</a>. <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> returned by <a href='SkSurface_Reference#SkSurface'>SkSurface</a> draws directly into pixels.
265Allocates and zeroes <a href='undocumented#Pixel'>pixel</a> memory. <a href='undocumented#Pixel'>Pixel</a> memory <a href='undocumented#Size'>size</a> is <a href='#SkSurface_MakeRaster_imageInfo'>imageInfo</a>.<a href='#SkImageInfo_height'>height()</a> times
266<a href='#SkSurface_MakeRaster_rowBytes'>rowBytes</a>, or times <a href='#SkSurface_MakeRaster_imageInfo'>imageInfo</a>.<a href='#SkImageInfo_minRowBytes'>minRowBytes</a>() if <a href='#SkSurface_MakeRaster_rowBytes'>rowBytes</a> is zero.
267<a href='undocumented#Pixel'>Pixel</a> memory is deleted when <a href='SkSurface_Reference#SkSurface'>SkSurface</a> is deleted.
268
269<a href='SkSurface_Reference#SkSurface'>SkSurface</a> is returned if all parameters are valid.
270Valid parameters include:
271info dimensions are greater than zero;
272info contains <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> and <a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a> supported by  <a href='undocumented#Raster_Surface'>raster surface</a>;
273<a href='#SkSurface_MakeRaster_rowBytes'>rowBytes</a> is large enough to contain info width pixels of <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a>, or is zero.
274
275If <a href='#SkSurface_MakeRaster_rowBytes'>rowBytes</a> is not zero, subsequent images returned by <a href='#SkSurface_makeImageSnapshot'>makeImageSnapshot</a>()
276have the same <a href='#SkSurface_MakeRaster_rowBytes'>rowBytes</a>.
277
278### Parameters
279
280<table>  <tr>    <td><a name='SkSurface_MakeRaster_imageInfo'><code><strong>imageInfo</strong></code></a></td>
281    <td>width, height, <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a>, <a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a>, <a href='undocumented#SkColorSpace'>SkColorSpace</a>,</td>
282  </tr>
283</table>
284
285of  <a href='undocumented#Raster_Surface'>raster surface</a>; width and height must be greater than zero
286
287### Parameters
288
289<table>  <tr>    <td><a name='SkSurface_MakeRaster_rowBytes'><code><strong>rowBytes</strong></code></a></td>
290    <td>interval from one <a href='SkSurface_Reference#SkSurface'>SkSurface</a> row to the next; may be zero</td>
291  </tr>
292  <tr>    <td><a name='SkSurface_MakeRaster_surfaceProps'><code><strong>surfaceProps</strong></code></a></td>
293    <td>LCD striping orientation and setting for <a href='undocumented#Device'>device</a> independent fonts;</td>
294  </tr>
295</table>
296
297may be nullptr
298
299### Return Value
300
301<a href='SkSurface_Reference#SkSurface'>SkSurface</a> if all parameters are valid; otherwise, nullptr
302
303### Example
304
305<div><fiddle-embed name="a803910ada4f8733f0b62456afead55f">
306
307#### Example Output
308
309~~~~
310---
311-x-
312---
313~~~~
314
315</fiddle-embed></div>
316
317### See Also
318
319<a href='#SkSurface_MakeRasterDirect'>MakeRasterDirect</a> <a href='#SkSurface_MakeRasterN32Premul'>MakeRasterN32Premul</a> <a href='#SkSurface_MakeRasterDirectReleaseProc'>MakeRasterDirectReleaseProc</a>
320
321<a name='SkSurface_MakeRaster_2'></a>
322
323---
324
325<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
326static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkSurface_Reference#SkSurface'>SkSurface</a>&gt; <a href='#SkSurface_MakeRaster'>MakeRaster</a>(const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo,
327                                   const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* props = nullptr)
328</pre>
329
330Allocates raster <a href='SkSurface_Reference#SkSurface'>SkSurface</a>. <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> returned by <a href='SkSurface_Reference#SkSurface'>SkSurface</a> draws directly into pixels.
331Allocates and zeroes <a href='undocumented#Pixel'>pixel</a> memory. <a href='undocumented#Pixel'>Pixel</a> memory <a href='undocumented#Size'>size</a> is <a href='#SkSurface_MakeRaster_2_imageInfo'>imageInfo</a>.<a href='#SkImageInfo_height'>height()</a> times
332<a href='#SkSurface_MakeRaster_2_imageInfo'>imageInfo</a>.<a href='#SkImageInfo_minRowBytes'>minRowBytes</a>().
333<a href='undocumented#Pixel'>Pixel</a> memory is deleted when <a href='SkSurface_Reference#SkSurface'>SkSurface</a> is deleted.
334
335<a href='SkSurface_Reference#SkSurface'>SkSurface</a> is returned if all parameters are valid.
336Valid parameters include:
337info dimensions are greater than zero;
338info contains <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> and <a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a> supported by  <a href='undocumented#Raster_Surface'>raster surface</a>.
339
340### Parameters
341
342<table>  <tr>    <td><a name='SkSurface_MakeRaster_2_imageInfo'><code><strong>imageInfo</strong></code></a></td>
343    <td>width, height, <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a>, <a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a>, <a href='undocumented#SkColorSpace'>SkColorSpace</a>,</td>
344  </tr>
345</table>
346
347of  <a href='undocumented#Raster_Surface'>raster surface</a>; width and height must be greater than zero
348
349### Parameters
350
351<table>  <tr>    <td><a name='SkSurface_MakeRaster_2_props'><code><strong>props</strong></code></a></td>
352    <td>LCD striping orientation and setting for <a href='undocumented#Device'>device</a> independent fonts;</td>
353  </tr>
354</table>
355
356may be nullptr
357
358### Return Value
359
360<a href='SkSurface_Reference#SkSurface'>SkSurface</a> if all parameters are valid; otherwise, nullptr
361
362### Example
363
364<div><fiddle-embed name="c6197d204ef9e4ccfb583242651fb2a7"></fiddle-embed></div>
365
366### See Also
367
368<a href='#SkSurface_MakeRasterDirect'>MakeRasterDirect</a> <a href='#SkSurface_MakeRasterN32Premul'>MakeRasterN32Premul</a> <a href='#SkSurface_MakeRasterDirectReleaseProc'>MakeRasterDirectReleaseProc</a>
369
370<a name='SkSurface_MakeRasterN32Premul'></a>
371
372---
373
374<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
375static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkSurface_Reference#SkSurface'>SkSurface</a>&gt; <a href='#SkSurface_MakeRasterN32Premul'>MakeRasterN32Premul</a>(int width, int height,
376                                            const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps = nullptr)
377</pre>
378
379Allocates raster <a href='SkSurface_Reference#SkSurface'>SkSurface</a>. <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> returned by <a href='SkSurface_Reference#SkSurface'>SkSurface</a> draws directly into pixels.
380Allocates and zeroes <a href='undocumented#Pixel'>pixel</a> memory. <a href='undocumented#Pixel'>Pixel</a> memory <a href='undocumented#Size'>size</a> is <a href='#SkSurface_MakeRasterN32Premul_height'>height</a> times <a href='#SkSurface_MakeRasterN32Premul_width'>width</a> times
381four. <a href='undocumented#Pixel'>Pixel</a> memory is deleted when <a href='SkSurface_Reference#SkSurface'>SkSurface</a> is deleted.
382
383Internally, sets <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a> to <a href='#SkSurface_MakeRasterN32Premul_width'>width</a>, <a href='#SkSurface_MakeRasterN32Premul_height'>height</a>, native  <a href='SkImageInfo_Reference#Color_Type'>color type</a>, and
384<a href='SkImageInfo_Reference#kPremul_SkAlphaType'>kPremul_SkAlphaType</a>.
385
386<a href='SkSurface_Reference#SkSurface'>SkSurface</a> is returned if <a href='#SkSurface_MakeRasterN32Premul_width'>width</a> and <a href='#SkSurface_MakeRasterN32Premul_height'>height</a> are greater than zero.
387
388Use to create <a href='SkSurface_Reference#SkSurface'>SkSurface</a> that matches <a href='SkColor_Reference#SkPMColor'>SkPMColor</a>, the native <a href='undocumented#Pixel'>pixel</a> arrangement on
389the platform. <a href='SkSurface_Reference#SkSurface'>SkSurface</a> drawn to output <a href='undocumented#Device'>device</a> skips converting its <a href='undocumented#Pixel'>pixel</a> format.
390
391### Parameters
392
393<table>  <tr>    <td><a name='SkSurface_MakeRasterN32Premul_width'><code><strong>width</strong></code></a></td>
394    <td><a href='undocumented#Pixel'>pixel</a> column count; must be greater than zero</td>
395  </tr>
396  <tr>    <td><a name='SkSurface_MakeRasterN32Premul_height'><code><strong>height</strong></code></a></td>
397    <td><a href='undocumented#Pixel'>pixel</a> row count; must be greater than zero</td>
398  </tr>
399  <tr>    <td><a name='SkSurface_MakeRasterN32Premul_surfaceProps'><code><strong>surfaceProps</strong></code></a></td>
400    <td>LCD striping orientation and setting for <a href='undocumented#Device'>device</a> independent</td>
401  </tr>
402</table>
403
404fonts; may be nullptr
405
406### Return Value
407
408<a href='SkSurface_Reference#SkSurface'>SkSurface</a> if all parameters are valid; otherwise, nullptr
409
410### Example
411
412<div><fiddle-embed name="b932a2bd68455fb0af2e7a1ed19e36b3">
413
414#### Example Output
415
416~~~~
417---
418-x-
419---
420~~~~
421
422</fiddle-embed></div>
423
424### See Also
425
426<a href='#SkSurface_MakeRasterDirect'>MakeRasterDirect</a> <a href='#SkSurface_MakeRasterN32Premul'>MakeRasterN32Premul</a> <a href='#SkSurface_MakeRasterDirectReleaseProc'>MakeRasterDirectReleaseProc</a>
427
428<a name='SkSurface_MakeFromBackendTexture'></a>
429
430---
431
432<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
433static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkSurface_Reference#SkSurface'>SkSurface</a>&gt; <a href='#SkSurface_MakeFromBackendTexture'>MakeFromBackendTexture</a>(<a href='undocumented#GrContext'>GrContext</a>* context,
434                                               const <a href='undocumented#GrBackendTexture'>GrBackendTexture</a>& backendTexture,
435                                               <a href='undocumented#GrSurfaceOrigin'>GrSurfaceOrigin</a> origin, int sampleCnt,
436                                               <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> colorType,
437                                               <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='undocumented#SkColorSpace'>SkColorSpace</a>&gt; colorSpace,
438                                               const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps)
439</pre>
440
441Wraps a GPU-backed <a href='undocumented#Texture'>texture</a> into <a href='SkSurface_Reference#SkSurface'>SkSurface</a>. Caller must ensure the <a href='undocumented#Texture'>texture</a> is
442valid for the lifetime of returned <a href='SkSurface_Reference#SkSurface'>SkSurface</a>. If <a href='#SkSurface_MakeFromBackendTexture_sampleCnt'>sampleCnt</a> greater than zero,
443creates an intermediate MSAA <a href='SkSurface_Reference#SkSurface'>SkSurface</a> which is used for drawing <a href='#SkSurface_MakeFromBackendTexture_backendTexture'>backendTexture</a>.
444
445<a href='SkSurface_Reference#SkSurface'>SkSurface</a> is returned if all parameters are valid. <a href='#SkSurface_MakeFromBackendTexture_backendTexture'>backendTexture</a> is valid if
446its <a href='undocumented#Pixel'>pixel</a> configuration agrees with <a href='#SkSurface_MakeFromBackendTexture_colorSpace'>colorSpace</a> and <a href='#SkSurface_MakeFromBackendTexture_context'>context</a>; for instance, if
447<a href='#SkSurface_MakeFromBackendTexture_backendTexture'>backendTexture</a> has an sRGB configuration, then <a href='#SkSurface_MakeFromBackendTexture_context'>context</a> must support sRGB,
448and <a href='#SkSurface_MakeFromBackendTexture_colorSpace'>colorSpace</a> must be present. Further, <a href='#SkSurface_MakeFromBackendTexture_backendTexture'>backendTexture</a> width and height must
449not exceed <a href='#SkSurface_MakeFromBackendTexture_context'>context</a> capabilities, and the <a href='#SkSurface_MakeFromBackendTexture_context'>context</a> must be able to support
450back-end textures.
451
452If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr.
453
454### Parameters
455
456<table>  <tr>    <td><a name='SkSurface_MakeFromBackendTexture_context'><code><strong>context</strong></code></a></td>
457    <td><a href='undocumented#GPU_Context'>GPU context</a></td>
458  </tr>
459  <tr>    <td><a name='SkSurface_MakeFromBackendTexture_backendTexture'><code><strong>backendTexture</strong></code></a></td>
460    <td><a href='undocumented#Texture'>texture</a> residing on GPU</td>
461  </tr>
462  <tr>    <td><a name='SkSurface_MakeFromBackendTexture_origin'><code><strong>origin</strong></code></a></td>
463    <td>one of: <a href='undocumented#kBottomLeft_GrSurfaceOrigin'>kBottomLeft_GrSurfaceOrigin</a>, <a href='undocumented#kTopLeft_GrSurfaceOrigin'>kTopLeft_GrSurfaceOrigin</a></td>
464  </tr>
465  <tr>    <td><a name='SkSurface_MakeFromBackendTexture_sampleCnt'><code><strong>sampleCnt</strong></code></a></td>
466    <td>samples per <a href='undocumented#Pixel'>pixel</a>, or 0 to disable full scene <a href='SkPaint_Reference#Anti_Alias'>anti-aliasing</a></td>
467  </tr>
468  <tr>    <td><a name='SkSurface_MakeFromBackendTexture_colorType'><code><strong>colorType</strong></code></a></td>
469    <td>one of:</td>
470  </tr>
471</table>
472
473<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>,
474<a href='SkImageInfo_Reference#kARGB_4444_SkColorType'>kARGB_4444_SkColorType</a>, <a href='SkImageInfo_Reference#kRGBA_8888_SkColorType'>kRGBA_8888_SkColorType</a>,
475<a href='SkImageInfo_Reference#kRGB_888x_SkColorType'>kRGB_888x_SkColorType</a>, <a href='SkImageInfo_Reference#kBGRA_8888_SkColorType'>kBGRA_8888_SkColorType</a>,
476<a href='SkImageInfo_Reference#kRGBA_1010102_SkColorType'>kRGBA_1010102_SkColorType</a>, <a href='SkImageInfo_Reference#kRGB_101010x_SkColorType'>kRGB_101010x_SkColorType</a>,
477<a href='SkImageInfo_Reference#kGray_8_SkColorType'>kGray_8_SkColorType</a>, <a href='SkImageInfo_Reference#kRGBA_F16_SkColorType'>kRGBA_F16_SkColorType</a>
478
479### Parameters
480
481<table>  <tr>    <td><a name='SkSurface_MakeFromBackendTexture_colorSpace'><code><strong>colorSpace</strong></code></a></td>
482    <td>range of colors; may be nullptr</td>
483  </tr>
484  <tr>    <td><a name='SkSurface_MakeFromBackendTexture_surfaceProps'><code><strong>surfaceProps</strong></code></a></td>
485    <td>LCD striping orientation and setting for <a href='undocumented#Device'>device</a> independent</td>
486  </tr>
487</table>
488
489fonts; may be nullptr
490
491### Return Value
492
493<a href='SkSurface_Reference#SkSurface'>SkSurface</a> if all parameters are valid; otherwise, nullptr
494
495### Example
496
497<div><fiddle-embed name="d3aec071998f871809f515e58abb1b0e" gpu="true" cpu="true"></fiddle-embed></div>
498
499### See Also
500
501<a href='undocumented#GrBackendTexture'>GrBackendTexture</a> <a href='#SkSurface_MakeFromBackendRenderTarget'>MakeFromBackendRenderTarget</a> <a href='#SkSurface_MakeRenderTarget'>MakeRenderTarget</a>
502
503<a name='SkSurface_MakeFromBackendRenderTarget'></a>
504
505---
506
507<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
508static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkSurface_Reference#SkSurface'>SkSurface</a>&gt; <a href='#SkSurface_MakeFromBackendRenderTarget'>MakeFromBackendRenderTarget</a>(<a href='undocumented#GrContext'>GrContext</a>* context,
509                                                   const <a href='undocumented#GrBackendRenderTarget'>GrBackendRenderTarget</a>& backendRenderTarget,
510                                                   <a href='undocumented#GrSurfaceOrigin'>GrSurfaceOrigin</a> origin, <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> colorType,
511                                                   <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='undocumented#SkColorSpace'>SkColorSpace</a>&gt; colorSpace,
512                                                   const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps)
513</pre>
514
515Wraps a GPU-backed buffer into <a href='SkSurface_Reference#SkSurface'>SkSurface</a>. Caller must ensure <a href='#SkSurface_MakeFromBackendRenderTarget_backendRenderTarget'>backendRenderTarget</a>
516is valid for the lifetime of returned <a href='SkSurface_Reference#SkSurface'>SkSurface</a>.
517
518<a href='SkSurface_Reference#SkSurface'>SkSurface</a> is returned if all parameters are valid. <a href='#SkSurface_MakeFromBackendRenderTarget_backendRenderTarget'>backendRenderTarget</a> is valid if
519its <a href='undocumented#Pixel'>pixel</a> configuration agrees with <a href='#SkSurface_MakeFromBackendRenderTarget_colorSpace'>colorSpace</a> and <a href='#SkSurface_MakeFromBackendRenderTarget_context'>context</a>; for instance, if
520<a href='#SkSurface_MakeFromBackendRenderTarget_backendRenderTarget'>backendRenderTarget</a> has an sRGB configuration, then <a href='#SkSurface_MakeFromBackendRenderTarget_context'>context</a> must support sRGB,
521and <a href='#SkSurface_MakeFromBackendRenderTarget_colorSpace'>colorSpace</a> must be present. Further, <a href='#SkSurface_MakeFromBackendRenderTarget_backendRenderTarget'>backendRenderTarget</a> width and height must
522not exceed <a href='#SkSurface_MakeFromBackendRenderTarget_context'>context</a> capabilities, and the <a href='#SkSurface_MakeFromBackendRenderTarget_context'>context</a> must be able to support
523back-end render targets.
524
525If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr.
526
527### Parameters
528
529<table>  <tr>    <td><a name='SkSurface_MakeFromBackendRenderTarget_context'><code><strong>context</strong></code></a></td>
530    <td><a href='undocumented#GPU_Context'>GPU context</a></td>
531  </tr>
532  <tr>    <td><a name='SkSurface_MakeFromBackendRenderTarget_backendRenderTarget'><code><strong>backendRenderTarget</strong></code></a></td>
533    <td>GPU intermediate memory buffer</td>
534  </tr>
535  <tr>    <td><a name='SkSurface_MakeFromBackendRenderTarget_origin'><code><strong>origin</strong></code></a></td>
536    <td>one of: <a href='undocumented#kBottomLeft_GrSurfaceOrigin'>kBottomLeft_GrSurfaceOrigin</a>, <a href='undocumented#kTopLeft_GrSurfaceOrigin'>kTopLeft_GrSurfaceOrigin</a></td>
537  </tr>
538  <tr>    <td><a name='SkSurface_MakeFromBackendRenderTarget_colorType'><code><strong>colorType</strong></code></a></td>
539    <td>one of:</td>
540  </tr>
541</table>
542
543<a href='SkImageInfo_Reference#kUnknown_SkColorType'>kUnknown_SkColorType</a>, <a href='SkImageInfo_Reference#kAlpha_8_SkColorType'>kAlpha_8_SkColorType</a>,
544<a href='SkImageInfo_Reference#kRGB_565_SkColorType'>kRGB_565_SkColorType</a>,
545<a href='SkImageInfo_Reference#kARGB_4444_SkColorType'>kARGB_4444_SkColorType</a>, <a href='SkImageInfo_Reference#kRGBA_8888_SkColorType'>kRGBA_8888_SkColorType</a>,
546<a href='SkImageInfo_Reference#kRGB_888x_SkColorType'>kRGB_888x_SkColorType</a>, <a href='SkImageInfo_Reference#kBGRA_8888_SkColorType'>kBGRA_8888_SkColorType</a>,
547<a href='SkImageInfo_Reference#kRGBA_1010102_SkColorType'>kRGBA_1010102_SkColorType</a>, <a href='SkImageInfo_Reference#kRGB_101010x_SkColorType'>kRGB_101010x_SkColorType</a>,
548<a href='SkImageInfo_Reference#kGray_8_SkColorType'>kGray_8_SkColorType</a>, <a href='SkImageInfo_Reference#kRGBA_F16_SkColorType'>kRGBA_F16_SkColorType</a>
549
550### Parameters
551
552<table>  <tr>    <td><a name='SkSurface_MakeFromBackendRenderTarget_colorSpace'><code><strong>colorSpace</strong></code></a></td>
553    <td>range of colors</td>
554  </tr>
555  <tr>    <td><a name='SkSurface_MakeFromBackendRenderTarget_surfaceProps'><code><strong>surfaceProps</strong></code></a></td>
556    <td>LCD striping orientation and setting for <a href='undocumented#Device'>device</a> independent</td>
557  </tr>
558</table>
559
560fonts; may be nullptr
561
562### Return Value
563
564<a href='SkSurface_Reference#SkSurface'>SkSurface</a> if all parameters are valid; otherwise, nullptr
565
566### Example
567
568<pre style="padding: 1em 1em 1em 1em; font-size: 13px width: 62.5em; background-color: #f0f0f0">
569
570    SkPaint paint;
571    paint.setTextSize(32);
572    GrContext* context = canvas->getGrContext();
573    if (!context) {
574         canvas->drawString("GPU only!", 20, 40, paint);
575         return;
576    }
577    sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendRenderTarget(context,
578            backEndRenderTarget, kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType,
579            nullptr, nullptr);
580    auto surfaceCanvas = gpuSurface->getCanvas();
581    surfaceCanvas->drawString("GPU rocks!", 20, 40, paint);
582    sk_sp<SkImage> image(gpuSurface->makeImageSnapshot());
583    canvas->drawImage(image, 0, 0);
584
585</pre>
586
587### See Also
588
589<a href='#SkSurface_MakeFromBackendTexture'>MakeFromBackendTexture</a> <a href='#SkSurface_MakeRenderTarget'>MakeRenderTarget</a>
590
591<a name='SkSurface_MakeFromBackendTextureAsRenderTarget'></a>
592
593---
594
595<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
596static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkSurface_Reference#SkSurface'>SkSurface</a>&gt; <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget'>MakeFromBackendTextureAsRenderTarget</a>(<a href='undocumented#GrContext'>GrContext</a>* context,
597                                            const <a href='undocumented#GrBackendTexture'>GrBackendTexture</a>& backendTexture,
598                                            <a href='undocumented#GrSurfaceOrigin'>GrSurfaceOrigin</a> origin, int sampleCnt,
599                                            <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> colorType, <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='undocumented#SkColorSpace'>SkColorSpace</a>&gt; colorSpace,
600                                            const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps)
601</pre>
602
603Wraps a GPU-backed <a href='undocumented#Texture'>texture</a> into <a href='SkSurface_Reference#SkSurface'>SkSurface</a>. Caller must ensure <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget_backendTexture'>backendTexture</a> is
604valid for the lifetime of returned <a href='SkSurface_Reference#SkSurface'>SkSurface</a>. If <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget_sampleCnt'>sampleCnt</a> greater than zero,
605creates an intermediate MSAA <a href='SkSurface_Reference#SkSurface'>SkSurface</a> which is used for drawing <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget_backendTexture'>backendTexture</a>.
606
607<a href='SkSurface_Reference#SkSurface'>SkSurface</a> is returned if all parameters are valid. <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget_backendTexture'>backendTexture</a> is valid if
608its <a href='undocumented#Pixel'>pixel</a> configuration agrees with <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget_colorSpace'>colorSpace</a> and <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget_context'>context</a>; for instance, if
609<a href='#SkSurface_MakeFromBackendTextureAsRenderTarget_backendTexture'>backendTexture</a> has an sRGB configuration, then <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget_context'>context</a> must support sRGB,
610and <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget_colorSpace'>colorSpace</a> must be present. Further, <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget_backendTexture'>backendTexture</a> width and height must
611not exceed <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget_context'>context</a> capabilities.
612
613Returned <a href='SkSurface_Reference#SkSurface'>SkSurface</a> is available only for drawing into, and cannot generate an
614<a href='SkImage_Reference#SkImage'>SkImage</a>.
615
616If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr.
617
618### Parameters
619
620<table>  <tr>    <td><a name='SkSurface_MakeFromBackendTextureAsRenderTarget_context'><code><strong>context</strong></code></a></td>
621    <td><a href='undocumented#GPU_Context'>GPU context</a></td>
622  </tr>
623  <tr>    <td><a name='SkSurface_MakeFromBackendTextureAsRenderTarget_backendTexture'><code><strong>backendTexture</strong></code></a></td>
624    <td><a href='undocumented#Texture'>texture</a> residing on GPU</td>
625  </tr>
626  <tr>    <td><a name='SkSurface_MakeFromBackendTextureAsRenderTarget_origin'><code><strong>origin</strong></code></a></td>
627    <td>one of: <a href='undocumented#kBottomLeft_GrSurfaceOrigin'>kBottomLeft_GrSurfaceOrigin</a>, <a href='undocumented#kTopLeft_GrSurfaceOrigin'>kTopLeft_GrSurfaceOrigin</a></td>
628  </tr>
629  <tr>    <td><a name='SkSurface_MakeFromBackendTextureAsRenderTarget_sampleCnt'><code><strong>sampleCnt</strong></code></a></td>
630    <td>samples per <a href='undocumented#Pixel'>pixel</a>, or 0 to disable full scene <a href='SkPaint_Reference#Anti_Alias'>anti-aliasing</a></td>
631  </tr>
632  <tr>    <td><a name='SkSurface_MakeFromBackendTextureAsRenderTarget_colorType'><code><strong>colorType</strong></code></a></td>
633    <td>one of:</td>
634  </tr>
635</table>
636
637<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>,
638<a href='SkImageInfo_Reference#kARGB_4444_SkColorType'>kARGB_4444_SkColorType</a>, <a href='SkImageInfo_Reference#kRGBA_8888_SkColorType'>kRGBA_8888_SkColorType</a>,
639<a href='SkImageInfo_Reference#kRGB_888x_SkColorType'>kRGB_888x_SkColorType</a>, <a href='SkImageInfo_Reference#kBGRA_8888_SkColorType'>kBGRA_8888_SkColorType</a>,
640<a href='SkImageInfo_Reference#kRGBA_1010102_SkColorType'>kRGBA_1010102_SkColorType</a>, <a href='SkImageInfo_Reference#kRGB_101010x_SkColorType'>kRGB_101010x_SkColorType</a>,
641<a href='SkImageInfo_Reference#kGray_8_SkColorType'>kGray_8_SkColorType</a>, <a href='SkImageInfo_Reference#kRGBA_F16_SkColorType'>kRGBA_F16_SkColorType</a>
642
643### Parameters
644
645<table>  <tr>    <td><a name='SkSurface_MakeFromBackendTextureAsRenderTarget_colorSpace'><code><strong>colorSpace</strong></code></a></td>
646    <td>range of colors; may be nullptr</td>
647  </tr>
648  <tr>    <td><a name='SkSurface_MakeFromBackendTextureAsRenderTarget_surfaceProps'><code><strong>surfaceProps</strong></code></a></td>
649    <td>LCD striping orientation and setting for <a href='undocumented#Device'>device</a> independent</td>
650  </tr>
651</table>
652
653fonts; may be nullptr
654
655### Return Value
656
657<a href='SkSurface_Reference#SkSurface'>SkSurface</a> if all parameters are valid; otherwise, nullptr
658
659### Example
660
661<div><fiddle-embed name="5e87093b9cbe95124ae14cbe77091eb7" gpu="true"></fiddle-embed></div>
662
663### See Also
664
665<a href='#SkSurface_MakeFromBackendRenderTarget'>MakeFromBackendRenderTarget</a> <a href='#SkSurface_MakeRenderTarget'>MakeRenderTarget</a>
666
667<a name='SkSurface_MakeRenderTarget'></a>
668
669---
670
671<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
672static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkSurface_Reference#SkSurface'>SkSurface</a>&gt; <a href='#SkSurface_MakeRenderTarget'>MakeRenderTarget</a>(<a href='undocumented#GrContext'>GrContext</a>* context, <a href='undocumented#SkBudgeted'>SkBudgeted</a> budgeted,
673                                         const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo, int sampleCount,
674                                         <a href='undocumented#GrSurfaceOrigin'>GrSurfaceOrigin</a> surfaceOrigin,
675                                         const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* surfaceProps,
676                                         bool shouldCreateWithMips = false)
677</pre>
678
679Returns <a href='SkSurface_Reference#SkSurface'>SkSurface</a> on GPU indicated by <a href='#SkSurface_MakeRenderTarget_context'>context</a>. Allocates memory for
680pixels, based on the width, height, and <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> in <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>.  <a href='#SkSurface_MakeRenderTarget_budgeted'>budgeted</a>
681selects whether allocation for pixels is tracked by <a href='#SkSurface_MakeRenderTarget_context'>context</a>. <a href='#SkSurface_MakeRenderTarget_imageInfo'>imageInfo</a>
682describes the <a href='undocumented#Pixel'>pixel</a> format in <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a>, and transparency in
683<a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a>, and <a href='SkColor_Reference#Color'>color</a> matching in <a href='undocumented#SkColorSpace'>SkColorSpace</a>.
684
685<a href='#SkSurface_MakeRenderTarget_sampleCount'>sampleCount</a> requests the number of samples per <a href='undocumented#Pixel'>pixel</a>.
686Pass zero to disable  <a href='undocumented#Multi_Sample_Anti_Aliasing'>multi-sample anti-aliasing</a>.  The request is rounded
687up to the next supported count, or rounded down if it is larger than the
688maximum supported count.
689
690<a href='#SkSurface_MakeRenderTarget_surfaceOrigin'>surfaceOrigin</a> pins either the top-left or the bottom-left corner to the origin.
691
692<a href='#SkSurface_MakeRenderTarget_shouldCreateWithMips'>shouldCreateWithMips</a> hints that <a href='SkImage_Reference#SkImage'>SkImage</a> returned by <a href='#SkSurface_makeImageSnapshot'>makeImageSnapshot</a>() is  <a href='undocumented#Mip_Map'>mip map</a>.
693
694If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr.
695
696### Parameters
697
698<table>  <tr>    <td><a name='SkSurface_MakeRenderTarget_context'><code><strong>context</strong></code></a></td>
699    <td><a href='undocumented#GPU_Context'>GPU context</a></td>
700  </tr>
701  <tr>    <td><a name='SkSurface_MakeRenderTarget_budgeted'><code><strong>budgeted</strong></code></a></td>
702    <td>one of: <a href='undocumented#SkBudgeted'>SkBudgeted</a>::<a href='#SkBudgeted_kNo'>kNo</a>, <a href='undocumented#SkBudgeted'>SkBudgeted</a>::<a href='#SkBudgeted_kYes'>kYes</a></td>
703  </tr>
704  <tr>    <td><a name='SkSurface_MakeRenderTarget_imageInfo'><code><strong>imageInfo</strong></code></a></td>
705    <td>width, height, <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a>, <a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a>, <a href='undocumented#SkColorSpace'>SkColorSpace</a>;</td>
706  </tr>
707</table>
708
709width, or height, or both, may be zero
710
711### Parameters
712
713<table>  <tr>    <td><a name='SkSurface_MakeRenderTarget_sampleCount'><code><strong>sampleCount</strong></code></a></td>
714    <td>samples per <a href='undocumented#Pixel'>pixel</a>, or 0 to disable full scene <a href='SkPaint_Reference#Anti_Alias'>anti-aliasing</a></td>
715  </tr>
716  <tr>    <td><a name='SkSurface_MakeRenderTarget_surfaceOrigin'><code><strong>surfaceOrigin</strong></code></a></td>
717    <td>one of: <a href='undocumented#kBottomLeft_GrSurfaceOrigin'>kBottomLeft_GrSurfaceOrigin</a>, <a href='undocumented#kTopLeft_GrSurfaceOrigin'>kTopLeft_GrSurfaceOrigin</a></td>
718  </tr>
719  <tr>    <td><a name='SkSurface_MakeRenderTarget_surfaceProps'><code><strong>surfaceProps</strong></code></a></td>
720    <td>LCD striping orientation and setting for <a href='undocumented#Device'>device</a> independent</td>
721  </tr>
722</table>
723
724fonts; may be nullptr
725
726### Parameters
727
728<table>  <tr>    <td><a name='SkSurface_MakeRenderTarget_shouldCreateWithMips'><code><strong>shouldCreateWithMips</strong></code></a></td>
729    <td>hint that <a href='SkSurface_Reference#SkSurface'>SkSurface</a> will host  <a href='undocumented#Mip_Map'>mip map</a> images</td>
730  </tr>
731</table>
732
733### Return Value
734
735<a href='SkSurface_Reference#SkSurface'>SkSurface</a> if all parameters are valid; otherwise, nullptr
736
737### Example
738
739<div><fiddle-embed name="67b6609471a3f1ed0f4b1657004cdecb" gpu="true"></fiddle-embed></div>
740
741### See Also
742
743<a href='#SkSurface_MakeFromBackendRenderTarget'>MakeFromBackendRenderTarget</a> <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget'>MakeFromBackendTextureAsRenderTarget</a>
744
745<a name='SkSurface_MakeRenderTarget_2'></a>
746
747---
748
749<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
750static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkSurface_Reference#SkSurface'>SkSurface</a>&gt; <a href='#SkSurface_MakeRenderTarget'>MakeRenderTarget</a>(<a href='undocumented#GrContext'>GrContext</a>* context, <a href='undocumented#SkBudgeted'>SkBudgeted</a> budgeted,
751                                         const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo, int sampleCount,
752                                         const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>* props)
753</pre>
754
755Returns <a href='SkSurface_Reference#SkSurface'>SkSurface</a> on GPU indicated by <a href='#SkSurface_MakeRenderTarget_2_context'>context</a>. Allocates memory for
756pixels, based on the width, height, and <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> in <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>.  <a href='#SkSurface_MakeRenderTarget_2_budgeted'>budgeted</a>
757selects whether allocation for pixels is tracked by <a href='#SkSurface_MakeRenderTarget_2_context'>context</a>. <a href='#SkSurface_MakeRenderTarget_2_imageInfo'>imageInfo</a>
758describes the <a href='undocumented#Pixel'>pixel</a> format in <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a>, and transparency in
759<a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a>, and <a href='SkColor_Reference#Color'>color</a> matching in <a href='undocumented#SkColorSpace'>SkColorSpace</a>.
760
761<a href='#SkSurface_MakeRenderTarget_2_sampleCount'>sampleCount</a> requests the number of samples per <a href='undocumented#Pixel'>pixel</a>.
762Pass zero to disable  <a href='undocumented#Multi_Sample_Anti_Aliasing'>multi-sample anti-aliasing</a>.  The request is rounded
763up to the next supported count, or rounded down if it is larger than the
764maximum supported count.
765
766<a href='SkSurface_Reference#SkSurface'>SkSurface</a> bottom-left corner is pinned to the origin.
767
768### Parameters
769
770<table>  <tr>    <td><a name='SkSurface_MakeRenderTarget_2_context'><code><strong>context</strong></code></a></td>
771    <td><a href='undocumented#GPU_Context'>GPU context</a></td>
772  </tr>
773  <tr>    <td><a name='SkSurface_MakeRenderTarget_2_budgeted'><code><strong>budgeted</strong></code></a></td>
774    <td>one of: <a href='undocumented#SkBudgeted'>SkBudgeted</a>::<a href='#SkBudgeted_kNo'>kNo</a>, <a href='undocumented#SkBudgeted'>SkBudgeted</a>::<a href='#SkBudgeted_kYes'>kYes</a></td>
775  </tr>
776  <tr>    <td><a name='SkSurface_MakeRenderTarget_2_imageInfo'><code><strong>imageInfo</strong></code></a></td>
777    <td>width, height, <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a>, <a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a>, <a href='undocumented#SkColorSpace'>SkColorSpace</a>,</td>
778  </tr>
779</table>
780
781of  <a href='undocumented#Raster_Surface'>raster surface</a>; width, or height, or both, may be zero
782
783### Parameters
784
785<table>  <tr>    <td><a name='SkSurface_MakeRenderTarget_2_sampleCount'><code><strong>sampleCount</strong></code></a></td>
786    <td>samples per <a href='undocumented#Pixel'>pixel</a>, or 0 to disable  <a href='undocumented#Multi_Sample_Anti_Aliasing'>multi-sample anti-aliasing</a></td>
787  </tr>
788  <tr>    <td><a name='SkSurface_MakeRenderTarget_2_props'><code><strong>props</strong></code></a></td>
789    <td>LCD striping orientation and setting for <a href='undocumented#Device'>device</a> independent</td>
790  </tr>
791</table>
792
793fonts; may be nullptr
794
795### Return Value
796
797<a href='SkSurface_Reference#SkSurface'>SkSurface</a> if all parameters are valid; otherwise, nullptr
798
799### Example
800
801<div><fiddle-embed name="640321e8ecfb3f9329f3bc6e1f02485f" gpu="true" cpu="true"><div>LCD <a href='undocumented#Text'>text</a> takes advantage of raster striping to improve resolution. Only one of
802the four combinations is correct, depending on whether monitor LCD striping is
803horizontal or vertical, and whether the order of the stripes is red blue green
804or red green blue.
805</div></fiddle-embed></div>
806
807### See Also
808
809<a href='#SkSurface_MakeFromBackendRenderTarget'>MakeFromBackendRenderTarget</a> <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget'>MakeFromBackendTextureAsRenderTarget</a>
810
811<a name='SkSurface_MakeRenderTarget_3'></a>
812
813---
814
815<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
816static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkSurface_Reference#SkSurface'>SkSurface</a>&gt; <a href='#SkSurface_MakeRenderTarget'>MakeRenderTarget</a>(<a href='undocumented#GrContext'>GrContext</a>* context, <a href='undocumented#SkBudgeted'>SkBudgeted</a> budgeted,
817                                         const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo)
818</pre>
819
820Returns <a href='SkSurface_Reference#SkSurface'>SkSurface</a> on GPU indicated by <a href='#SkSurface_MakeRenderTarget_3_context'>context</a>. Allocates memory for
821pixels, based on the width, height, and <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> in <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>.  <a href='#SkSurface_MakeRenderTarget_3_budgeted'>budgeted</a>
822selects whether allocation for pixels is tracked by <a href='#SkSurface_MakeRenderTarget_3_context'>context</a>. <a href='#SkSurface_MakeRenderTarget_3_imageInfo'>imageInfo</a>
823describes the <a href='undocumented#Pixel'>pixel</a> format in <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a>, and transparency in
824<a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a>, and <a href='SkColor_Reference#Color'>color</a> matching in <a href='undocumented#SkColorSpace'>SkColorSpace</a>.
825
826<a href='SkSurface_Reference#SkSurface'>SkSurface</a> bottom-left corner is pinned to the origin.
827
828### Parameters
829
830<table>  <tr>    <td><a name='SkSurface_MakeRenderTarget_3_context'><code><strong>context</strong></code></a></td>
831    <td><a href='undocumented#GPU_Context'>GPU context</a></td>
832  </tr>
833  <tr>    <td><a name='SkSurface_MakeRenderTarget_3_budgeted'><code><strong>budgeted</strong></code></a></td>
834    <td>one of: <a href='undocumented#SkBudgeted'>SkBudgeted</a>::<a href='#SkBudgeted_kNo'>kNo</a>, <a href='undocumented#SkBudgeted'>SkBudgeted</a>::<a href='#SkBudgeted_kYes'>kYes</a></td>
835  </tr>
836  <tr>    <td><a name='SkSurface_MakeRenderTarget_3_imageInfo'><code><strong>imageInfo</strong></code></a></td>
837    <td>width, height, <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a>, <a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a>, <a href='undocumented#SkColorSpace'>SkColorSpace</a>,</td>
838  </tr>
839</table>
840
841of  <a href='undocumented#Raster_Surface'>raster surface</a>; width, or height, or both, may be zero
842
843### Return Value
844
845<a href='SkSurface_Reference#SkSurface'>SkSurface</a> if all parameters are valid; otherwise, nullptr
846
847### Example
848
849<div><fiddle-embed name="5c7629c15e9ac93f098335e72560fa2e" gpu="true"></fiddle-embed></div>
850
851### See Also
852
853<a href='#SkSurface_MakeFromBackendRenderTarget'>MakeFromBackendRenderTarget</a> <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget'>MakeFromBackendTextureAsRenderTarget</a>
854
855<a name='SkSurface_MakeRenderTarget_4'></a>
856
857---
858
859<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
860static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkSurface_Reference#SkSurface'>SkSurface</a>&gt; <a href='#SkSurface_MakeRenderTarget'>MakeRenderTarget</a>(<a href='undocumented#GrContext'>GrContext</a>* context,
861                                         const <a href='undocumented#SkSurfaceCharacterization'>SkSurfaceCharacterization</a>& characterization,
862                                         <a href='undocumented#SkBudgeted'>SkBudgeted</a> budgeted)
863</pre>
864
865Returns <a href='SkSurface_Reference#SkSurface'>SkSurface</a> on GPU indicated by <a href='#SkSurface_MakeRenderTarget_4_context'>context</a> that is compatible with the provided
866<a href='#SkSurface_MakeRenderTarget_4_characterization'>characterization</a>. <a href='#SkSurface_MakeRenderTarget_4_budgeted'>budgeted</a> selects whether allocation for pixels is tracked by <a href='#SkSurface_MakeRenderTarget_4_context'>context</a>.
867
868### Parameters
869
870<table>  <tr>    <td><a name='SkSurface_MakeRenderTarget_4_context'><code><strong>context</strong></code></a></td>
871    <td><a href='undocumented#GPU_Context'>GPU context</a></td>
872  </tr>
873  <tr>    <td><a name='SkSurface_MakeRenderTarget_4_characterization'><code><strong>characterization</strong></code></a></td>
874    <td>description of the desired <a href='SkSurface_Reference#SkSurface'>SkSurface</a></td>
875  </tr>
876  <tr>    <td><a name='SkSurface_MakeRenderTarget_4_budgeted'><code><strong>budgeted</strong></code></a></td>
877    <td>one of: <a href='undocumented#SkBudgeted'>SkBudgeted</a>::<a href='#SkBudgeted_kNo'>kNo</a>, <a href='undocumented#SkBudgeted'>SkBudgeted</a>::<a href='#SkBudgeted_kYes'>kYes</a></td>
878  </tr>
879</table>
880
881### Return Value
882
883<a href='SkSurface_Reference#SkSurface'>SkSurface</a> if all parameters are valid; otherwise, nullptr
884
885### See Also
886
887<a href='#SkSurface_MakeFromBackendRenderTarget'>MakeFromBackendRenderTarget</a> <a href='#SkSurface_MakeFromBackendTextureAsRenderTarget'>MakeFromBackendTextureAsRenderTarget</a>
888
889<a name='SkSurface_MakeNull'></a>
890
891---
892
893<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
894static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkSurface_Reference#SkSurface'>SkSurface</a>&gt; <a href='#SkSurface_MakeNull'>MakeNull</a>(int width, int height)
895</pre>
896
897Returns <a href='SkSurface_Reference#SkSurface'>SkSurface</a> without backing pixels. Drawing to <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> returned from <a href='SkSurface_Reference#SkSurface'>SkSurface</a>
898has no effect. Calling <a href='#SkSurface_makeImageSnapshot'>makeImageSnapshot</a>() on returned <a href='SkSurface_Reference#SkSurface'>SkSurface</a> returns nullptr.
899
900### Parameters
901
902<table>  <tr>    <td><a name='SkSurface_MakeNull_width'><code><strong>width</strong></code></a></td>
903    <td>one or greater</td>
904  </tr>
905  <tr>    <td><a name='SkSurface_MakeNull_height'><code><strong>height</strong></code></a></td>
906    <td>one or greater</td>
907  </tr>
908</table>
909
910### Return Value
911
912<a href='SkSurface_Reference#SkSurface'>SkSurface</a> if <a href='#SkSurface_MakeNull_width'>width</a> and <a href='#SkSurface_MakeNull_height'>height</a> are positive; otherwise, nullptr
913
914### Example
915
916<div><fiddle-embed name="99a54b814ccab7d2b1143c88581649ff">
917
918#### Example Output
919
920~~~~
921SkSurface::MakeNull(0, 0) == nullptr
922surf->makeImageSnapshot() == nullptr
923~~~~
924
925</fiddle-embed></div>
926
927### See Also
928
929<a href='#SkSurface_MakeRaster'>MakeRaster</a> <a href='#SkSurface_MakeRenderTarget'>MakeRenderTarget</a>
930
931<a name='Property'></a>
932
933<a name='SkSurface_width'></a>
934
935---
936
937<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
938int <a href='#SkSurface_width'>width()</a>const
939</pre>
940
941Returns <a href='undocumented#Pixel'>pixel</a> count in each row; may be zero or greater.
942
943### Return Value
944
945number of <a href='undocumented#Pixel'>pixel</a> columns
946
947### Example
948
949<div><fiddle-embed name="df066b56dd97c7c589fd2bb6a2539de8">
950
951#### Example Output
952
953~~~~
954surface width=37  canvas width=37
955~~~~
956
957</fiddle-embed></div>
958
959### See Also
960
961<a href='#SkSurface_height'>height()</a>
962
963<a name='SkSurface_height'></a>
964
965---
966
967<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
968int <a href='#SkSurface_height'>height()</a>const
969</pre>
970
971Returns <a href='undocumented#Pixel'>pixel</a> row count; may be zero or greater.
972
973### Return Value
974
975number of <a href='undocumented#Pixel'>pixel</a> rows
976
977### Example
978
979<div><fiddle-embed name="20571cc23e3146deaa09046b64cc0aef">
980
981#### Example Output
982
983~~~~
984surface height=1000  canvas height=1000
985~~~~
986
987</fiddle-embed></div>
988
989### See Also
990
991<a href='#SkSurface_width'>width()</a>
992
993<a name='SkSurface_generationID'></a>
994
995---
996
997<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
998uint32_t <a href='#SkSurface_generationID'>generationID</a>()
999</pre>
1000
1001Returns unique value identifying the content of <a href='SkSurface_Reference#SkSurface'>SkSurface</a>. Returned value changes
1002each time the content changes. Content is changed by drawing, or by calling
1003<a href='#SkSurface_notifyContentWillChange'>notifyContentWillChange</a>().
1004
1005### Return Value
1006
1007unique content identifier
1008
1009### Example
1010
1011<div><fiddle-embed name="be9574c4a14f891e1abb4ec2b1e51d6c">
1012
1013#### Example Output
1014
1015~~~~
1016surface generationID: 1
1017surface generationID: 2
1018surface generationID: 3
1019~~~~
1020
1021</fiddle-embed></div>
1022
1023### See Also
1024
1025<a href='#SkSurface_notifyContentWillChange'>notifyContentWillChange</a> <a href='#SkSurface_ContentChangeMode'>ContentChangeMode</a> <a href='#SkSurface_getCanvas'>getCanvas</a>
1026
1027<a name='SkSurface_ContentChangeMode'></a>
1028
1029---
1030
1031<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1032    enum <a href='#SkSurface_ContentChangeMode'>ContentChangeMode</a> {
1033        <a href='#SkSurface_kDiscard_ContentChangeMode'>kDiscard_ContentChangeMode</a>,
1034        <a href='#SkSurface_kRetain_ContentChangeMode'>kRetain_ContentChangeMode</a>,
1035    };
1036</pre>
1037
1038<a href='#SkSurface_ContentChangeMode'>ContentChangeMode</a> members are parameters to <a href='#SkSurface_notifyContentWillChange'>notifyContentWillChange</a>.
1039
1040### Constants
1041
1042<table style='border-collapse: collapse; width: 62.5em'>
1043  <tr><th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Const</th>
1044<th style='text-align: center; border: 2px solid #dddddd; padding: 8px; '>Value</th>
1045<th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Description</th></tr>
1046  <tr style='background-color: #f0f0f0; '>
1047    <td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='SkSurface_kDiscard_ContentChangeMode'><code>SkSurface::kDiscard_ContentChangeMode</code></a></td>
1048    <td style='text-align: center; border: 2px solid #dddddd; padding: 8px; '>#Line # discards surface on change ##</td>
1049    <td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>
1050Pass to <a href='#SkSurface_notifyContentWillChange'>notifyContentWillChange</a> to discard <a href='SkSurface_Reference#Surface'>surface</a> contents when
1051the <a href='SkSurface_Reference#Surface'>surface</a> is cleared or overwritten.
1052</td>
1053  </tr>
1054  <tr>
1055    <td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='SkSurface_kRetain_ContentChangeMode'><code>SkSurface::kRetain_ContentChangeMode</code></a></td>
1056    <td style='text-align: center; border: 2px solid #dddddd; padding: 8px; '>#Line # preserves surface on change ##</td>
1057    <td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>
1058Pass to <a href='#SkSurface_notifyContentWillChange'>notifyContentWillChange</a> when to preserve <a href='SkSurface_Reference#Surface'>surface</a> contents.
1059If a snapshot has been generated, this copies the <a href='SkSurface_Reference#Surface'>Surface</a> contents.
1060</td>
1061  </tr>
1062</table>
1063
1064### See Also
1065
1066<a href='#SkSurface_notifyContentWillChange'>notifyContentWillChange</a> <a href='#SkSurface_generationID'>generationID</a>
1067
1068<a name='Miscellaneous'></a>
1069
1070<a name='SkSurface_notifyContentWillChange'></a>
1071
1072---
1073
1074<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1075void <a href='#SkSurface_notifyContentWillChange'>notifyContentWillChange</a>(<a href='#SkSurface_ContentChangeMode'>ContentChangeMode</a> mode)
1076</pre>
1077
1078Notifies that <a href='SkSurface_Reference#SkSurface'>SkSurface</a> contents will be changed by code outside of Skia.
1079Subsequent calls to <a href='#SkSurface_generationID'>generationID</a>() return a different value.
1080
1081### Parameters
1082
1083<table>  <tr>    <td><a name='SkSurface_notifyContentWillChange_mode'><code><strong>mode</strong></code></a></td>
1084    <td>one of: <a href='#SkSurface_kDiscard_ContentChangeMode'>kDiscard_ContentChangeMode</a>, <a href='#SkSurface_kRetain_ContentChangeMode'>kRetain_ContentChangeMode</a></td>
1085  </tr>
1086</table>
1087
1088### Example
1089
1090<div><fiddle-embed name="be9574c4a14f891e1abb4ec2b1e51d6c"></fiddle-embed></div>
1091
1092### See Also
1093
1094<a href='#SkSurface_ContentChangeMode'>ContentChangeMode</a> <a href='#SkSurface_generationID'>generationID</a>
1095
1096<a name='SkSurface_BackendHandleAccess'></a>
1097
1098---
1099
1100<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1101    enum <a href='#SkSurface_BackendHandleAccess'>BackendHandleAccess</a> {
1102        <a href='#SkSurface_kFlushRead_BackendHandleAccess'>kFlushRead_BackendHandleAccess</a>,
1103        <a href='#SkSurface_kFlushWrite_BackendHandleAccess'>kFlushWrite_BackendHandleAccess</a>,
1104        <a href='#SkSurface_kDiscardWrite_BackendHandleAccess'>kDiscardWrite_BackendHandleAccess</a>,
1105    };
1106
1107    static const <a href='#SkSurface_BackendHandleAccess'>BackendHandleAccess</a> kFlushRead_TextureHandleAccess =
1108            <a href='#SkSurface_kFlushRead_BackendHandleAccess'>kFlushRead_BackendHandleAccess</a>;
1109    static const <a href='#SkSurface_BackendHandleAccess'>BackendHandleAccess</a> kFlushWrite_TextureHandleAccess =
1110            <a href='#SkSurface_kFlushWrite_BackendHandleAccess'>kFlushWrite_BackendHandleAccess</a>;
1111    static const <a href='#SkSurface_BackendHandleAccess'>BackendHandleAccess</a> kDiscardWrite_TextureHandleAccess =
1112            <a href='#SkSurface_kDiscardWrite_BackendHandleAccess'>kDiscardWrite_BackendHandleAccess</a>;
1113</pre>
1114
1115### Constants
1116
1117<table style='border-collapse: collapse; width: 62.5em'>
1118  <tr><th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Const</th>
1119<th style='text-align: center; border: 2px solid #dddddd; padding: 8px; '>Value</th>
1120<th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Description</th></tr>
1121  <tr style='background-color: #f0f0f0; '>
1122    <td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='SkSurface_kFlushRead_BackendHandleAccess'><code>SkSurface::kFlushRead_BackendHandleAccess</code></a></td>
1123    <td style='text-align: center; border: 2px solid #dddddd; padding: 8px; '>0</td>
1124    <td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>
1125Caller may read from the back-end object.
1126</td>
1127  </tr>
1128  <tr>
1129    <td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='SkSurface_kFlushWrite_BackendHandleAccess'><code>SkSurface::kFlushWrite_BackendHandleAccess</code></a></td>
1130    <td style='text-align: center; border: 2px solid #dddddd; padding: 8px; '>1</td>
1131    <td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>
1132Caller may write to the back-end object.
1133</td>
1134  </tr>
1135  <tr style='background-color: #f0f0f0; '>
1136    <td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='SkSurface_kDiscardWrite_BackendHandleAccess'><code>SkSurface::kDiscardWrite_BackendHandleAccess</code></a></td>
1137    <td style='text-align: center; border: 2px solid #dddddd; padding: 8px; '>2</td>
1138    <td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>
1139Caller must overwrite the entire back-end object.
1140</td>
1141  </tr>
1142</table>
1143
1144### See Also
1145
1146<a href='#SkSurface_getBackendTexture'>getBackendTexture</a> <a href='#SkSurface_getBackendRenderTarget'>getBackendRenderTarget</a>
1147
1148<a name='SkSurface_getBackendTexture'></a>
1149
1150---
1151
1152<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1153<a href='undocumented#GrBackendTexture'>GrBackendTexture</a> <a href='#SkSurface_getBackendTexture'>getBackendTexture</a>(<a href='#SkSurface_BackendHandleAccess'>BackendHandleAccess</a> backendHandleAccess)
1154</pre>
1155
1156Retrieves the back-end <a href='undocumented#Texture'>texture</a>. If <a href='SkSurface_Reference#SkSurface'>SkSurface</a> has no back-end <a href='undocumented#Texture'>texture</a>, an invalid
1157object is returned. Call <a href='undocumented#GrBackendTexture'>GrBackendTexture</a>::<a href='#GrBackendTexture_isValid'>isValid</a> to determine if the result
1158is valid.
1159
1160The returned <a href='undocumented#GrBackendTexture'>GrBackendTexture</a> should be discarded if the <a href='SkSurface_Reference#SkSurface'>SkSurface</a> is drawn to or deleted.
1161
1162### Parameters
1163
1164<table>  <tr>    <td><a name='SkSurface_getBackendTexture_backendHandleAccess'><code><strong>backendHandleAccess</strong></code></a></td>
1165    <td>one of:  <a href='#SkSurface_kFlushRead_BackendHandleAccess'>kFlushRead_BackendHandleAccess</a>,</td>
1166  </tr>
1167</table>
1168
1169<a href='#SkSurface_kFlushWrite_BackendHandleAccess'>kFlushWrite_BackendHandleAccess</a>,
1170<a href='#SkSurface_kDiscardWrite_BackendHandleAccess'>kDiscardWrite_BackendHandleAccess</a>
1171
1172### Return Value
1173
1174<a href='undocumented#GPU_Texture'>GPU texture</a> reference; invalid on failure
1175
1176### See Also
1177
1178<a href='undocumented#GrBackendTexture'>GrBackendTexture</a> <a href='#SkSurface_BackendHandleAccess'>BackendHandleAccess</a> <a href='#SkSurface_getBackendRenderTarget'>getBackendRenderTarget</a>
1179
1180<a name='SkSurface_getBackendRenderTarget'></a>
1181
1182---
1183
1184<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1185<a href='undocumented#GrBackendRenderTarget'>GrBackendRenderTarget</a> <a href='#SkSurface_getBackendRenderTarget'>getBackendRenderTarget</a>(<a href='#SkSurface_BackendHandleAccess'>BackendHandleAccess</a> backendHandleAccess)
1186</pre>
1187
1188Retrieves the back-end  <a href='undocumented#Render_Target'>render target</a>. If <a href='SkSurface_Reference#SkSurface'>SkSurface</a> has no back-end  <a href='undocumented#Render_Target'>render target</a>, an invalid
1189object is returned. Call <a href='undocumented#GrBackendRenderTarget'>GrBackendRenderTarget</a>::<a href='#GrBackendRenderTarget_isValid'>isValid</a> to determine if the result
1190is valid.
1191
1192The returned <a href='undocumented#GrBackendRenderTarget'>GrBackendRenderTarget</a> should be discarded if the <a href='SkSurface_Reference#SkSurface'>SkSurface</a> is drawn to
1193or deleted.
1194
1195### Parameters
1196
1197<table>  <tr>    <td><a name='SkSurface_getBackendRenderTarget_backendHandleAccess'><code><strong>backendHandleAccess</strong></code></a></td>
1198    <td>one of:  <a href='#SkSurface_kFlushRead_BackendHandleAccess'>kFlushRead_BackendHandleAccess</a>,</td>
1199  </tr>
1200</table>
1201
1202<a href='#SkSurface_kFlushWrite_BackendHandleAccess'>kFlushWrite_BackendHandleAccess</a>,
1203<a href='#SkSurface_kDiscardWrite_BackendHandleAccess'>kDiscardWrite_BackendHandleAccess</a>
1204
1205### Return Value
1206
1207GPU  <a href='undocumented#Render_Target'>render target</a> reference; invalid on failure
1208
1209### See Also
1210
1211<a href='undocumented#GrBackendRenderTarget'>GrBackendRenderTarget</a> <a href='#SkSurface_BackendHandleAccess'>BackendHandleAccess</a> <a href='#SkSurface_getBackendTexture'>getBackendTexture</a>
1212
1213<a name='SkSurface_getCanvas'></a>
1214
1215---
1216
1217<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1218<a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>* <a href='#SkSurface_getCanvas'>getCanvas</a>()
1219</pre>
1220
1221Returns <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> that draws into <a href='SkSurface_Reference#SkSurface'>SkSurface</a>. Subsequent calls return the same <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>.
1222<a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> returned is managed and owned by <a href='SkSurface_Reference#SkSurface'>SkSurface</a>, and is deleted when <a href='SkSurface_Reference#SkSurface'>SkSurface</a>
1223is deleted.
1224
1225### Return Value
1226
1227drawing <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> for <a href='SkSurface_Reference#SkSurface'>SkSurface</a>
1228
1229### Example
1230
1231<div><fiddle-embed name="33d0c5ad5a4810e533ae1010e29f8b75"></fiddle-embed></div>
1232
1233### See Also
1234
1235<a href='#SkSurface_makeSurface'>makeSurface</a> <a href='#SkSurface_makeImageSnapshot'>makeImageSnapshot</a> <a href='#SkSurface_draw'>draw</a>
1236
1237<a name='SkSurface_makeSurface'></a>
1238
1239---
1240
1241<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1242<a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkSurface_Reference#SkSurface'>SkSurface</a>&gt; <a href='#SkSurface_makeSurface'>makeSurface</a>(const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& imageInfo)
1243</pre>
1244
1245Returns a compatible <a href='SkSurface_Reference#SkSurface'>SkSurface</a>, or nullptr. Returned <a href='SkSurface_Reference#SkSurface'>SkSurface</a> contains
1246the same raster, GPU, or null properties as the original. Returned <a href='SkSurface_Reference#SkSurface'>SkSurface</a>
1247does not share the same pixels.
1248
1249Returns nullptr if <a href='#SkSurface_makeSurface_imageInfo'>imageInfo</a> width or height are zero, or if <a href='#SkSurface_makeSurface_imageInfo'>imageInfo</a>
1250is incompatible with <a href='SkSurface_Reference#SkSurface'>SkSurface</a>.
1251
1252### Parameters
1253
1254<table>  <tr>    <td><a name='SkSurface_makeSurface_imageInfo'><code><strong>imageInfo</strong></code></a></td>
1255    <td>width, height, <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a>, <a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a>, <a href='undocumented#SkColorSpace'>SkColorSpace</a>,</td>
1256  </tr>
1257</table>
1258
1259of <a href='SkSurface_Reference#SkSurface'>SkSurface</a>; width and height must be greater than zero
1260
1261### Return Value
1262
1263compatible <a href='SkSurface_Reference#SkSurface'>SkSurface</a> or nullptr
1264
1265### Example
1266
1267<div><fiddle-embed name="a9889b519a26896b900da0444e423c61"></fiddle-embed></div>
1268
1269### See Also
1270
1271<a href='#SkSurface_makeImageSnapshot'>makeImageSnapshot</a> <a href='#SkSurface_getCanvas'>getCanvas</a> <a href='#SkSurface_draw'>draw</a>
1272
1273<a name='SkSurface_makeImageSnapshot'></a>
1274
1275---
1276
1277<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1278<a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkImage_Reference#SkImage'>SkImage</a>&gt; <a href='#SkSurface_makeImageSnapshot'>makeImageSnapshot</a>()
1279</pre>
1280
1281Returns <a href='SkImage_Reference#SkImage'>SkImage</a> capturing <a href='SkSurface_Reference#SkSurface'>SkSurface</a> contents. Subsequent drawing to <a href='SkSurface_Reference#SkSurface'>SkSurface</a> contents
1282are not captured. <a href='SkImage_Reference#SkImage'>SkImage</a> allocation is accounted for if <a href='SkSurface_Reference#SkSurface'>SkSurface</a> was created with
1283<a href='undocumented#SkBudgeted'>SkBudgeted</a>::<a href='#SkBudgeted_kYes'>kYes</a>.
1284
1285### Return Value
1286
1287<a href='SkImage_Reference#SkImage'>SkImage</a> initialized with <a href='SkSurface_Reference#SkSurface'>SkSurface</a> contents
1288
1289### Example
1290
1291<div><fiddle-embed name="46f1fa0d95e590a64bed0140407ce5f7"></fiddle-embed></div>
1292
1293### See Also
1294
1295<a href='#SkSurface_draw'>draw</a> <a href='#SkSurface_getCanvas'>getCanvas</a>
1296
1297<a name='SkSurface_makeImageSnapshot_2'></a>
1298
1299---
1300
1301<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1302<a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkImage_Reference#SkImage'>SkImage</a>&gt; <a href='#SkSurface_makeImageSnapshot'>makeImageSnapshot</a>(const <a href='SkIRect_Reference#SkIRect'>SkIRect</a>& bounds)
1303</pre>
1304
1305Like the no-parameter version, this returns an <a href='SkImage_Reference#Image'>image</a> of the current <a href='SkSurface_Reference#Surface'>surface</a> contents.
1306This variant takes a rectangle specifying the subset of the <a href='SkSurface_Reference#Surface'>surface</a> that is of interest.
1307These bounds will be sanitized before being used.
1308- If bounds extends beyond the <a href='SkSurface_Reference#Surface'>surface</a>, it will be trimmed to just the intersection of
1309it and the <a href='SkSurface_Reference#Surface'>surface</a>.
1310- If bounds does not intersect the <a href='SkSurface_Reference#Surface'>surface</a>, then this returns nullptr.
1311- If bounds == the <a href='SkSurface_Reference#Surface'>surface</a>, then this is the same as calling the no-parameter variant.
1312
1313### Example
1314
1315<div><fiddle-embed name="b18b8ab693b09eb70a1d22ab63790cc7"></fiddle-embed></div>
1316
1317### See Also
1318
1319<a href='#SkSurface_draw'>draw</a> <a href='#SkSurface_getCanvas'>getCanvas</a>
1320
1321<a name='Pixels'></a>
1322
1323<a name='SkSurface_draw'></a>
1324
1325---
1326
1327<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1328void draw(<a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>* <a href='SkCanvas_Reference#Canvas'>canvas</a>, <a href='undocumented#SkScalar'>SkScalar</a> x, <a href='undocumented#SkScalar'>SkScalar</a> y, const <a href='SkPaint_Reference#SkPaint'>SkPaint</a>* <a href='SkPaint_Reference#Paint'>paint</a>)
1329</pre>
1330
1331Draws <a href='SkSurface_Reference#SkSurface'>SkSurface</a> contents to <a href='#SkSurface_draw_canvas'>canvas</a>, with its top-left corner at (<a href='#SkSurface_draw_x'>x</a>, <a href='#SkSurface_draw_y'>y</a>).
1332
1333If <a href='SkPaint_Reference#SkPaint'>SkPaint</a> <a href='#SkSurface_draw_paint'>paint</a> is not nullptr, apply <a href='undocumented#SkColorFilter'>SkColorFilter</a>, <a href='SkColor_Reference#Alpha'>alpha</a>, <a href='undocumented#SkImageFilter'>SkImageFilter</a>,
1334<a href='SkBlendMode_Reference#SkBlendMode'>SkBlendMode</a>, and <a href='undocumented#SkDrawLooper'>SkDrawLooper</a>.
1335
1336### Parameters
1337
1338<table>  <tr>    <td><a name='SkSurface_draw_canvas'><code><strong>canvas</strong></code></a></td>
1339    <td><a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> drawn into</td>
1340  </tr>
1341  <tr>    <td><a name='SkSurface_draw_x'><code><strong>x</strong></code></a></td>
1342    <td>horizontal offset in <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a></td>
1343  </tr>
1344  <tr>    <td><a name='SkSurface_draw_y'><code><strong>y</strong></code></a></td>
1345    <td>vertical offset in <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a></td>
1346  </tr>
1347  <tr>    <td><a name='SkSurface_draw_paint'><code><strong>paint</strong></code></a></td>
1348    <td><a href='SkPaint_Reference#SkPaint'>SkPaint</a> containing <a href='SkBlendMode_Reference#SkBlendMode'>SkBlendMode</a>, <a href='undocumented#SkColorFilter'>SkColorFilter</a>, <a href='undocumented#SkImageFilter'>SkImageFilter</a>,</td>
1349  </tr>
1350</table>
1351
1352and so on; or nullptr
1353
1354### Example
1355
1356<div><fiddle-embed name="0de693f4d8dd898a60be8cfba23952be"></fiddle-embed></div>
1357
1358### See Also
1359
1360<a href='#SkSurface_makeImageSnapshot'>makeImageSnapshot</a> <a href='#SkSurface_getCanvas'>getCanvas</a>
1361
1362<a name='SkSurface_peekPixels'></a>
1363
1364---
1365
1366<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1367bool <a href='#SkSurface_peekPixels'>peekPixels</a>(<a href='SkPixmap_Reference#SkPixmap'>SkPixmap</a>* <a href='SkPixmap_Reference#Pixmap'>pixmap</a>)
1368</pre>
1369
1370Copies <a href='SkSurface_Reference#SkSurface'>SkSurface</a> <a href='undocumented#Pixel'>pixel</a> address, row bytes, and <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a> to <a href='SkPixmap_Reference#SkPixmap'>SkPixmap</a>, if address
1371is available, and returns true. If <a href='undocumented#Pixel'>pixel</a> address is not available, return
1372false and leave <a href='SkPixmap_Reference#SkPixmap'>SkPixmap</a> unchanged.
1373
1374<a href='#SkSurface_peekPixels_pixmap'>pixmap</a> contents become invalid on any future change to <a href='SkSurface_Reference#SkSurface'>SkSurface</a>.
1375
1376### Parameters
1377
1378<table>  <tr>    <td><a name='SkSurface_peekPixels_pixmap'><code><strong>pixmap</strong></code></a></td>
1379    <td>storage for <a href='undocumented#Pixel'>pixel</a> state if pixels are readable; otherwise, ignored</td>
1380  </tr>
1381</table>
1382
1383### Return Value
1384
1385true if <a href='SkSurface_Reference#SkSurface'>SkSurface</a> has direct access to pixels
1386
1387### Example
1388
1389<div><fiddle-embed name="8c6184f22cfe068f021704cf92a147a1"></fiddle-embed></div>
1390
1391### See Also
1392
1393<a href='#SkSurface_readPixels'>readPixels</a> <a href='#SkSurface_writePixels'>writePixels</a>
1394
1395<a name='SkSurface_readPixels'></a>
1396
1397---
1398
1399<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1400bool <a href='#SkSurface_readPixels'>readPixels</a>(const <a href='SkPixmap_Reference#SkPixmap'>SkPixmap</a>& dst, int srcX, int srcY)
1401</pre>
1402
1403Copies <a href='SkRect_Reference#Rect'>Rect</a> of pixels to <a href='#SkSurface_readPixels_dst'>dst</a>.
1404
1405Source <a href='SkRect_Reference#Rect'>Rect</a> corners are (<a href='#SkSurface_readPixels_srcX'>srcX</a>, <a href='#SkSurface_readPixels_srcY'>srcY</a>) and <a href='SkSurface_Reference#Surface'>Surface</a> (<a href='#SkSurface_width'>width()</a>, <a href='#SkSurface_height'>height()</a>).
1406Destination <a href='SkRect_Reference#Rect'>Rect</a> corners are (0, 0) and (<a href='#SkSurface_readPixels_dst'>dst</a>.<a href='#SkPixmap_width'>width()</a>, <a href='#SkSurface_readPixels_dst'>dst</a>.<a href='#SkPixmap_height'>height()</a>).
1407Copies each readable <a href='undocumented#Pixel'>pixel</a> intersecting both rectangles, without scaling,
1408converting to <a href='#SkSurface_readPixels_dst'>dst</a>.<a href='#SkPixmap_colorType'>colorType</a>() and <a href='#SkSurface_readPixels_dst'>dst</a>.<a href='#SkPixmap_alphaType'>alphaType</a>() if required.
1409
1410Pixels are readable when <a href='SkSurface_Reference#Surface'>Surface</a> is raster, or backed by a GPU.
1411
1412The destination  <a href='undocumented#Pixel_Storage'>pixel storage</a> must be allocated by the caller.
1413
1414<a href='undocumented#Pixel'>Pixel</a> values are converted only if <a href='#Image_Info_Color_Type'>Color_Type</a> and <a href='#Image_Info_Alpha_Type'>Alpha_Type</a>
1415do not match. Only pixels within both source and destination rectangles
1416are copied. <a href='#SkSurface_readPixels_dst'>dst</a> contents outside <a href='SkRect_Reference#Rect'>Rect</a> intersection are unchanged.
1417
1418Pass negative values for <a href='#SkSurface_readPixels_srcX'>srcX</a> or <a href='#SkSurface_readPixels_srcY'>srcY</a> to offset pixels across or down destination.
1419
1420Does not copy, and returns false if:
1421
1422<table>  <tr>
1423    <td>Source and destination rectangles do not intersect.</td>
1424  </tr>  <tr>
1425    <td><a href='SkPixmap_Reference#Pixmap'>Pixmap</a> pixels could not be allocated.</td>
1426  </tr>  <tr>
1427    <td><a href='#SkSurface_readPixels_dst'>dst</a>.<a href='#SkPixmap_rowBytes'>rowBytes</a>() is too small to contain one row of pixels.</td>
1428  </tr>
1429</table>
1430
1431### Parameters
1432
1433<table>  <tr>    <td><a name='SkSurface_readPixels_dst'><code><strong>dst</strong></code></a></td>
1434    <td>storage for pixels copied from <a href='SkSurface_Reference#Surface'>Surface</a></td>
1435  </tr>
1436  <tr>    <td><a name='SkSurface_readPixels_srcX'><code><strong>srcX</strong></code></a></td>
1437    <td>offset into readable pixels on x-axis; may be negative</td>
1438  </tr>
1439  <tr>    <td><a name='SkSurface_readPixels_srcY'><code><strong>srcY</strong></code></a></td>
1440    <td>offset into readable pixels on y-axis; may be negative</td>
1441  </tr>
1442</table>
1443
1444### Return Value
1445
1446true if pixels were copied
1447
1448### Example
1449
1450<div><fiddle-embed name="9f454fb93bca6482598d198b4121f0a6"></fiddle-embed></div>
1451
1452### See Also
1453
1454<a href='#SkSurface_peekPixels'>peekPixels</a> <a href='#SkSurface_writePixels'>writePixels</a>
1455
1456<a name='SkSurface_readPixels_2'></a>
1457
1458---
1459
1460<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1461bool <a href='#SkSurface_readPixels'>readPixels</a>(const <a href='SkImageInfo_Reference#SkImageInfo'>SkImageInfo</a>& dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY)
1462</pre>
1463
1464Copies <a href='SkRect_Reference#Rect'>Rect</a> of pixels from <a href='SkCanvas_Reference#Canvas'>Canvas</a> into <a href='#SkSurface_readPixels_2_dstPixels'>dstPixels</a>.
1465
1466Source <a href='SkRect_Reference#Rect'>Rect</a> corners are (<a href='#SkSurface_readPixels_2_srcX'>srcX</a>, <a href='#SkSurface_readPixels_2_srcY'>srcY</a>) and <a href='SkSurface_Reference#Surface'>Surface</a> (<a href='#SkSurface_width'>width()</a>, <a href='#SkSurface_height'>height()</a>).
1467Destination <a href='SkRect_Reference#Rect'>Rect</a> corners are (0, 0) and (<a href='#SkSurface_readPixels_2_dstInfo'>dstInfo</a>.<a href='#SkImageInfo_width'>width()</a>, <a href='#SkSurface_readPixels_2_dstInfo'>dstInfo</a>.<a href='#SkImageInfo_height'>height()</a>).
1468Copies each readable <a href='undocumented#Pixel'>pixel</a> intersecting both rectangles, without scaling,
1469converting to <a href='#SkSurface_readPixels_2_dstInfo'>dstInfo</a>.<a href='#SkImageInfo_colorType'>colorType</a>() and <a href='#SkSurface_readPixels_2_dstInfo'>dstInfo</a>.<a href='#SkImageInfo_alphaType'>alphaType</a>() if required.
1470
1471Pixels are readable when <a href='SkSurface_Reference#Surface'>Surface</a> is raster, or backed by a GPU.
1472
1473The destination  <a href='undocumented#Pixel_Storage'>pixel storage</a> must be allocated by the caller.
1474
1475<a href='undocumented#Pixel'>Pixel</a> values are converted only if <a href='#Image_Info_Color_Type'>Color_Type</a> and <a href='#Image_Info_Alpha_Type'>Alpha_Type</a>
1476do not match. Only pixels within both source and destination rectangles
1477are copied. <a href='#SkSurface_readPixels_2_dstPixels'>dstPixels</a> contents outside <a href='SkRect_Reference#Rect'>Rect</a> intersection are unchanged.
1478
1479Pass negative values for <a href='#SkSurface_readPixels_2_srcX'>srcX</a> or <a href='#SkSurface_readPixels_2_srcY'>srcY</a> to offset pixels across or down destination.
1480
1481Does not copy, and returns false if:
1482
1483<table>  <tr>
1484    <td>Source and destination rectangles do not intersect.</td>
1485  </tr>  <tr>
1486    <td><a href='SkSurface_Reference#Surface'>Surface</a> pixels could not be converted to <a href='#SkSurface_readPixels_2_dstInfo'>dstInfo</a>.<a href='#SkImageInfo_colorType'>colorType</a>() or <a href='#SkSurface_readPixels_2_dstInfo'>dstInfo</a>.<a href='#SkImageInfo_alphaType'>alphaType</a>().</td>
1487  </tr>  <tr>
1488    <td><a href='#SkSurface_readPixels_2_dstRowBytes'>dstRowBytes</a> is too small to contain one row of pixels.</td>
1489  </tr>
1490</table>
1491
1492### Parameters
1493
1494<table>  <tr>    <td><a name='SkSurface_readPixels_2_dstInfo'><code><strong>dstInfo</strong></code></a></td>
1495    <td>width, height, <a href='#Image_Info_Color_Type'>Color_Type</a>, and <a href='#Image_Info_Alpha_Type'>Alpha_Type</a> of <a href='#SkSurface_readPixels_2_dstPixels'>dstPixels</a></td>
1496  </tr>
1497  <tr>    <td><a name='SkSurface_readPixels_2_dstPixels'><code><strong>dstPixels</strong></code></a></td>
1498    <td>storage for pixels; <a href='#SkSurface_readPixels_2_dstInfo'>dstInfo</a>.<a href='#SkImageInfo_height'>height()</a> times <a href='#SkSurface_readPixels_2_dstRowBytes'>dstRowBytes</a>, or larger</td>
1499  </tr>
1500  <tr>    <td><a name='SkSurface_readPixels_2_dstRowBytes'><code><strong>dstRowBytes</strong></code></a></td>
1501    <td><a href='undocumented#Size'>size</a> of one destination row; <a href='#SkSurface_readPixels_2_dstInfo'>dstInfo</a>.<a href='#SkImageInfo_width'>width()</a> times <a href='undocumented#Pixel'>pixel</a> <a href='undocumented#Size'>size</a>, or larger</td>
1502  </tr>
1503  <tr>    <td><a name='SkSurface_readPixels_2_srcX'><code><strong>srcX</strong></code></a></td>
1504    <td>offset into readable pixels on x-axis; may be negative</td>
1505  </tr>
1506  <tr>    <td><a name='SkSurface_readPixels_2_srcY'><code><strong>srcY</strong></code></a></td>
1507    <td>offset into readable pixels on y-axis; may be negative</td>
1508  </tr>
1509</table>
1510
1511### Return Value
1512
1513true if pixels were copied
1514
1515### Example
1516
1517<div><fiddle-embed name="484d60dab5d846bf28c7a4d48892324a"><div>A black <a href='undocumented#Oval'>oval</a> drawn on a red background provides an <a href='SkImage_Reference#Image'>image</a> to copy.
1518<a href='#SkSurface_readPixels'>readPixels</a> copies one quarter of the <a href='SkSurface_Reference#Surface'>Surface</a> into each of the four corners.
1519The copied quarter <a href='undocumented#Oval'>ovals</a> overdraw the original <a href='undocumented#Oval'>oval</a>.
1520</div></fiddle-embed></div>
1521
1522### See Also
1523
1524<a href='#SkSurface_peekPixels'>peekPixels</a> <a href='#SkSurface_writePixels'>writePixels</a>
1525
1526<a name='SkSurface_readPixels_3'></a>
1527
1528---
1529
1530<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1531bool <a href='#SkSurface_readPixels'>readPixels</a>(const <a href='SkBitmap_Reference#SkBitmap'>SkBitmap</a>& dst, int srcX, int srcY)
1532</pre>
1533
1534Copies <a href='SkRect_Reference#Rect'>Rect</a> of pixels from <a href='SkSurface_Reference#Surface'>Surface</a> into <a href='SkBitmap_Reference#Bitmap'>bitmap</a>.
1535
1536Source <a href='SkRect_Reference#Rect'>Rect</a> corners are (<a href='#SkSurface_readPixels_3_srcX'>srcX</a>, <a href='#SkSurface_readPixels_3_srcY'>srcY</a>) and <a href='SkSurface_Reference#Surface'>Surface</a> (<a href='#SkSurface_width'>width()</a>, <a href='#SkSurface_height'>height()</a>).
1537Destination <a href='SkRect_Reference#Rect'>Rect</a> corners are (0, 0) and (<a href='SkBitmap_Reference#Bitmap'>bitmap</a>.<a href='#SkSurface_width'>width()</a>, <a href='SkBitmap_Reference#Bitmap'>bitmap</a>.<a href='#SkSurface_height'>height()</a>).
1538Copies each readable <a href='undocumented#Pixel'>pixel</a> intersecting both rectangles, without scaling,
1539converting to <a href='#SkSurface_readPixels_3_dst'>dst</a>.<a href='#SkBitmap_colorType'>colorType</a>() and <a href='#SkSurface_readPixels_3_dst'>dst</a>.<a href='#SkBitmap_alphaType'>alphaType</a>() if required.
1540
1541Pixels are readable when <a href='SkSurface_Reference#Surface'>Surface</a> is raster, or backed by a GPU.
1542
1543The destination  <a href='undocumented#Pixel_Storage'>pixel storage</a> must be allocated by the caller.
1544
1545<a href='undocumented#Pixel'>Pixel</a> values are converted only if <a href='#Image_Info_Color_Type'>Color_Type</a> and <a href='#Image_Info_Alpha_Type'>Alpha_Type</a>
1546do not match. Only pixels within both source and destination rectangles
1547are copied. <a href='#SkSurface_readPixels_3_dst'>dst</a> contents outside <a href='SkRect_Reference#Rect'>Rect</a> intersection are unchanged.
1548
1549Pass negative values for <a href='#SkSurface_readPixels_3_srcX'>srcX</a> or <a href='#SkSurface_readPixels_3_srcY'>srcY</a> to offset pixels across or down destination.
1550
1551Does not copy, and returns false if:
1552
1553<table>  <tr>
1554    <td>Source and destination rectangles do not intersect.</td>
1555  </tr>  <tr>
1556    <td><a href='SkSurface_Reference#Surface'>Surface</a> pixels could not be converted to <a href='#SkSurface_readPixels_3_dst'>dst</a>.<a href='#SkBitmap_colorType'>colorType</a>() or <a href='#SkSurface_readPixels_3_dst'>dst</a>.<a href='#SkBitmap_alphaType'>alphaType</a>().</td>
1557  </tr>  <tr>
1558    <td><a href='#SkSurface_readPixels_3_dst'>dst</a> pixels could not be allocated.</td>
1559  </tr>  <tr>
1560    <td><a href='#SkSurface_readPixels_3_dst'>dst</a>.<a href='#SkBitmap_rowBytes'>rowBytes</a>() is too small to contain one row of pixels.</td>
1561  </tr>
1562</table>
1563
1564### Parameters
1565
1566<table>  <tr>    <td><a name='SkSurface_readPixels_3_dst'><code><strong>dst</strong></code></a></td>
1567    <td>storage for pixels copied from <a href='SkSurface_Reference#Surface'>Surface</a></td>
1568  </tr>
1569  <tr>    <td><a name='SkSurface_readPixels_3_srcX'><code><strong>srcX</strong></code></a></td>
1570    <td>offset into readable pixels on x-axis; may be negative</td>
1571  </tr>
1572  <tr>    <td><a name='SkSurface_readPixels_3_srcY'><code><strong>srcY</strong></code></a></td>
1573    <td>offset into readable pixels on y-axis; may be negative</td>
1574  </tr>
1575</table>
1576
1577### Return Value
1578
1579true if pixels were copied
1580
1581### Example
1582
1583<div><fiddle-embed name="2d991a231e49d1de13eeb2ba9b440e01"></fiddle-embed></div>
1584
1585### See Also
1586
1587<a href='#SkSurface_peekPixels'>peekPixels</a> <a href='#SkSurface_writePixels'>writePixels</a>
1588
1589<a name='SkSurface_writePixels'></a>
1590
1591---
1592
1593<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1594void <a href='#SkSurface_writePixels'>writePixels</a>(const <a href='SkPixmap_Reference#SkPixmap'>SkPixmap</a>& src, int dstX, int dstY)
1595</pre>
1596
1597Copies <a href='SkRect_Reference#Rect'>Rect</a> of pixels from the <a href='#SkSurface_writePixels_src'>src</a> <a href='SkPixmap_Reference#Pixmap'>Pixmap</a> to the <a href='SkSurface_Reference#Surface'>Surface</a>.
1598
1599Source <a href='SkRect_Reference#Rect'>Rect</a> corners are (0, 0) and (<a href='#SkSurface_writePixels_src'>src</a>.<a href='#SkPixmap_width'>width()</a>, <a href='#SkSurface_writePixels_src'>src</a>.<a href='#SkPixmap_height'>height()</a>).
1600Destination <a href='SkRect_Reference#Rect'>Rect</a> corners are (<a href='#SkSurface_writePixels_dstX'>dstX</a>, <a href='#SkSurface_writePixels_dstY'>dstY</a>) and
1601<code>(<a href='#SkSurface_writePixels_dstX'>dstX</a> + <a href='SkSurface_Reference#Surface'>Surface</a> <a href='#SkSurface_width'>width()</a>, <a href='#SkSurface_writePixels_dstY'>dstY</a> + <a href='SkSurface_Reference#Surface'>Surface</a> <a href='#SkSurface_height'>height()</a>)</code>.
1602
1603Copies each readable <a href='undocumented#Pixel'>pixel</a> intersecting both rectangles, without scaling,
1604converting to <a href='SkSurface_Reference#Surface'>Surface</a> <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> and <a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a> if required.
1605
1606### Parameters
1607
1608<table>  <tr>    <td><a name='SkSurface_writePixels_src'><code><strong>src</strong></code></a></td>
1609    <td>storage for pixels to copy to <a href='SkSurface_Reference#Surface'>Surface</a></td>
1610  </tr>
1611  <tr>    <td><a name='SkSurface_writePixels_dstX'><code><strong>dstX</strong></code></a></td>
1612    <td>x-axis position relative to <a href='SkSurface_Reference#Surface'>Surface</a> to begin copy; may be negative</td>
1613  </tr>
1614  <tr>    <td><a name='SkSurface_writePixels_dstY'><code><strong>dstY</strong></code></a></td>
1615    <td>y-axis position relative to <a href='SkSurface_Reference#Surface'>Surface</a> to begin copy; may be negative</td>
1616  </tr>
1617</table>
1618
1619### Example
1620
1621<div><fiddle-embed name="760793bcf0ef193fa61ea03e6e8fc825"></fiddle-embed></div>
1622
1623### See Also
1624
1625<a href='#SkSurface_readPixels'>readPixels</a> <a href='#SkSurface_peekPixels'>peekPixels</a>
1626
1627<a name='SkSurface_writePixels_2'></a>
1628
1629---
1630
1631<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1632void <a href='#SkSurface_writePixels'>writePixels</a>(const <a href='SkBitmap_Reference#SkBitmap'>SkBitmap</a>& src, int dstX, int dstY)
1633</pre>
1634
1635Copies <a href='SkRect_Reference#Rect'>Rect</a> of pixels from the <a href='#SkSurface_writePixels_2_src'>src</a> <a href='SkBitmap_Reference#Bitmap'>Bitmap</a> to the <a href='SkSurface_Reference#Surface'>Surface</a>.
1636
1637Source <a href='SkRect_Reference#Rect'>Rect</a> corners are (0, 0) and (<a href='#SkSurface_writePixels_2_src'>src</a>.<a href='#SkBitmap_width'>width()</a>, <a href='#SkSurface_writePixels_2_src'>src</a>.<a href='#SkBitmap_height'>height()</a>).
1638Destination <a href='SkRect_Reference#Rect'>Rect</a> corners are (<a href='#SkSurface_writePixels_2_dstX'>dstX</a>, <a href='#SkSurface_writePixels_2_dstY'>dstY</a>) and
1639<code>(<a href='#SkSurface_writePixels_2_dstX'>dstX</a> + <a href='SkSurface_Reference#Surface'>Surface</a> <a href='#SkSurface_width'>width()</a>, <a href='#SkSurface_writePixels_2_dstY'>dstY</a> + <a href='SkSurface_Reference#Surface'>Surface</a> <a href='#SkSurface_height'>height()</a>)</code>.
1640
1641Copies each readable <a href='undocumented#Pixel'>pixel</a> intersecting both rectangles, without scaling,
1642converting to <a href='SkSurface_Reference#Surface'>Surface</a> <a href='SkImageInfo_Reference#SkColorType'>SkColorType</a> and <a href='SkImageInfo_Reference#SkAlphaType'>SkAlphaType</a> if required.
1643
1644### Parameters
1645
1646<table>  <tr>    <td><a name='SkSurface_writePixels_2_src'><code><strong>src</strong></code></a></td>
1647    <td>storage for pixels to copy to <a href='SkSurface_Reference#Surface'>Surface</a></td>
1648  </tr>
1649  <tr>    <td><a name='SkSurface_writePixels_2_dstX'><code><strong>dstX</strong></code></a></td>
1650    <td>x-axis position relative to <a href='SkSurface_Reference#Surface'>Surface</a> to begin copy; may be negative</td>
1651  </tr>
1652  <tr>    <td><a name='SkSurface_writePixels_2_dstY'><code><strong>dstY</strong></code></a></td>
1653    <td>y-axis position relative to <a href='SkSurface_Reference#Surface'>Surface</a> to begin copy; may be negative</td>
1654  </tr>
1655</table>
1656
1657### Example
1658
1659<div><fiddle-embed name="d77790dd3bc9f678fa4f582347fb8fba"></fiddle-embed></div>
1660
1661### See Also
1662
1663<a href='#SkSurface_readPixels'>readPixels</a> <a href='#SkSurface_peekPixels'>peekPixels</a>
1664
1665<a name='SkSurface_props'></a>
1666
1667---
1668
1669<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1670const <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>& <a href='#SkSurface_props'>props()</a>const
1671</pre>
1672
1673Returns <a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a> for <a href='SkSurface_Reference#Surface'>surface</a>.
1674
1675### Return Value
1676
1677LCD striping orientation and setting for <a href='undocumented#Device'>device</a> independent fonts
1678
1679### Example
1680
1681<div><fiddle-embed name="13cf9e7b2894ae6e98c1fd719040bf01">
1682
1683#### Example Output
1684
1685~~~~
1686surf.props(): kRGB_H_SkPixelGeometry
1687~~~~
1688
1689</fiddle-embed></div>
1690
1691### See Also
1692
1693<a href='undocumented#SkSurfaceProps'>SkSurfaceProps</a>
1694
1695<a name='Utility'></a>
1696
1697<a name='SkSurface_flush'></a>
1698
1699---
1700
1701<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1702void <a href='#SkSurface_flush'>flush()</a>
1703</pre>
1704
1705Issues pending <a href='SkSurface_Reference#SkSurface'>SkSurface</a> commands to the GPU-backed API and resolves any <a href='SkSurface_Reference#SkSurface'>SkSurface</a> MSAA.
1706
1707Skia flushes as needed, so it is not necessary to call this if Skia manages
1708drawing and object lifetime. Call when interleaving Skia calls with native
1709GPU calls.
1710
1711### See Also
1712
1713<a href='undocumented#GrBackendSemaphore'>GrBackendSemaphore</a>
1714
1715<a name='SkSurface_flushAndSignalSemaphores'></a>
1716
1717---
1718
1719<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1720<a href='undocumented#GrSemaphoresSubmitted'>GrSemaphoresSubmitted</a> <a href='#SkSurface_flushAndSignalSemaphores'>flushAndSignalSemaphores</a>(int numSemaphores,
1721                                               <a href='undocumented#GrBackendSemaphore'>GrBackendSemaphore</a> signalSemaphores[])
1722</pre>
1723
1724Issues pending <a href='SkSurface_Reference#SkSurface'>SkSurface</a> commands to the GPU-backed API and resolves any <a href='SkSurface_Reference#SkSurface'>SkSurface</a> MSAA.
1725After issuing all commands, <a href='#SkSurface_flushAndSignalSemaphores_signalSemaphores'>signalSemaphores</a> of count <a href='#SkSurface_flushAndSignalSemaphores_numSemaphores'>numSemaphores</a> semaphores
1726are signaled by the GPU.
1727
1728For each <a href='undocumented#GrBackendSemaphore'>GrBackendSemaphore</a> in <a href='#SkSurface_flushAndSignalSemaphores_signalSemaphores'>signalSemaphores</a>:
1729if <a href='undocumented#GrBackendSemaphore'>GrBackendSemaphore</a> is initialized, the GPU back-end uses the semaphore as is;
1730otherwise, a new semaphore is created and initializes <a href='undocumented#GrBackendSemaphore'>GrBackendSemaphore</a>.
1731
1732The caller must delete the semaphores created and returned in <a href='#SkSurface_flushAndSignalSemaphores_signalSemaphores'>signalSemaphores</a>.
1733<a href='undocumented#GrBackendSemaphore'>GrBackendSemaphore</a> can be deleted as soon as this function returns.
1734
1735If the back-end API is OpenGL only uninitialized  <a href='undocumented#Backend_Semaphore'>backend semaphores</a> are supported.
1736
1737If the back-end API is Vulkan semaphores may be initialized or uninitialized.
1738If uninitialized, created semaphores are valid only with the VkDevice
1739with which they were created.
1740
1741If <a href='undocumented#GrSemaphoresSubmitted'>GrSemaphoresSubmitted</a>::<a href='#GrSemaphoresSubmitted_kNo'>kNo</a> is returned, the GPU back-end did not create or
1742add any semaphores to signal on the GPU; the caller should not instruct the GPU
1743to wait on any of the semaphores.
1744
1745Pending <a href='SkSurface_Reference#Surface'>surface</a> commands are flushed regardless of the return result.
1746
1747### Parameters
1748
1749<table>  <tr>    <td><a name='SkSurface_flushAndSignalSemaphores_numSemaphores'><code><strong>numSemaphores</strong></code></a></td>
1750    <td><a href='undocumented#Size'>size</a> of <a href='#SkSurface_flushAndSignalSemaphores_signalSemaphores'>signalSemaphores</a> array</td>
1751  </tr>
1752  <tr>    <td><a name='SkSurface_flushAndSignalSemaphores_signalSemaphores'><code><strong>signalSemaphores</strong></code></a></td>
1753    <td>array of semaphore containers</td>
1754  </tr>
1755</table>
1756
1757### Return Value
1758
1759one of: <a href='undocumented#GrSemaphoresSubmitted'>GrSemaphoresSubmitted</a>::<a href='#GrSemaphoresSubmitted_kYes'>kYes</a>, <a href='undocumented#GrSemaphoresSubmitted'>GrSemaphoresSubmitted</a>::<a href='#GrSemaphoresSubmitted_kNo'>kNo</a>
1760
1761### See Also
1762
1763<a href='#SkSurface_wait'>wait</a> <a href='undocumented#GrBackendSemaphore'>GrBackendSemaphore</a>
1764
1765<a name='SkSurface_wait'></a>
1766
1767---
1768
1769<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1770bool wait(int numSemaphores, const <a href='undocumented#GrBackendSemaphore'>GrBackendSemaphore</a>* waitSemaphores)
1771</pre>
1772
1773Inserts a list of GPU semaphores that the current GPU-backed API must wait on before
1774executing any more commands on the GPU for this <a href='SkSurface_Reference#Surface'>surface</a>. Skia will take ownership of the
1775underlying semaphores and delete them once they have been signaled and waited on.
1776If this call returns false, then the GPU back-end will not wait on any passed in semaphores,
1777and the client will still own the semaphores.
1778
1779### Parameters
1780
1781<table>  <tr>    <td><a name='SkSurface_wait_numSemaphores'><code><strong>numSemaphores</strong></code></a></td>
1782    <td><a href='undocumented#Size'>size</a> of <a href='#SkSurface_wait_waitSemaphores'>waitSemaphores</a> array</td>
1783  </tr>
1784  <tr>    <td><a name='SkSurface_wait_waitSemaphores'><code><strong>waitSemaphores</strong></code></a></td>
1785    <td>array of semaphore containers</td>
1786  </tr>
1787</table>
1788
1789### Return Value
1790
1791true if GPU is waiting on semaphores
1792
1793### See Also
1794
1795<a href='#SkSurface_flushAndSignalSemaphores'>flushAndSignalSemaphores</a> <a href='undocumented#GrBackendSemaphore'>GrBackendSemaphore</a>
1796
1797<a name='SkSurface_characterize'></a>
1798
1799---
1800
1801<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1802bool <a href='#SkSurface_characterize'>characterize</a>(<a href='undocumented#SkSurfaceCharacterization'>SkSurfaceCharacterization</a>* characterization)const
1803</pre>
1804
1805Initializes <a href='undocumented#SkSurfaceCharacterization'>SkSurfaceCharacterization</a> that can be used to perform GPU back-end
1806processing in a separate thread. Typically this is used to divide drawing
1807into multiple tiles. <a href='undocumented#SkDeferredDisplayListRecorder'>SkDeferredDisplayListRecorder</a> records the drawing commands
1808for each tile.
1809
1810Return true if <a href='SkSurface_Reference#SkSurface'>SkSurface</a> supports <a href='#SkSurface_characterize_characterization'>characterization</a>.  <a href='undocumented#Raster_Surface'>raster surface</a> returns false.
1811
1812### Parameters
1813
1814<table>  <tr>    <td><a name='SkSurface_characterize_characterization'><code><strong>characterization</strong></code></a></td>
1815    <td>properties for parallel drawing</td>
1816  </tr>
1817</table>
1818
1819### Return Value
1820
1821true if supported
1822
1823### Example
1824
1825<div><fiddle-embed name="6de6f3ef699a72ff26da1b26b23a3316" gpu="true"></fiddle-embed></div>
1826
1827### See Also
1828
1829<a href='#SkSurface_draw'>draw()</a> <a href='undocumented#SkSurfaceCharacterization'>SkSurfaceCharacterization</a> <a href='undocumented#SkDeferredDisplayList'>SkDeferredDisplayList</a>
1830
1831<a name='SkSurface_draw_2'></a>
1832
1833---
1834
1835<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
1836bool draw(<a href='undocumented#SkDeferredDisplayList'>SkDeferredDisplayList</a>* deferredDisplayList)
1837</pre>
1838
1839Draws   deferred display list created using <a href='undocumented#SkDeferredDisplayListRecorder'>SkDeferredDisplayListRecorder</a>.
1840Has no effect and returns false if <a href='undocumented#SkSurfaceCharacterization'>SkSurfaceCharacterization</a> stored in
1841<a href='#SkSurface_draw_2_deferredDisplayList'>deferredDisplayList</a> is not compatible with <a href='SkSurface_Reference#SkSurface'>SkSurface</a>.
1842
1843<a href='undocumented#Raster_Surface'>raster surface</a> returns false.
1844
1845### Parameters
1846
1847<table>  <tr>    <td><a name='SkSurface_draw_2_deferredDisplayList'><code><strong>deferredDisplayList</strong></code></a></td>
1848    <td>drawing commands</td>
1849  </tr>
1850</table>
1851
1852### Return Value
1853
1854false if <a href='#SkSurface_draw_2_deferredDisplayList'>deferredDisplayList</a> is not compatible
1855
1856### Example
1857
1858<div><fiddle-embed name="46d9bacf593deaaeabd74ff42f2571a0" gpu="true" cpu="true"></fiddle-embed></div>
1859
1860### See Also
1861
1862<a href='#SkSurface_characterize'>characterize()</a> <a href='undocumented#SkSurfaceCharacterization'>SkSurfaceCharacterization</a> <a href='undocumented#SkDeferredDisplayList'>SkDeferredDisplayList</a>
1863
1864