5#define FML_USED_ON_EMBEDDER
10#include "flutter/shell/platform/embedder/tests/embedder_test_backingstore_producer.h"
11#include "flutter/shell/platform/embedder/tests/embedder_unittests_util.h"
23 const auto image_info =
53 FML_CHECK(
false) <<
"Unable to allocate data.";
59 FML_CHECK(
false) <<
"Unable to read pixels.";
76 return normalized_a->
equals(normalized_b.
get());
80 const std::string&
name) {
91 bool opengl_framebuffer) {
96 if (opengl_framebuffer) {
111 bool opengl_framebuffer) {
117 if (opengl_framebuffer) {
135 const std::string&
name,
157 <<
"Could not find fixture: " << fixture_file_name;
165 FML_CHECK(fixture_image) <<
"Could not create image from fixture: "
166 << fixture_file_name;
168 FML_CHECK(scene_image) <<
"Invalid scene image.";
170 auto scene_image_subset = scene_image->
makeSubset(
175 <<
"Could not create image subset for fixture comparison: "
176 << scene_image_subset;
178 const auto images_are_same =
184 if (!images_are_same) {
187 const auto actual_file_name =
"actual_" + fixture_file_name;
188 const auto expect_file_name =
"expectation_" + fixture_file_name;
194 <<
"Could not write file to disk: " << actual_file_name;
197 <<
"Could not write file to disk: " << expect_file_name;
199 FML_LOG(
ERROR) <<
"Image did not match expectation." << std::endl
207 return images_are_same;
216 const std::vector<uint8_t>& bytes) {
224 (memcmp(bytes.data(), pixmap.
addr(), bytes.size()) == 0);
227 FML_LOG(
ERROR) <<
"SkImage pixel data didn't match bytes.";
230 const uint8_t*
addr =
static_cast<const uint8_t*
>(pixmap.
addr());
233 stream <<
"0x" << std::setfill(
'0') << std::setw(2) << std::uppercase
234 << std::hex << static_cast<int>(
addr[
i]);
243 for (
auto b = bytes.begin();
b != bytes.end(); ++
b) {
244 stream <<
"0x" << std::setfill(
'0') << std::setw(2) << std::uppercase
245 << std::hex << static_cast<int>(*
b);
246 if (
b != bytes.end() - 1) {
258 const std::vector<uint8_t>& bytes) {
268 if (mutations ==
nullptr) {
272 for (
size_t i = 0;
i <
count; ++
i) {
298 [&](
const auto& mutation) {
@ kTopLeft_GrSurfaceOrigin
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
static bool ok(int result)
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
static sk_sp< SkData > MakeUninitialized(size_t length)
bool equals(const SkData *other) const
sk_sp< SkImage > makeRasterImage(GrDirectContext *, CachingHint cachingHint=kDisallow_CachingHint) const
bool readPixels(GrDirectContext *context, const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
virtual sk_sp< SkImage > makeSubset(GrDirectContext *direct, const SkIRect &subset) const =0
SkMatrix & preConcat(const SkMatrix &other)
size_t computeByteSize() const
const void * addr() const
size_t GetSize() const override
const uint8_t * GetMapping() const override
FlutterPlatformViewMutationType
@ kFlutterPlatformViewMutationTypeTransformation
@ kFlutterOpenGLTargetTypeFramebuffer
@ kFlutterOpenGLTargetTypeTexture
@ kFlutterBackingStoreTypeMetal
Specifies a Metal backing store. This is backed by a Metal texture.
@ kFlutterBackingStoreTypeVulkan
Specifies a Vulkan backing store. This is backed by a Vulkan VkImage.
@ kFlutterBackingStoreTypeSoftware
Specified an software allocation for Flutter to render into using the CPU.
@ kFlutterBackingStoreTypeOpenGL
SkMatrix SkMatrixMake(const FlutterTransformation &xformation)
#define FML_LOG(severity)
#define FML_CHECK(condition)
Dart_NativeFunction function
SK_API sk_sp< SkImage > DeferredFromEncodedData(sk_sp< SkData > encoded, std::optional< SkAlphaType > alphaType=std::nullopt)
static constexpr skcms_Matrix3x3 kRec2020
static constexpr skcms_TransferFunction kRec2020
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
sk_sp< const SkImage > image
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)
const char * GetFixturesPath()
Returns the directory containing the test fixture for the target if this target has fixtures configur...
bool WriteImageToDisk(const fml::UniqueFD &directory, const std::string &name, const sk_sp< SkImage > &image)
sk_sp< SkSurface > CreateRenderSurface(const FlutterLayer &layer, GrDirectContext *context)
void FilterMutationsByType(const FlutterPlatformViewMutation **mutations, size_t count, FlutterPlatformViewMutationType type, const std::function< void(const FlutterPlatformViewMutation &mutation)> &handler)
static sk_sp< SkData > NormalizeImage(const sk_sp< SkImage > &image)
bool SurfacePixelDataMatchesBytes(SkSurface *surface, const std::vector< uint8_t > &bytes)
fml::UniqueFD OpenFixture(const std::string &fixture_name)
Opens a fixture of the given file name.
fml::UniqueFD OpenFixturesDirectory()
Opens the fixtures directory for the unit-test harness.
void ConfigureBackingStore(FlutterBackingStore &backing_store, EmbedderTestContextType backend, bool opengl_framebuffer)
Configures per-backend properties for a given backing store.
bool RasterImagesAreSame(const sk_sp< SkImage > &a, const sk_sp< SkImage > &b)
SkMatrix GetTotalMutationTransformationMatrix(const FlutterPlatformViewMutation **mutations, size_t count)
std::string FixtureNameForBackend(EmbedderTestContextType backend, const std::string &name)
Prepends a prefix to the name which is unique to the test context type. This is useful for tests that...
bool ImageMatchesFixture(const std::string &fixture_file_name, const sk_sp< SkImage > &scene_image)
EmbedderTestBackingStoreProducer::RenderTargetType GetRenderTargetFromBackend(EmbedderTestContextType backend, bool opengl_framebuffer)
Resolves a render target type for a given backend description. This is useful for tests that use Embe...
DEF_SWITCHES_START aot vmservice shared library name
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
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
std::string JoinPaths(std::initializer_list< std::string > components)
bool WriteAtomically(const fml::UniqueFD &base_directory, const char *file_name, const Mapping &mapping)
FlutterBackingStoreType type
Specifies the type of backing store.
FlutterOpenGLBackingStore open_gl
The description of the OpenGL backing store.
FlutterSize size
The size of the layer (in physical pixels).
FlutterOpenGLTargetType type
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
static SkImageInfo MakeN32Premul(int width, int height)
size_t minRowBytes() const
size_t computeByteSize(size_t rowBytes) const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)