Move shader function to its own TU

This commit is contained in:
Chinmay Garde
2021-05-22 18:01:55 -07:00
committed by Dan Field
parent 72471e7536
commit 799565a26d
5 changed files with 66 additions and 41 deletions

View File

@@ -18,6 +18,8 @@ impeller_component("compositor") {
"pipeline_library.mm",
"renderer.h",
"renderer.mm",
"shader_function.h",
"shader_function.mm",
"shader_library.h",
"shader_library.mm",
"surface.h",

View File

@@ -0,0 +1,41 @@
// 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.
#pragma once
#include <Metal/Metal.h>
#include "flutter/fml/hash_combine.h"
#include "flutter/fml/macros.h"
#include "impeller/compositor/comparable.h"
#include "impeller/shader_glue/shader_types.h"
namespace impeller {
class ShaderFunction : public Comparable<ShaderFunction> {
public:
virtual ~ShaderFunction();
ShaderStage GetStage() const;
id<MTLFunction> GetMTLFunction() const;
// Comparable<ShaderFunction>
std::size_t GetHash() const override;
// Comparable<ShaderFunction>
bool IsEqual(const ShaderFunction& other) const override;
private:
friend class ShaderLibrary;
id<MTLFunction> function_ = nullptr;
ShaderStage stage_;
ShaderFunction(id<MTLFunction> function, ShaderStage stage);
FML_DISALLOW_COPY_AND_ASSIGN(ShaderFunction);
};
} // namespace impeller

View File

@@ -0,0 +1,22 @@
// 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/compositor/shader_function.h"
namespace impeller {
ShaderFunction::ShaderFunction(id<MTLFunction> function, ShaderStage stage)
: function_(function), stage_(stage) {}
ShaderFunction::~ShaderFunction() = default;
id<MTLFunction> ShaderFunction::GetMTLFunction() const {
return function_;
}
ShaderStage ShaderFunction::GetStage() const {
return stage_;
}
} // namespace impeller

View File

@@ -11,40 +11,13 @@
#include <string_view>
#include <unordered_map>
#include "flutter/fml/hash_combine.h"
#include "flutter/fml/macros.h"
#include "impeller/compositor/comparable.h"
#include "impeller/shader_glue/shader_types.h"
#include "impeller/compositor/shader_function.h"
namespace impeller {
class Context;
class ShaderFunction : public Comparable<ShaderFunction> {
public:
virtual ~ShaderFunction();
ShaderStage GetStage() const;
id<MTLFunction> GetMTLFunction() const;
// Comparable<ShaderFunction>
std::size_t GetHash() const override;
// Comparable<ShaderFunction>
bool IsEqual(const ShaderFunction& other) const override;
private:
friend class ShaderLibrary;
id<MTLFunction> function_ = nullptr;
ShaderStage stage_;
ShaderFunction(id<MTLFunction> function, ShaderStage stage);
FML_DISALLOW_COPY_AND_ASSIGN(ShaderFunction);
};
class ShaderLibrary {
public:
~ShaderLibrary();

View File

@@ -6,19 +6,6 @@
namespace impeller {
ShaderFunction::ShaderFunction(id<MTLFunction> function, ShaderStage stage)
: function_(function), stage_(stage) {}
ShaderFunction::~ShaderFunction() = default;
id<MTLFunction> ShaderFunction::GetMTLFunction() const {
return function_;
}
ShaderStage ShaderFunction::GetStage() const {
return stage_;
}
ShaderLibrary::ShaderLibrary(id<MTLLibrary> library) : library_(library) {}
ShaderLibrary::~ShaderLibrary() = default;