mirror of
https://gitee.com/csharpui/CPF.git
synced 2025-06-28 13:16:22 +08:00
解决GLView显示的问题
This commit is contained in:
parent
0b613adc2c
commit
23289bbf15
@ -18,19 +18,27 @@ namespace CPF.Skia
|
|||||||
int DepthRenderBuffer;
|
int DepthRenderBuffer;
|
||||||
Size oldSize;
|
Size oldSize;
|
||||||
SKImage image;
|
SKImage image;
|
||||||
|
SKPaint paint;
|
||||||
|
GRBackendTexture backendTexture;
|
||||||
|
|
||||||
//IGlContext context;
|
//IGlContext context;
|
||||||
protected unsafe override void OnRender(DrawingContext dc)
|
protected unsafe override void OnRender(DrawingContext dc)
|
||||||
{
|
{
|
||||||
var size1 = ActualSize;
|
var cSize = ActualSize;
|
||||||
if (size1.Width <= 0 || size1.Height <= 0 || DesignMode)
|
if (cSize.Width <= 0 || cSize.Height <= 0 || DesignMode)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var size = new PixelSize((int)Math.Round(size1.Width * Root.RenderScaling), (int)Math.Round(size1.Height * Root.RenderScaling));
|
var size = new PixelSize((int)Math.Round(cSize.Width * Root.RenderScaling), (int)Math.Round(cSize.Height * Root.RenderScaling));
|
||||||
var skia = dc as SkiaDrawingContext;
|
var skia = dc as SkiaDrawingContext;
|
||||||
var _gl = skia.GlContext;
|
var _gl = skia.GlContext;
|
||||||
|
if (paint == null)
|
||||||
|
{
|
||||||
|
paint = new SKPaint();
|
||||||
|
}
|
||||||
|
paint.IsAntialias = IsAntiAlias;
|
||||||
|
paint.FilterQuality = IsAntiAlias ? SKFilterQuality.Medium : SKFilterQuality.None;
|
||||||
|
|
||||||
if (Id == 0)
|
if (Id == 0)
|
||||||
{
|
{
|
||||||
@ -48,9 +56,9 @@ namespace CPF.Skia
|
|||||||
|
|
||||||
OnGLLoaded(_gl);
|
OnGLLoaded(_gl);
|
||||||
}
|
}
|
||||||
if (size1 != oldSize)
|
if (cSize != oldSize)
|
||||||
{
|
{
|
||||||
oldSize = size1;
|
oldSize = cSize;
|
||||||
|
|
||||||
_gl.BindTexture(GlConsts.GL_TEXTURE_2D, ColorBuffer);
|
_gl.BindTexture(GlConsts.GL_TEXTURE_2D, ColorBuffer);
|
||||||
_gl.TexImage2D(GlConsts.GL_TEXTURE_2D, 0, GlConsts.GL_RGBA, (int)size.Width, (int)size.Height, 0, GlConsts.GL_RGB, GlConsts.GL_UNSIGNED_BYTE, IntPtr.Zero);
|
_gl.TexImage2D(GlConsts.GL_TEXTURE_2D, 0, GlConsts.GL_RGBA, (int)size.Width, (int)size.Height, 0, GlConsts.GL_RGB, GlConsts.GL_UNSIGNED_BYTE, IntPtr.Zero);
|
||||||
@ -73,7 +81,11 @@ namespace CPF.Skia
|
|||||||
{
|
{
|
||||||
image.Dispose();
|
image.Dispose();
|
||||||
}
|
}
|
||||||
GRBackendTexture backendTexture = new GRBackendTexture((int)(size.Width / Root.RenderScaling), (int)(size.Height / Root.RenderScaling), false, new GRGlTextureInfo(0x0DE1, (uint)ColorBuffer, SKColorType.Rgba8888.ToGlSizedFormat()));
|
if (backendTexture != null)
|
||||||
|
{
|
||||||
|
backendTexture.Dispose();
|
||||||
|
}
|
||||||
|
backendTexture = new GRBackendTexture((int)(size.Width), (int)(size.Height), false, new GRGlTextureInfo(0x0DE1, (uint)ColorBuffer, SKColorType.Rgba8888.ToGlSizedFormat()));
|
||||||
|
|
||||||
image = SKImage.FromTexture((GRContext)skia.GlContext.GRContext, backendTexture, GRSurfaceOrigin.BottomLeft, SKColorType.Rgba8888);
|
image = SKImage.FromTexture((GRContext)skia.GlContext.GRContext, backendTexture, GRSurfaceOrigin.BottomLeft, SKColorType.Rgba8888);
|
||||||
}
|
}
|
||||||
@ -84,7 +96,9 @@ namespace CPF.Skia
|
|||||||
_gl.Viewport(0, 0, (int)size.Width, (int)size.Height);
|
_gl.Viewport(0, 0, (int)size.Width, (int)size.Height);
|
||||||
OnGLRender(_gl);
|
OnGLRender(_gl);
|
||||||
_gl.Viewport((int)vp[0], (int)vp[1], (int)vp[2], (int)vp[3]);
|
_gl.Viewport((int)vp[0], (int)vp[1], (int)vp[2], (int)vp[3]);
|
||||||
skia.SKCanvas.DrawImage(image, 0, 0);
|
_gl.BindFramebuffer(GlConsts.GL_FRAMEBUFFER, 0);
|
||||||
|
//_gl.Flush();
|
||||||
|
skia.SKCanvas.DrawImage(image, new SKRect(0, 0, size.Width, size.Height), new SKRect(0, 0, cSize.Width, cSize.Height), paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -117,12 +131,23 @@ namespace CPF.Skia
|
|||||||
OpenglEx.DeleteFramebuffers(null, 1, new int[] { Id });
|
OpenglEx.DeleteFramebuffers(null, 1, new int[] { Id });
|
||||||
OpenglEx.DeleteTextures(null, 1, new int[] { ColorBuffer });
|
OpenglEx.DeleteTextures(null, 1, new int[] { ColorBuffer });
|
||||||
OpenglEx.DeleteRenderbuffers(null, 1, new int[] { DepthRenderBuffer });
|
OpenglEx.DeleteRenderbuffers(null, 1, new int[] { DepthRenderBuffer });
|
||||||
|
Id = 0;
|
||||||
}
|
}
|
||||||
if (image != null)
|
if (image != null)
|
||||||
{
|
{
|
||||||
image.Dispose();
|
image.Dispose();
|
||||||
image = null;
|
image = null;
|
||||||
}
|
}
|
||||||
|
if (paint != null)
|
||||||
|
{
|
||||||
|
paint.Dispose();
|
||||||
|
paint = null;
|
||||||
|
}
|
||||||
|
if (backendTexture != null)
|
||||||
|
{
|
||||||
|
backendTexture.Dispose();
|
||||||
|
backendTexture = null;
|
||||||
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,6 +158,6 @@ namespace CPF.Skia
|
|||||||
{
|
{
|
||||||
Context = gl;
|
Context = gl;
|
||||||
}
|
}
|
||||||
public IGlContext Context { get;private set; }
|
public IGlContext Context { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,6 +156,11 @@ namespace CPF.Skia
|
|||||||
surface.Dispose();
|
surface.Dispose();
|
||||||
surface = null;
|
surface = null;
|
||||||
}
|
}
|
||||||
|
if (gRContext != null)
|
||||||
|
{
|
||||||
|
//gRContext.Flush();
|
||||||
|
gRContext.ResetContext();
|
||||||
|
}
|
||||||
//if (grContext != null)
|
//if (grContext != null)
|
||||||
//{
|
//{
|
||||||
// //grContext.Flush();
|
// //grContext.Flush();
|
||||||
@ -729,7 +734,7 @@ namespace CPF.Skia
|
|||||||
}
|
}
|
||||||
lines = newText.Split('\n');
|
lines = newText.Split('\n');
|
||||||
var ws = paint.Paint.MeasureAllChar(lines[0]);
|
var ws = paint.Paint.MeasureAllChar(lines[0]);
|
||||||
|
|
||||||
var wsEnd = new List<(string, float)>();
|
var wsEnd = new List<(string, float)>();
|
||||||
for (int i = ws.Count - 1; i >= 0; i--)
|
for (int i = ws.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
@ -742,7 +747,7 @@ namespace CPF.Skia
|
|||||||
{
|
{
|
||||||
//lenEnd = (lenEnd.Item1, lenEnd.Item2, newText.Substring(newText.Length - lenEnd.Item1, lenEnd.Item1));
|
//lenEnd = (lenEnd.Item1, lenEnd.Item2, newText.Substring(newText.Length - lenEnd.Item1, lenEnd.Item1));
|
||||||
lenEnd.Item3 = newText.Substring(newText.Length - lenEnd.Item1, lenEnd.Item1);
|
lenEnd.Item3 = newText.Substring(newText.Length - lenEnd.Item1, lenEnd.Item1);
|
||||||
if (lenEnd.Item3.Length>2)
|
if (lenEnd.Item3.Length > 2)
|
||||||
{
|
{
|
||||||
lenEnd.Item3 = lenEnd.Item3.Substring(1, lenEnd.Item3.Length - 1);
|
lenEnd.Item3 = lenEnd.Item3.Substring(1, lenEnd.Item3.Length - 1);
|
||||||
}
|
}
|
||||||
|
@ -226,15 +226,31 @@ namespace CPF
|
|||||||
BindingMode = bindingMode;
|
BindingMode = bindingMode;
|
||||||
}
|
}
|
||||||
internal Binding() { }
|
internal Binding() { }
|
||||||
|
/// <summary>
|
||||||
|
/// 多级绑定的属性集合
|
||||||
|
/// </summary>
|
||||||
|
string[] sourcePropertyNames;
|
||||||
internal bool IsDataContext = true;
|
internal bool IsDataContext = true;
|
||||||
|
|
||||||
|
string sourcePropertyName;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据源字段名
|
/// 数据源字段名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string SourcePropertyName
|
public string SourcePropertyName
|
||||||
{
|
{
|
||||||
get;
|
get { return sourcePropertyName; }
|
||||||
internal set;
|
internal set
|
||||||
|
{
|
||||||
|
sourcePropertyName = value;
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
sourcePropertyNames = SourcePropertyName.Split('.');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sourcePropertyNames = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 链式绑定下标
|
/// 链式绑定下标
|
||||||
@ -362,7 +378,7 @@ namespace CPF
|
|||||||
current.Push(this);
|
current.Push(this);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Source == null || !Source.IsAlive)
|
if (Source == null || !Source.IsAlive)
|
||||||
{
|
{
|
||||||
if (Owner.HasProperty(TargetPropertyName))
|
if (Owner.HasProperty(TargetPropertyName))
|
||||||
@ -389,8 +405,9 @@ namespace CPF
|
|||||||
value = Source.Target.GetPropretyValue(SourcePropertyName);
|
value = Source.Target.GetPropretyValue(SourcePropertyName);
|
||||||
}*/
|
}*/
|
||||||
value = GetPropertySource(SourcePropertyName, Source.Target);
|
value = GetPropertySource(SourcePropertyName, Source.Target);
|
||||||
if (value != null) {
|
if (value != null)
|
||||||
value = value.GetPropretyValue(SourcePropertyName.Split('.').LastOrDefault());
|
{
|
||||||
|
value = value.GetPropretyValue(sourcePropertyNames.LastOrDefault());
|
||||||
}
|
}
|
||||||
if (Convert != null)
|
if (Convert != null)
|
||||||
{
|
{
|
||||||
@ -456,7 +473,7 @@ namespace CPF
|
|||||||
{
|
{
|
||||||
if (!b.SetValue(nv, SourcePropertyName))
|
if (!b.SetValue(nv, SourcePropertyName))
|
||||||
{
|
{
|
||||||
/*var SourcePropertyNames = SourcePropertyName.Split('.');
|
/*var SourcePropertyNames = sourcePropertyNames;
|
||||||
if (SourcePropertyNames.Length == 1)
|
if (SourcePropertyNames.Length == 1)
|
||||||
{
|
{
|
||||||
b.SetValue(SourcePropertyName, nv);
|
b.SetValue(SourcePropertyName, nv);
|
||||||
@ -466,12 +483,13 @@ namespace CPF
|
|||||||
{
|
{
|
||||||
Target = Target.GetPropretyValue(SourcePropertyNames[i]) as CpfObject;
|
Target = Target.GetPropretyValue(SourcePropertyNames[i]) as CpfObject;
|
||||||
}*/
|
}*/
|
||||||
var SourcePropertyNames = SourcePropertyName.Split('.');
|
var SourcePropertyNames = sourcePropertyNames;
|
||||||
var Target = GetPropertySource(SourcePropertyName, b);
|
var Target = GetPropertySource(SourcePropertyName, b);
|
||||||
if (Target != null) {
|
if (Target != null)
|
||||||
|
{
|
||||||
Target.SetValue(SourcePropertyNames.LastOrDefault(), nv);
|
Target.SetValue(SourcePropertyNames.LastOrDefault(), nv);
|
||||||
}
|
}
|
||||||
|
|
||||||
//b.Type.GetProperty(SourcePropertyName).FastSetValue(b, nv);
|
//b.Type.GetProperty(SourcePropertyName).FastSetValue(b, nv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -551,7 +569,7 @@ namespace CPF
|
|||||||
}
|
}
|
||||||
void PropertyChanged(object sender, PropertyChangedEventArgs e)
|
void PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
var Temp_SourcePropertyName = SourcePropertyName.Split('.').LastOrDefault();
|
var Temp_SourcePropertyName = sourcePropertyNames.LastOrDefault();
|
||||||
if (Temp_SourcePropertyName == e.PropertyName)
|
if (Temp_SourcePropertyName == e.PropertyName)
|
||||||
{
|
{
|
||||||
//CPFObject s = sender as CPFObject;
|
//CPFObject s = sender as CPFObject;
|
||||||
@ -576,11 +594,11 @@ namespace CPF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal object GetPropertySource(string SourcePropertyName,object Source)
|
internal object GetPropertySource(string SourcePropertyName, object Source)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var SourcePropertyNames = SourcePropertyName.Split('.');
|
var SourcePropertyNames = sourcePropertyNames;
|
||||||
if (SourcePropertyNames.Length == 1)
|
if (SourcePropertyNames.Length == 1)
|
||||||
{
|
{
|
||||||
return Source;
|
return Source;
|
||||||
@ -610,7 +628,7 @@ namespace CPF
|
|||||||
BindingMode == BindingMode.OneWay ||
|
BindingMode == BindingMode.OneWay ||
|
||||||
BindingMode == BindingMode.OneTime)
|
BindingMode == BindingMode.OneTime)
|
||||||
{
|
{
|
||||||
var SourcePropertyNames = SourcePropertyName.Split('.');
|
var SourcePropertyNames = sourcePropertyNames;
|
||||||
var Temp_Target = GetPropertySource(SourcePropertyName, Source.Target);
|
var Temp_Target = GetPropertySource(SourcePropertyName, Source.Target);
|
||||||
var data = (Temp_Target as CpfObject)?.GetValue(SourcePropertyNames.LastOrDefault());
|
var data = (Temp_Target as CpfObject)?.GetValue(SourcePropertyNames.LastOrDefault());
|
||||||
Owner.SetPropretyValue(TargetPropertyName, data);
|
Owner.SetPropretyValue(TargetPropertyName, data);
|
||||||
@ -624,7 +642,7 @@ namespace CPF
|
|||||||
//{
|
//{
|
||||||
// throw new Exception("错误");
|
// throw new Exception("错误");
|
||||||
//}
|
//}
|
||||||
var SourcePropertyNames = SourcePropertyName.Split('.');
|
var SourcePropertyNames = sourcePropertyNames;
|
||||||
if (SourcePropertyNames.Length == 1)
|
if (SourcePropertyNames.Length == 1)
|
||||||
{
|
{
|
||||||
RegisterPropertyChanged(notify, PropertyChanged);
|
RegisterPropertyChanged(notify, PropertyChanged);
|
||||||
|
@ -72,7 +72,7 @@ namespace ConsoleApp1
|
|||||||
|
|
||||||
_gl.DeleteShader(vertexShader);
|
_gl.DeleteShader(vertexShader);
|
||||||
_gl.DeleteShader(fragmentShader);
|
_gl.DeleteShader(fragmentShader);
|
||||||
base.OnGLLoaded(gl);
|
//base.OnGLLoaded(gl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -82,14 +82,13 @@ namespace ConsoleApp1
|
|||||||
_gl.Clear(Silk.NET.OpenGLES.ClearBufferMask.ColorBufferBit | Silk.NET.OpenGLES.ClearBufferMask.DepthBufferBit | Silk.NET.OpenGLES.ClearBufferMask.StencilBufferBit);
|
_gl.Clear(Silk.NET.OpenGLES.ClearBufferMask.ColorBufferBit | Silk.NET.OpenGLES.ClearBufferMask.DepthBufferBit | Silk.NET.OpenGLES.ClearBufferMask.StencilBufferBit);
|
||||||
|
|
||||||
_gl.UseProgram(shaderProgram);
|
_gl.UseProgram(shaderProgram);
|
||||||
|
|
||||||
_gl.BindVertexArray(vao);
|
_gl.BindVertexArray(vao);
|
||||||
|
|
||||||
_gl.DrawArrays(Silk.NET.OpenGLES.GLEnum.Triangles, 0, 3);
|
_gl.DrawArrays(Silk.NET.OpenGLES.GLEnum.Triangles, 0, 3);
|
||||||
|
|
||||||
_gl.BindVertexArray(0);
|
_gl.BindVertexArray(0);
|
||||||
_gl.UseProgram(0);
|
_gl.UseProgram(0);
|
||||||
base.OnGLRender(gl);
|
//base.OnGLRender(gl);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -472,6 +472,7 @@ namespace ConsoleApp1
|
|||||||
},
|
},
|
||||||
new ScrollViewer
|
new ScrollViewer
|
||||||
{
|
{
|
||||||
|
Background = "url(res://ConsoleApp1/icon.png) Tile None 0,0,0,0",
|
||||||
MarginLeft = 421,//HorizontalScrollBarVisibility= ScrollBarVisibility.Disabled,
|
MarginLeft = 421,//HorizontalScrollBarVisibility= ScrollBarVisibility.Disabled,
|
||||||
//VerticalScrollBarVisibility= ScrollBarVisibility.Visible,
|
//VerticalScrollBarVisibility= ScrollBarVisibility.Visible,
|
||||||
Commands =
|
Commands =
|
||||||
@ -505,8 +506,9 @@ namespace ConsoleApp1
|
|||||||
{
|
{
|
||||||
Height = 336,
|
Height = 336,
|
||||||
Width = 421,
|
Width = 421,
|
||||||
|
IsAntiAlias=true,
|
||||||
},
|
},
|
||||||
#else
|
#else
|
||||||
new WrapPanel
|
new WrapPanel
|
||||||
{
|
{
|
||||||
Width="100%",
|
Width="100%",
|
||||||
@ -570,7 +572,7 @@ namespace ConsoleApp1
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
Height=300,
|
Height=300,
|
||||||
MarginTop=19,
|
MarginTop=19,
|
||||||
MarginRight=29
|
MarginRight=29
|
||||||
@ -625,7 +627,7 @@ namespace ConsoleApp1
|
|||||||
Value=0.001,
|
Value=0.001,
|
||||||
Bindings =
|
Bindings =
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Button
|
new Button
|
||||||
@ -1967,7 +1969,7 @@ namespace ConsoleApp1
|
|||||||
},
|
},
|
||||||
new Separator
|
new Separator
|
||||||
{
|
{
|
||||||
|
|
||||||
},
|
},
|
||||||
new MenuItem
|
new MenuItem
|
||||||
{
|
{
|
||||||
@ -2465,8 +2467,6 @@ new TabItemTemplate{
|
|||||||
Content="删除对象",
|
Content="删除对象",
|
||||||
[nameof(Button.Click)]=new CommandDescribe((s,e)=>
|
[nameof(Button.Click)]=new CommandDescribe((s,e)=>
|
||||||
{
|
{
|
||||||
data a = new data();
|
|
||||||
a.test.test.Name = "666666";
|
|
||||||
(DataContext as MainModel).Test1.test.test = null;
|
(DataContext as MainModel).Test1.test.test = null;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -2476,7 +2476,7 @@ new TabItemTemplate{
|
|||||||
[nameof(Button.Click)]=new CommandDescribe((s,e)=>
|
[nameof(Button.Click)]=new CommandDescribe((s,e)=>
|
||||||
{
|
{
|
||||||
data a = new data();
|
data a = new data();
|
||||||
a.test.test.Name = "666666";
|
a.test.test.Name = "8888";
|
||||||
(DataContext as MainModel).Test1.test.test = a;
|
(DataContext as MainModel).Test1.test.test = a;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -3456,10 +3456,19 @@ new TabItemTemplate{
|
|||||||
{
|
{
|
||||||
MaximizeBox = true,
|
MaximizeBox = true,
|
||||||
ShadowBlur = 10,
|
ShadowBlur = 10,
|
||||||
#if !DesignMode
|
#if !DesignMode
|
||||||
//Effect = effect
|
//Effect = effect
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//#if !Net4 && !NETCOREAPP3_0
|
||||||
|
// Children.Add(new GLView
|
||||||
|
// {
|
||||||
|
// Height = "30%",
|
||||||
|
// Width = "30%",
|
||||||
|
// IsAntiAlias = true,
|
||||||
|
// });
|
||||||
|
//#endif
|
||||||
LoadStyleFile("res://ConsoleApp1/Stylesheet3.css");
|
LoadStyleFile("res://ConsoleApp1/Stylesheet3.css");
|
||||||
//加载样式文件,文件需要设置为内嵌资源
|
//加载样式文件,文件需要设置为内嵌资源
|
||||||
Console.WriteLine(testBtn[DockPanel.Dock]);
|
Console.WriteLine(testBtn[DockPanel.Dock]);
|
||||||
|
Loading…
Reference in New Issue
Block a user