本文整理汇总了C#中MediaPortal.UI.SkinEngine.Rendering.RenderContext类的典型用法代码示例。如果您正苦于以下问题:C# RenderContext类的具体用法?C# RenderContext怎么用?C# RenderContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RenderContext类属于MediaPortal.UI.SkinEngine.Rendering命名空间,在下文中一共展示了RenderContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public override void Render(RenderContext parentRenderContext)
{
Effect effect = Effect;
if (!IsVisible || effect == null)
return;
RectangleF bounds = ActualBounds;
if (bounds.Width <= 0 || bounds.Height <= 0)
return;
Matrix? layoutTransformMatrix = LayoutTransform == null ? new Matrix?() : LayoutTransform.GetTransform();
Matrix? renderTransformMatrix = RenderTransform == null ? new Matrix?() : RenderTransform.GetTransform();
RenderContext localRenderContext = parentRenderContext.Derive(bounds, layoutTransformMatrix, renderTransformMatrix, RenderTransformOrigin, Opacity);
_inverseFinalTransform = Matrix.Invert(localRenderContext.Transform);
DeviceEx device = SkinContext.Device;
Surface backBuffer = device.GetRenderTarget(0);
SurfaceDescription desc = backBuffer.Description;
SurfaceDescription? textureDesc = _texture == null ? new SurfaceDescription?() : _texture.GetLevelDescription(0);
if (!textureDesc.HasValue || textureDesc.Value.Width != desc.Width || textureDesc.Value.Height != desc.Height)
{
TryDispose(ref _texture);
_texture = new Texture(device, desc.Width, desc.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
}
using (Surface destSurfaceRef = _texture.GetSurfaceLevel(0))
device.StretchRectangle(backBuffer, destSurfaceRef, TextureFilter.None);
UpdateEffectMask(effect, localRenderContext.OccupiedTransformedBounds, desc.Width, desc.Height, localRenderContext.ZOrder);
if (effect.BeginRender(_texture, new RenderContext(Matrix.Identity, 1.0d, bounds, localRenderContext.ZOrder)))
{
_effectContext.Render(0);
effect.EndRender();
}
}
示例2: DoPerformLayout
protected override void DoPerformLayout(RenderContext context)
{
base.DoPerformLayout(context);
// Setup brushes
if (Fill != null || (Stroke != null && StrokeThickness > 0))
{
using (GraphicsPath path = CalculateTransformedPath(GetPolygon(), _innerRect))
{
float centerX;
float centerY;
PointF[] pathPoints = path.PathPoints;
TriangulateHelper.CalcCentroid(pathPoints, out centerX, out centerY);
PositionColoredTextured[] verts;
if (Fill != null)
{
TriangulateHelper.FillPolygon_TriangleList(pathPoints, centerX, centerY, 1, out verts);
Fill.SetupBrush(this, ref verts, context.ZOrder, true);
PrimitiveBuffer.SetPrimitiveBuffer(ref _fillContext, ref verts, PrimitiveType.TriangleList);
}
else
PrimitiveBuffer.DisposePrimitiveBuffer(ref _fillContext);
if (Stroke != null && StrokeThickness > 0)
{
TriangulateHelper.TriangulateStroke_TriangleList(pathPoints, (float) StrokeThickness, true, 1, StrokeLineJoin, out verts);
Stroke.SetupBrush(this, ref verts, context.ZOrder, true);
PrimitiveBuffer.SetPrimitiveBuffer(ref _strokeContext, ref verts, PrimitiveType.TriangleList);
}
else
PrimitiveBuffer.DisposePrimitiveBuffer(ref _strokeContext);
}
}
}
示例3: RenderOverride
public override void RenderOverride(RenderContext localRenderContext)
{
base.RenderOverride(localRenderContext);
FrameworkElement keyboardControl = _keyboardLayoutControl;
if (keyboardControl == null)
return;
keyboardControl.Render(localRenderContext);
}
示例4: BeginRenderEffectOverride
protected override bool BeginRenderEffectOverride(Texture texture, RenderContext renderContext)
{
if (_refresh)
{
_effectContext = new EffectContext();
_refresh = false;
}
RectangleF rect = renderContext.OccupiedTransformedBounds;
SizeF frameSize = new SizeF(rect.Width, rect.Height);
_effectContext.ExtraParameters = GetShaderParameters();
_effectContext.ShaderEffect = _shaderEffectName;
Vector4 lastFrameData = new Vector4(rect.Width, rect.Height, 0.0f, 0.0f);
_effectContext.StartRender(renderContext, frameSize, texture, CROP_FULLSIZE, 0, lastFrameData);
return true;
}
示例5: BeginRenderEffectOverride
protected override bool BeginRenderEffectOverride(Texture texture, RenderContext renderContext)
{
if (_refresh)
{
_imageContext = new ImageContext();
_refresh = false;
}
RectangleF rect = renderContext.OccupiedTransformedBounds;
SizeF frameSize = new SizeF(rect.Width, rect.Height);
_imageContext.FrameSize = frameSize;
_imageContext.ExtraParameters = GetShaderParameters();
_imageContext.ShaderEffect = SkinResources.EFFECTS_SUB_DIRECTORY + '\\' + _partialShaderEffect;
Vector4 lastFrameData = new Vector4(rect.Width, rect.Height, 0.0f, 0.0f);
_imageContext.StartRender(renderContext, frameSize, texture, CROP_FULLSIZE, Color.Transparent, lastFrameData);
return true;
}
示例6: RenderOverride
public override void RenderOverride(RenderContext localRenderContext)
{
ImageSourceState allocatedSource = GetLoadedSource(true);
if (allocatedSource == null)
base.RenderOverride(localRenderContext);
else
{
// Update source geometry if necessary (source has changed, layout has changed).
if (!allocatedSource.Setup)
{
allocatedSource.ImageSource.Setup(_innerRect, localRenderContext.ZOrder, SkinNeutralAR);
allocatedSource.Setup = true;
}
base.RenderOverride(localRenderContext);
allocatedSource.ImageSource.Render(localRenderContext, Stretch, StretchDirection);
}
}
示例7: BeginRenderBrushOverride
protected override bool BeginRenderBrushOverride(PrimitiveBuffer primitiveContext, RenderContext renderContext)
{
if (_gradientBrushTexture == null || _refresh)
{
_gradientBrushTexture = BrushCache.Instance.GetGradientBrush(GradientStops);
if (_gradientBrushTexture == null)
return false;
}
Matrix finalTransform = renderContext.Transform.Clone();
if (_refresh)
{
_refresh = false;
_effect = ContentManager.Instance.GetEffect(EFFECT_LINEARGRADIENT);
g_startpoint = new float[] {StartPoint.X, StartPoint.Y};
g_endpoint = new float[] {EndPoint.X, EndPoint.Y};
if (MappingMode == BrushMappingMode.Absolute)
{
g_startpoint[0] /= _vertsBounds.Width;
g_startpoint[1] /= _vertsBounds.Height;
g_endpoint[0] /= _vertsBounds.Width;
g_endpoint[1] /= _vertsBounds.Height;
}
g_framesize = new float[] {_vertsBounds.Width, _vertsBounds.Height};
if (RelativeTransform != null)
{
Matrix m = RelativeTransform.GetTransform();
m.Transform(ref g_startpoint[0], ref g_startpoint[1]);
m.Transform(ref g_endpoint[0], ref g_endpoint[1]);
}
}
_effect.Parameters[PARAM_FRAMESIZE] = g_framesize;
_effect.Parameters[PARAM_TRANSFORM] = GetCachedFinalBrushTransform();
_effect.Parameters[PARAM_OPACITY] = (float) (Opacity * renderContext.Opacity);
_effect.Parameters[PARAM_STARTPOINT] = g_startpoint;
_effect.Parameters[PARAM_ENDPOINT] = g_endpoint;
GraphicsDevice.Device.SetSamplerState(0, SamplerState.AddressU, SpreadAddressMode);
_effect.StartRender(_gradientBrushTexture.Texture, finalTransform);
return true;
}
示例8: BeginRenderBrushOverride
protected abstract bool BeginRenderBrushOverride(PrimitiveBuffer primitiveContext, RenderContext renderContext);
示例9: BeginRenderBrushOverride
protected override bool BeginRenderBrushOverride(PrimitiveBuffer primitiveBuffer, RenderContext renderContext)
{
Matrix finalTransform = renderContext.Transform.Clone();
Color4 v = ColorConverter.FromColor(Color);
v.Alpha *= (float) (Opacity * renderContext.Opacity);
_effect = ContentManager.Instance.GetEffect(EFFECT_SOLID);
_effect.Parameters[PARAM_SOLIDCOLOR] = v;
_effect.StartRender(finalTransform);
return true;
}
示例10: RenderChildren
protected override void RenderChildren(RenderContext localRenderContext)
{
// Lock access to Children during render pass to avoid controls to be disposed during rendering.
lock (Children.SyncRoot)
base.RenderChildren(localRenderContext);
}
示例11: Render
public override void Render(RenderContext parentRenderContext)
{
if (OpacityMask == null && (TotalHeight > ActualHeight || TotalWidth > ActualWidth))
{
SolidColorBrush brush = new SolidColorBrush {Color = Color.Black};
OpacityMask = brush;
_forcedOpacityMask = true;
}
else if (_forcedOpacityMask && TotalHeight <= ActualHeight && TotalWidth <= ActualWidth && OpacityMask != null)
{
OpacityMask.Dispose();
OpacityMask = null;
_opacityMaskContext.Dispose();
_opacityMaskContext = null;
_forcedOpacityMask = false;
}
base.Render(parentRenderContext);
}
示例12: SetEffectParameters
protected void SetEffectParameters(RenderContext renderContext)
{
Vector2 uvoffset = new Vector2(0.0f, 0.0f);
switch (Tile)
{
case TileMode.Tile:
// Tile both directions
_effect.Parameters[PARAM_TILE_U] = 1; // D3DTADDRESS_WRAP
_effect.Parameters[PARAM_TILE_V] = 1; // D3DTADDRESS_WRAP
break;
case TileMode.FlipX:
// Tile both directions but mirror texture on alterate repeats in u/x direction
_effect.Parameters[PARAM_TILE_U] = 2; // D3DTADDRESS_MIRROR
_effect.Parameters[PARAM_TILE_V] = 1; // D3DTADDRESS_WRAP
uvoffset.X = 1.0f - TextureMaxUV.X;
break;
case TileMode.FlipY:
// Tile both directions but mirror texture on alterate repeats in v/y direction
_effect.Parameters[PARAM_TILE_U] = 1; // D3DTADDRESS_WRAP
_effect.Parameters[PARAM_TILE_V] = 2; // D3DTADDRESS_MIRROR
uvoffset.Y = 1.0f - TextureMaxUV.Y;
break;
case TileMode.FlipXY:
// Tile and mirror texture in both directions
_effect.Parameters[PARAM_TILE_U] = 2; // D3DTADDRESS_MIRROR
_effect.Parameters[PARAM_TILE_V] = 2; // D3DTADDRESS_MIRROR
uvoffset = TextureMaxUV;
uvoffset.X = 1.0f - uvoffset.X;
uvoffset.Y = 1.0f - uvoffset.Y;
break;
case TileMode.None:
default:
// No tiling
_effect.Parameters[PARAM_TILE_U] = 4; // D3DTADDRESS_BORDER
_effect.Parameters[PARAM_TILE_V] = 4; // D3DTADDRESS_BORDER
break;
}
_effect.Parameters[PARAM_RELATIVE_TRANSFORM] = _relativeTransformCache;
_effect.Parameters[PARAM_TRANSFORM] = GetCachedFinalBrushTransform();
_effect.Parameters[PARAM_OPACITY] = (float) (Opacity * renderContext.Opacity);
_effect.Parameters[PARAM_TEXTURE_VIEWPORT] = _textureViewport;
_effect.Parameters[PARAM_BRUSH_TRANSFORM] = _brushTransform;
_effect.Parameters[PARAM_U_OFFSET] = uvoffset.X;
_effect.Parameters[PARAM_V_OFFSET] = uvoffset.Y;
}
示例13: Render
public override void Render(RenderContext renderContext, Stretch stretchMode, StretchDirection stretchDirection)
{
if (!IsAllocated)
return;
SizeF rawSourceSize = RawSourceSize;
SizeF modifiedSourceSize = StretchSource(_imageContext.RotatedFrameSize, rawSourceSize, stretchMode, stretchDirection);
Vector4 frameData = new Vector4(rawSourceSize.Width, rawSourceSize.Height, (float) EffectTimer, 0);
if (_primitiveBuffer != null && _imageContext.StartRender(renderContext, modifiedSourceSize, Texture, TextureClip, BorderColor, frameData))
{
_primitiveBuffer.Render(0);
_imageContext.EndRender();
}
}
示例14: BeginRenderOpacityBrushOverride
protected override bool BeginRenderOpacityBrushOverride(Texture tex, RenderContext renderContext)
{
throw new NotImplementedException("VideoBrush doesn't support being rendered as an opacity brush");
}
示例15: BeginRenderBrushOverride
protected override bool BeginRenderBrushOverride(PrimitiveBuffer primitiveContext, RenderContext renderContext)
{
if (Texture == null)
return false;
Matrix finalTransform = renderContext.Transform.Clone();
if (_refresh)
{
RefreshEffectParameters();
_effect = ContentManager.Instance.GetEffect(_simplemode ? EFFECT_TILE_SIMPLE : EFFECT_TILE);
_refresh = false;
}
if (_simplemode)
SetSimpleEffectParameters(renderContext);
else
SetEffectParameters(renderContext);
_effect.StartRender(Texture, finalTransform);
return true;
}