Flutter Impeller
surface_control_impl.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 
9 
10 namespace impeller::android {
11 
13  const char* debug_name) {
14  if (window == nullptr) {
15  VALIDATION_LOG << "Parent window of surface was null.";
16  return;
17  }
18  if (debug_name == nullptr) {
19  debug_name = "Impeller Layer";
20  }
21  control_.reset(
22  GetProcTable().ASurfaceControl_createFromWindow(window, debug_name));
23 }
24 
26  if (IsValid() && !RemoveFromParent()) {
27  VALIDATION_LOG << "Surface control could not be removed from its parent. "
28  "Expect a leak.";
29  }
30 }
31 
33  return control_.is_valid();
34 }
35 
36 ASurfaceControl* SurfaceControlImpl::GetHandle() const {
37  return control_.get();
38 }
39 
41  if (!IsValid()) {
42  return false;
43  }
44  SurfaceTransaction transaction;
45  if (!transaction.SetParent(*this, nullptr)) {
46  return false;
47  }
48  return transaction.Apply();
49 }
50 
51 } // namespace impeller::android
SurfaceControlImpl(const SurfaceControlImpl &)=delete
ASurfaceControl * GetHandle() const override
bool RemoveFromParent() const override
Remove the surface control from the hierarchy of nodes presented by the system compositor.
A wrapper for ASurfaceTransaction. https://developer.android.com/ndk/reference/group/native-activity#...
bool Apply(OnCompleteCallback callback=nullptr)
Applies the updated encoded in the transaction and invokes the callback when the updated are complete...
bool SetParent(const SurfaceControl &control, const SurfaceControl *new_parent=nullptr)
Set the new parent control of the given control. If the new parent is null, it is removed from the co...
const ProcTable & GetProcTable()
Definition: proc_table.cc:12
#define VALIDATION_LOG
Definition: validation.h:91