skia2/site/user/api/SkPicture_Reference.md

517 lines
17 KiB
Markdown
Raw Normal View History

SkPicture Reference
===
# <a name='Picture'>Picture</a>
# <a name='SkPicture'>Class SkPicture</a>
## <a name='Constructor'>Constructor</a>
SkPicture can be constructed or initialized by these functions, including C++ class constructors.
<table style='border-collapse: collapse; width: 62.5em'>
<tr><th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Topic</th>
<th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Description</th></tr>
<tr style='background-color: #f0f0f0; '>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkPicture_MakeFromData'>MakeFromData</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>incomplete</td>
</tr>
<tr>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkPicture_MakeFromStream'>MakeFromStream</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>incomplete</td>
</tr>
<tr style='background-color: #f0f0f0; '>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkPicture_MakePlaceholder'>MakePlaceholder</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>incomplete</td>
</tr>
</table>
An <a href='#SkPicture'>SkPicture</a> records drawing commands made to a canvas to be played back at a later time.
This base class handles serialization and a few other miscellany.
## Overview
<table style='border-collapse: collapse; width: 62.5em'>
<tr><th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Topic</th>
<th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Description</th></tr>
<tr style='background-color: #f0f0f0; '>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#Class'>Class Declarations</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>embedded class members</td>
</tr>
<tr>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#Constructor'>Constructors</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>functions that construct <a href='#SkPicture'>SkPicture</a></td>
</tr>
<tr style='background-color: #f0f0f0; '>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#Member_Function'>Functions</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>global and class member functions</td>
</tr>
</table>
## <a name='Class'>Class</a>
SkPicture uses C++ classes to declare the public data structures and interfaces.
<table style='border-collapse: collapse; width: 62.5em'>
<tr><th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Topic</th>
<th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Description</th></tr>
<tr style='background-color: #f0f0f0; '>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkPicture_AbortCallback'>AbortCallback</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>incomplete</td>
</tr>
</table>
## <a name='Member_Function'>Member Function</a>
SkPicture member functions read and modify the structure properties.
<table style='border-collapse: collapse; width: 62.5em'>
<tr><th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Topic</th>
<th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Description</th></tr>
<tr style='background-color: #f0f0f0; '>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkPicture_MakeFromData'>MakeFromData</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>incomplete</td>
</tr>
<tr>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkPicture_MakeFromStream'>MakeFromStream</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>incomplete</td>
</tr>
<tr style='background-color: #f0f0f0; '>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkPicture_MakePlaceholder'>MakePlaceholder</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>incomplete</td>
</tr>
<tr>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkPicture_approximateBytesUsed'>approximateBytesUsed</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>incomplete</td>
</tr>
<tr style='background-color: #f0f0f0; '>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkPicture_approximateOpCount'>approximateOpCount</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>incomplete</td>
</tr>
<tr>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkPicture_cullRect'>cullRect</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>incomplete</td>
</tr>
<tr style='background-color: #f0f0f0; '>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkPicture_playback'>playback</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>incomplete</td>
</tr>
<tr>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkPicture_serialize'>serialize</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>incomplete</td>
</tr>
<tr style='background-color: #f0f0f0; '>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkPicture_uniqueID'>uniqueID</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>incomplete</td>
</tr>
</table>
# <a name='SkPicture_AbortCallback'>Class SkPicture::AbortCallback</a>
## <a name='Constructor'>Constructor</a>
SkPicture can be constructed or initialized by these functions, including C++ class constructors.
<table style='border-collapse: collapse; width: 62.5em'>
<tr><th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Topic</th>
<th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Description</th></tr>
</table>
## <a name='Member_Function'>Member_Function</a>
SkPicture member functions read and modify the structure properties.
<table style='border-collapse: collapse; width: 62.5em'>
<tr><th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Topic</th>
<th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Description</th></tr>
</table>
<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
</pre>
<a href='undocumented#Subclasses'>Subclasses</a> of this can be passed to <a href='#SkPicture_playback'>playback</a>. During the playback
of the picture, this callback will periodically be invoked. If its
<a href='#SkPicture_AbortCallback_abort'>abort</a> returns true, then picture playback will be interrupted.
The resulting drawing is undefined, as there is no guarantee how often the
callback will be invoked. If the abort happens inside some level of nested
calls to save(), restore will automatically be called to return the state
to the same level it was before the playback call was made.
<a name='SkPicture_AbortCallback_empty_constructor'></a>
## AbortCallback
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
<a href='#SkPicture_AbortCallback_empty_constructor'>AbortCallback</a>()
</pre>
### Return Value
incomplete
### Example
<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
### See Also
incomplete
---
<a name='SkPicture_destructor'></a>
## ~AbortCallback
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
virtual
</pre>
### Example
<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
### See Also
incomplete
---
<a name='SkPicture_AbortCallback_abort'></a>
## abort
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
virtual bool <a href='#SkPicture_AbortCallback_abort'>abort</a>() = 0
</pre>
### Return Value
incomplete
### Example
<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
### See Also
incomplete
---
<a name='SkPicture_MakeFromStream'></a>
## MakeFromStream
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
static <a href='undocumented#sk_sp'>sk sp</a>&lt;<a href='#SkPicture'>SkPicture</a>&gt; <a href='#SkPicture_MakeFromStream'>MakeFromStream</a>(<a href='undocumented#SkStream'>SkStream</a>* stream, const <a href='undocumented#SkDeserialProcs'>SkDeserialProcs</a>* procs = nullptr)
</pre>
Recreate a picture that was serialized into a <a href='#SkPicture_MakeFromStream_stream'>stream</a> or data.
### Parameters
<table> <tr> <td><a name='SkPicture_MakeFromStream_stream'><code><strong>stream</strong></code></a></td>
<td>incomplete</td>
</tr>
<tr> <td><a name='SkPicture_MakeFromStream_procs'><code><strong>procs</strong></code></a></td>
<td>incomplete</td>
</tr>
</table>
### Return Value
incomplete
### Example
<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
### See Also
incomplete
---
<a name='SkPicture_MakeFromData'></a>
## MakeFromData
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
static <a href='undocumented#sk_sp'>sk sp</a>&lt;<a href='#SkPicture'>SkPicture</a>&gt; <a href='#SkPicture_MakeFromData'>MakeFromData</a>(const <a href='undocumented#SkData'>SkData</a>* data, const <a href='undocumented#SkDeserialProcs'>SkDeserialProcs</a>* procs = nullptr)
</pre>
### Parameters
<table> <tr> <td><a name='SkPicture_MakeFromData_data'><code><strong>data</strong></code></a></td>
<td>incomplete</td>
</tr>
<tr> <td><a name='SkPicture_MakeFromData_procs'><code><strong>procs</strong></code></a></td>
<td>incomplete</td>
</tr>
</table>
### Return Value
incomplete
### Example
<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
### See Also
incomplete
---
<a name='SkPicture_MakeFromData_2'></a>
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
static <a href='undocumented#sk_sp'>sk sp</a>&lt;<a href='#SkPicture'>SkPicture</a>&gt; <a href='#SkPicture_MakeFromData'>MakeFromData</a>(const void* data, size_t size,
const <a href='undocumented#SkDeserialProcs'>SkDeserialProcs</a>* procs = nullptr)
</pre>
### Parameters
<table> <tr> <td><a name='SkPicture_MakeFromData_2_data'><code><strong>data</strong></code></a></td>
<td>incomplete</td>
</tr>
<tr> <td><a name='SkPicture_MakeFromData_2_size'><code><strong>size</strong></code></a></td>
<td>incomplete</td>
</tr>
<tr> <td><a name='SkPicture_MakeFromData_2_procs'><code><strong>procs</strong></code></a></td>
<td>incomplete</td>
</tr>
</table>
### Return Value
incomplete
### Example
<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
### See Also
incomplete
---
<a name='SkPicture_playback'></a>
## playback
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
virtual void <a href='#SkPicture_playback'>playback</a>(<a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>* canvas, <a href='#SkPicture_AbortCallback'>AbortCallback</a>* callback = nullptr) const = 0
</pre>
Replays the drawing commands on the specified <a href='#SkPicture_playback_canvas'>canvas</a>. Note that
this has the effect of unfurling this picture into the destination
<a href='#SkPicture_playback_canvas'>canvas</a>. Using the <a href='SkCanvas_Reference#SkCanvas_drawPicture'>SkCanvas::drawPicture</a> entry point gives the destination
<a href='#SkPicture_playback_canvas'>canvas</a> the option of just taking a ref.
### Parameters
<table> <tr> <td><a name='SkPicture_playback_canvas'><code><strong>canvas</strong></code></a></td>
<td>the <a href='#SkPicture_playback_canvas'>canvas</a> receiving the drawing commands.
</td>
</tr>
<tr> <td><a name='SkPicture_playback_callback'><code><strong>callback</strong></code></a></td>
<td>a <a href='#SkPicture_playback_callback'>callback</a> that allows interruption of playback</td>
</tr>
</table>
### Return Value
incomplete
### Example
<div><fiddle-embed name="a45cdd46ef2fe0df62d84d41713e82e2"></fiddle-embed></div>
### See Also
incomplete
---
<a name='SkPicture_cullRect'></a>
## cullRect
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
virtual <a href='SkRect_Reference#SkRect'>SkRect</a> <a href='#SkPicture_cullRect'>cullRect</a>() const = 0
</pre>
Return a cull rect for this picture.
Ops recorded into this picture that attempt to draw outside the cull might not be drawn.
### Return Value
incomplete
### Example
<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
### See Also
incomplete
---
<a name='SkPicture_uniqueID'></a>
## uniqueID
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
uint32_t <a href='#SkPicture_uniqueID'>uniqueID</a>() const
</pre>
Returns a non-zero value unique among all pictures.
### Return Value
incomplete
### Example
<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
### See Also
incomplete
---
<a name='SkPicture_serialize'></a>
## serialize
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
<a href='undocumented#sk_sp'>sk sp</a>&lt;<a href='undocumented#SkData'>SkData</a>&gt; <a href='#SkPicture_serialize'>serialize</a>(const <a href='undocumented#SkSerialProcs'>SkSerialProcs</a>* procs = nullptr) const
</pre>
### Parameters
<table> <tr> <td><a name='SkPicture_serialize_procs'><code><strong>procs</strong></code></a></td>
<td>incomplete</td>
</tr>
</table>
### Return Value
incomplete
### Example
<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
### See Also
incomplete
---
<a name='SkPicture_serialize_2'></a>
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
void <a href='#SkPicture_serialize'>serialize</a>(<a href='undocumented#SkWStream'>SkWStream</a>* stream, const <a href='undocumented#SkSerialProcs'>SkSerialProcs</a>* procs = nullptr) const
</pre>
### Parameters
<table> <tr> <td><a name='SkPicture_serialize_2_stream'><code><strong>stream</strong></code></a></td>
<td>incomplete</td>
</tr>
<tr> <td><a name='SkPicture_serialize_2_procs'><code><strong>procs</strong></code></a></td>
<td>incomplete</td>
</tr>
</table>
### Example
<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
### See Also
incomplete
---
<a name='SkPicture_MakePlaceholder'></a>
## MakePlaceholder
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
static <a href='undocumented#sk_sp'>sk sp</a>&lt;<a href='#SkPicture'>SkPicture</a>&gt; <a href='#SkPicture_MakePlaceholder'>MakePlaceholder</a>(<a href='SkRect_Reference#SkRect'>SkRect</a> cull)
</pre>
Return a placeholder <a href='#SkPicture'>SkPicture</a>.
This placeholder does not draw anything itself. It has a distinct <a href='#SkPicture_uniqueID'>uniqueID</a>
(just like all <a href='#Picture'>Pictures</a>) and will always be visible to <a href='undocumented#SkSerialProcs'>SkSerialProcs</a>.
### Parameters
<table> <tr> <td><a name='SkPicture_MakePlaceholder_cull'><code><strong>cull</strong></code></a></td>
<td>the placeholder's dimensions</td>
</tr>
</table>
### Return Value
incomplete
### Example
<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
### See Also
incomplete
---
<a name='SkPicture_approximateOpCount'></a>
## approximateOpCount
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
virtual int <a href='#SkPicture_approximateOpCount'>approximateOpCount</a>() const = 0
</pre>
Return the approximate number of operations in this picture. This
number may be greater or less than the number of <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> calls
recorded: some calls may be recorded as more than one operation, or some
calls may be optimized away.
### Return Value
incomplete
### Example
<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
### See Also
incomplete
---
<a name='SkPicture_approximateBytesUsed'></a>
## approximateBytesUsed
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
virtual size_t <a href='#SkPicture_approximateBytesUsed'>approximateBytesUsed</a>() const = 0
</pre>
Returns the approximate byte size of this picture, not including large ref'd objects.
### Return Value
incomplete
### Example
<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
### See Also
incomplete
---