Flutter Engine
 
Loading...
Searching...
No Matches
embedder_test_compositor.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
11#include "third_party/skia/include/core/SkSurface.h"
12
13namespace flutter {
14namespace testing {
15
17 sk_sp<GrDirectContext> context)
18 : surface_size_(surface_size), context_(std::move(context)) {
19 FML_CHECK(!surface_size_.IsEmpty()) << "Surface size must not be empty";
20}
21
23
24static void InvokeAllCallbacks(const std::vector<fml::closure>& callbacks) {
25 for (const auto& callback : callbacks) {
26 if (callback) {
27 callback();
28 }
29 }
30}
31
33 const FlutterBackingStoreConfig* config,
34 FlutterBackingStore* backing_store_out) {
35 bool success = backingstore_producer_->Create(config, backing_store_out);
36 if (success) {
39 }
40 return success;
41}
42
44 const FlutterBackingStore* backing_store) {
45 // We have already set the destruction callback for the various backing
46 // stores. Our user_data is just the canvas from that backing store and does
47 // not need to be explicitly collected. Embedders might have some other state
48 // they want to collect though.
51 return true;
52}
53
55 const FlutterBackingStore* backing_store) const {
56 return backingstore_producer_->GetSurface(backing_store);
57}
58
62
64 const FlutterLayer** layers,
65 size_t layers_count) {
67 FML_LOG(ERROR)
68 << "Could not update the off-screen composition in the test compositor";
69 return false;
70 }
71
72 // If the test has asked to access the layers and renderers being presented.
73 // Access the same and present it to the test for its test assertions.
77 present_callback_ = nullptr;
78 }
80 }
81
83 return true;
84}
85
87 const PresentCallback& next_present_callback) {
88 SetPresentCallback(next_present_callback, true);
89}
90
92 const PresentCallback& present_callback,
93 bool one_shot) {
95 present_callback_ = present_callback;
97}
98
100 const NextSceneCallback& next_scene_callback) {
102 next_scene_callback_ = next_scene_callback;
103}
104
109
114
118
122
127
132
137
138sk_sp<GrDirectContext> EmbedderTestCompositor::GetGrContext() {
139 return context_;
140}
141
142} // namespace testing
143} // namespace flutter
void AddOnCreateRenderTargetCallback(const fml::closure &callback)
void AddOnPresentCallback(const fml::closure &callback)
void SetNextSceneCallback(const NextSceneCallback &next_scene_callback)
sk_sp< SkSurface > GetSurface(const FlutterBackingStore *backing_store) const
void AddOnCollectRenderTargetCallback(const fml::closure &callback)
std::vector< fml::closure > on_create_render_target_callbacks_
std::function< void(FlutterViewId view_id, const FlutterLayer **layers, size_t layers_count)> PresentCallback
bool CollectBackingStore(const FlutterBackingStore *backing_store)
std::function< void(sk_sp< SkImage > image)> NextSceneCallback
std::vector< fml::closure > on_collect_render_target_callbacks_
EmbedderTestCompositor(DlISize surface_size, sk_sp< GrDirectContext > context)
bool CreateBackingStore(const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
void SetNextPresentCallback(const PresentCallback &next_present_callback)
Allows tests to install a callback to notify them when the entire render tree has been finalized so t...
bool Present(FlutterViewId view_id, const FlutterLayer **layers, size_t layers_count)
virtual bool UpdateOffscrenComposition(const FlutterLayer **layers, size_t layers_count)=0
void SetPresentCallback(const PresentCallback &present_callback, bool one_shot)
std::unique_ptr< EmbedderTestBackingStoreProducer > backingstore_producer_
std::function< sk_sp< SkImage >(const FlutterLayer &layer, GrDirectContext *context)> PlatformViewRendererCallback
PlatformViewRendererCallback platform_view_renderer_callback_
void SetPlatformViewRendererCallback(const PlatformViewRendererCallback &callback)
const FlutterLayer size_t layers_count
const FlutterLayer ** layers
G_BEGIN_DECLS FlutterViewId view_id
FlutterDesktopBinaryReply callback
#define FML_LOG(severity)
Definition logging.h:101
#define FML_CHECK(condition)
Definition logging.h:104
static void InvokeAllCallbacks(const std::vector< fml::closure > &callbacks)
int64_t FlutterViewId
std::function< void()> closure
Definition closure.h:14
Definition ref_ptr.h:261
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition size.h:123