Flutter Engine
The Flutter Engine
Classes | Namespaces | Functions
SkRuntimeEffectPriv.h File Reference
#include "include/core/SkColor.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkString.h"
#include "include/effects/SkRuntimeEffect.h"
#include "include/private/SkSLSampleUsage.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkSpan_impl.h"
#include "include/private/base/SkTArray.h"
#include "src/core/SkEffectPriv.h"
#include "src/sksl/codegen/SkSLRasterPipelineBuilder.h"
#include <cstddef>
#include <cstdint>
#include <functional>
#include <memory>
#include "include/sksl/SkSLVersion.h"

Go to the source code of this file.

Classes

class  SkRuntimeEffectPriv
 
struct  SkRuntimeEffectPriv::UniformsCallbackContext
 
class  RuntimeEffectRPCallbacks
 

Namespaces

namespace  SkShaders
 
namespace  SkSL
 

Functions

sk_sp< SkRuntimeEffectSkMakeCachedRuntimeEffect (SkRuntimeEffect::Result(*make)(SkString sksl, const SkRuntimeEffect::Options &), SkString sksl)
 
sk_sp< SkRuntimeEffectSkMakeCachedRuntimeEffect (SkRuntimeEffect::Result(*make)(SkString, const SkRuntimeEffect::Options &), const char *sksl)
 
SkRuntimeEffectSkMakeRuntimeEffect (SkRuntimeEffect::Result(*make)(SkString, const SkRuntimeEffect::Options &), const char *sksl, SkRuntimeEffect::Options options=SkRuntimeEffect::Options{})
 

Function Documentation

◆ SkMakeCachedRuntimeEffect() [1/2]

sk_sp< SkRuntimeEffect > SkMakeCachedRuntimeEffect ( SkRuntimeEffect::Result(*)(SkString sksl, const SkRuntimeEffect::Options &)  make,
SkString  sksl 
)

Definition at line 680 of file SkRuntimeEffect.cpp.

682 {
683 static SkNoDestructor<SkMutex> mutex;
685
686 uint64_t key = SkChecksum::Hash64(sksl.c_str(), sksl.size());
687 {
688 SkAutoMutexExclusive _(*mutex);
689 if (sk_sp<SkRuntimeEffect>* found = cache->find(key)) {
690 return *found;
691 }
692 }
693
696
697 auto [effect, err] = make(std::move(sksl), options);
698 if (!effect) {
699 SkDEBUGFAILF("%s", err.c_str());
700 return nullptr;
701 }
702 SkASSERT(err.isEmpty());
703
704 {
705 SkAutoMutexExclusive _(*mutex);
706 cache->insert_or_update(key, effect);
707 }
708 return effect;
709}
const char * options
#define SkDEBUGFAILF(fmt,...)
Definition: SkAssert.h:119
#define SkASSERT(cond)
Definition: SkAssert.h:116
static void AllowPrivateAccess(SkRuntimeEffect::Options *options)
size_t size() const
Definition: SkString.h:131
const char * c_str() const
Definition: SkString.h:133
uint64_t Hash64(const void *data, size_t bytes, uint64_t seed)
Definition: SkChecksum.cpp:117
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
Definition: switches.h:191
static void make(SkBitmap *bitmap, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace)
Definition: encode_srgb.cpp:35

◆ SkMakeCachedRuntimeEffect() [2/2]

sk_sp< SkRuntimeEffect > SkMakeCachedRuntimeEffect ( SkRuntimeEffect::Result(*)(SkString, const SkRuntimeEffect::Options &)  make,
const char *  sksl 
)
inline

Definition at line 154 of file SkRuntimeEffectPriv.h.

156 {
158}
sk_sp< SkRuntimeEffect > SkMakeCachedRuntimeEffect(SkRuntimeEffect::Result(*make)(SkString sksl, const SkRuntimeEffect::Options &), SkString sksl)

◆ SkMakeRuntimeEffect()

SkRuntimeEffect * SkMakeRuntimeEffect ( SkRuntimeEffect::Result(*)(SkString, const SkRuntimeEffect::Options &)  make,
const char *  sksl,
SkRuntimeEffect::Options  options = SkRuntimeEffect::Options{} 
)
inline

Definition at line 163 of file SkRuntimeEffectPriv.h.

166 {}) {
167#if defined(SK_DEBUG)
168 // Our SKSL snippets we embed in Skia should not have comments or excess indentation.
169 // Removing them helps trim down code size and speeds up parsing
170 if (SkStrContains(sksl, "//") || SkStrContains(sksl, " ")) {
171 SkDEBUGFAILF("Found SkSL snippet that can be minified: \n %s\n", sksl);
172 }
173#endif
175 auto result = make(SkString{sksl}, options);
176 if (!result.effect) {
177 SK_ABORT("%s", result.errorText.c_str());
178 }
179 return result.effect.release();
180}
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
static bool SkStrContains(const char string[], const char substring[])
Definition: SkString.h:53
GAsyncResult * result