Detailed Description

This helps 'render' elements from the DOM into a set of 3D meshes. It also performs things such as alignment and line packing.

Public Member Functions

 Renderman (WorldUI worldUI)
 Creates a new renderer for rendering in the world. More...
 
 Renderman ()
 Creates a new renderer and a new document. More...
 
 Renderman (ReflowDocument root)
 Creates a new renderer with the given document. More...
 
 Renderman (bool aot)
 Creates a renderman for use in the Editor with AOT compiling Nitro. More...
 
void SetInputMode (bool acceptInput)
 Called when the physics input mode changes. Ensures all batches in this renderer are on the correct new input mode. More...
 
void RelocateCollider ()
 Figures out where the box collider should be if we're in physics mode. More...
 
void IncreaseDepth ()
 Increases the current depth value. More...
 
void Destroy ()
 Destroys this renderman when it's no longer needed. More...
 
void SetupBatchGI (DisplayableProperty property, TextureAtlas graphics, TextureAtlas font)
 Sets up the current batch as a 'globally isolated' batch. This acts like a hybrid between isolated and shared. More...
 
void SetupBatch (DisplayableProperty property, TextureAtlas graphics, TextureAtlas font)
 Sets up the current batch based on the isolation settings requested by a property. More...
 
void AddBatch (UIBatch batch)
 Adds the given batch to the main linked list for processing. More...
 
LineBoxMeta BeginLines (RenderableData renderable, VirtualElements virts, LayoutBox box, bool autoWidth)
 Sets up this renderer so that it's ready to start packing child elements of a given element into lines. More...
 
void EndLines (LineBoxMeta lineZone, VirtualElements virts, LayoutBox box)
 Lets the renderer know that the given parent element has finished packing all of its kids. This allows alignment to occur next. More...
 
bool IsInvisible (float left, float top, float width, float height)
 Checks if the given box coordinates are outside the current clipping boundary. If they are, the box is considered invisible. More...
 
void SetBoundary (ComputedStyle computed, LayoutBox box)
 Sets the clipping boundary from the given computed style. More...
 
void ResetBoundary ()
 Resets the clipping boundary back to the whole screen. More...
 
void Reset ()
 Resets all values in the renderer. Called before each layout. More...
 
void RenderWithCamera (int id)
 Puts all batches of this renderer into the given unity layer. More...
 
void RequestLayout ()
 Asks the renderer to perform a layout next update. More...
 
void RequestUpdate (Css.RenderableData style, UpdateMode mode)
 Asks the renderer to perform a paint on the given style object next update. More...
 
void Update ()
 Update causes all changes to be applied and layouts to occur. More...
 
void PoolBoxes (LayoutBox firstBox, LayoutBox lastBox)
 Adds a linked list of boxes to the box pool. More...
 
LayoutBox PooledBox ()
 Gets a box from the pool or creates one. More...
 
void Layout ()
 Relocates all DOM elements by calculating their onscreen position. Each element may allocate sections of the 3D mesh (blocks) which are then flushed out into the unity mesh and onto the screen. More...
 
Vector3 PixelToWorldUnit (float px, float py, float depth)
 Converts the given screen coordinate to world coordinates. More...
 

Public Attributes

int RenderQueue =3000
 The starting offset for all batches. More...
 
float Depth =0f
 The current depth the rendering is occuring at. More...
 
float MaxDepth =0f
 The deepest element rendered so far. More...
 
bool DepthUsed
 Set to true when an element has been placed in the depth buffer. More...
 
UpdateMode HighestUpdateMode =UpdateMode.None
 The "highest" update mode used. More...
 
Color ColorOverlay =Color.white
 A colour that is applied over the top of this element. More...
 
Stack< RenderableDataFlowRootAncestors =new Stack<RenderableData>()
 The nearest outer block ancestors or inner flow root (block, inline-block, table etc). More...
 
Stack< RenderableDataPositionedAncestors =new Stack<RenderableData>()
 The nearest positioned (non 'static') ancestor. If this is null, use the viewport. More...
 
Stack< RenderableDataTransformedAncestors =new Stack<RenderableData>()
 The nearest transformed ancestor. If this is null, use the viewport. More...
 
TransformationStack Transformations =new TransformationStack()
 A stack of transformations to apply to elements. Updated during a layout event. More...
 
UIBatch CurrentBatch
 The batch that we are currently rendering to. More...
 
BoxRegion ClippingBoundary
 The active clipping boundary. Usually the bounds of the parent element. More...
 
int BatchDepth
 Essentially counts how many batches were issued. Used to define the render order. More...
 
float FontAliasingTop
 The current top font aliasing value. More...
 
float FontAliasingBottom
 The current bottom font aliasing value. More...
 
int RenderLayer
 The unity layer that all meshes should go into. More...
 
bool LayoutOccuring
 A flag which notes if the vital parts of a layout are occuring. During this, the DOM delays updates. More...
 
UIBatch LastBatch
 The tail of the batch linked list. More...
 
UIBatch FirstBatch
 The head of the batch linked list. More...
 
ReflowDocument RootDocument
 The base document being rendered. More...
 
float DepthResolution =0.05f
 How far apart along z elements are placed on the UI. More...
 
bool DoLayout
 True if a layout event was requested. More...
 
RenderableData StylesToUpdate
 The start of a linked list of styles that need to be painted. This linked list helps prevent layouts occuring as many updates only affect the appearance. More...
 
ElementStyle StylesToRecompute
 The start of a linked list of styles that need to be recomputed. More...
 
GameObject Node
 An optional gameobject to parent all content to. More...
 
bool ScreenClip =true
 True if the screen should clip this renderer. More...
 
WorldUI InWorldUI
 Used if this renderer is generating a UI in the game world (e.g. on a billboard). More...
 
int StallStatus
 Used to halt the renderer from rendering anything else of a child (or anything else of a document etc). More...
 
ShaderSet CurrentShaderSet
 The active shader set. Expected to never be null. More...
 
Transform PhysicsModeCollider
 The transform of a gameobject containing a cube collider. More...
 
MeshBlock Block
 A shared block used as an interface for reading/ writing from meshes. More...
 
int Segment =LineBoxSegment.All
 The segment to draw. Used by inline elements when they're drawing e.g. a border. More...
 
SparkInformerNode FirstInformer
 A list of 'active' informers. Used by special effects like first-line. More...
 
Stack< LineBoxMetaBoxStack =new Stack<LineBoxMeta>()
 The current stack of boxes that we're working on. More...
 
BlockBoxMeta LastBlockBox
 
InputGrid InputGrid =new InputGrid()
 A fast grid for input lookups. More...
 
BoxRegion ScreenViewport =new BoxRegion()
 The root screen viewport. More...
 
BoxRegion Viewport
 The current viewport. Note that this changes whenever a new document starts rendering (such as inside an iframe). More...
 
LayoutBox LastBoxPool
 A pool of layout boxes. More...
 
LayoutBox FirstBoxPool
 A pool of layout boxes. More...
 

Package Attributes

bool FullReflow
 True if this renderer is performing a complete reflow. More...
 
bool ViewportBackground
 True if we've handled the viewport background (originates from the first of either html or body). More...
 
SparkInformerNode FirstLetter
 The informer for the first-letter CSS selector. If it's not null then a text node will deal with it. More...
 
SparkInformerNode FirstLine
 The informer for the first-line CSS selector. More...
 
int CharacterIndex
 
LayoutBox CurrentBox
 
Color FontColour
 
BoxRegion CurrentRegion
 
float TopOffset
 
float TextScaleFactor
 
float TextAscender
 
float TextDepth
 

Properties

Transformation Transform [get]
 The active transformation. More...
 
bool RenderingInWorld [get]
 Is this a renderer for a WorldUI? More...
 
GameObject Parent [get]
 Gets the parent gameobject for this renderman, if there is one. More...
 
RenderMode RenderMode [get, set]
 How this renderman renders images; either on an atlas or with them 'as is'. More...
 
FilterMode FilterMode [get, set]
 The image filter mode. If you're using lots of WorldUI's or animations its best to have this on bilinear. More...
 
LineBoxMeta TopOfStack [get]
 The current box meta on the TOS. More...
 
LineBoxMeta TopOfStackSafe [get]
 The current box meta on the TOS. More...
 
RenderableData FlowRootAncestor [get]
 Nearest flow root. Null if you should use viewport. More...
 
RenderableData PositionedAncestor [get]
 Nearest positioned ancestor. Null if you should use viewport. More...
 
RenderableData TransformedAncestor [get]
 Nearest transformed ancestor. Null if you should use viewport. More...
 
float MaxX [get]
 The max Y value. Essentially the virtual screens width. More...
 
float MaxY [get]
 The max Y value. Essentially the virtual screens height. More...
 
int Layer [get, set]
 The layer to put this Renderer in. Simply an alias for RenderWithCamera. More...
 

Private Member Functions

void Init ()
 Sets up this renderman. More...
 

Private Attributes

FilterMode ImageFilterMode =FilterMode.Point
 The default filtering mode used by all images of this renderer. More...
 

Static Private Attributes

static RenderMode UIRenderMode =RenderMode.Atlas
 How this renderman renders images; either on an atlas or with them 'as is'. More...
 

Constructor & Destructor Documentation

Css.Renderman.Renderman ( WorldUI  worldUI)
inline

Creates a new renderer for rendering in the world.

Css.Renderman.Renderman ( )
inline

Creates a new renderer and a new document.

Css.Renderman.Renderman ( ReflowDocument  root)
inline

Creates a new renderer with the given document.

Css.Renderman.Renderman ( bool  aot)
inline

Creates a renderman for use in the Editor with AOT compiling Nitro.

Member Function Documentation

void Css.Renderman.AddBatch ( UIBatch  batch)
inline

Adds the given batch to the main linked list for processing.

LineBoxMeta Css.Renderman.BeginLines ( RenderableData  renderable,
VirtualElements  virts,
LayoutBox  box,
bool  autoWidth 
)
inline

Sets up this renderer so that it's ready to start packing child elements of a given element into lines.

Parameters
renderableThe parent render data whose children will be packed.
void Css.Renderman.Destroy ( )
inline

Destroys this renderman when it's no longer needed.

void Css.Renderman.EndLines ( LineBoxMeta  lineZone,
VirtualElements  virts,
LayoutBox  box 
)
inline

Lets the renderer know that the given parent element has finished packing all of its kids. This allows alignment to occur next.

Parameters
renderableThe element that is done packing.
void Css.Renderman.IncreaseDepth ( )
inline

Increases the current depth value.

void Css.Renderman.Init ( )
inlineprivate

Sets up this renderman.

bool Css.Renderman.IsInvisible ( float  left,
float  top,
float  width,
float  height 
)
inline

Checks if the given box coordinates are outside the current clipping boundary. If they are, the box is considered invisible.

Parameters
leftThe x coordinate of the left edge of the box in pixels from the left of the screen.
topThe y coordinate of the top edge of the box in pixels from the top edge of the screen.
widthThe width of the box.
heightThe height of the box (extends down the screen).
Returns
True if the box was outside the current clipping boundary.
void Css.Renderman.Layout ( )
inline

Relocates all DOM elements by calculating their onscreen position. Each element may allocate sections of the 3D mesh (blocks) which are then flushed out into the unity mesh and onto the screen.

Vector3 Css.Renderman.PixelToWorldUnit ( float  px,
float  py,
float  depth 
)
inline

Converts the given screen coordinate to world coordinates.

Parameters
pxThe screen x coordinate in pixels from the left.
pyThe screen y coordinate in pixels from the top.
depthThe z depth.
void Css.Renderman.PoolBoxes ( LayoutBox  firstBox,
LayoutBox  lastBox 
)
inline

Adds a linked list of boxes to the box pool.

LayoutBox Css.Renderman.PooledBox ( )
inline

Gets a box from the pool or creates one.

void Css.Renderman.RelocateCollider ( )
inline

Figures out where the box collider should be if we're in physics mode.

void Css.Renderman.RenderWithCamera ( int  id)
inline

Puts all batches of this renderer into the given unity layer.

Parameters
idThe ID of the unity layer.
void Css.Renderman.RequestLayout ( )
inline

Asks the renderer to perform a layout next update.

void Css.Renderman.RequestUpdate ( Css.RenderableData  style,
UpdateMode  mode 
)
inline

Asks the renderer to perform a paint on the given style object next update.

Parameters
styleThe style to paint.
void Css.Renderman.Reset ( )
inline

Resets all values in the renderer. Called before each layout.

void Css.Renderman.ResetBoundary ( )
inline

Resets the clipping boundary back to the whole screen.

void Css.Renderman.SetBoundary ( ComputedStyle  computed,
LayoutBox  box 
)
inline

Sets the clipping boundary from the given computed style.

Parameters
styleThe computed style to find the clipping boundary from.
void Css.Renderman.SetInputMode ( bool  acceptInput)
inline

Called when the physics input mode changes. Ensures all batches in this renderer are on the correct new input mode.

Parameters
modeThe new input mode to use.
void Css.Renderman.SetupBatch ( DisplayableProperty  property,
TextureAtlas  graphics,
TextureAtlas  font 
)
inline

Sets up the current batch based on the isolation settings requested by a property.

Parameters
propertyThe displayable property which wants the batch.
fontTextureThe font texture to use with this batch.
void Css.Renderman.SetupBatchGI ( DisplayableProperty  property,
TextureAtlas  graphics,
TextureAtlas  font 
)
inline

Sets up the current batch as a 'globally isolated' batch. This acts like a hybrid between isolated and shared.

Parameters
propertyThe displayable property which wants the batch.
fontTextureThe font texture to use with this batch.
void Css.Renderman.Update ( )
inline

Update causes all changes to be applied and layouts to occur.

Member Data Documentation

int Css.Renderman.BatchDepth

Essentially counts how many batches were issued. Used to define the render order.

MeshBlock Css.Renderman.Block

A shared block used as an interface for reading/ writing from meshes.

Stack<LineBoxMeta> Css.Renderman.BoxStack =new Stack<LineBoxMeta>()

The current stack of boxes that we're working on.

int Css.Renderman.CharacterIndex
package
BoxRegion Css.Renderman.ClippingBoundary

The active clipping boundary. Usually the bounds of the parent element.

Color Css.Renderman.ColorOverlay =Color.white

A colour that is applied over the top of this element.

UIBatch Css.Renderman.CurrentBatch

The batch that we are currently rendering to.

LayoutBox Css.Renderman.CurrentBox
package
BoxRegion Css.Renderman.CurrentRegion
package
ShaderSet Css.Renderman.CurrentShaderSet

The active shader set. Expected to never be null.

float Css.Renderman.Depth =0f

The current depth the rendering is occuring at.

float Css.Renderman.DepthResolution =0.05f

How far apart along z elements are placed on the UI.

bool Css.Renderman.DepthUsed

Set to true when an element has been placed in the depth buffer.

bool Css.Renderman.DoLayout

True if a layout event was requested.

UIBatch Css.Renderman.FirstBatch

The head of the batch linked list.

LayoutBox Css.Renderman.FirstBoxPool

A pool of layout boxes.

SparkInformerNode Css.Renderman.FirstInformer

A list of 'active' informers. Used by special effects like first-line.

SparkInformerNode Css.Renderman.FirstLetter
package

The informer for the first-letter CSS selector. If it's not null then a text node will deal with it.

SparkInformerNode Css.Renderman.FirstLine
package

The informer for the first-line CSS selector.

Stack<RenderableData> Css.Renderman.FlowRootAncestors =new Stack<RenderableData>()

The nearest outer block ancestors or inner flow root (block, inline-block, table etc).

float Css.Renderman.FontAliasingBottom

The current bottom font aliasing value.

float Css.Renderman.FontAliasingTop

The current top font aliasing value.

Color Css.Renderman.FontColour
package
bool Css.Renderman.FullReflow
package

True if this renderer is performing a complete reflow.

UpdateMode Css.Renderman.HighestUpdateMode =UpdateMode.None

The "highest" update mode used.

FilterMode Css.Renderman.ImageFilterMode =FilterMode.Point
private

The default filtering mode used by all images of this renderer.

InputGrid Css.Renderman.InputGrid =new InputGrid()

A fast grid for input lookups.

WorldUI Css.Renderman.InWorldUI

Used if this renderer is generating a UI in the game world (e.g. on a billboard).

UIBatch Css.Renderman.LastBatch

The tail of the batch linked list.

BlockBoxMeta Css.Renderman.LastBlockBox
LayoutBox Css.Renderman.LastBoxPool

A pool of layout boxes.

bool Css.Renderman.LayoutOccuring

A flag which notes if the vital parts of a layout are occuring. During this, the DOM delays updates.

float Css.Renderman.MaxDepth =0f

The deepest element rendered so far.

GameObject Css.Renderman.Node

An optional gameobject to parent all content to.

Transform Css.Renderman.PhysicsModeCollider

The transform of a gameobject containing a cube collider.

Stack<RenderableData> Css.Renderman.PositionedAncestors =new Stack<RenderableData>()

The nearest positioned (non 'static') ancestor. If this is null, use the viewport.

int Css.Renderman.RenderLayer

The unity layer that all meshes should go into.

int Css.Renderman.RenderQueue =3000

The starting offset for all batches.

ReflowDocument Css.Renderman.RootDocument

The base document being rendered.

bool Css.Renderman.ScreenClip =true

True if the screen should clip this renderer.

BoxRegion Css.Renderman.ScreenViewport =new BoxRegion()

The root screen viewport.

int Css.Renderman.Segment =LineBoxSegment.All

The segment to draw. Used by inline elements when they're drawing e.g. a border.

int Css.Renderman.StallStatus

Used to halt the renderer from rendering anything else of a child (or anything else of a document etc).

ElementStyle Css.Renderman.StylesToRecompute

The start of a linked list of styles that need to be recomputed.

RenderableData Css.Renderman.StylesToUpdate

The start of a linked list of styles that need to be painted. This linked list helps prevent layouts occuring as many updates only affect the appearance.

float Css.Renderman.TextAscender
package
float Css.Renderman.TextDepth
package
float Css.Renderman.TextScaleFactor
package
float Css.Renderman.TopOffset
package
TransformationStack Css.Renderman.Transformations =new TransformationStack()

A stack of transformations to apply to elements. Updated during a layout event.

Stack<RenderableData> Css.Renderman.TransformedAncestors =new Stack<RenderableData>()

The nearest transformed ancestor. If this is null, use the viewport.

RenderMode Css.Renderman.UIRenderMode =RenderMode.Atlas
staticprivate

How this renderman renders images; either on an atlas or with them 'as is'.

BoxRegion Css.Renderman.Viewport

The current viewport. Note that this changes whenever a new document starts rendering (such as inside an iframe).

bool Css.Renderman.ViewportBackground
package

True if we've handled the viewport background (originates from the first of either html or body).

Property Documentation

FilterMode Css.Renderman.FilterMode
getset

The image filter mode. If you're using lots of WorldUI's or animations its best to have this on bilinear.

RenderableData Css.Renderman.FlowRootAncestor
get

Nearest flow root. Null if you should use viewport.

int Css.Renderman.Layer
getset

The layer to put this Renderer in. Simply an alias for RenderWithCamera.

float Css.Renderman.MaxX
get

The max Y value. Essentially the virtual screens width.

float Css.Renderman.MaxY
get

The max Y value. Essentially the virtual screens height.

GameObject Css.Renderman.Parent
get

Gets the parent gameobject for this renderman, if there is one.

RenderableData Css.Renderman.PositionedAncestor
get

Nearest positioned ancestor. Null if you should use viewport.

bool Css.Renderman.RenderingInWorld
get

Is this a renderer for a WorldUI?

RenderMode Css.Renderman.RenderMode
getset

How this renderman renders images; either on an atlas or with them 'as is'.

LineBoxMeta Css.Renderman.TopOfStack
get

The current box meta on the TOS.

LineBoxMeta Css.Renderman.TopOfStackSafe
get

The current box meta on the TOS.

Transformation Css.Renderman.Transform
get

The active transformation.

RenderableData Css.Renderman.TransformedAncestor
get

Nearest transformed ancestor. Null if you should use viewport.