Skip to content

Commit

Permalink
Renamed filter input to source0 for consistency; fixed a rare InfiniT…
Browse files Browse the repository at this point in the history
…ext incorrect array length issue; Fixed an occasional uv size exception; caret no longer shows up in sometimes random locations (fixes issue Kulestar#1)
  • Loading branch information
Bablakeluke committed Feb 5, 2017
1 parent ea93664 commit d3b6c01
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Assets/PowerUI/Source/Blaze
Submodule Blaze updated from d83614 to 1dbd60
2 changes: 1 addition & 1 deletion Assets/PowerUI/Source/Engine/FixedSizeBuffer.cs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
//--------------------------------------// PowerUI//// For documentation or // if you have any issues, visit// powerUI.kulestar.com//// Copyright © 2013 Kulestar Ltd// www.kulestar.com//--------------------------------------using System;using System.Collections;using System.Collections.Generic;namespace PowerUI{ /// <summary> /// A special type of array which is made up of a set of 'blocks'. /// Each block consists of a fixed amount of type T elements. /// This fixed amount is the block size. /// It regulates an internal array and only resizes when necessary. /// Example usage: <see cref="PowerUI.DynamicMesh.Vertices"/> /// For example, A block size of 4 (e.g. 4 vertices in a square) and a /// block count of 3 generates a 12 element array. /// </summary> public class FixedSizeBuffer<T>{ /// <summary>The output array.</summary> public T[] Buffer; /// <summary>Should this buffer clear?</summary> private bool Clear; /// <summary>How many T typed objects make up a 'block' in our buffer.</summary> public int BlockSize; /// <summary>How many blocks are currently in the buffer.</summary> public int BlockCount; /// <summary>Creates a new buffer with the given block size - that's /// how many T elements form a block.</summary> public FixedSizeBuffer(int blockSize){ BlockSize=blockSize; } /// <summary>Creates a new buffer with the given block size - that's /// how many T elements form a block.</summary> public FixedSizeBuffer(int blockSize,bool clear){ BlockSize=blockSize; Clear=clear; } /// <summary>Resizes the buffer to make sure the given amount of blocks will fit.</summary> /// <param name="blockCount">How many blocks we want in the buffer.</param> public void Resize(int blockCount){ if(BlockCount==blockCount && Buffer!=null){ return; } BlockCount=blockCount; int newSize=BlockSize*blockCount; if(Buffer!=null && newSize<Buffer.Length){ if(Clear){ // Clear the section of the array: Array.Clear(Buffer,newSize,Buffer.Length-newSize); } return; } Buffer=new T[newSize]; } } }
//--------------------------------------// PowerUI//// For documentation or // if you have any issues, visit// powerUI.kulestar.com//// Copyright © 2013 Kulestar Ltd// www.kulestar.com//--------------------------------------using System;using System.Collections;using System.Collections.Generic;namespace PowerUI{ /// <summary> /// A special type of array which is made up of a set of 'blocks'. /// Each block consists of a fixed amount of type T elements. /// This fixed amount is the block size. /// It regulates an internal array and only resizes when necessary. /// Example usage: <see cref="PowerUI.DynamicMesh.Vertices"/> /// For example, A block size of 4 (e.g. 4 vertices in a square) and a /// block count of 3 generates a 12 element array. /// </summary> public class FixedSizeBuffer<T>{ /// <summary>The output array.</summary> public T[] Buffer; /// <summary>Should this buffer clear?</summary> private bool Clear; /// <summary>How many T typed objects make up a 'block' in our buffer.</summary> public int BlockSize; /// <summary>How many blocks are currently in the buffer.</summary> public int BlockCount; /// <summary>Creates a new buffer with the given block size - that's /// how many T elements form a block.</summary> public FixedSizeBuffer(int blockSize){ BlockSize=blockSize; } /// <summary>Creates a new buffer with the given block size - that's /// how many T elements form a block.</summary> public FixedSizeBuffer(int blockSize,bool clear){ BlockSize=blockSize; Clear=clear; } /// <summary>Resizes the buffer so it matches the given length.</summary> public void ResizeMatch(int blockCount,int length){ if(Buffer!=null && Buffer.Length==length){ return; } // Update blocks: BlockCount=blockCount; // Create it now: Buffer=new T[length]; } /// <summary>Resizes the buffer to make sure the given amount of blocks will fit.</summary> /// <param name="blockCount">How many blocks we want in the buffer.</param> public void Resize(int blockCount){ if(BlockCount==blockCount && Buffer!=null){ return; } BlockCount=blockCount; int newSize=BlockSize*blockCount; if(Buffer!=null && newSize<Buffer.Length){ if(Clear){ // Clear the section of the array: Array.Clear(Buffer,newSize,Buffer.Length-newSize); } return; } Buffer=new T[newSize]; } } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void SetFilter(Loonim.SurfaceTexture tex){
if(Renderer!=null){

// Update it now:
Filter.Set("source1",Renderer.Texture);
Filter.Set("source0",Renderer.Texture);

// Note that the next draw will update Output for us.

Expand Down Expand Up @@ -174,7 +174,7 @@ private void UpdateRenderer(LayoutBox box,float width,float height){

}else{

Filter.Set("source1",Renderer.Texture);
Filter.Set("source0",Renderer.Texture);
// Output will be updated shortly.

// Always mark as changed:
Expand Down Expand Up @@ -261,7 +261,7 @@ internal override void Layout(LayoutBox box,Renderman renderer){

if(Filter!=null){
// Set source:
Filter.Set("source1",Renderer.Texture);
Filter.Set("source0",Renderer.Texture);
}

// Grab the output texture:
Expand Down
6 changes: 3 additions & 3 deletions Assets/PowerUI/Source/Engine/Loonim Extension/sparkFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void BuildFilter(Css.Value value,RenderableData context,FilterEven
if(value is Css.Functions.UrlFunction){

// - (A URL to an SVG filter) (not supported yet here)
// - A URL to a Loonim filter (with a property called source1)
// - A URL to a Loonim filter (with a property called source0)

// Load it now!
DataPackage dp=new DataPackage(value.Text,context.Document.basepath);
Expand Down Expand Up @@ -105,9 +105,9 @@ public static void BuildFilter(Css.Value value,RenderableData context,FilterEven

// Create the texture:
st=new SurfaceTexture();
st["source1"]=new Values.TextureValue(null);
st["source0"]=new Values.TextureValue(null);
st.Root=first;
first.Sources[0]=new Loonim.Property(st,"source1");
first.Sources[0]=new Loonim.Property(st,"source0");
}

// Run the callback now!
Expand Down
22 changes: 12 additions & 10 deletions Assets/PowerUI/Source/Engine/Rendering/DynamicMesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,20 +277,20 @@ public void CompletedLayout(){
// We gained or lost some blocks - resize our buffers:
UV.Resize(total);
UV2.Resize(total);

if(Normals!=null){
Normals.Resize(total);
}

if(UV3!=null){
UV3.Resize(total);
}

Colours.Resize(total);
Vertices.Resize(total);
Triangles.Resize(total);
}

// Always make sure UV3 and Normals are valid:
if(Normals!=null){
Normals.ResizeMatch(total,Vertices.Buffer.Length);
}

if(UV3!=null){
UV3.ResizeMatch(total,Vertices.Buffer.Length);
}

LastBlockCount=total;

// Flatten now:
Expand Down Expand Up @@ -399,7 +399,9 @@ public void Flush(){
OutputMesh.vertices=Vertices.Buffer;
OutputMesh.colors=Colours.Buffer;

if(UV3!=null){
if(UV3==null){
OutputMesh.uv3=null;
}else{
OutputMesh.uv3=UV3.Buffer;
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/PowerUI/Source/Engine/Tags/caret.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class HtmlCaretElement:HtmlElement{
/// <summary>Text index of the caret.</summary>
public int Index;
/// <summary>True if the caret should be relocated after the next update.</summary>
public bool Locate;
public bool Locate=true;


/// <summary>The host input element. Either a textarea or input.</summary>
Expand Down

0 comments on commit d3b6c01

Please sign in to comment.