Flutter Engine
 
Loading...
Searching...
No Matches
context_mtl.mm
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
8#include "impeller/entity/mtl/entity_shaders.h"
9#include "impeller/entity/mtl/framebuffer_blend_shaders.h"
10#include "impeller/entity/mtl/modern_shaders.h"
12#include "impeller/renderer/mtl/compute_shaders.h"
13
14namespace impeller::interop {
15
16static std::vector<std::shared_ptr<fml::Mapping>>
18 return {std::make_shared<fml::NonOwnedMapping>(
19 impeller_entity_shaders_data, impeller_entity_shaders_length),
20 std::make_shared<fml::NonOwnedMapping>(
21 impeller_modern_shaders_data, impeller_modern_shaders_length),
22 std::make_shared<fml::NonOwnedMapping>(
23 impeller_framebuffer_blend_shaders_data,
24 impeller_framebuffer_blend_shaders_length),
25 std::make_shared<fml::NonOwnedMapping>(
26 impeller_compute_shaders_data, impeller_compute_shaders_length)};
27}
28
30 auto impeller_context =
32 std::make_shared<fml::SyncSwitch>(), //
33 "Impeller" //
34 );
35 if (!impeller_context) {
36 VALIDATION_LOG << "Could not create Impeller context.";
37 return {};
38 }
39 return Create(std::move(impeller_context));
40}
41
43 const std::shared_ptr<impeller::Context>& impeller_context) {
44 // Can't call Create because of private constructor. Adopt the raw pointer
45 // instead.
46 auto context = Adopt<Context>(new ContextMTL(impeller_context));
47 if (!context->IsValid()) {
48 VALIDATION_LOG << " Could not create valid context.";
49 return {};
50 }
51 return context;
52}
53
54ContextMTL::ContextMTL(const std::shared_ptr<impeller::Context>& context)
55 : Context(context),
56 swapchain_transients_(std::make_shared<SwapchainTransientsMTL>(
57 context->GetResourceAllocator())) {}
58
59ContextMTL::~ContextMTL() = default;
60
61const std::shared_ptr<SwapchainTransientsMTL>&
63 return swapchain_transients_;
64}
65
66} // namespace impeller::interop
static std::shared_ptr< ContextMTL > Create(const Flags &flags, const std::vector< std::string > &shader_library_paths, std::shared_ptr< const fml::SyncSwitch > is_gpu_disabled_sync_switch)
A cache for the onscreen texture attachments used in surface_mtl.
const std::shared_ptr< SwapchainTransientsMTL > & GetSwapchainTransients() const
static ScopedObject< Context > Create()
ContextMTL(const ContextMTL &)=delete
static std::vector< std::shared_ptr< fml::Mapping > > CreateShaderLibraryMappings()
Definition ref_ptr.h:261
#define VALIDATION_LOG
Definition validation.h:91