From 799565a26d92b1d8da05dc202a905de0c644219b Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Sat, 22 May 2021 18:01:55 -0700 Subject: [PATCH] Move shader function to its own TU --- .../impeller/impeller/compositor/BUILD.gn | 2 + .../impeller/compositor/shader_function.h | 41 +++++++++++++++++++ .../impeller/compositor/shader_function.mm | 22 ++++++++++ .../impeller/compositor/shader_library.h | 29 +------------ .../impeller/compositor/shader_library.mm | 13 ------ 5 files changed, 66 insertions(+), 41 deletions(-) create mode 100644 engine/src/flutter/impeller/impeller/compositor/shader_function.h create mode 100644 engine/src/flutter/impeller/impeller/compositor/shader_function.mm diff --git a/engine/src/flutter/impeller/impeller/compositor/BUILD.gn b/engine/src/flutter/impeller/impeller/compositor/BUILD.gn index 35aa61cd0b..a23f1db99e 100644 --- a/engine/src/flutter/impeller/impeller/compositor/BUILD.gn +++ b/engine/src/flutter/impeller/impeller/compositor/BUILD.gn @@ -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", diff --git a/engine/src/flutter/impeller/impeller/compositor/shader_function.h b/engine/src/flutter/impeller/impeller/compositor/shader_function.h new file mode 100644 index 0000000000..2adaf90b90 --- /dev/null +++ b/engine/src/flutter/impeller/impeller/compositor/shader_function.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 + +#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 { + public: + virtual ~ShaderFunction(); + + ShaderStage GetStage() const; + + id GetMTLFunction() const; + + // Comparable + std::size_t GetHash() const override; + + // Comparable + bool IsEqual(const ShaderFunction& other) const override; + + private: + friend class ShaderLibrary; + + id function_ = nullptr; + ShaderStage stage_; + + ShaderFunction(id function, ShaderStage stage); + + FML_DISALLOW_COPY_AND_ASSIGN(ShaderFunction); +}; + +} // namespace impeller diff --git a/engine/src/flutter/impeller/impeller/compositor/shader_function.mm b/engine/src/flutter/impeller/impeller/compositor/shader_function.mm new file mode 100644 index 0000000000..1a2653aaeb --- /dev/null +++ b/engine/src/flutter/impeller/impeller/compositor/shader_function.mm @@ -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 function, ShaderStage stage) + : function_(function), stage_(stage) {} + +ShaderFunction::~ShaderFunction() = default; + +id ShaderFunction::GetMTLFunction() const { + return function_; +} + +ShaderStage ShaderFunction::GetStage() const { + return stage_; +} + +} // namespace impeller diff --git a/engine/src/flutter/impeller/impeller/compositor/shader_library.h b/engine/src/flutter/impeller/impeller/compositor/shader_library.h index 1a96ebad00..06595e786d 100644 --- a/engine/src/flutter/impeller/impeller/compositor/shader_library.h +++ b/engine/src/flutter/impeller/impeller/compositor/shader_library.h @@ -11,40 +11,13 @@ #include #include -#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 { - public: - virtual ~ShaderFunction(); - - ShaderStage GetStage() const; - - id GetMTLFunction() const; - - // Comparable - std::size_t GetHash() const override; - - // Comparable - bool IsEqual(const ShaderFunction& other) const override; - - private: - friend class ShaderLibrary; - - id function_ = nullptr; - ShaderStage stage_; - - ShaderFunction(id function, ShaderStage stage); - - FML_DISALLOW_COPY_AND_ASSIGN(ShaderFunction); -}; - class ShaderLibrary { public: ~ShaderLibrary(); diff --git a/engine/src/flutter/impeller/impeller/compositor/shader_library.mm b/engine/src/flutter/impeller/impeller/compositor/shader_library.mm index 20b6f881ba..852bb88bf0 100644 --- a/engine/src/flutter/impeller/impeller/compositor/shader_library.mm +++ b/engine/src/flutter/impeller/impeller/compositor/shader_library.mm @@ -6,19 +6,6 @@ namespace impeller { -ShaderFunction::ShaderFunction(id function, ShaderStage stage) - : function_(function), stage_(stage) {} - -ShaderFunction::~ShaderFunction() = default; - -id ShaderFunction::GetMTLFunction() const { - return function_; -} - -ShaderStage ShaderFunction::GetStage() const { - return stage_; -} - ShaderLibrary::ShaderLibrary(id library) : library_(library) {} ShaderLibrary::~ShaderLibrary() = default;