28#if defined(SK_BUILD_FOR_MAC) && defined(SK_FONTMGR_CORETEXT_AVAILABLE)
30#elif defined(SK_BUILD_FOR_UNIX) && defined(SK_FONTMGR_FONTCONFIG_AVAILABLE)
42static DEFINE_int(set_dst_width, 0,
"set destination width (height will be computed)");
56int main(
int argc,
char** argv) {
62 if (FLAGS_input.size() == 0) {
63 SkDebugf(
"-i input_file.json argument required\n");
67 auto contextType = skgpu::ContextType::kGL;
72 if (FLAGS_assetPath.size() > 0) {
73 assetPath.
set(FLAGS_assetPath[0]);
82#if defined(SK_BUILD_FOR_MAC) && defined(SK_FONTMGR_CORETEXT_AVAILABLE)
84#elif defined(SK_BUILD_FOR_ANDROID) && defined(SK_FONTMGR_ANDROID_AVAILABLE)
86#elif defined(SK_BUILD_FOR_UNIX) && defined(SK_FONTMGR_FONTCONFIG_AVAILABLE)
98 SkDebugf(
"failed to load %s\n", FLAGS_input[0]);
102 SkISize dim = animation->size().toRound();
103 double duration = animation->duration();
104 int fps =
SkTPin(FLAGS_fps, 1, 240);
105 double fps_scale = animation->fps() / fps;
108 if (FLAGS_set_dst_width > 0) {
109 scale = FLAGS_set_dst_width / (float)dim.
width();
114 const double frame_duration = 1.0 / fps;
117 SkDebugf(
"Size %dx%d duration %g, fps %d, frame_duration %g\n",
131 if (!
encoder.beginRecording(dim, fps)) {
132 SkDEBUGF(
"Invalid video stream configuration.\n");
156 for (
int i = 0; i <= frames; ++i) {
157 const double frame = i * fps_scale;
167 std::unique_ptr<const SkSurface::AsyncReadResult>
result) {
173 surf->asyncRescaleAndReadPixels(
info, {0, 0,
info.width(),
info.height()},
174 SkSurface::RescaleGamma::kSrc,
175 SkImage::RescaleMode::kNearest,
176 read_pixels_cb, &asyncRec);
193 SkDebugf(
"recording secs %g, frames %d, recording fps %d\n",
194 loop_dur, frames, (
int)(frames / loop_dur));
196 }
while (FLAGS_loop);
198 if (FLAGS_output.size() == 0) {
199 SkDebugf(
"missing -o output_file.mp4 argument\n");
205 SkDebugf(
"Can't create output file %s\n", FLAGS_output[0]);
208 ostream.
write(data->data(), data->size());
#define DEFINE_int(name, defaultValue, helpString)
#define DEFINE_bool2(name, shortName, defaultValue, helpString)
#define DEFINE_string2(name, shortName, defaultValue, helpString)
#define DEFINE_int_2(name, shortName, defaultValue, helpString)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kTopLeft_GrSurfaceOrigin
#define SkAssertResult(cond)
constexpr SkColor SK_ColorWHITE
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
SK_API sk_sp< SkFontMgr > SkFontMgr_New_Android(const SkFontMgr_Android_CustomFonts *custom)
SK_API sk_sp< SkFontMgr > SkFontMgr_New_Custom_Empty()
SK_API sk_sp< SkFontMgr > SkFontMgr_New_FontConfig(FcConfig *fc)
SK_API sk_sp< SkFontMgr > SkFontMgr_New_CoreText(CTFontCollectionRef)
#define SkScalarRoundToInt(x)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
static void Parse(int argc, const char *const *argv)
static void SetUsage(const char *usage)
bool submit(GrSyncCpu sync=GrSyncCpu::kNo)
void flushAndSubmit(GrSyncCpu sync=GrSyncCpu::kNo)
void clear(SkColor color)
bool write(const void *buffer, size_t size) override
static SkString Dirname(const char *fullPath)
void set(const SkString &src)
const char * c_str() const
bool addFrame(const SkPixmap &)
GrDirectContext * directContext() const
ContextInfo getContextInfo(ContextType type, ContextOverrides=ContextOverrides::kNone)
Builder & setResourceProvider(sk_sp< ResourceProvider >)
Builder & setFontManager(sk_sp< SkFontMgr >)
Builder & setTextShapingFactory(sk_sp< SkShapers::Factory >)
sk_sp< Animation > makeFromFile(const char path[])
void seekFrame(double t, sksg::InvalidationController *ic=nullptr)
void render(SkCanvas *canvas, const SkRect *dst=nullptr) const
static sk_sp< FileResourceProvider > Make(SkString base_dir, ImageDecodeStrategy=ImageDecodeStrategy::kLazyDecode)
sk_sp< SkFontMgr > fontMgr
void RegisterAllAvailable()
sk_sp< Factory > BestAvailable()
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
static void produce_frame(SkSurface *surf, skottie::Animation *anim, double frame)
constexpr int32_t width() const
constexpr int32_t height() const
static SkImageInfo MakeN32Premul(int width, int height)