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;