// Copyright 2013 The Flutter 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 "impeller/renderer/pipeline.h" #include #include "compute_pipeline_descriptor.h" #include "impeller/base/promise.h" #include "impeller/renderer/compute_pipeline_descriptor.h" #include "impeller/renderer/context.h" #include "impeller/renderer/pipeline_library.h" #include "pipeline_descriptor.h" namespace impeller { template Pipeline::Pipeline(std::weak_ptr library, T desc) : library_(std::move(library)), desc_(std::move(desc)) {} template Pipeline::~Pipeline() = default; PipelineFuture CreatePipelineFuture( const Context& context, std::optional desc) { if (!context.IsValid()) { return {desc, RealizedFuture>>( nullptr)}; } return context.GetPipelineLibrary()->GetPipeline(std::move(desc)); } PipelineFuture CreatePipelineFuture( const Context& context, std::optional desc) { if (!context.IsValid()) { return { desc, RealizedFuture>>( nullptr)}; } return context.GetPipelineLibrary()->GetPipeline(std::move(desc)); } template const T& Pipeline::GetDescriptor() const { return desc_; } template PipelineFuture Pipeline::CreateVariant( bool async, std::function descriptor_callback) const { if (!descriptor_callback) { return {std::nullopt, RealizedFuture>>(nullptr)}; } auto copied_desc = desc_; descriptor_callback(copied_desc); auto library = library_.lock(); if (!library) { VALIDATION_LOG << "The library from which this pipeline was created was " "already collected."; return {desc_, RealizedFuture>>(nullptr)}; } return library->GetPipeline(std::move(copied_desc), async); } template class Pipeline; template class Pipeline; } // namespace impeller