Records a single frame's draw ops into an SkPicture and serializes it to a .skp artifact. More...
#include <skp_capture.hpp>
Public Member Functions | |
| SkpFrameCapture (int width, int height, skgpu::graphite::Context *graphite_context=nullptr) | |
| Begin a capture sized to width x height logical pixels. | |
| ~SkpFrameCapture () | |
| SkpFrameCapture (const SkpFrameCapture &)=delete | |
| SkpFrameCapture & | operator= (const SkpFrameCapture &)=delete |
| bool | available () const |
| True when Skia is compiled in and the recording canvas exists. | |
| canvas::Canvas * | canvas () |
| The canvas to paint the frame into. | |
| SkpCaptureResult | finish_to_file (const std::string &path) |
| Finish recording and write the .skp to path. | |
| SkpCaptureResult | finish_to_memory (std::string &out_blob) |
| Finish recording and serialize the .skp into out_blob (raw .skp bytes). | |
Records a single frame's draw ops into an SkPicture and serializes it to a .skp artifact.
Usage: SkpFrameCapture capture(width, height); if (capture.available()) { root_view.paint_all(*capture.canvas()); // re-run the paint auto result = capture.finish_to_file(path); }
The capture canvas is a normal pulp::canvas::Canvas, so any code that paints a live frame paints a capture frame unchanged. After finish_to_file / finish_to_memory the capture is consumed and canvas() returns nullptr.
|
explicit |
Begin a capture sized to width x height logical pixels.
The cull rect of the recorded SkPicture is [0,0,width,height].
graphite_context is optional. Pass the live Graphite Context (e.g. from the SkiaSurface the frame is rendered on) when the frame may embed GPU-texture-backed images — atlas glyphs, surface snapshots. The capture uses it to read those images off the GPU so they PNG-encode into the .skp. A purely vector / raster-image frame needs no context and nullptr is fine.
| pulp::render::SkpFrameCapture::~SkpFrameCapture | ( | ) |
|
delete |
| bool pulp::render::SkpFrameCapture::available | ( | ) | const |
True when Skia is compiled in and the recording canvas exists.
False builds degrade gracefully — canvas() is nullptr and finish_* return a failed result.
| canvas::Canvas * pulp::render::SkpFrameCapture::canvas | ( | ) |
The canvas to paint the frame into.
Valid until finish_* is called or the capture is destroyed; nullptr when unavailable.
| SkpCaptureResult pulp::render::SkpFrameCapture::finish_to_file | ( | const std::string & | path | ) |
Finish recording and write the .skp to path.
Embedded images are PNG-encoded via SkSerialProcs::fImageProc. Consumes the capture: a second call returns a failed result.
| SkpCaptureResult pulp::render::SkpFrameCapture::finish_to_memory | ( | std::string & | out_blob | ) |
Finish recording and serialize the .skp into out_blob (raw .skp bytes).
Useful for tests and in-memory transport. Consumes the capture.
|
delete |