Flutter Engine
 
Loading...
Searching...
No Matches
flutter::GPUSurfaceSoftware Class Reference

#include <gpu_surface_software.h>

Inheritance diagram for flutter::GPUSurfaceSoftware:
flutter::Surface flutter::TesterGPUSurfaceSoftware

Public Member Functions

 GPUSurfaceSoftware (GPUSurfaceSoftwareDelegate *delegate, bool render_to_surface)
 
 ~GPUSurfaceSoftware () override
 
bool IsValid () override
 
std::unique_ptr< SurfaceFrameAcquireFrame (const DlISize &size) override
 
DlMatrix GetRootTransformation () const override
 
GrDirectContext * GetContext () override
 
- Public Member Functions inherited from flutter::Surface
 Surface ()
 
virtual ~Surface ()
 
virtual std::unique_ptr< GLContextResultMakeRenderContextCurrent ()
 
virtual bool ClearRenderContext ()
 
virtual bool AllowsDrawingWhenGpuDisabled () const
 
virtual bool EnableRasterCache () const
 
virtual std::shared_ptr< impeller::AiksContextGetAiksContext () const
 
virtual SurfaceData GetSurfaceData () const
 

Detailed Description

Definition at line 15 of file gpu_surface_software.h.

Constructor & Destructor Documentation

◆ GPUSurfaceSoftware()

flutter::GPUSurfaceSoftware::GPUSurfaceSoftware ( GPUSurfaceSoftwareDelegate delegate,
bool  render_to_surface 
)

Definition at line 17 of file gpu_surface_software.cc.

19 : delegate_(delegate),
20 render_to_surface_(render_to_surface),
21 weak_factory_(this) {}

◆ ~GPUSurfaceSoftware()

flutter::GPUSurfaceSoftware::~GPUSurfaceSoftware ( )
overridedefault

Member Function Documentation

◆ AcquireFrame()

std::unique_ptr< SurfaceFrame > flutter::GPUSurfaceSoftware::AcquireFrame ( const DlISize size)
overridevirtual

Implements flutter::Surface.

Definition at line 31 of file gpu_surface_software.cc.

32 {
33 SurfaceFrame::FramebufferInfo framebuffer_info;
34 framebuffer_info.supports_readback = true;
35
36 // TODO(38466): Refactor GPU surface APIs take into account the fact that an
37 // external view embedder may want to render to the root surface.
38 if (!render_to_surface_) {
39 return std::make_unique<SurfaceFrame>(
40 nullptr, framebuffer_info,
41 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) {
42 return true;
43 },
44 [](const SurfaceFrame& surface_frame) { return true; }, logical_size);
45 }
46
47 if (!IsValid()) {
48 return nullptr;
49 }
50
51 const auto size = DlISize(logical_size.width, logical_size.height);
52
53 sk_sp<SkSurface> backing_store = delegate_->AcquireBackingStore(size);
54
55 if (backing_store == nullptr) {
56 return nullptr;
57 }
58
59 if (size.width != backing_store->width() ||
60 size.height != backing_store->height()) {
61 return nullptr;
62 }
63
64 // If the surface has been scaled, we need to apply the inverse scaling to the
65 // underlying canvas so that coordinates are mapped to the same spot
66 // irrespective of surface scaling.
67 SkCanvas* canvas = backing_store->getCanvas();
68 canvas->resetMatrix();
69
70 SurfaceFrame::EncodeCallback encode_callback =
71 [self = weak_factory_.GetWeakPtr()](const SurfaceFrame& surface_frame,
72 DlCanvas* canvas) -> bool {
73 // If the surface itself went away, there is nothing more to do.
74 if (!self || !self->IsValid() || canvas == nullptr) {
75 return false;
76 }
77
78 canvas->Flush();
79 return true;
80 };
81 SurfaceFrame::SubmitCallback submit_callback =
82 [self = weak_factory_.GetWeakPtr()](const SurfaceFrame& surface_frame) {
83 // If the surface itself went away, there is nothing more to do.
84 if (!self || !self->IsValid()) {
85 return false;
86 }
87 return self->delegate_->PresentBackingStore(
88 surface_frame.SkiaSurface());
89 };
90
91 return std::make_unique<SurfaceFrame>(backing_store, framebuffer_info,
92 encode_callback, submit_callback,
93 logical_size);
94}
virtual sk_sp< SkSurface > AcquireBackingStore(const DlISize &size)=0
Called when the GPU surface needs a new buffer to render a new frame into.
std::function< bool(SurfaceFrame &surface_frame, DlCanvas *canvas)> EncodeCallback
std::function< bool(SurfaceFrame &surface_frame)> SubmitCallback
impeller::ISize32 DlISize
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all 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
flutter::DlCanvas DlCanvas

References flutter::GPUSurfaceSoftwareDelegate::AcquireBackingStore(), impeller::TSize< T >::height, IsValid(), self, flutter::size, flutter::SurfaceFrame::FramebufferInfo::supports_readback, and impeller::TSize< T >::width.

◆ GetContext()

GrDirectContext * flutter::GPUSurfaceSoftware::GetContext ( )
overridevirtual

Implements flutter::Surface.

Definition at line 104 of file gpu_surface_software.cc.

104 {
105 // There is no GrContext associated with a software surface.
106 return nullptr;
107}

◆ GetRootTransformation()

DlMatrix flutter::GPUSurfaceSoftware::GetRootTransformation ( ) const
overridevirtual

Implements flutter::Surface.

Definition at line 97 of file gpu_surface_software.cc.

97 {
98 // This backend does not currently support root surface transformations. Just
99 // return identity.
100 return DlMatrix();
101}
impeller::Matrix DlMatrix

◆ IsValid()

bool flutter::GPUSurfaceSoftware::IsValid ( )
overridevirtual

Implements flutter::Surface.

Definition at line 26 of file gpu_surface_software.cc.

26 {
27 return delegate_ != nullptr;
28}

Referenced by AcquireFrame().


The documentation for this class was generated from the following files: