Flutter Engine
The Flutter Engine
dl_test_surface_provider.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_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_PROVIDER_H_
6#define FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_PROVIDER_H_
7
8#include <utility>
9
10#include "flutter/display_list/display_list.h"
11#include "flutter/display_list/image/dl_image.h"
12#include "flutter/fml/mapping.h"
13#include "flutter/testing/testing.h"
14
16
17namespace flutter {
18namespace testing {
19
20class DlPixelData : public SkRefCnt {
21 public:
22 virtual ~DlPixelData() = default;
23
24 virtual const uint32_t* addr32(int x, int y) const = 0;
25 virtual size_t width() const = 0;
26 virtual size_t height() const = 0;
27 virtual void write(const std::string& path) const = 0;
28};
29
31 public:
32 virtual ~DlSurfaceInstance() = default;
33
34 virtual sk_sp<SkSurface> sk_surface() const = 0;
35
36 int width() const { return sk_surface()->width(); }
37 int height() const { return sk_surface()->height(); }
38};
39
41 public:
43 : surface_(std::move(surface)) {}
45
46 sk_sp<SkSurface> sk_surface() const override { return surface_; }
47
48 private:
49 sk_sp<SkSurface> surface_;
50};
51
53 public:
56
58 switch (format) {
61 case k565PixelFormat:
64 }
65 FML_DCHECK(false);
66 }
67
68 static std::string BackendName(BackendType type);
69 static std::unique_ptr<DlSurfaceProvider> Create(BackendType backend_type);
70
71 virtual ~DlSurfaceProvider() = default;
72 virtual const std::string backend_name() const = 0;
73 virtual BackendType backend_type() const = 0;
74 virtual bool supports(PixelFormat format) const = 0;
75 virtual bool supports_impeller() const { return false; }
76 virtual bool InitializeSurface(
77 size_t width,
78 size_t height,
80 virtual std::shared_ptr<DlSurfaceInstance> GetPrimarySurface() const = 0;
81 virtual std::shared_ptr<DlSurfaceInstance> MakeOffscreenSurface(
82 size_t width,
83 size_t height,
85
86 virtual bool Snapshot(std::string& filename) const;
88 int width,
89 int height) const {
90 return nullptr;
91 }
93 int width,
94 int height) const {
95 return nullptr;
96 }
97
98 protected:
99 DlSurfaceProvider() = default;
100};
101
102} // namespace testing
103} // namespace flutter
104
105#endif // FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_PROVIDER_H_
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition: SkColorType.h:22
GLenum type
int width() const
Definition: SkSurface.h:178
int height() const
Definition: SkSurface.h:184
virtual size_t height() const =0
virtual ~DlPixelData()=default
virtual void write(const std::string &path) const =0
virtual const uint32_t * addr32(int x, int y) const =0
virtual size_t width() const =0
DlSurfaceInstanceBase(sk_sp< SkSurface > surface)
sk_sp< SkSurface > sk_surface() const override
virtual sk_sp< SkSurface > sk_surface() const =0
virtual bool supports(PixelFormat format) const =0
virtual std::shared_ptr< DlSurfaceInstance > GetPrimarySurface() const =0
virtual sk_sp< DlImage > MakeImpellerImage(const sk_sp< DisplayList > &list, int width, int height) const
virtual bool Snapshot(std::string &filename) const
static std::string BackendName(BackendType type)
static SkImageInfo MakeInfo(PixelFormat format, int w, int h)
static std::unique_ptr< DlSurfaceProvider > Create(BackendType backend_type)
virtual sk_sp< DlPixelData > ImpellerSnapshot(const sk_sp< DisplayList > &list, int width, int height) const
virtual std::shared_ptr< DlSurfaceInstance > MakeOffscreenSurface(size_t width, size_t height, PixelFormat format=kN32PremulPixelFormat) const =0
virtual BackendType backend_type() const =0
virtual bool InitializeSurface(size_t width, size_t height, PixelFormat format=kN32PremulPixelFormat)=0
virtual const std::string backend_name() const =0
VkSurfaceKHR surface
Definition: main.cc:49
#define FML_DCHECK(condition)
Definition: logging.h:103
double y
double x
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder h
Definition: switches.h:59
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent Remove all existing persistent cache This is mainly for debugging purposes such as reproducing the shader compilation jank trace to Write the timeline trace to a file at the specified path The file will be in Perfetto s proto format
Definition: switches.h:203
Definition: ref_ptr.h:256
SkScalar w
int32_t height
int32_t width
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
static SkImageInfo MakeN32Premul(int width, int height)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)