29#include "third_party/skia/include/codec/SkCodecAnimation.h"
30#include "third_party/skia/include/core/SkData.h"
31#include "third_party/skia/include/core/SkImage.h"
32#include "third_party/skia/include/core/SkImageInfo.h"
33#include "third_party/skia/include/core/SkSize.h"
34#include "third_party/skia/include/encode/SkPngEncoder.h"
50 bool IsValid()
const override {
return true; }
57 return std::make_shared<TestImpellerAllocator>();
82 const std::function<
void()>& failure)
override {
83 tasks_.push_back(PendingTask{task, failure});
87 for (
auto& task : tasks_) {
111 std::function<void()> task;
112 std::function<void()> failure;
114 std::vector<PendingTask> tasks_;
115 std::shared_ptr<const Capabilities> capabilities_;
116 bool did_dispose_ =
false;
127 bool has_gpu_context =
true)
130 gl_context_(has_gpu_context ? gl_surface_.CreateGrContext() : nullptr),
131 weak_gl_context_factory_(
133 ?
std::make_unique<
fml::WeakPtrFactory<GrDirectContext>>(
138 fml::TimeDelta::FromNanoseconds(0),
140 runner_(task_runner),
141 is_gpu_disabled_sync_switch_(
std::make_shared<
fml::SyncSwitch>()),
142 weak_factory_(this) {
143 FML_CHECK(task_runner->RunsTasksOnCurrentThread())
144 <<
"The IO manager must be initialized its primary task runner. The "
145 "test harness may not be set up correctly/safely.";
146 weak_prototype_ = weak_factory_.GetWeakPtr();
152 [&latch,
queue = unref_queue_]() {
161 return weak_prototype_;
166 return weak_gl_context_factory_ ? weak_gl_context_factory_->GetWeakPtr()
178 return is_gpu_disabled_sync_switch_;
183 return impeller_context_;
187 is_gpu_disabled_sync_switch_->SetSwitch(disabled);
194 std::shared_ptr<impeller::Context> impeller_context_;
195 sk_sp<GrDirectContext> gl_context_;
196 std::unique_ptr<fml::WeakPtrFactory<GrDirectContext>>
197 weak_gl_context_factory_;
201 std::shared_ptr<fml::SyncSwitch> is_gpu_disabled_sync_switch_;
211 auto thread_task_runner = CreateNewThread();
221 TestIOManager manager(runners.GetIOTaskRunner());
223 auto decoder = ImageDecoder::Make(settings, runners, loop->GetTaskRunner(),
224 manager.GetWeakIOManager(),
225 std::make_shared<fml::SyncSwitch>());
226 ASSERT_NE(decoder, nullptr);
235 const SkImageInfo&
GetInfo() {
return info_; }
242 return {std::nullopt, 0, SkCodecAnimation::DisposalMethod::kKeep};
246 return SkISize::Make(info_.width(), info_.height());
252 unsigned int frame_index,
253 std::optional<unsigned int> prior_frame) {
263 auto thread_task_runner = CreateNewThread();
272 thread_task_runner->PostTask([&]() {
277 std::make_shared<fml::SyncSwitch>());
283 fml::MakeRefCounted<ImageDescriptor>(
284 std::move(
data), std::make_unique<UnknownImageGenerator>());
287 const std::string& decode_error) {
292 decoder->Decode(image_descriptor, {.target_width = 0, .target_height = 0},
301 CreateNewThread(
"platform"),
302 CreateNewThread(
"raster"),
303 CreateNewThread(
"ui"),
304 CreateNewThread(
"io")
309 std::unique_ptr<TestIOManager> io_manager;
311 auto release_io_manager = [&]() {
315 auto decode_image = [&]() {
318 settings, runners, loop->GetTaskRunner(),
319 io_manager->GetWeakIOManager(), std::make_shared<fml::SyncSwitch>());
324 ASSERT_GE(
data->size(), 0u);
327 std::shared_ptr<ImageGenerator> generator =
329 ASSERT_TRUE(generator);
331 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
332 std::move(
data), std::move(generator));
335 const std::string& decode_error) {
338 EXPECT_TRUE(io_manager->did_access_is_gpu_disabled_sync_switch_);
341 EXPECT_FALSE(io_manager->did_access_is_gpu_disabled_sync_switch_);
342 image_decoder->Decode(
344 {.target_width =
static_cast<uint32_t
>(descriptor->width()),
345 .target_height =
static_cast<uint32_t
>(descriptor->height())},
349 auto set_up_io_manager_and_decode = [&]() {
350 io_manager = std::make_unique<TestIOManager>(runners.
GetIOTaskRunner());
359#if !IMPELLER_SUPPORTS_RENDERING
360 GTEST_SKIP() <<
"Impeller only test.";
363 auto no_gpu_access_context =
364 std::make_shared<impeller::TestImpellerContext>();
365 auto gpu_disabled_switch = std::make_shared<fml::SyncSwitch>(
true);
367 auto info = SkImageInfo::Make(10, 10, SkColorType::kRGBA_8888_SkColorType,
368 SkAlphaType::kPremul_SkAlphaType);
373 auto bitmap = std::make_shared<SkBitmap>();
374 bitmap->allocPixels(info, 10 * 4);
377 auto buffer = std::make_shared<impeller::TestImpellerDeviceBuffer>(desc);
379 bool invoked =
false;
380 auto cb = [&invoked](
const sk_sp<DlImage>&
image,
381 const std::string&
message) { invoked =
true; };
384 cb, no_gpu_access_context,
buffer, decoder_info, std::nullopt,
385 gpu_disabled_switch);
387 EXPECT_EQ(no_gpu_access_context->command_buffer_count_, 0ul);
388 EXPECT_FALSE(invoked);
389 EXPECT_EQ(no_gpu_access_context->DidDisposeResources(),
false);
392 no_gpu_access_context,
bitmap);
394 ASSERT_EQ(no_gpu_access_context->command_buffer_count_, 0ul);
395 ASSERT_EQ(result.second,
"");
396 EXPECT_EQ(no_gpu_access_context->DidDisposeResources(),
true);
398 result.first->impeller_texture()->GetTextureDescriptor().storage_mode,
401 no_gpu_access_context->FlushTasks(
true);
405 ImpellerUploadToSharedNoGpuTaskFlushingFailure) {
406#if !IMPELLER_SUPPORTS_RENDERING
407 GTEST_SKIP() <<
"Impeller only test.";
410 auto no_gpu_access_context =
411 std::make_shared<impeller::TestImpellerContext>();
412 auto gpu_disabled_switch = std::make_shared<fml::SyncSwitch>(
true);
414 auto info = SkImageInfo::Make(10, 10, SkColorType::kRGBA_8888_SkColorType,
415 SkAlphaType::kPremul_SkAlphaType);
420 auto bitmap = std::make_shared<SkBitmap>();
421 bitmap->allocPixels(info, 10 * 4);
424 auto buffer = std::make_shared<impeller::TestImpellerDeviceBuffer>(desc);
426 sk_sp<DlImage>
image;
428 bool invoked =
false;
429 auto cb = [&invoked, &
image, &
message](sk_sp<DlImage> p_image,
430 std::string p_message) {
432 image = std::move(p_image);
433 message = std::move(p_message);
437 cb, no_gpu_access_context,
buffer, decoder_info, std::nullopt,
438 gpu_disabled_switch);
440 EXPECT_EQ(no_gpu_access_context->command_buffer_count_, 0ul);
441 EXPECT_FALSE(invoked);
443 no_gpu_access_context->FlushTasks(
true);
445 EXPECT_TRUE(invoked);
451 auto info = SkImageInfo::Make(10, 10, SkColorType::kRGBA_8888_SkColorType,
452 SkAlphaType::kPremul_SkAlphaType);
454 bitmap.allocPixels(info, 10 * 4);
455 auto data = SkData::MakeWithoutCopy(
bitmap.getPixels(), 10 * 10 * 4);
457 ASSERT_TRUE(
image !=
nullptr);
458 EXPECT_EQ(SkISize::Make(10, 10),
image->dimensions());
459 EXPECT_EQ(
nullptr,
image->colorSpace());
461 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
465#if IMPELLER_SUPPORTS_RENDERING
466 std::shared_ptr<impeller::Capabilities> capabilities =
470 std::shared_ptr<impeller::Allocator>
allocator =
471 std::make_shared<impeller::TestImpellerAllocator>();
472 absl::StatusOr<ImageDecoderImpeller::DecompressResult> decompressed =
474 descriptor.get(), {.target_width = 100, .target_height = 100},
477 ASSERT_TRUE(decompressed.ok());
478 EXPECT_EQ(decompressed->image_info.format,
484 auto info = SkImageInfo::Make(10, 10, SkColorType::kRGBA_F32_SkColorType,
485 SkAlphaType::kUnpremul_SkAlphaType);
487 bitmap.allocPixels(info, 10 * 16);
488 auto data = SkData::MakeWithoutCopy(
bitmap.getPixels(), 10 * 10 * 16);
491 ASSERT_TRUE(
image !=
nullptr);
492 EXPECT_EQ(SkISize::Make(10, 10),
image->dimensions());
493 EXPECT_EQ(
nullptr,
image->colorSpace());
495 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
499#if IMPELLER_SUPPORTS_RENDERING
500 std::shared_ptr<impeller::Capabilities> capabilities =
504 std::shared_ptr<impeller::Allocator>
allocator =
505 std::make_shared<impeller::TestImpellerAllocator>();
506 absl::StatusOr<ImageDecoderImpeller::DecompressResult> decompressed =
508 descriptor.get(), {.target_width = 100, .target_height = 100},
512 ASSERT_TRUE(decompressed.ok());
513 EXPECT_EQ(decompressed->image_info.format,
520 auto image = SkImages::DeferredFromEncodedData(
data);
521 ASSERT_TRUE(
image !=
nullptr);
522 ASSERT_EQ(SkISize::Make(100, 100),
image->dimensions());
525 std::shared_ptr<ImageGenerator> generator =
527 ASSERT_TRUE(generator);
529 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(std::move(
data),
530 std::move(generator));
532#if IMPELLER_SUPPORTS_RENDERING
533 std::shared_ptr<impeller::Capabilities> capabilities =
537 std::shared_ptr<impeller::Allocator>
allocator =
538 std::make_shared<impeller::TestImpellerAllocator>();
539 absl::StatusOr<ImageDecoderImpeller::DecompressResult> wide_result =
541 descriptor.get(), {.target_width = 100, .target_height = 100},
545 ASSERT_TRUE(wide_result.ok());
546 ASSERT_EQ(wide_result->image_info.format,
549 const uint32_t* pixel_ptr =
reinterpret_cast<const uint32_t*
>(
550 wide_result->device_buffer->OnGetContents());
551 bool found_deep_red =
false;
552 for (
int i = 0;
i < wide_result->image_info.size.width *
553 wide_result->image_info.size.height;
555 uint32_t pixel = *pixel_ptr++;
559 if (fabsf(red - 1.0931f) < 0.01f && fabsf(green - -0.2268f) < 0.01f &&
560 fabsf(blue - -0.1501f) < 0.01f) {
561 found_deep_red =
true;
565 ASSERT_TRUE(found_deep_red);
567 absl::StatusOr<ImageDecoderImpeller::DecompressResult> narrow_result =
569 descriptor.get(), {.target_width = 100, .target_height = 100},
573 ASSERT_TRUE(narrow_result.ok());
574 ASSERT_EQ(narrow_result->image_info.format,
581 auto image = SkImages::DeferredFromEncodedData(
data);
582 ASSERT_TRUE(
image !=
nullptr);
583 ASSERT_EQ(SkISize::Make(600, 200),
image->dimensions());
586 std::shared_ptr<ImageGenerator> generator =
588 ASSERT_TRUE(generator);
590 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(std::move(
data),
591 std::move(generator));
593#if IMPELLER_SUPPORTS_RENDERING
594 std::shared_ptr<impeller::Capabilities> capabilities =
598 std::shared_ptr<impeller::Allocator>
allocator =
599 std::make_shared<impeller::TestImpellerAllocator>();
600 absl::StatusOr<ImageDecoderImpeller::DecompressResult> result =
602 descriptor.get(), {.target_width = 600, .target_height = 200},
606 ASSERT_TRUE(result.ok());
607 ASSERT_EQ(result->image_info.format,
615 CreateNewThread(
"platform"),
616 CreateNewThread(
"raster"),
617 CreateNewThread(
"ui"),
618 CreateNewThread(
"io")
623 std::unique_ptr<IOManager> io_manager;
625 auto release_io_manager = [&]() {
630 SkISize decoded_size = SkISize::MakeEmpty();
631 auto decode_image = [&]() {
634 settings, runners, loop->GetTaskRunner(),
635 io_manager->GetWeakIOManager(), std::make_shared<fml::SyncSwitch>());
640 ASSERT_GE(
data->size(), 0u);
643 std::shared_ptr<ImageGenerator> generator =
645 ASSERT_TRUE(generator);
647 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
648 std::move(
data), std::move(generator));
651 const std::string& decode_error) {
654 decoded_size =
image->skia_image()->dimensions();
657 image_decoder->Decode(
659 {.target_width =
static_cast<uint32_t
>(descriptor->width()),
660 .target_height =
static_cast<uint32_t
>(descriptor->height())},
664 auto set_up_io_manager_and_decode = [&]() {
665 io_manager = std::make_unique<TestIOManager>(runners.
GetIOTaskRunner());
673 ASSERT_EQ(decoded_size.width(), 600);
674 ASSERT_EQ(decoded_size.height(), 200);
680 CreateNewThread(
"platform"),
681 CreateNewThread(
"raster"),
682 CreateNewThread(
"ui"),
683 CreateNewThread(
"io")
688 std::unique_ptr<IOManager> io_manager;
690 auto release_io_manager = [&]() {
695 auto decode_image = [&]() {
698 settings, runners, loop->GetTaskRunner(),
699 io_manager->GetWeakIOManager(), std::make_shared<fml::SyncSwitch>());
704 ASSERT_GE(
data->size(), 0u);
707 std::shared_ptr<ImageGenerator> generator =
709 ASSERT_TRUE(generator);
711 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
712 std::move(
data), std::move(generator));
715 const std::string& decode_error) {
720 image_decoder->Decode(
722 {.target_width =
static_cast<uint32_t
>(descriptor->width()),
723 .target_height =
static_cast<uint32_t
>(descriptor->height())},
727 auto set_up_io_manager_and_decode = [&]() {
739 const auto image_dimensions =
740 SkImages::DeferredFromEncodedData(
744 ASSERT_FALSE(image_dimensions.isEmpty());
746 ASSERT_NE(image_dimensions.width(), image_dimensions.height());
750 CreateNewThread(
"platform"),
751 CreateNewThread(
"raster"),
752 CreateNewThread(
"ui"),
753 CreateNewThread(
"io")
757 std::unique_ptr<IOManager> io_manager;
758 std::unique_ptr<ImageDecoder> image_decoder;
762 io_manager = std::make_unique<TestIOManager>(runners.GetIOTaskRunner());
768 image_decoder = ImageDecoder::Make(settings, runners, loop->GetTaskRunner(),
769 io_manager->GetWeakIOManager(),
770 std::make_shared<fml::SyncSwitch>());
774 auto decoded_size = [&](uint32_t target_width,
775 uint32_t target_height) -> SkISize {
776 SkISize final_size = SkISize::MakeEmpty();
781 ASSERT_GE(
data->size(), 0u);
784 std::shared_ptr<ImageGenerator> generator =
786 ASSERT_TRUE(generator);
788 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
789 std::move(
data), std::move(generator));
792 [&](
const sk_sp<DlImage>&
image,
const std::string& decode_error) {
795 final_size =
image->skia_image()->dimensions();
798 image_decoder->Decode(
800 {.target_width = target_width, .target_height = target_height},
807 ASSERT_EQ(SkISize::Make(3024, 4032), image_dimensions);
808 ASSERT_EQ(decoded_size(3024, 4032), image_dimensions);
809 ASSERT_EQ(decoded_size(100, 100), SkISize::Make(100, 100));
821 VerifyCodecRepeatCountsForGifAndWebPAreConsistentWithLoopCounts) {
826 ASSERT_TRUE(gif_mapping);
827 ASSERT_TRUE(webp_mapping);
834 ASSERT_TRUE(gif_generator);
835 ASSERT_TRUE(webp_generator);
838 ASSERT_EQ(gif_generator->GetPlayCount(),
static_cast<unsigned int>(2));
839 ASSERT_EQ(webp_generator->GetPlayCount(),
static_cast<unsigned int>(2));
842TEST(ImageDecoderTest, VerifySimpleDecoding) {
844 auto image = SkImages::DeferredFromEncodedData(
data);
845 ASSERT_TRUE(
image !=
nullptr);
846 EXPECT_EQ(600,
image->width());
847 EXPECT_EQ(200,
image->height());
850 std::shared_ptr<ImageGenerator> generator =
852 ASSERT_TRUE(generator);
854 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(std::move(
data),
855 std::move(generator));
858 EXPECT_EQ(compressed_image->width(), 6);
859 EXPECT_EQ(compressed_image->height(), 2);
860 EXPECT_EQ(compressed_image->alphaType(), kOpaque_SkAlphaType);
862#if IMPELLER_SUPPORTS_RENDERING
863 std::shared_ptr<impeller::Capabilities> capabilities =
867 std::shared_ptr<impeller::Capabilities> capabilities_no_blit =
873 std::shared_ptr<impeller::Allocator>
allocator =
874 std::make_shared<impeller::TestImpellerAllocator>();
876 descriptor.get(), {.target_width = 6, .target_height = 2}, {1000, 1000},
878 ASSERT_TRUE(result_1.ok());
879 EXPECT_EQ(result_1->image_info.size.width, 75);
880 EXPECT_EQ(result_1->image_info.size.height, 25);
885 descriptor.get(), {.target_width = 6, .target_height = 2}, {10, 10},
887 ASSERT_TRUE(result_2.ok());
888 EXPECT_EQ(result_2->image_info.size.width, 6);
889 EXPECT_EQ(result_2->image_info.size.height, 2);
894 descriptor.get(), {.target_width = 60, .target_height = 20}, {10, 10},
896 ASSERT_TRUE(result_3.ok());
897 EXPECT_EQ(result_3->image_info.size.width, 10);
898 EXPECT_EQ(result_3->image_info.size.height, 10);
902 descriptor.get(), {.target_width = 6, .target_height = 2}, {1000, 1000},
904 ASSERT_TRUE(result_4.ok());
905 EXPECT_EQ(result_4->image_info.size.width, 6);
906 EXPECT_EQ(result_4->image_info.size.height, 2);
910TEST(ImageDecoderTest, ImagesWithTransparencyArePremulAlpha) {
914 std::shared_ptr<ImageGenerator> generator =
916 ASSERT_TRUE(generator);
918 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(std::move(
data),
919 std::move(generator));
922 ASSERT_TRUE(compressed_image);
923 ASSERT_EQ(compressed_image->width(), 250);
924 ASSERT_EQ(compressed_image->height(), 250);
925 ASSERT_EQ(compressed_image->alphaType(), kPremul_SkAlphaType);
928TEST(ImageDecoderTest, VerifySubpixelDecodingPreservesExifOrientation) {
932 std::shared_ptr<ImageGenerator> generator =
934 ASSERT_TRUE(generator);
936 fml::MakeRefCounted<ImageDescriptor>(
data, std::move(generator));
940 ASSERT_EQ(600, descriptor->width());
941 ASSERT_EQ(200, descriptor->height());
943 auto image = SkImages::DeferredFromEncodedData(
data);
944 ASSERT_TRUE(
image !=
nullptr);
945 ASSERT_EQ(600,
image->width());
946 ASSERT_EQ(200,
image->height());
948 auto decode = [descriptor](uint32_t target_width, uint32_t target_height) {
950 descriptor.get(), target_width, target_height,
955 ASSERT_TRUE(expected_data !=
nullptr);
956 ASSERT_FALSE(expected_data->isEmpty());
958 auto assert_image = [&](
const auto& decoded_image,
959 const std::string& decode_error) {
960 ASSERT_EQ(decoded_image->dimensions(), SkISize::Make(300, 100));
961 sk_sp<SkData> encoded =
962 SkPngEncoder::Encode(
nullptr, decoded_image.get(), {});
963 ASSERT_TRUE(encoded->equals(expected_data.get()));
966 assert_image(decode(300, 100), {});
970 MultiFrameCodecCanBeCollectedBeforeIOTasksFinish) {
984 auto settings = CreateSettingsForFixture();
986 auto vm_data = vm_ref.GetVMData();
990 ASSERT_TRUE(gif_mapping);
993 std::shared_ptr<ImageGenerator> gif_generator =
995 ASSERT_TRUE(gif_generator);
998 CreateNewThread(
"platform"),
999 CreateNewThread(
"raster"),
1000 CreateNewThread(
"ui"),
1001 CreateNewThread(
"io")
1005 std::unique_ptr<TestIOManager> io_manager;
1009 io_manager = std::make_unique<TestIOManager>(runners.GetIOTaskRunner());
1014 io_manager->GetWeakIOManager());
1020 fml::AutoResetWaitableEvent isolate_latch;
1021 fml::RefPtr<MultiFrameCodec> codec;
1022 EXPECT_TRUE(isolate->RunInIsolateScope([&]() -> bool {
1023 Dart_Handle library = Dart_RootLibrary();
1024 if (Dart_IsError(library)) {
1025 isolate_latch.Signal();
1028 Dart_Handle closure =
1029 Dart_GetField(library, Dart_NewStringFromCString(
"frameCallback"));
1030 if (Dart_IsError(closure) || !Dart_IsClosure(closure)) {
1031 isolate_latch.Signal();
1035 codec = fml::MakeRefCounted<MultiFrameCodec>(std::move(gif_generator));
1036 codec->getNextFrame(closure);
1038 isolate_latch.Signal();
1041 isolate_latch.Wait();
1043 EXPECT_FALSE(codec);
1049 PostTaskSync(runners.GetIOTaskRunner(), [&]() { io_manager.reset(); });
1053 auto context = std::make_shared<impeller::TestImpellerContext>();
1056 EXPECT_FALSE(
allocator.allocPixelRef(
nullptr));
static DartVMRef Create(const Settings &settings, fml::RefPtr< const DartSnapshot > vm_snapshot=nullptr, fml::RefPtr< const DartSnapshot > isolate_snapshot=nullptr)
std::function< void(sk_sp< DlImage >, std::string)> ImageResult
static std::unique_ptr< ImageDecoder > Make(const Settings &settings, const TaskRunners &runners, std::shared_ptr< fml::ConcurrentTaskRunner > concurrent_task_runner, const fml::WeakPtr< IOManager > &io_manager, const std::shared_ptr< fml::SyncSwitch > &gpu_disabled_switch)
static absl::StatusOr< DecompressResult > DecompressTexture(ImageDescriptor *descriptor, const ImageDecoder::Options &options, impeller::ISize max_texture_size, bool supports_wide_gamut, const std::shared_ptr< const impeller::Capabilities > &capabilities, const std::shared_ptr< impeller::Allocator > &allocator)
static void UploadTextureToPrivate(ImageResult result, const std::shared_ptr< impeller::Context > &context, const std::shared_ptr< impeller::DeviceBuffer > &buffer, const ImageInfo &image_info, const std::optional< SkImageInfo > &resize_info, const std::shared_ptr< const fml::SyncSwitch > &gpu_disabled_switch)
Create a device private texture from the provided host buffer.
static std::pair< sk_sp< DlImage >, std::string > UploadTextureToStorage(const std::shared_ptr< impeller::Context > &context, std::shared_ptr< SkBitmap > bitmap)
Create a texture from the provided bitmap.
static sk_sp< SkImage > ImageFromCompressedData(ImageDescriptor *descriptor, uint32_t target_width, uint32_t target_height, const fml::tracing::TraceFlow &flow)
static ImageInfo CreateImageInfo(const SkImageInfo &sk_image_info)
The minimal interface necessary for defining a decoder that can be used for both single and multi-fra...
Keeps a priority-ordered registry of image generator builders to be used when decoding images....
std::shared_ptr< ImageGenerator > CreateCompatibleGenerator(const sk_sp< SkData > &buffer)
Walks the list of image generator builders in descending priority order until a compatible ImageGener...
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
fml::RefPtr< fml::TaskRunner > GetIOTaskRunner() const
fml::RefPtr< flutter::SkiaUnrefQueue > GetSkiaUnrefQueue() const override
std::shared_ptr< const fml::SyncSwitch > GetIsGpuDisabledSyncSwitch() override
~TestIOManager() override
void SetGpuDisabled(bool disabled)
fml::WeakPtr< IOManager > GetWeakIOManager() const override
std::shared_ptr< impeller::Context > GetImpellerContext() const override
Retrieve the impeller::Context.
bool did_access_is_gpu_disabled_sync_switch_
TestIOManager(const fml::RefPtr< fml::TaskRunner > &task_runner, bool has_gpu_context=true)
fml::WeakPtr< GrDirectContext > GetResourceContext() const override
An Image generator that pretends it can't recognize the data it was given.
const SkImageInfo & GetInfo()
Returns basic information about the contents of the encoded image. This information can almost always...
unsigned int GetPlayCount() const
The number of times an animated image should play through before playback stops.
const ImageGenerator::FrameInfo GetFrameInfo(unsigned int frame_index)
Get information about a single frame in the context of a multi-frame image, useful for animation and ...
bool GetPixels(const SkImageInfo &info, void *pixels, size_t row_bytes, unsigned int frame_index, std::optional< unsigned int > prior_frame)
Decode the image into a given buffer. This method is currently always used for sub-pixel image decodi...
~UnknownImageGenerator()=default
SkISize GetScaledDimensions(float scale)
Given a scale value, find the closest image size that can be used for efficiently decoding the image....
unsigned int GetFrameCount() const
Get the number of frames that the encoded image stores. This method is always expected to be called b...
static std::shared_ptr< ConcurrentMessageLoop > Create(size_t worker_count=std::thread::hardware_concurrency())
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)
virtual void PostTask(const fml::closure &task) override
virtual bool RunsTasksOnCurrentThread()
CapabilitiesBuilder & SetSupportsTextureToTextureBlits(bool value)
std::unique_ptr< Capabilities > Build()
To do anything rendering related with Impeller, you need a context.
std::shared_ptr< CommandQueue > GetCommandQueue() const override
Return the graphics queue for submitting command buffers.
std::shared_ptr< ShaderLibrary > GetShaderLibrary() const override
Returns the library of shaders used to specify the programmable stages of a pipeline.
RuntimeStageBackend GetRuntimeStageBackend() const override
Retrieve the runtime stage for this context type.
std::shared_ptr< PipelineLibrary > GetPipelineLibrary() const override
Returns the library of pipelines used by render or compute commands.
void Shutdown() override
Force all pending asynchronous work to finish. This is achieved by deleting all owned concurrent mess...
std::shared_ptr< Allocator > GetResourceAllocator() const override
Returns the allocator used to create textures and buffers on the device.
bool IsValid() const override
Determines if a context is valid. If the caller ever receives an invalid context, they must discard i...
void DisposeThreadLocalCachedResources() override
const std::shared_ptr< const Capabilities > & GetCapabilities() const override
Get the capabilities of Impeller context. All optionally supported feature of the platform,...
std::string DescribeGpuModel() const override
BackendType GetBackendType() const override
Get the graphics backend of an Impeller context.
size_t command_buffer_count_
std::shared_ptr< CommandBuffer > CreateCommandBuffer() const override
Create a new command buffer. Command buffers can be used to encode graphics, blit,...
void StoreTaskForGPU(const std::function< void()> &task, const std::function< void()> &failure) override
void FlushTasks(bool fail=false)
bool DidDisposeResources() const
std::shared_ptr< SamplerLibrary > GetSamplerLibrary() const override
Returns the library of combined image samplers used in shaders.
FlutterVulkanImage * image
G_BEGIN_DECLS GBytes * message
FlutterDesktopBinaryReply callback
#define FML_CHECK(condition)
#define FML_UNREACHABLE()
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
std::shared_ptr< SkBitmap > bitmap
std::shared_ptr< ImpellerAllocator > allocator
std::string GetCurrentTestName()
Gets the name of the currently running test. This is useful in generating logs or assets based on tes...
TEST_F(DisplayListTest, Defaults)
void PostTaskSync(const fml::RefPtr< fml::TaskRunner > &task_runner, const std::function< void()> &function)
std::string GetDefaultKernelFilePath()
Returns the default path to kernel_blob.bin. This file is within the directory returned by GetFixture...
std::unique_ptr< AutoIsolateShutdown > RunDartCodeInIsolate(DartVMRef &vm_ref, const Settings &settings, const TaskRunners &task_runners, std::string entrypoint, const std::vector< std::string > &args, const std::string &kernel_file_path, fml::WeakPtr< IOManager > io_manager, std::unique_ptr< PlatformConfiguration > platform_configuration)
float DecodeBGR10(uint32_t x)
sk_sp< SkData > OpenFixtureAsSkData(const std::string &fixture_name)
Opens a fixture of the given file name and returns a Skia SkData holding its contents.
TEST(NativeAssetsManagerTest, NoAvailableAssets)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font manager
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
TEST_F(EngineAnimatorTest, AnimatorAcceptsMultipleRenders)
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
Info about a single frame in the context of a multi-frame image, useful for animation and blending.