cohtml.Net.Library

This class encapsulates the global Cohtml library.

Inherits from SystemIDisposable

Public Functions

Name
virtual voidDispose()
virtual voidStopWorkers()
Stops all work happening on auxiliary threads. The developer should call this to break the loops in ExecuteResourceWork and ExecuteLayoutWork and then eventually join the threads.
virtual global.System.IntPtrGetFeatureInterface(uint featureID)
Used for acquiring specific feature objects.
virtual voidExecuteWork(WorkType type, WorkExecutionMode mode, int family)
Executes Cohtml tasks. Some work in Cohtml has to happen asynchronously which improves performance and the scalability of the solution. The type of work is either Resources (loading, parsing, GC) or Layout. When new work is available, the user is notified through the OnWorkAvailable callback and should make sure that at some point that work is executed. The mode parameter is important to decide if you’ll only do some tasks (WEM_UntilQueueEmpty) or use it with a dedicated thread until the Library lives. Using a dedicated thread (WEM_UntilQuit) is simpler, but offers less control. This method can be called on any thread.
virtual voidExecuteWork(WorkType type, WorkExecutionMode mode)
Executes Cohtml tasks. Some work in Cohtml has to happen asynchronously which improves performance and the scalability of the solution. The type of work is either Resources (loading, parsing, GC) or Layout. When new work is available, the user is notified through the OnWorkAvailable callback and should make sure that at some point that work is executed. The mode parameter is important to decide if you’ll only do some tasks (WEM_UntilQueueEmpty) or use it with a dedicated thread until the Library lives. Using a dedicated thread (WEM_UntilQuit) is simpler, but offers less control. This method can be called on any thread.
virtual voidEnableProfiling(bool enabled, string file, uint level)
Start/Stop the emitting of internal profiling markers.
virtual global.System.IntPtrReservedMethod(global.System.IntPtr command, global.System.IntPtr data)
Reserved method for internal usage. Do not use.
virtual ScriptCompilerCreateScriptCompiler()
Creates new ScriptCompiler. Can be used to compile Script files and produce compiled data. Remember to Destroy the compiler instance when you no longer need it. Can return nullptr if not supported by the current scripting engine.
virtual GPUMemoryInfoGetGPUMemoryStats()
Get a struct with the GPU memory information for Cohtml resources. This is available only in a Developer configuration, and will return nullptr otherwise Call the Release() method on the returned GPUMemoryInfo to release the memory allocated for the data
virtual UserGPUMemoryInfoGetUserGPUMemoryStats()
Get a struct with the GPU memory information for user resources. This is available only in a Developer configuration, and will return nullptr otherwise Call the Release() method on the returned UserGPUMemoryInfo to release the memory allocated for the data
virtual voidResetGPUMemoryTrackerPeaks()
Resets all peaks tracked in the GPU memory tracker to the current state.
virtual UISystemCreateSystem(SystemSettings settings)
Create a Cohtml System that can hold multiple Views
LibraryInitialize(string licenseKey, LibraryParams libraryParams, IUnityPluginListener listener, string deviceModel)
Initializes the library with an externally initialized rendering library
stringGetDefaultUserAgent()
Get default User Agent string which can be used to reset view UA.
voidHintThreadUsage(WorkType type)
This hints Cohtml that the calling thread will be used for certain work. The call is optional and used for profiling purposes only. It is not necessary to call it in a final shipping environment.
voidDecodeURLString(string url, uint urlLen, string decoded, uint [] decodedSize)
Decodes a URL string substituting any URL-encoded characters (%20, %21 etc.) with their ASCII counterparts i.e. ‘my%20url.html’ -> ‘my url.html’.
stringGetBuildSDKVersion()
Get a string with the version of the SDK that has been used to build Cohtml library.
stringGetLibraryVersion()
Get a string with the version of the Cohtml library.
voidEnableCSSParserErrorLocations(bool enable)
When enabled, adds line, column and file to CSS parser errors at the cost of reduced CSS parsing performance. Enabled by default for Debug builds, disabled by default for Release builds.
LibraryInitialize(string licenseKey, LibraryParams arg1, IUnityPluginListener listener)
Initializes the library with an externally initialized rendering library
voidUninitialize()
Uninitializes the Cohtml library

Protected Attributes

Name
boolswigCMemOwn

Public Functions Documentation

function Dispose

virtual void Dispose()

function StopWorkers

virtual void StopWorkers()

Stops all work happening on auxiliary threads. The developer should call this to break the loops in ExecuteResourceWork and ExecuteLayoutWork and then eventually join the threads.

function GetFeatureInterface

virtual global.System.IntPtr GetFeatureInterface(
    uint featureID
)

Used for acquiring specific feature objects.

function ExecuteWork

virtual void ExecuteWork(
    WorkType type,
    WorkExecutionMode mode,
    int family
)

Executes Cohtml tasks. Some work in Cohtml has to happen asynchronously which improves performance and the scalability of the solution. The type of work is either Resources (loading, parsing, GC) or Layout. When new work is available, the user is notified through the OnWorkAvailable callback and should make sure that at some point that work is executed. The mode parameter is important to decide if you’ll only do some tasks (WEM_UntilQueueEmpty) or use it with a dedicated thread until the Library lives. Using a dedicated thread (WEM_UntilQuit) is simpler, but offers less control. This method can be called on any thread.

Parameters:

  • type Sets the work type to schedule. Layout work shouldn’t be executed if the UseDedicatedLayoutThread parameter is false. In that case the Layout will happen in the View.Advance calls.
  • mode Sets the mode to use in the Execution. Note that WEM_UntilQuit will not return until Cohtml itself is uninitialized.
  • family Sets the task family Layout work to execute. Each View has a task family that can be retrieved through View.GetTaskFamilyId. The parameter allows executing work for a specific View, you can also pass COHTML_ANY_TASK_FAMILY_ID, which will execute any Layout work available for all Views.

function ExecuteWork

virtual void ExecuteWork(
    WorkType type,
    WorkExecutionMode mode
)

Executes Cohtml tasks. Some work in Cohtml has to happen asynchronously which improves performance and the scalability of the solution. The type of work is either Resources (loading, parsing, GC) or Layout. When new work is available, the user is notified through the OnWorkAvailable callback and should make sure that at some point that work is executed. The mode parameter is important to decide if you’ll only do some tasks (WEM_UntilQueueEmpty) or use it with a dedicated thread until the Library lives. Using a dedicated thread (WEM_UntilQuit) is simpler, but offers less control. This method can be called on any thread.

Parameters:

  • type Sets the work type to schedule. Layout work shouldn’t be executed if the UseDedicatedLayoutThread parameter is false. In that case the Layout will happen in the View.Advance calls.
  • mode Sets the mode to use in the Execution. Note that WEM_UntilQuit will not return until Cohtml itself is uninitialized.

function EnableProfiling

virtual void EnableProfiling(
    bool enabled,
    string file,
    uint level
)

Start/Stop the emitting of internal profiling markers.

Parameters:

  • enabled Whether the profiling should be stopped or started
  • file If the profiling is done throught minitrace, the path for the JSON file where the profiling messages will be written to.
  • level The profiling level 1 or 2. 1 - enables only basic markers, 2 - enables all markers and can negatively impact performance but provides a lot of information

Note: The profiling can be enabled only in Development builds of Cohtml

function ReservedMethod

virtual global.System.IntPtr ReservedMethod(
    global.System.IntPtr command,
    global.System.IntPtr data
)

Reserved method for internal usage. Do not use.

function CreateScriptCompiler

virtual ScriptCompiler CreateScriptCompiler()

Creates new ScriptCompiler. Can be used to compile Script files and produce compiled data. Remember to Destroy the compiler instance when you no longer need it. Can return nullptr if not supported by the current scripting engine.

function GetGPUMemoryStats

virtual GPUMemoryInfo GetGPUMemoryStats()

Get a struct with the GPU memory information for Cohtml resources. This is available only in a Developer configuration, and will return nullptr otherwise Call the Release() method on the returned GPUMemoryInfo to release the memory allocated for the data

function GetUserGPUMemoryStats

virtual UserGPUMemoryInfo GetUserGPUMemoryStats()

Get a struct with the GPU memory information for user resources. This is available only in a Developer configuration, and will return nullptr otherwise Call the Release() method on the returned UserGPUMemoryInfo to release the memory allocated for the data

function ResetGPUMemoryTrackerPeaks

virtual void ResetGPUMemoryTrackerPeaks()

Resets all peaks tracked in the GPU memory tracker to the current state.

function CreateSystem

virtual UISystem CreateSystem(
    SystemSettings settings
)

Create a Cohtml System that can hold multiple Views

Parameters:

  • settings the system creation parameters

Return: a native Cohtml system object.

function Initialize

static Library Initialize(
    string licenseKey,
    LibraryParams libraryParams,
    IUnityPluginListener listener,
    string deviceModel
)

Initializes the library with an externally initialized rendering library

Parameters:

  • licenseKey license key provided by Coherent Labs
  • listener The Helper class providing plugin events.

Return: The created library object. Null if the operation is unsuccessful.

Note: you can have only one library active at a time. Use this only when you need to reuse the rendering library.

function GetDefaultUserAgent

static string GetDefaultUserAgent()

Get default User Agent string which can be used to reset view UA.

function HintThreadUsage

static void HintThreadUsage(
    WorkType type
)

This hints Cohtml that the calling thread will be used for certain work. The call is optional and used for profiling purposes only. It is not necessary to call it in a final shipping environment.

Parameters:

  • type Sets the work type of this thread.

function DecodeURLString

static void DecodeURLString(
    string url,
    uint urlLen,
    string decoded,
    uint [] decodedSize
)

Decodes a URL string substituting any URL-encoded characters (%20, %21 etc.) with their ASCII counterparts i.e. ‘my%20url.html’ -> ‘my url.html’.

Parameters:

  • url the url string to decode
  • urlLen the number of characters in the url
  • decoded pointer to the buffer where to copy the decoded string. Can be nullptr in order to query the size of the output
  • decodedSize the length of the decoded string, including the terminating null

function GetBuildSDKVersion

static string GetBuildSDKVersion()

Get a string with the version of the SDK that has been used to build Cohtml library.

Return: String with the version of the platform SDK

function GetLibraryVersion

static string GetLibraryVersion()

Get a string with the version of the Cohtml library.

Return: String with the version of the Cohtml library

function EnableCSSParserErrorLocations

static void EnableCSSParserErrorLocations(
    bool enable
)

When enabled, adds line, column and file to CSS parser errors at the cost of reduced CSS parsing performance. Enabled by default for Debug builds, disabled by default for Release builds.

function Initialize

static Library Initialize(
    string licenseKey,
    LibraryParams arg1,
    IUnityPluginListener listener
)

Initializes the library with an externally initialized rendering library

Parameters:

  • licenseKey license key provided by Coherent Labs
  • listener The Helper class providing plugin events.

Return: The created library object. Null if the operation is unsuccessful.

Note: you can have only one library active at a time. Use this only when you need to reuse the rendering library.

function Uninitialize

static void Uninitialize()

Uninitializes the Cohtml library

Warning: The last time you call this function you must call it with. Freeing the memory is usually done on application exit so all user allocations are cleared.

Protected Attributes Documentation

variable swigCMemOwn

bool swigCMemOwn;