Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions shell/platform/embedder/tests/embedder_test_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "flutter/shell/platform/embedder/tests/embedder_test_context.h"

#include "flutter/fml/make_copyable.h"
#include "flutter/runtime/dart_vm.h"
#include "flutter/shell/platform/embedder/tests/embedder_assertions.h"
#include "third_party/dart/runtime/bin/elf_loader.h"
Expand Down Expand Up @@ -225,6 +226,16 @@ void EmbedderTestContext::SetNextSceneCallback(
next_scene_callback_ = next_scene_callback;
}

std::future<sk_sp<SkImage>> EmbedderTestContext::GetNextSceneImage() {
std::promise<sk_sp<SkImage>> promise;
auto future = promise.get_future();
SetNextSceneCallback(
fml::MakeCopyable([promise = std::move(promise)](auto image) mutable {
promise.set_value(image);
}));
return future;
}

bool EmbedderTestContext::SofwarePresent(sk_sp<SkImage> image) {
software_surface_present_count_++;

Expand Down
8 changes: 6 additions & 2 deletions shell/platform/embedder/tests/embedder_test_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONTEXT_H_
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONTEXT_H_

#include <future>
#include <map>
#include <memory>
#include <string>
Expand Down Expand Up @@ -60,8 +61,7 @@ class EmbedderTestContext {

EmbedderTestCompositor& GetCompositor();

using NextSceneCallback = std::function<void(sk_sp<SkImage> image)>;
void SetNextSceneCallback(const NextSceneCallback& next_scene_callback);
std::future<sk_sp<SkImage>> GetNextSceneImage();

size_t GetGLSurfacePresentCount() const;

Expand All @@ -71,6 +71,8 @@ class EmbedderTestContext {
// This allows the builder to access the hooks.
friend class EmbedderConfigBuilder;

using NextSceneCallback = std::function<void(sk_sp<SkImage> image)>;

std::string assets_path_;

// Pieces of the Dart snapshot in ELF form, loaded by Dart's ELF library.
Expand Down Expand Up @@ -129,6 +131,8 @@ class EmbedderTestContext {
void FireRootSurfacePresentCallbackIfPresent(
const std::function<sk_sp<SkImage>(void)>& image_callback);

void SetNextSceneCallback(const NextSceneCallback& next_scene_callback);

FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTestContext);
};

Expand Down
Loading