blob: 7a3fdb59859711549b6495b2b08ddc6b8cc6e2c8 [file] [log] [blame]
* Copyright 2019 Google LLC
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
#include "include/private/SkSLSymbol.h"
#include "src/core/SkVM.h"
namespace SkSL {
class Type;
class ExternalFunction : public Symbol {
inline static constexpr Kind kIRNodeKind = Kind::kExternal;
ExternalFunction(const char* name, const Type& type)
: INHERITED(Position(), kIRNodeKind, name, &type) {}
virtual int callParameterCount() const = 0;
* Fills in the outTypes array with pointers to the parameter types. outTypes must be able to
* hold callParameterCount() pointers.
virtual void getCallParameterTypes(const Type** outTypes) const = 0;
virtual void call(skvm::Builder* builder,
skvm::F32* arguments,
skvm::F32* outResult,
skvm::I32 mask) const = 0;
std::string description() const override {
return "external<" + std::string(this->name()) + ">";
// Disable IRNode pooling on external function nodes. ExternalFunction node lifetimes are
// controlled by the calling code; we can't guarantee that they will be destroyed before a
// Program is freed. (In fact, it's very unlikely that they would be.)
static void* operator new(const size_t size) {
return ::operator new(size);
static void operator delete(void* ptr) {
::operator delete(ptr);
using INHERITED = Symbol;
} // namespace SkSL