Flutter Engine
 
Loading...
Searching...
No Matches
embedder_test_compositor.h
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
5#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_COMPOSITOR_H_
6#define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_COMPOSITOR_H_
7
8#include <vector>
9
11#include "flutter/fml/closure.h"
12#include "flutter/fml/macros.h"
15#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
16
17namespace flutter {
18namespace testing {
19
21 public:
23 std::function<sk_sp<SkImage>(const FlutterLayer& layer,
24 GrDirectContext* context)>;
25 using PresentCallback = std::function<void(FlutterViewId view_id,
26 const FlutterLayer** layers,
27 size_t layers_count)>;
28
29 EmbedderTestCompositor(DlISize surface_size, sk_sp<GrDirectContext> context);
30
32
33 virtual void SetRenderTargetType(
35 FlutterSoftwarePixelFormat software_pixfmt) = 0;
36
38 FlutterBackingStore* backing_store_out);
39
40 bool CollectBackingStore(const FlutterBackingStore* backing_store);
41
43 const FlutterLayer** layers,
44 size_t layers_count);
45
48
49 sk_sp<SkSurface> GetSurface(const FlutterBackingStore* backing_store) const;
50
51 //----------------------------------------------------------------------------
52 /// @brief Allows tests to install a callback to notify them when the
53 /// entire render tree has been finalized so they can run their
54 /// assertions.
55 ///
56 /// @param[in] next_present_callback The next present callback
57 ///
58 void SetNextPresentCallback(const PresentCallback& next_present_callback);
59
60 void SetPresentCallback(const PresentCallback& present_callback,
61 bool one_shot);
62
63 using NextSceneCallback = std::function<void(sk_sp<SkImage> image)>;
64 void SetNextSceneCallback(const NextSceneCallback& next_scene_callback);
65
66 sk_sp<SkImage> GetLastComposition();
67
68 size_t GetPendingBackingStoresCount() const;
69
70 size_t GetBackingStoresCreatedCount() const;
71
72 size_t GetBackingStoresCollectedCount() const;
73
75
77
79
80 sk_sp<GrDirectContext> GetGrContext();
81
82 protected:
84 size_t layers_count) = 0;
85
86 // TODO(gw280): encapsulate these properly for subclasses to use
87 std::unique_ptr<EmbedderTestBackingStoreProducer> backingstore_producer_;
89 sk_sp<GrDirectContext> context_;
90
95 sk_sp<SkImage> last_composition_;
98 std::vector<fml::closure> on_create_render_target_callbacks_;
99 std::vector<fml::closure> on_collect_render_target_callbacks_;
100 std::vector<fml::closure> on_present_callbacks_;
101
103};
104
105} // namespace testing
106} // namespace flutter
107
108#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_COMPOSITOR_H_
GLenum type
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_
virtual void SetRenderTargetType(EmbedderTestBackingStoreProducer::RenderTargetType type, FlutterSoftwarePixelFormat software_pixfmt)=0
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_
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)
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTestCompositor)
FlutterSoftwarePixelFormat
Definition embedder.h:450
FlutterVulkanImage * image
const FlutterLayer size_t layers_count
const FlutterLayer ** layers
G_BEGIN_DECLS FlutterViewId view_id
FlutterDesktopBinaryReply callback
int64_t FlutterViewId
std::function< void()> closure
Definition closure.h:14