23#if defined(HAVE_VIDEO_DECODER)
31#if defined(HAVE_VIDEO_DECODER)
36 auto decoder = std::make_unique<SkVideoDecoder>();
39 decoder->duration() <= 0) {
47 explicit VideoAsset(std::unique_ptr<SkVideoDecoder> decoder)
48 : fDecoder(
std::move(decoder)) {
51 bool isMultiFrame()
override {
return true; }
57 fWindow[0] = std::move(fWindow[1]);
58 fWindow[1].frame = fDecoder->nextImage(&fWindow[1].
stamp);
59 fEof = !fWindow[1].frame;
63 const auto t =
SkTPin(
static_cast<double>(t_float), 0.0, fDecoder->duration());
65 if (t < fWindow[0].
stamp) {
68 fWindow[0].stamp = fWindow[1].stamp = 0;
72 while (!fEof && t >= fWindow[1].
stamp) {
78 return fWindow[0].frame;
81 const std::unique_ptr<SkVideoDecoder> fDecoder;
113 std::make_unique<SkAnimCodecPlayer>(std::move(codec)), strat));
122 std::make_unique<SkAnimCodecPlayer>(std::move(codec)), strat));
125MultiFrameImageAsset::MultiFrameImageAsset(std::unique_ptr<SkAnimCodecPlayer> player,
127 : fPlayer(
std::move(player)), fStrategy(strat) {
132 return fPlayer->duration() > 0;
139 static constexpr size_t kMaxArea = 2048 * 2048;
142 if (image_area > kMaxArea) {
144 const auto scale =
std::sqrt(
static_cast<float>(kMaxArea) / image_area);
163 fPlayer->seek(
static_cast<uint32_t
>(t * 1000));
164 auto frame = fPlayer->getFrame();
179 fCachedFrame = this->generateFrame(t);
187 std::move(base_dir), strat))
192 : fDir(
std::move(base_dir)), fStrategy(strat) {}
203 const char[])
const {
207 return std::move(
image);
210#if defined(HAVE_VIDEO_DECODER)
212 return std::move(video);
230 const char rid[])
const {
231 return fProxy ?
fProxy->loadImageAsset(rpath, rname, rid)
236 const char url[])
const {
256sk_sp<ImageAsset> CachingResourceProvider::loadImageAsset(
const char resource_path[],
258 const char resource_id[])
const {
262 if (
const auto* asset = fImageCache.find(
key)) {
267 fImageCache.set(
key, asset);
282 :
INHERITED(
std::move(rp)), fStrategy(strat), fFontMgr(
std::move(mgr)) {}
287 static constexpr char kDataURIEncodingStr[] =
";base64,";
289 const size_t prefixLen = strlen(
prefix);
290 if (strncmp(uri,
prefix, prefixLen) != 0) {
294 const char* encoding = strstr(uri + prefixLen, kDataURIEncodingStr);
299 const char* b64Data = encoding +
std::size(kDataURIEncodingStr) - 1;
300 size_t b64DataLen = strlen(b64Data);
307 void* rawData =
data->writable_data();
315sk_sp<ImageAsset> DataURIResourceProviderProxy::loadImageAsset(
const char rpath[],
317 const char rid[])
const {
327 const char url[])
const {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
const TextureProxy * fProxy
bool sk_isdir(const char *path)
static const char * resource_name(SkPDFResourceType type)
#define INHERITED(method,...)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
constexpr size_t SkToSizeT(S x)
sk_sp< SkImage > asImage() const
const SkPixmap & pixmap() const
bool tryAllocPixels(const SkImageInfo &info, size_t rowBytes)
static std::unique_ptr< SkCodec > MakeFromData(sk_sp< SkData >, SkSpan< const SkCodecs::Decoder > decoders, SkPngChunkReader *=nullptr)
static sk_sp< SkData > MakeUninitialized(size_t length)
static sk_sp< SkData > MakeFromFileName(const char path[])
sk_sp< SkTypeface > makeFromData(sk_sp< SkData >, int ttcIndex=0) const
sk_sp< SkImage > makeRasterImage(GrDirectContext *, CachingHint cachingHint=kDisallow_CachingHint) const
virtual bool isLazyGenerated() const =0
@ kDisallow_CachingHint
disallows internally caching decoded and copied pixels
bool scalePixels(const SkPixmap &dst, const SkSamplingOptions &, CachingHint cachingHint=kAllow_CachingHint) const
static const SkMatrix & I()
static std::unique_ptr< SkMemoryStream > Make(sk_sp< SkData > data)
static SkString Join(const char *rootPath, const char *relativePath)
const char * c_str() const
static sk_sp< DataURIResourceProviderProxy > Make(sk_sp< ResourceProvider > rp, ImageDecodeStrategy=ImageDecodeStrategy::kLazyDecode, sk_sp< const SkFontMgr > fontMgr=nullptr)
sk_sp< ImageAsset > loadImageAsset(const char[], const char[], const char[]) const override
sk_sp< SkData > load(const char resource_path[], const char resource_name[]) const override
static sk_sp< FileResourceProvider > Make(SkString base_dir, ImageDecodeStrategy=ImageDecodeStrategy::kLazyDecode)
virtual sk_sp< SkImage > getFrame(float t)
virtual FrameData getFrameData(float t)
static sk_sp< MultiFrameImageAsset > Make(sk_sp< SkData >, ImageDecodeStrategy=ImageDecodeStrategy::kLazyDecode)
bool isMultiFrame() override
sk_sp< SkImage > getFrame(float t) override
sk_sp< SkTypeface > loadTypeface(const char[], const char[]) const override
ResourceProviderProxyBase(sk_sp< ResourceProvider >)
sk_sp< ImageAsset > loadImageAsset(const char[], const char[], const char[]) const override
sk_sp< ExternalTrackAsset > loadAudioAsset(const char[], const char[], const char[]) override
const sk_sp< ResourceProvider > fProxy
sk_sp< SkData > load(const char[], const char[]) const override
sk_sp< SkData > loadFont(const char[], const char[]) const override
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
sk_sp< const SkImage > image
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
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
SkSamplingOptions(SkFilterMode::kLinear))
skresources::ImageAsset ImageAsset
static sk_sp< SkData > decode_datauri(const char prefix[], const char uri[])
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
static DecodeResult decode(std::string path)
static Error Decode(const void *src, size_t srcLength, void *dst, size_t *dstLength)
static SkImageInfo MakeN32Premul(int width, int height)
std::shared_ptr< const fml::Mapping > data