MCPcopy Create free account
hub / github.com/Tencent/tgfx / MakeFrom

Method MakeFrom

src/core/ImageSource.cpp:22–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20
21namespace tgfx {
22std::unique_ptr<DataSource<ImageBuffer>> ImageSource::MakeFrom(
23 std::shared_ptr<ImageGenerator> generator, bool tryHardware, bool asyncDecoding) {
24 if (generator == nullptr) {
25 return nullptr;
26 }
27 if (asyncDecoding && !generator->asyncSupport()) {
28 // The generator may have built-in async decoding support which will not block the main thread.
29 // Therefore, we should trigger the decoding ASAP.
30 auto buffer = generator->makeBuffer(tryHardware);
31 return Wrap(std::move(buffer));
32 }
33 auto imageSource = std::make_unique<ImageSource>(std::move(generator), tryHardware);
34 if (asyncDecoding) {
35 return Async(std::move(imageSource));
36 }
37 return imageSource;
38}
39
40ImageSource::ImageSource(std::shared_ptr<ImageGenerator> generator, bool tryHardware)
41 : generator(std::move(generator)), tryHardware(tryHardware) {

Callers

nothing calls this directly

Calls 2

asyncSupportMethod · 0.45
makeBufferMethod · 0.45

Tested by

no test coverage detected