Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
SkSL::Program Struct Reference

#include <SkSLProgram.h>

Classes

class  ElementsCollection
 

Public Types

using Interface = ProgramInterface
 

Public Member Functions

 Program (std::unique_ptr< std::string > source, std::unique_ptr< ProgramConfig > config, std::shared_ptr< Context > context, std::vector< std::unique_ptr< ProgramElement > > elements, std::unique_ptr< SymbolTable > symbols, std::unique_ptr< Pool > pool)
 
 ~Program ()
 
ElementsCollection elements () const
 
const FunctionDeclarationgetFunction (const char *functionName) const
 
std::string description () const
 
const ProgramUsageusage () const
 

Public Attributes

std::unique_ptr< std::string > fSource
 
std::unique_ptr< ProgramConfigfConfig
 
std::shared_ptr< ContextfContext
 
std::unique_ptr< ProgramUsagefUsage
 
std::unique_ptr< SymbolTablefSymbols
 
std::unique_ptr< PoolfPool
 
std::vector< std::unique_ptr< ProgramElement > > fOwnedElements
 
std::vector< const ProgramElement * > fSharedElements
 
ProgramInterface fInterface
 

Detailed Description

Represents a fully-digested program, ready for code generation.

Definition at line 65 of file SkSLProgram.h.

Member Typedef Documentation

◆ Interface

Definition at line 167 of file SkSLProgram.h.

Constructor & Destructor Documentation

◆ Program()

SkSL::Program::Program ( std::unique_ptr< std::string >  source,
std::unique_ptr< ProgramConfig config,
std::shared_ptr< Context context,
std::vector< std::unique_ptr< ProgramElement > >  elements,
std::unique_ptr< SymbolTable symbols,
std::unique_ptr< Pool pool 
)

Definition at line 22 of file SkSLProgram.cpp.

28 : fSource(std::move(source))
29 , fConfig(std::move(config))
30 , fContext(context)
31 , fSymbols(std::move(symbols))
32 , fPool(std::move(pool))
33 , fOwnedElements(std::move(elements)) {
35}
AutoreleasePool pool
SkBitmap source
Definition examples.cpp:28
std::unique_ptr< ProgramUsage > GetUsage(const Program &program)
std::vector< std::unique_ptr< ProgramElement > > fOwnedElements
ElementsCollection elements() const
std::shared_ptr< Context > fContext
std::unique_ptr< ProgramUsage > fUsage
std::unique_ptr< Pool > fPool
std::unique_ptr< SymbolTable > fSymbols
std::unique_ptr< std::string > fSource
std::unique_ptr< ProgramConfig > fConfig

◆ ~Program()

SkSL::Program::~Program ( )

Definition at line 37 of file SkSLProgram.cpp.

37 {
38 // Some or all of the program elements are in the pool. To free them safely, we must attach
39 // the pool before destroying any program elements. (Otherwise, we may accidentally call
40 // delete on a pooled node.)
41 AutoAttachPoolToThread attach(fPool.get());
42
43 fOwnedElements.clear();
44 fContext.reset();
45 fSymbols.reset();
46}

Member Function Documentation

◆ description()

std::string SkSL::Program::description ( ) const

Definition at line 48 of file SkSLProgram.cpp.

48 {
49 std::string result = fConfig->versionDescription();
50 for (const ProgramElement* e : this->elements()) {
51 result += e->description();
52 }
53 return result;
54}
GAsyncResult * result

◆ elements()

ElementsCollection SkSL::Program::elements ( ) const
inline

Iterates over all elements in this Program, both owned and shared (builtin). The iterator's value type is const ProgramElement*, so it's clear that you must not modify anything (as you might be mutating shared data).

Definition at line 140 of file SkSLProgram.h.

140{ return ElementsCollection(*this); }

◆ getFunction()

const FunctionDeclaration * SkSL::Program::getFunction ( const char *  functionName) const

Returns a function declaration with the given name; null is returned if the function doesn't exist or has no definition. If the function might have overloads, you can use nextOverload() to search for the function with the expected parameter list.

Definition at line 56 of file SkSLProgram.cpp.

56 {
57 const Symbol* symbol = fSymbols->find(functionName);
58 bool valid = symbol && symbol->is<FunctionDeclaration>() &&
59 symbol->as<FunctionDeclaration>().definition();
60 return valid ? &symbol->as<FunctionDeclaration>() : nullptr;
61}

◆ usage()

const ProgramUsage * SkSL::Program::usage ( ) const
inline

Definition at line 150 of file SkSLProgram.h.

150{ return fUsage.get(); }

Member Data Documentation

◆ fConfig

std::unique_ptr<ProgramConfig> SkSL::Program::fConfig

Definition at line 153 of file SkSLProgram.h.

◆ fContext

std::shared_ptr<Context> SkSL::Program::fContext

Definition at line 154 of file SkSLProgram.h.

◆ fInterface

ProgramInterface SkSL::Program::fInterface

Definition at line 165 of file SkSLProgram.h.

◆ fOwnedElements

std::vector<std::unique_ptr<ProgramElement> > SkSL::Program::fOwnedElements

Definition at line 161 of file SkSLProgram.h.

◆ fPool

std::unique_ptr<Pool> SkSL::Program::fPool

Definition at line 159 of file SkSLProgram.h.

◆ fSharedElements

std::vector<const ProgramElement*> SkSL::Program::fSharedElements

Definition at line 164 of file SkSLProgram.h.

◆ fSource

std::unique_ptr<std::string> SkSL::Program::fSource

Definition at line 152 of file SkSLProgram.h.

◆ fSymbols

std::unique_ptr<SymbolTable> SkSL::Program::fSymbols

Definition at line 158 of file SkSLProgram.h.

◆ fUsage

std::unique_ptr<ProgramUsage> SkSL::Program::fUsage

Definition at line 155 of file SkSLProgram.h.


The documentation for this struct was generated from the following files: