Flutter Engine
 
Loading...
Searching...
No Matches
surface.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
11
12namespace impeller::interop {
13
14Surface::Surface(Context& context, std::shared_ptr<impeller::Surface> surface)
15 : context_(Ref(&context)), surface_(std::move(surface)) {
16 is_valid_ =
17 context_ && context_->IsValid() && surface_ && surface_->IsValid();
18}
19
20Surface::~Surface() = default;
21
22bool Surface::IsValid() const {
23 return is_valid_;
24}
25
27 if (!IsValid() || !dl.IsValid()) {
28 return false;
29 }
30
31 auto display_list = dl.GetDisplayList();
32 auto& content_context = context_->GetAiksContext().GetContentContext();
33 auto render_target = surface_->GetRenderTarget();
34
35 const auto cull_rect = Rect::MakeSize(surface_->GetSize());
36
37 auto result = RenderToTarget(content_context, render_target, display_list,
38 cull_rect, /*reset_host_buffer=*/true);
39 context_->GetContext()->ResetThreadLocalState();
40 return result;
41}
42
43bool Surface::Present() const {
44 if (!IsValid()) {
45 return false;
46 }
47 return surface_->Present();
48}
49
50} // namespace impeller::interop
const sk_sp< flutter::DisplayList > GetDisplayList() const
Definition dl.cc:18
bool DrawDisplayList(const DisplayList &dl) const
Definition surface.cc:26
VkSurfaceKHR surface
Definition main.cc:65
EGLSurface surface_
ScopedObject< Object > Ref(Object *object)
Definition object.h:146
bool RenderToTarget(ContentContext &context, RenderTarget render_target, const sk_sp< flutter::DisplayList > &display_list, Rect cull_rect, bool reset_host_buffer, bool is_onscreen)
Render the provided display list to the render target.
Definition ref_ptr.h:261
static constexpr TRect MakeSize(const TSize< U > &size)
Definition rect.h:150