Add 'Save to SKP' option to Viewer
Bug: skia: Change-Id: Iea3794ce8710c84f2529b78b21655f2bf6aaa90e Reviewed-on: https://skia-review.googlesource.com/79160 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
762d5e7e1c
commit
3ac99cfaa2
@ -30,6 +30,7 @@
|
||||
#include "SkOnce.h"
|
||||
#include "SkOSFile.h"
|
||||
#include "SkOSPath.h"
|
||||
#include "SkPictureRecorder.h"
|
||||
#include "SkRandom.h"
|
||||
#include "SkScan.h"
|
||||
#include "SkStream.h"
|
||||
@ -265,6 +266,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
|
||||
, fCumulativeMeasurementCount(0)
|
||||
, fDisplayStats(false)
|
||||
, fRefresh(false)
|
||||
, fSaveToSKP(false)
|
||||
, fShowImGuiDebugWindow(false)
|
||||
, fShowSlidePicker(false)
|
||||
, fShowImGuiTestWindow(false)
|
||||
@ -481,6 +483,10 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
|
||||
this->updateTitle();
|
||||
fWindow->inval();
|
||||
});
|
||||
fCommands.addCommand('K', "IO", "Save slide to SKP", [this]() {
|
||||
fSaveToSKP = true;
|
||||
fWindow->inval();
|
||||
});
|
||||
|
||||
// set up slides
|
||||
this->initSlides();
|
||||
@ -866,6 +872,23 @@ void Viewer::drawSlide(SkCanvas* canvas) {
|
||||
}
|
||||
}
|
||||
|
||||
if (fSaveToSKP) {
|
||||
SkPictureRecorder recorder;
|
||||
SkCanvas* recorderCanvas = recorder.beginRecording(
|
||||
SkRect::Make(fSlides[fCurrentSlide]->getDimensions()));
|
||||
// In xform-canvas mode, record the transformed output
|
||||
std::unique_ptr<SkCanvas> xformCanvas = nullptr;
|
||||
if (ColorMode::kColorManagedSRGB8888_NonLinearBlending == fColorMode) {
|
||||
xformCanvas = SkCreateColorSpaceXformCanvas(recorderCanvas, cs);
|
||||
recorderCanvas = xformCanvas.get();
|
||||
}
|
||||
fSlides[fCurrentSlide]->draw(recorderCanvas);
|
||||
sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
|
||||
SkFILEWStream stream("sample_app.skp");
|
||||
picture->serialize(&stream);
|
||||
fSaveToSKP = false;
|
||||
}
|
||||
|
||||
// If we're in F16, or we're zooming, or we're in color correct 8888 and the gamut isn't sRGB,
|
||||
// we need to render offscreen. We also need to render offscreen if we're in any raster mode,
|
||||
// because the window surface is actually GL.
|
||||
|
@ -81,6 +81,8 @@ private:
|
||||
bool fDisplayStats;
|
||||
bool fRefresh; // whether to continuously refresh for measuring render time
|
||||
|
||||
bool fSaveToSKP;
|
||||
|
||||
SkPaint fImGuiFontPaint;
|
||||
SkPaint fImGuiGamutPaint;
|
||||
bool fShowImGuiDebugWindow;
|
||||
|
Loading…
Reference in New Issue
Block a user