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

#include <dl_test_surface_instance_skia.h>

Inheritance diagram for flutter::testing::DlSurfaceInstanceSkiaBase:
flutter::testing::DlSurfaceInstance flutter::testing::DlMetalSurfaceInstance flutter::testing::DlSurfaceInstanceSkia

Public Member Functions

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.
 
sk_sp< SkSurface > sk_surface () override
 
- Public Member Functions inherited from flutter::testing::DlSurfaceInstance
virtual ~DlSurfaceInstance ()=default
 
DlISize GetSize () const
 The size of the underlying surface.
 

Protected Member Functions

 DlSurfaceInstanceSkiaBase ()
 
virtual ~DlSurfaceInstanceSkiaBase ()
 
virtual sk_sp< SkSurface > GetSurface () const =0
 

Detailed Description

Definition at line 13 of file dl_test_surface_instance_skia.h.

Constructor & Destructor Documentation

◆ DlSurfaceInstanceSkiaBase()

flutter::testing::DlSurfaceInstanceSkiaBase::DlSurfaceInstanceSkiaBase ( )
explicitprotected

Definition at line 99 of file dl_test_surface_instance_skia.cc.

99{}

◆ ~DlSurfaceInstanceSkiaBase()

flutter::testing::DlSurfaceInstanceSkiaBase::~DlSurfaceInstanceSkiaBase ( )
protectedvirtualdefault

Member Function Documentation

◆ Clear()

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

Clear the entire surface to the indicated color.

Implements flutter::testing::DlSurfaceInstance.

Definition at line 108 of file dl_test_surface_instance_skia.cc.

108 {
109 GetCanvas()->Clear(color);
110}
void Clear(DlColor color)
Definition dl_canvas.h:104

References flutter::DlCanvas::Clear(), and GetCanvas().

◆ FlushSubmitCpuSync()

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

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

Implements flutter::testing::DlSurfaceInstance.

Definition at line 125 of file dl_test_surface_instance_skia.cc.

125 {
126 auto surface = GetSurface();
127 if (!surface) {
128 return;
129 }
130 if (GrDirectContext* dContext =
131 GrAsDirectContext(surface->recordingContext())) {
132 dContext->flushAndSubmit(surface.get(), GrSyncCpu::kYes);
133 }
134 adapter_.canvas()->restoreToCount(0);
135 adapter_.canvas()->save();
136}
virtual sk_sp< SkSurface > GetSurface() const =0
VkSurfaceKHR surface
Definition main.cc:65

References flutter::DlSkCanvasAdapter::canvas(), GetSurface(), and surface.

◆ GetCanvas()

DlCanvas * flutter::testing::DlSurfaceInstanceSkiaBase::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 112 of file dl_test_surface_instance_skia.cc.

112 {
113 if (adapter_.canvas() == nullptr) {
114 adapter_.set_canvas(GetSurface()->getCanvas());
115 adapter_.canvas()->save();
116 }
117 return &adapter_;
118}
void set_canvas(SkCanvas *canvas)

References flutter::DlSkCanvasAdapter::canvas(), GetSurface(), and flutter::DlSkCanvasAdapter::set_canvas().

Referenced by Clear(), and RenderDisplayList().

◆ GetSurface()

virtual sk_sp< SkSurface > flutter::testing::DlSurfaceInstanceSkiaBase::GetSurface ( ) const
protectedpure virtual

◆ height()

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

The height of the underlying surface.

Implements flutter::testing::DlSurfaceInstance.

Definition at line 167 of file dl_test_surface_instance_skia.cc.

167 {
168 return GetSurface()->height();
169}

References GetSurface().

◆ RenderDisplayList()

void flutter::testing::DlSurfaceInstanceSkiaBase::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 120 of file dl_test_surface_instance_skia.cc.

121 {
122 GetCanvas()->DrawDisplayList(display_list);
123}
virtual void DrawDisplayList(const sk_sp< DisplayList > display_list, DlScalar opacity=SK_Scalar1)=0

References flutter::DlCanvas::DrawDisplayList(), and GetCanvas().

◆ sk_surface()

sk_sp< SkSurface > flutter::testing::DlSurfaceInstanceSkiaBase::sk_surface ( )
inlineoverridevirtual

Return a pointer to an underlying SkSurface if the image instance has one. THIS METHOD IS DEPRECATED AND ONLY USED IN DL_RENDERING_UNITTESTS.

Reimplemented from flutter::testing::DlSurfaceInstance.

Definition at line 43 of file dl_test_surface_instance_skia.h.

43{ return GetSurface(); }

References GetSurface().

◆ SnapshotToFile()

bool flutter::testing::DlSurfaceInstanceSkiaBase::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 138 of file dl_test_surface_instance_skia.cc.

138 {
139 sk_sp<SkImage> raster = GetRasterImage();
140 if (!raster) {
141 return false;
142 }
143 sk_sp<SkData> data = SkPngEncoder::Encode(nullptr, raster.get(), {});
144 if (!data) {
145 return false;
146 }
147 fml::NonOwnedMapping mapping(static_cast<const uint8_t*>(data->data()),
148 data->size());
149 return WriteAtomically(OpenFixturesDirectory(), filename.c_str(), mapping);
150}
fml::UniqueFD OpenFixturesDirectory()
Opens the fixtures directory for the unit-test harness.
Definition testing.cc:22
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36
bool WriteAtomically(const fml::UniqueFD &base_directory, const char *file_name, const Mapping &mapping)

References flutter::data, and flutter::testing::OpenFixturesDirectory().

◆ SnapshotToImage()

sk_sp< DlImage > flutter::testing::DlSurfaceInstanceSkiaBase::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 159 of file dl_test_surface_instance_skia.cc.

159 {
160 return DlImageSkia::Make(GetRasterImage());
161}
static sk_sp< DlImage > Make(const SkImage *image)

References flutter::DlImageSkia::Make().

◆ SnapshotToPixelData()

std::unique_ptr< DlPixelData > flutter::testing::DlSurfaceInstanceSkiaBase::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 152 of file dl_test_surface_instance_skia.cc.

153 {
154 sk_sp<SkImage> raster = GetRasterImage();
155
156 return raster ? DlSkiaPixelData::MakeFromRasterImage(raster) : nullptr;
157}

◆ width()

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

The width of the underlying surface.

Implements flutter::testing::DlSurfaceInstance.

Definition at line 163 of file dl_test_surface_instance_skia.cc.

163 {
164 return GetSurface()->width();
165}

References GetSurface().


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