本文整理汇总了C#中MediaPortal.UI.SkinEngine.Rendering.RenderContext类的典型用法代码示例。如果您正苦于以下问题:C# RenderContext类的具体用法?C# RenderContext怎么用?C# RenderContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RenderContext类属于MediaPortal.UI.SkinEngine.Rendering命名空间,在下文中一共展示了RenderContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
}
开发者ID:CAARNICL,项目名称:MediaPortal-2,代码行数:35,代码来源:BackgroundEffect.cs
示例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);
}
}
}
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:34,代码来源:Polygon.cs
示例3: RenderOverride
public override void RenderOverride(RenderContext localRenderContext)
{
base.RenderOverride(localRenderContext);
FrameworkElement keyboardControl = _keyboardLayoutControl;
if (keyboardControl == null)
return;
keyboardControl.Render(localRenderContext);
}
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:8,代码来源:VirtualKeyboardPresenter.cs
示例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;
}
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:17,代码来源:ShaderEffect.cs
示例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;
}
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:18,代码来源:ImageEffect.cs
示例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);
}
}
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:17,代码来源:Image.cs
示例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;
}
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:45,代码来源:LinearGradientBrush.cs
示例8: BeginRenderBrushOverride
protected abstract bool BeginRenderBrushOverride(PrimitiveBuffer primitiveContext, RenderContext renderContext);
开发者ID:BigGranu,项目名称:MediaPortal-2,代码行数:1,代码来源:Brush.cs
示例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;
}
开发者ID:jgauffin,项目名称:MediaPortal-2,代码行数:10,代码来源:SolidColorBrush.cs
示例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);
}
开发者ID:BigGranu,项目名称:MediaPortal-2,代码行数:6,代码来源:EpgGrid.cs
示例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);
}
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:18,代码来源:ScrollContentPresenter.cs
示例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;
}
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:46,代码来源:TileBrush.cs
示例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();
}
}
开发者ID:aspik,项目名称:MediaPortal-2,代码行数:13,代码来源:TextureImageSource.cs
示例14: BeginRenderOpacityBrushOverride
protected override bool BeginRenderOpacityBrushOverride(Texture tex, RenderContext renderContext)
{
throw new NotImplementedException("VideoBrush doesn't support being rendered as an opacity brush");
}
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:4,代码来源:VideoBrush.cs
示例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;
}
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:23,代码来源:TileBrush.cs
示例16: BeginRenderBrushOverride
protected override bool BeginRenderBrushOverride(PrimitiveBuffer primitiveContext, RenderContext renderContext)
{
IPlayerManager playerManager = ServiceRegistration.Get<IPlayerManager>(false);
if (playerManager == null)
return false;
ISlimDXVideoPlayer player = playerManager[Stream] as ISlimDXVideoPlayer;
if (player == null)
return false;
if (!RefreshEffectParameters(player))
return false;
lock (player.SurfaceLock)
{
Surface playerSurface = player.Surface;
if (playerSurface == null)
return false;
DeviceEx device = SkinContext.Device;
SurfaceDescription desc = playerSurface.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 target = _texture.GetSurfaceLevel(0))
device.StretchRectangle(playerSurface, target, TextureFilter.None);
}
return _imageContext.StartRender(renderContext, _scaledVideoSize, _texture, _videoTextureClip, BorderColor.ToArgb(), _lastFrameData);
}
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:31,代码来源:VideoBrush.cs
示例17: Render
public override void Render(RenderContext renderContext, Stretch stretchMode, StretchDirection stretchDirection)
{
Allocate();
Texture currentTexture = CurrentTexture;
SizeF currentRawSourceSize = CurrentRawSourceSize;
RectangleF currentTextureClip = CurrentTextureClip;
Vector4 frameData = new Vector4(currentRawSourceSize.Width, currentRawSourceSize.Height, (float) EffectTimer, 0);
if (_transitionActive)
{
double elapsed = (SkinContext.FrameRenderingStartTime - _transitionStart).TotalSeconds / Math.Max(TransitionDuration, 0.01);
if (elapsed > 1.0)
_transitionActive = false;
else
{
Texture lastTexture = LastTexture;
SizeF lastRawSourceSize = LastRawSourceSize;
RectangleF lastTextureClip = LastTextureClip;
Vector4 lastFrameData = new Vector4(lastRawSourceSize.Width, lastRawSourceSize.Height, (float) EffectTimer, 0);
Texture start = lastTexture ?? NullTexture.Texture;
Texture end = currentTexture ?? NullTexture.Texture;
if (start != end)
{
SizeF startSize = StretchSource(_lastImageContext.RotatedFrameSize, lastRawSourceSize, stretchMode, stretchDirection);
SizeF endSize = StretchSource(_imageContext.RotatedFrameSize, currentRawSourceSize, stretchMode, stretchDirection);
// Render transition from last texture to current texture
_lastImageContext.Update(startSize, start, lastTextureClip);
if (_imageContext.StartRenderTransition(renderContext, (float) elapsed, _lastImageContext,
endSize, end, currentTextureClip, BorderColor, lastFrameData, frameData))
{
_primitiveBuffer.Render(0);
_imageContext.EndRenderTransition();
}
}
return;
}
}
if (IsAllocated)
{
SizeF sourceSize = StretchSource(_imageContext.RotatedFrameSize, currentRawSourceSize, stretchMode, stretchDirection);
if (_imageContext.StartRender(renderContext, sourceSize, currentTexture, currentTextureClip, BorderColor, frameData))
{
_primitiveBuffer.Render(0);
_imageContext.EndRender();
}
}
}
开发者ID:aspik,项目名称:MediaPortal-2,代码行数:53,代码来源:MultiImageSourceBase.cs
示例18: RenderOverride
public override void RenderOverride(RenderContext localRenderContext)
{
base.RenderOverride(localRenderContext);
FrameworkElement content = Content;
if (content != null)
content.Render(localRenderContext);
}
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:7,代码来源:ARRetainingControl.cs
示例19: BeginRenderOpacityBrushOverride
protected override bool BeginRenderOpacityBrushOverride(Texture tex, 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_LINEAROPACITYGRADIENT);
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]);
}
}
SurfaceDescription desc = tex.GetLevelDescription(0);
float[] g_LowerVertsBounds = new float[] {_vertsBounds.Left / desc.Width, _vertsBounds.Top / desc.Height};
float[] g_UpperVertsBounds = new float[] {_vertsBounds.Right / desc.Width, _vertsBounds.Bottom / desc.Height};
_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;
_effect.Parameters[PARAM_FRAMESIZE] = g_framesize;
_effect.Parameters[PARAM_ALPHATEX] = _gradientBrushTexture.Texture;
_effect.Parameters[PARAM_UPPERVERTSBOUNDS] = g_UpperVertsBounds;
_effect.Parameters[PARAM_LOWERVERTSBOUNDS] = g_LowerVertsBounds;
GraphicsDevice.Device.SetSamplerState(0, SamplerState.AddressU, SpreadAddressMode);
_effect.StartRender(tex, finalTransform);
return true;
}
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:51,代码来源:LinearGradientBrush.cs
示例20: BeginRenderBrushOverride
protected override bool BeginRenderBrushOverride(PrimitiveBuffer primitiveContext, RenderContext renderContext)
{
Allocate();
if (_tex != null)
_tex.Bind(0);
return base.BeginRenderBrushOverride(primitiveContext, renderContext);
}
开发者ID:HeinA,项目名称:MediaPortal-2,代码行数:7,代码来源:ImageBrush.cs
注:本文中的MediaPortal.UI.SkinEngine.Rendering.RenderContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论