Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
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 SkISize &size) override
 
SkMatrix GetRootTransformation () const override
 
GrDirectContextGetContext () override
 
- Public Member Functions inherited from flutter::Surface
 Surface ()
 
virtual ~Surface ()
 
virtual bool IsValid ()=0
 
virtual std::unique_ptr< SurfaceFrameAcquireFrame (const SkISize &size)=0
 
virtual SkMatrix GetRootTransformation () const =0
 
virtual GrDirectContextGetContext ()=0
 
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 15 of file gpu_surface_software.cc.

17 : delegate_(delegate),
18 render_to_surface_(render_to_surface),
19 weak_factory_(this) {}

◆ ~GPUSurfaceSoftware()

flutter::GPUSurfaceSoftware::~GPUSurfaceSoftware ( )
overridedefault

Member Function Documentation

◆ AcquireFrame()

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

Implements flutter::Surface.

Definition at line 29 of file gpu_surface_software.cc.

30 {
31 SurfaceFrame::FramebufferInfo framebuffer_info;
32 framebuffer_info.supports_readback = true;
33
34 // TODO(38466): Refactor GPU surface APIs take into account the fact that an
35 // external view embedder may want to render to the root surface.
36 if (!render_to_surface_) {
37 return std::make_unique<SurfaceFrame>(
38 nullptr, framebuffer_info,
39 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) {
40 return true;
41 },
42 logical_size);
43 }
44
45 if (!IsValid()) {
46 return nullptr;
47 }
48
49 const auto size = SkISize::Make(logical_size.width(), logical_size.height());
50
51 sk_sp<SkSurface> backing_store = delegate_->AcquireBackingStore(size);
52
53 if (backing_store == nullptr) {
54 return nullptr;
55 }
56
57 if (size != SkISize::Make(backing_store->width(), backing_store->height())) {
58 return nullptr;
59 }
60
61 // If the surface has been scaled, we need to apply the inverse scaling to the
62 // underlying canvas so that coordinates are mapped to the same spot
63 // irrespective of surface scaling.
64 SkCanvas* canvas = backing_store->getCanvas();
65 canvas->resetMatrix();
66
68 [self = weak_factory_.GetWeakPtr()](const SurfaceFrame& surface_frame,
69 DlCanvas* canvas) -> bool {
70 // If the surface itself went away, there is nothing more to do.
71 if (!self || !self->IsValid() || canvas == nullptr) {
72 return false;
73 }
74
75 canvas->Flush();
76
77 return self->delegate_->PresentBackingStore(surface_frame.SkiaSurface());
78 };
79
80 return std::make_unique<SurfaceFrame>(backing_store, framebuffer_info,
81 on_submit, logical_size);
82}
void resetMatrix()
Definition: SkCanvas.cpp:1355
SkCanvas * getCanvas()
Definition: SkSurface.cpp:82
int width() const
Definition: SkSurface.h:178
int height() const
Definition: SkSurface.h:184
virtual sk_sp< SkSurface > AcquireBackingStore(const SkISize &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)> SubmitCallback
Definition: surface_frame.h:27
it will be possible to load the file into Perfetto s trace viewer 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
Definition: switches.h:259
flutter::DlCanvas DlCanvas
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ GetContext()

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

Implements flutter::Surface.

Definition at line 94 of file gpu_surface_software.cc.

94 {
95 // There is no GrContext associated with a software surface.
96 return nullptr;
97}

◆ GetRootTransformation()

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

Implements flutter::Surface.

Definition at line 85 of file gpu_surface_software.cc.

85 {
86 // This backend does not currently support root surface transformations. Just
87 // return identity.
89 matrix.reset();
90 return matrix;
91}
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258

◆ IsValid()

bool flutter::GPUSurfaceSoftware::IsValid ( )
overridevirtual

Implements flutter::Surface.

Definition at line 24 of file gpu_surface_software.cc.

24 {
25 return delegate_ != nullptr;
26}

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