33 return fPlayer ? fPlayer->maxDimensions() :
SkISize{0, 0};
38 ImGui::Text(
"Could not read mskp file %s.\n",
fName.
c_str());
45 if (ImGui::Button(fPaused ?
"Play " :
"Pause")) {
53 ImGui::Text(
"FPS: "); ImGui::SameLine();
54 ImGui::RadioButton(
"1", &fFPS, 1); ImGui::SameLine();
55 ImGui::RadioButton(
"15", &fFPS, 15); ImGui::SameLine();
56 ImGui::RadioButton(
"30", &fFPS, 30); ImGui::SameLine();
57 ImGui::RadioButton(
"60", &fFPS, 60); ImGui::SameLine();
58 ImGui::RadioButton(
"120", &fFPS, 120); ImGui::SameLine();
59 ImGui::RadioButton(
"1:1", &fFPS, -1);
66 ImGui::Text(
"Frame:");
68 ImGui::PushButtonRepeat(
true);
69 int oldFrame = fFrame;
70 if (ImGui::ArrowButton(
"-mksp_frame", ImGuiDir_Left)) {
71 fFrame = (fFrame + fPlayer->numFrames() - 1)%fPlayer->numFrames();
74 if (ImGui::SliderInt(
"##msk_frameslider", &fFrame, 0, fPlayer->numFrames()-1,
"% 3d")) {
75 fFrame =
SkTPin(fFrame, 0, fPlayer->numFrames() - 1);
78 if (ImGui::ArrowButton(
"+mskp_frame", ImGuiDir_Right)) {
79 fFrame = (fFrame + 1)%fPlayer->numFrames();
81 if (fFrame != oldFrame) {
86 ImGui::PopButtonRepeat();
90 ImGui::Checkbox(
"Show Frame Bounds", &fShowFrameBounds);
91 ImGui::SetNextItemWidth(200);
92 ImGui::ColorPicker4(
"background", fBackgroundColor, ImGuiColorEditFlags_AlphaBar);
94 for (
float& component : fBackgroundColor) {
95 component =
SkTPin(component, 0.f, 1.f);
100 ImGui::Text(
"Offscreen Layers "); ImGui::SameLine();
101 ImGui::Checkbox(
"List All Layers", &fListAllLayers);
102 ImGui::RadioButton(
"root", &fDrawLayerID, -1);
103 const std::vector<int>& layerIDs = fListAllLayers ? fAllLayerIDs : fFrameLayerIDs[fFrame];
104 fLayerIDStrings.resize(layerIDs.size());
105 for (
size_t i = 0;
i < layerIDs.size(); ++
i) {
107 ImGui::RadioButton(fLayerIDStrings[
i].c_str(), &fDrawLayerID, layerIDs[
i]);
113 if (fShowFrameBounds) {
125 if (fDrawLayerID >= 0) {
134 fBackgroundColor[3]});
135 fPlayer->playFrame(canvas, fFrame);
138 if (fDrawLayerID >= 0) {
139 if (
sk_sp<SkImage> layerImage = fPlayer->layerSnapshot(fDrawLayerID)) {
145 fBackgroundColor[3]});
146 canvas->
drawImage(std::move(layerImage), 0, 0);
154 if (!fPlayer || fPaused) {
157 if (fLastFrameTime < 0) {
160 fFrame = (fFrame + 1)%fPlayer->numFrames();
161 fLastFrameTime = nanos;
162 return this->fPlayer->numFrames() > 1;
166 fFrame = (fFrame + 1)%fPlayer->numFrames();
167 return this->fPlayer->numFrames() > 1;
169 double elapsed = nanos - fLastFrameTime;
170 double frameTime = 1E9/fFPS;
171 int framesToAdvance = elapsed/frameTime;
172 fFrame = fFrame + framesToAdvance;
173 if (fFrame >= fPlayer->numFrames()) {
174 this->redrawLayers();
176 fFrame %= fPlayer->numFrames();
178 fLastFrameTime += framesToAdvance*frameTime;
179 return framesToAdvance > 0;
191 fAllLayerIDs = fPlayer->layerIDs();
192 fFrameLayerIDs.clear();
193 fFrameLayerIDs.resize(fPlayer->numFrames());
194 for (
int i = 0;
i < fPlayer->numFrames(); ++
i) {
195 fFrameLayerIDs[
i] = fPlayer->layerIDs(
i);
203 fPlayer->resetLayers();
207void MSKPSlide::redrawLayers() {
208 if (fDrawLayerID >= 0) {
211 fPlayer->resetLayers();
217 fPlayer->rewindLayers();
constexpr SkColor SK_ColorRED
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
static std::unique_ptr< MSKPPlayer > Make(SkStreamSeekable *stream)
bool animate(double nanos) override
void draw(SkCanvas *canvas) override
SkISize getDimensions() const override
void load(SkScalar winWidth, SkScalar winHeight) override
void gpuTeardown() override
MSKPSlide(const SkString &name, const SkString &path)
void drawRect(const SkRect &rect, const SkPaint &paint)
void clipIRect(const SkIRect &irect, SkClipOp op=SkClipOp::kIntersect)
void clear(SkColor color)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
void setStyle(Style style)
void setColor(SkColor color)
void setAntiAlias(bool aa)
@ kStroke_Style
set to stroke geometry
void setStrokeWidth(SkScalar width)
const char * c_str() const
Optional< SkRect > bounds
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DEF_SWITCHES_START aot vmservice shared library name
static constexpr SkIRect MakeSize(const SkISize &size)
static constexpr SkIRect MakeEmpty()
static SkRect Make(const SkISize &size)