mirror of
https://github.com/encounter/engine.git
synced 2026-03-30 11:09:55 -07:00
796259c089
* Enable software rendering backend on android. Add "enable-software-rendering" flag. * Fix variable naming and threading.
82 lines
2.0 KiB
C++
82 lines
2.0 KiB
C++
// Copyright 2016 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/shell/platform/android/android_surface_vulkan.h"
|
|
|
|
#include <utility>
|
|
|
|
#include "flutter/shell/gpu/gpu_surface_vulkan.h"
|
|
#include "flutter/vulkan/vulkan_native_surface_android.h"
|
|
#include "lib/ftl/logging.h"
|
|
|
|
namespace shell {
|
|
|
|
AndroidSurfaceVulkan::AndroidSurfaceVulkan()
|
|
: proc_table_(ftl::MakeRefCounted<vulkan::VulkanProcTable>()) {}
|
|
|
|
AndroidSurfaceVulkan::~AndroidSurfaceVulkan() = default;
|
|
|
|
bool AndroidSurfaceVulkan::IsValid() const {
|
|
return proc_table_->HasAcquiredMandatoryProcAddresses();
|
|
}
|
|
|
|
void AndroidSurfaceVulkan::TeardownOnScreenContext() {
|
|
//
|
|
}
|
|
|
|
std::unique_ptr<Surface> AndroidSurfaceVulkan::CreateGPUSurface() {
|
|
if (!IsValid()) {
|
|
return nullptr;
|
|
}
|
|
|
|
if (!native_window_ || !native_window_->IsValid()) {
|
|
return nullptr;
|
|
}
|
|
|
|
auto vulkan_surface_android =
|
|
std::make_unique<vulkan::VulkanNativeSurfaceAndroid>(
|
|
native_window_->handle());
|
|
|
|
if (!vulkan_surface_android->IsValid()) {
|
|
return nullptr;
|
|
}
|
|
|
|
auto gpu_surface = std::make_unique<GPUSurfaceVulkan>(
|
|
proc_table_, std::move(vulkan_surface_android));
|
|
|
|
if (!gpu_surface->IsValid()) {
|
|
return nullptr;
|
|
}
|
|
|
|
if (!gpu_surface->Setup()) {
|
|
return nullptr;
|
|
}
|
|
|
|
return gpu_surface;
|
|
}
|
|
|
|
SkISize AndroidSurfaceVulkan::OnScreenSurfaceSize() const {
|
|
return native_window_ ? native_window_->GetSize() : SkISize::Make(0, 0);
|
|
}
|
|
|
|
bool AndroidSurfaceVulkan::OnScreenSurfaceResize(const SkISize& size) const {
|
|
return true;
|
|
}
|
|
|
|
bool AndroidSurfaceVulkan::ResourceContextMakeCurrent() {
|
|
return false;
|
|
}
|
|
|
|
void AndroidSurfaceVulkan::SetFlutterView(
|
|
const fml::jni::JavaObjectWeakGlobalRef& flutter_view) {}
|
|
|
|
bool AndroidSurfaceVulkan::SetNativeWindow(
|
|
ftl::RefPtr<AndroidNativeWindow> window,
|
|
PlatformView::SurfaceConfig config) {
|
|
native_window_ = std::move(window);
|
|
return native_window_ && native_window_->IsValid();
|
|
}
|
|
|
|
} // namespace shell
|