Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::testing::DlSurfaceInstanceImpeller Class Reference

#include <dl_test_surface_instance_impeller.h>

Inheritance diagram for flutter::testing::DlSurfaceInstanceImpeller:
flutter::testing::DlSurfaceInstance

Public Member Functions

 DlSurfaceInstanceImpeller (std::shared_ptr< impeller::Context > context, std::shared_ptr< impeller::Surface > surface)
 
 DlSurfaceInstanceImpeller (std::shared_ptr< impeller::Context > context, std::shared_ptr< impeller::RenderTarget > surface)
 
virtual ~DlSurfaceInstanceImpeller ()
 
void Clear (const DlColor &color) override
 Clear the entire surface to the indicated color.
 
DlCanvasGetCanvas () override
 
void RenderDisplayList (const sk_sp< DisplayList > &display_list) override
 
void FlushSubmitCpuSync () override
 
std::unique_ptr< DlPixelDataSnapshotToPixelData () const override
 
sk_sp< DlImageSnapshotToImage () const override
 
bool SnapshotToFile (std::string &filename) const override
 Store a snapshot of this Surface to the file indicated by the filename.
 
int width () const override
 The width of the underlying surface.
 
int height () const override
 The height of the underlying surface.
 
- Public Member Functions inherited from flutter::testing::DlSurfaceInstance
virtual ~DlSurfaceInstance ()=default
 
DlISize GetSize () const
 The size of the underlying surface.
 
virtual sk_sp< SkSurface > sk_surface ()
 

Detailed Description

Definition at line 20 of file dl_test_surface_instance_impeller.h.

Constructor & Destructor Documentation

◆ DlSurfaceInstanceImpeller() [1/2]

flutter::testing::DlSurfaceInstanceImpeller::DlSurfaceInstanceImpeller ( std::shared_ptr< impeller::Context context,
std::shared_ptr< impeller::Surface surface 
)
explicit

Definition at line 51 of file dl_test_surface_instance_impeller.cc.

54 : context_(std::move(context)),
55 surface_(std::move(surface)),
56 aiks_context_(context_, typographer_context_) {}

References surface.

◆ DlSurfaceInstanceImpeller() [2/2]

flutter::testing::DlSurfaceInstanceImpeller::DlSurfaceInstanceImpeller ( std::shared_ptr< impeller::Context context,
std::shared_ptr< impeller::RenderTarget surface 
)
explicit

Definition at line 58 of file dl_test_surface_instance_impeller.cc.

61 : context_(std::move(context)),
62 target_holder_(std::move(target)),
63 aiks_context_(context_, typographer_context_) {}
uint32_t * target

◆ ~DlSurfaceInstanceImpeller()

flutter::testing::DlSurfaceInstanceImpeller::~DlSurfaceInstanceImpeller ( )
virtualdefault

Member Function Documentation

◆ Clear()

void flutter::testing::DlSurfaceInstanceImpeller::Clear ( const DlColor color)
overridevirtual

Clear the entire surface to the indicated color.

Implements flutter::testing::DlSurfaceInstance.

Definition at line 78 of file dl_test_surface_instance_impeller.cc.

78 {
79 if (!builder_.IsEmpty()) {
80 // Use the Build method to clear whatever is in the builder as it is
81 // now irrelevant and ignore the returned DisplayList as it would be
82 // useless to try to render it before a surface clear.
83 std::ignore = builder_.Build();
84 }
85 builder_.Clear(color);
86 DoRenderDisplayList(builder_.Build());
87}
bool IsEmpty() const
Return true if the builder has not yet recorded any commands.
sk_sp< DisplayList > Build()
void Clear(DlColor color)
Definition dl_canvas.h:104

References flutter::DisplayListBuilder::Build(), flutter::DlCanvas::Clear(), and flutter::DisplayListBuilder::IsEmpty().

◆ FlushSubmitCpuSync()

void flutter::testing::DlSurfaceInstanceImpeller::FlushSubmitCpuSync ( )
overridevirtual

Ensure that all outstanding calls executed on the DlCanvas instance are rendered to the surface.

Implements flutter::testing::DlSurfaceInstance.

Definition at line 99 of file dl_test_surface_instance_impeller.cc.

99 {
100 Flush();
101 if (!context_->FinishQueue()) {
102 FML_LOG(ERROR) << "Impeller backend did not implement FinishQueue";
104 }
105}
#define FML_LOG(severity)
Definition logging.h:101
#define FML_UNREACHABLE()
Definition logging.h:128

References FML_LOG, and FML_UNREACHABLE.

◆ GetCanvas()

DlCanvas * flutter::testing::DlSurfaceInstanceImpeller::GetCanvas ( )
overridevirtual

Return a DlCanvas instance that renders to this surface. Note that actual execution of the rendering calls are not guaranteed until the FlushSubmitCpuSync method is called. The DlCanvas will also be reset by the operations of the sync method so transform and clip state will not be carried over to subsequent calls.

Rendering to this canvas does not necessarily render the commands immediately in all backends, some backends accumulate the commands into a DisplayList and only flush that DisplayList when the FlushSubmitCpuSync is called. Tests should strongly prefer using RenderDisplayList instead of multiple calls on this canvas object.

Implements flutter::testing::DlSurfaceInstance.

Definition at line 89 of file dl_test_surface_instance_impeller.cc.

89 {
90 return &builder_;
91}

◆ height()

int flutter::testing::DlSurfaceInstanceImpeller::height ( ) const
overridevirtual

The height of the underlying surface.

Implements flutter::testing::DlSurfaceInstance.

Definition at line 164 of file dl_test_surface_instance_impeller.cc.

164 {
165 return GetRenderTarget().GetRenderTargetSize().height;
166}
ISize GetRenderTargetSize() const
Type height
Definition size.h:29

References impeller::RenderTarget::GetRenderTargetSize(), and impeller::TSize< T >::height.

◆ RenderDisplayList()

void flutter::testing::DlSurfaceInstanceImpeller::RenderDisplayList ( const sk_sp< DisplayList > &  display_list)
overridevirtual

Render the indicated DisplayList to the surface. Note that the commands may be enqueued by this call and will be rendered at some time in the future, but the caller must call FlushSubmitCpuSync to be sure they are done being rendered.

In some cases this may be faster than using: GetCanvas().DrawDisplayList(display_list);

Implements flutter::testing::DlSurfaceInstance.

Definition at line 93 of file dl_test_surface_instance_impeller.cc.

94 {
95 Flush();
96 DoRenderDisplayList(display_list);
97}

◆ SnapshotToFile()

bool flutter::testing::DlSurfaceInstanceImpeller::SnapshotToFile ( std::string &  filename) const
overridevirtual

Store a snapshot of this Surface to the file indicated by the filename.

Implements flutter::testing::DlSurfaceInstance.

Definition at line 156 of file dl_test_surface_instance_impeller.cc.

156 {
157 return false;
158}

◆ SnapshotToImage()

sk_sp< DlImage > flutter::testing::DlSurfaceInstanceImpeller::SnapshotToImage ( ) const
overridevirtual

Return the current contents of the surface as a DlImage compatible with the DlCanvas that it provides.

Implements flutter::testing::DlSurfaceInstance.

Definition at line 133 of file dl_test_surface_instance_impeller.cc.

133 {
134 auto texture = GetRenderTarget().GetRenderTargetTexture();
135 // temp_image will not be a snapshot, so we must make a copy of it to
136 // satisfy the demands of the "SnapshotToImage" API.
137 auto temp_image = impeller::DlImageImpeller::Make(texture);
138
139 // Make a temporary "image surface" into which we can copy our current
140 // texture so that we can return a stable snapshot DlImage from the copy.
142 context_, temp_image->width(), temp_image->height(),
143 DlSurfaceProvider::PixelFormat::kN32Premul);
144
145 // Copy the temp_image made from our texture into the image surface.
146 image_surface->GetCanvas()->DrawImage(temp_image, DlPoint(0, 0),
148 image_surface->FlushSubmitCpuSync();
149
150 // Return an image based on the temporary, but stable, image_surface's
151 // texture.
153 image_surface->GetRenderTarget().GetRenderTargetTexture());
154}
std::unique_ptr< DlSurfaceInstance > MakeOffscreenSurface(size_t width, size_t height, PixelFormat format) const override
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
std::shared_ptr< Texture > GetRenderTargetTexture() const
FlTexture * texture
impeller::Point DlPoint

References impeller::RenderTarget::GetRenderTargetTexture(), flutter::kNearestNeighbor, impeller::DlImageImpeller::Make(), flutter::testing::DlSurfaceProviderImpeller::MakeOffscreenSurface(), and texture.

◆ SnapshotToPixelData()

std::unique_ptr< DlPixelData > flutter::testing::DlSurfaceInstanceImpeller::SnapshotToPixelData ( ) const
overridevirtual

Read back the current contents of the surface and return it as a DlPixelData structure.

Implements flutter::testing::DlSurfaceInstance.

Definition at line 124 of file dl_test_surface_instance_impeller.cc.

125 {
126 std::unique_ptr<impeller::testing::Screenshot> snapshot =
127 snapshotter_.MakeScreenshot(aiks_context_,
128 GetRenderTarget().GetRenderTargetTexture());
129 return snapshot ? std::make_unique<DlImpellerPixelData>(std::move(snapshot))
130 : nullptr;
131}
std::unique_ptr< Screenshot > MakeScreenshot(const AiksContext &aiks_context, const std::shared_ptr< Texture > texture) override

References impeller::testing::MetalScreenshotter::MakeScreenshot().

◆ width()

int flutter::testing::DlSurfaceInstanceImpeller::width ( ) const
overridevirtual

The width of the underlying surface.

Implements flutter::testing::DlSurfaceInstance.

Definition at line 160 of file dl_test_surface_instance_impeller.cc.

160 {
161 return GetRenderTarget().GetRenderTargetSize().width;
162}
Type width
Definition size.h:28

References impeller::RenderTarget::GetRenderTargetSize(), and impeller::TSize< T >::width.


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