Flutter Engine
 
Loading...
Searching...
No Matches
embedder_test_context_software.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include <utility>
8
10#include "flutter/fml/paths.h"
15#include "third_party/dart/runtime/bin/elf_loader.h"
16#include "third_party/skia/include/core/SkBitmap.h"
17#include "third_party/skia/include/core/SkSurface.h"
18
19namespace flutter::testing {
20
22 std::string assets_path)
23 : EmbedderTestContext(std::move(assets_path)) {
27 .surface_present_callback =
28 [](void* context, const void* allocation, size_t row_bytes,
29 size_t height) {
30 auto image_info = SkImageInfo::MakeN32Premul(
31 SkISize::Make(row_bytes / 4, height));
32 SkBitmap bitmap;
33 if (!bitmap.installPixels(image_info, const_cast<void*>(allocation),
34 row_bytes)) {
35 FML_LOG(ERROR) << "Could not copy pixels for the software "
36 "composition from the engine.";
37 return false;
38 }
39 bitmap.setImmutable();
40 return reinterpret_cast<EmbedderTestContextSoftware*>(context)
41 ->Present(SkImages::RasterFromBitmap(bitmap));
42 },
43 };
44}
45
47
51
52void EmbedderTestContextSoftware::SetSurface(DlISize surface_size) {
53 surface_size_ = surface_size;
54}
55
56void EmbedderTestContextSoftware::SetupCompositor() {
57 FML_CHECK(!compositor_) << "Already set up a compositor in this context.";
58 compositor_ = std::make_unique<EmbedderTestCompositorSoftware>(surface_size_);
59}
60
62 return software_surface_present_count_;
63}
64
65bool EmbedderTestContextSoftware::Present(const sk_sp<SkImage>& image) {
66 software_surface_present_count_++;
68 return true;
69}
70
71} // namespace flutter::testing
std::unique_ptr< EmbedderTestCompositor > compositor_
void FireRootSurfacePresentCallbackIfPresent(const std::function< sk_sp< SkImage >(void)> &image_callback)
EmbedderTestContextType GetContextType() const override
@ kSoftware
Definition embedder.h:81
FlutterVulkanImage * image
#define FML_LOG(severity)
Definition logging.h:101
#define FML_CHECK(condition)
Definition logging.h:104
Definition ref_ptr.h:261
int32_t height
FlutterSoftwareRendererConfig software
Definition embedder.h:1034
FlutterRendererType type
Definition embedder.h:1031
size_t struct_size
The size of this struct. Must be sizeof(FlutterSoftwareRendererConfig).
Definition embedder.h:1022