| Flutter Impeller |

Public Member Functions | Static Public Member Functions | List of all members
impeller::interop::Surface Class Referencefinal

`#include <surface.h>`

Inheritance diagram for impeller::interop::Surface:

## Public Member Functions
| Surface (Context &context, std::shared_ptr< impeller::Surface > surface)
| ~Surface () override
| Surface (const Surface &)=delete
Surface & | operator= (const Surface &)=delete
bool | IsValid () const
bool | DrawDisplayList (const DisplayList &dl) const
Public Member Functions inherited from impeller::interop::ObjectBase
| ObjectBase ()=default
virtual | ~ObjectBase ()=default
| ObjectBase (const ObjectBase &)=delete
| ObjectBase (ObjectBase &&)=delete
ObjectBase & | operator= (const ObjectBase &)=delete
ObjectBase & | operator= (ObjectBase &&)=delete
void | Retain ()
void | Release ()
uint64_t | GetRefCountForTests () const

## Static Public Member Functions
static ScopedObject< Surface > | WrapFBO (Context &context, uint64_t fbo, PixelFormat color_format, ISize size)
Static Public Member Functions inherited from impeller::interop::ObjectBase
static void | SafeRetain (void *ptr)
static void | SafeRelease (void *ptr)

## Additional Inherited Members
Public Types inherited from impeller::interop::Object< Surface, IMPELLER_INTERNAL_HANDLE_NAME(ImpellerSurface)>
using | InteropClass = Surface
using | InteropCSibling = IMPELLER_INTERNAL_HANDLE_NAME(ImpellerSurface)

## Detailed Description

Definition at line 18 of file surface.h.

## Constructor & Destructor Documentation

## ◆ Surface() [1/2]

impeller::interop::Surface::Surface | ( | Context & | context,
|  | std::shared_ptr< impeller::Surface > | surface
| ) |  |
| explicit

Definition at line 15 of file surface.cc.

16 : context_(Ref(&context)), surface_(std::move(surface)) {
17 is_valid_ =
18 context_ && context_->IsValid() && surface_ && surface_->IsValid();
19 }

## ◆ ~Surface()

impeller::interop::Surface::~Surface | ( |  | ) |
| override default

## ◆ Surface() [2/2]

impeller::interop::Surface::Surface | ( | const Surface & |  | ) |
| delete

## Member Function Documentation

## ◆ DrawDisplayList()

bool impeller::interop::Surface::DrawDisplayList | ( | const DisplayList & | dl | ) | const

Definition at line 52 of file surface.cc.

52 {
53 if (!IsValid() || !dl.IsValid()) {
54 return false;
55 }
56
57 auto display_list = dl.GetDisplayList();
58 auto& content_context = context_->GetAiksContext().GetContentContext();
59 auto render_target = surface_->GetRenderTarget();
60
61 const auto cull_rect = IRect::MakeSize(surface_->GetSize());
62 auto skia_cull_rect =
63 SkIRect::MakeWH(cull_rect.GetWidth(), cull_rect.GetHeight());
64
65 return RenderToOnscreen(content_context, render_target, display_list,
66 skia_cull_rect, /*reset_host_buffer=*/true);
67 }

References impeller::interop::DisplayList::GetDisplayList(), impeller::interop::DisplayList::IsValid(), IsValid(), impeller::TRect< T >::MakeSize(), and impeller::RenderToOnscreen().

## ◆ IsValid()

bool impeller::interop::Surface::IsValid | ( |  | ) | const

Definition at line 48 of file surface.cc.

48 {
49 return is_valid_;
50 }

Referenced by DrawDisplayList().

## ◆ operator=()

Surface& impeller::interop::Surface::operator= | ( | const Surface & |  | ) |
| delete

## ◆ WrapFBO()

ScopedObject< Surface > impeller::interop::Surface::WrapFBO | ( | Context & | context,
|  | uint64_t | fbo,
|  | PixelFormat | color_format,
|  | ISize | size
| ) |  |
| static

Definition at line 23 of file surface.cc.

26 {
27 if (context.GetContext()->GetBackendType() !=
28 impeller::Context::BackendType::kOpenGLES) {
29 VALIDATION_LOG << "Context is not OpenGL ES based.";
30 return nullptr;
31 }
32
33 auto impeller_surface = impeller::SurfaceGLES::WrapFBO(
34 context.GetContext(), []() { return true; }, fbo, color_format, size);
35 if (!impeller_surface || !impeller_surface->IsValid()) {
36 VALIDATION_LOG << "Could not wrap FBO as a surface";
37 return nullptr;
38 }
39
40 auto surface = Create<Surface>(context, std::move(impeller_surface));
41 if (!surface->IsValid()) {
42 VALIDATION_LOG << "Could not create valid surface.";
43 return nullptr;
44 }
45 return surface;
46 }

References impeller::interop::Context::GetContext(), impeller::Context::kOpenGLES, VALIDATION_LOG, and impeller::SurfaceGLES::WrapFBO().

Referenced by impeller::interop::ImpellerSurfaceCreateWrappedFBONew().

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

- impeller/toolkit/interop/surface.h
- impeller/toolkit/interop/surface.cc

impeller::RenderToOnscreen
bool RenderToOnscreen(ContentContext &context, RenderTarget render_target, const sk_sp< flutter::DisplayList > &display_list, SkIRect cull_rect, bool reset_host_buffer)
Render the provided display list to the render target.
Definition: dl_dispatcher.cc:1253
impeller::Context::BackendType::kOpenGLES
@ kOpenGLES
impeller::interop::Ref
ScopedObject< Object > Ref(Object *object)
Definition: object.h:145
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91
impeller::interop::Surface::IsValid
bool IsValid() const
Definition: surface.cc:48
impeller::TRect::MakeSize
constexpr static TRect MakeSize(const TSize< U > &size)
Definition: rect.h:150
impeller::SurfaceGLES::WrapFBO
static std::unique_ptr< Surface > WrapFBO(const std::shared_ptr< Context > &context, SwapCallback swap_callback, GLuint fbo, PixelFormat color_format, ISize fbo_size)
Definition: surface_gles.cc:14