Move shader function to its own TU
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user