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 53 of file dl_test_surface_instance_impeller.cc.

56 : context_(std::move(context)),
57 surface_(std::move(surface)),
58 aiks_context_(context_, typographer_context_) {}
std::shared_ptr< ContextGLES > 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 60 of file dl_test_surface_instance_impeller.cc.

63 : context_(std::move(context)),
64 target_holder_(std::move(target)),
65 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 80 of file dl_test_surface_instance_impeller.cc.

80 {
81 if (!builder_.IsEmpty()) {
82 // Use the Build method to clear whatever is in the builder as it is
83 // now irrelevant and ignore the returned DisplayList as it would be
84 // useless to try to render it before a surface clear.
85 std::ignore = builder_.Build();
86 }
87 builder_.Clear(color);
88 DoRenderDisplayList(builder_.Build());
89}
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 101 of file dl_test_surface_instance_impeller.cc.

101 {
102 Flush();
103 if (!context_->FinishQueue()) {
104 FML_LOG(ERROR) << "Impeller backend did not implement FinishQueue";
106 }
107}
#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 91 of file dl_test_surface_instance_impeller.cc.

91 {
92 return &builder_;
93}

◆ height()

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

The height of the underlying surface.

Implements flutter::testing::DlSurfaceInstance.

Definition at line 167 of file dl_test_surface_instance_impeller.cc.

167 {
168 return GetRenderTarget().GetRenderTargetSize().height;
169}
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 95 of file dl_test_surface_instance_impeller.cc.

96 {
97 Flush();
98 DoRenderDisplayList(display_list);
99}

◆ 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 159 of file dl_test_surface_instance_impeller.cc.

159 {
160 return false;
161}

◆ 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 136 of file dl_test_surface_instance_impeller.cc.

136 {
137 auto texture = GetRenderTarget().GetRenderTargetTexture();
138 // temp_image will not be a snapshot, so we must make a copy of it to
139 // satisfy the demands of the "SnapshotToImage" API.
140 auto temp_image = impeller::DlImageImpeller::Make(texture);
141
142 // Make a temporary "image surface" into which we can copy our current
143 // texture so that we can return a stable snapshot DlImage from the copy.
145 context_, temp_image->width(), temp_image->height(),
146 DlSurfaceProvider::PixelFormat::kN32Premul);
147
148 // Copy the temp_image made from our texture into the image surface.
149 image_surface->GetCanvas()->DrawImage(temp_image, DlPoint(0, 0),
151 image_surface->FlushSubmitCpuSync();
152
153 // Return an image based on the temporary, but stable, image_surface's
154 // texture.
156 image_surface->GetRenderTarget().GetRenderTargetTexture());
157}
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 126 of file dl_test_surface_instance_impeller.cc.

127 {
128 std::shared_ptr<impeller::Context> context = aiks_context_.GetContext();
129 std::unique_ptr<impeller::testing::Screenshot> snapshot =
131 context, GetRenderTarget().GetRenderTargetTexture());
132 return snapshot ? std::make_unique<DlImpellerPixelData>(std::move(snapshot))
133 : nullptr;
134}
std::shared_ptr< Context > GetContext() const
static std::unique_ptr< Screenshot > MakeScreenshot(std::shared_ptr< Context > &context, const std::shared_ptr< Texture > &texture)

References context, impeller::AiksContext::GetContext(), and impeller::testing::Screenshotter::MakeScreenshot().

◆ width()

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

The width of the underlying surface.

Implements flutter::testing::DlSurfaceInstance.

Definition at line 163 of file dl_test_surface_instance_impeller.cc.

163 {
164 return GetRenderTarget().GetRenderTargetSize().width;
165}
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: