Esempio n. 1
0
 public static void SetPrimitiveBuffer(ref PrimitiveBuffer _buffer, ref PositionColoredTextured[] verts, PrimitiveType type)
 {
     if (_buffer == null)
     {
         _buffer = new PrimitiveBuffer();
     }
     _buffer.Set(ref verts, type);
 }
Esempio n. 2
0
 public static void DisposePrimitiveBuffer(ref PrimitiveBuffer _buffer)
 {
     if (_buffer != null)
     {
         _buffer.Dispose();
     }
     _buffer = null;
 }
Esempio n. 3
0
 protected override bool BeginRenderBrushOverride(PrimitiveBuffer primitiveContext, RenderContext renderContext)
 {
   Allocate();
   if (_tex != null)
     _tex.Bind(0);
   return base.BeginRenderBrushOverride(primitiveContext, renderContext);
 }
Esempio n. 4
0
    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;
    }
    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;
    }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
 protected abstract bool BeginRenderBrushOverride(PrimitiveBuffer primitiveContext, RenderContext renderContext);
Esempio n. 8
0
 public bool BeginRenderBrush(PrimitiveBuffer primitiveContext, RenderContext renderContext)
 {
   if (_vertsBounds.IsEmpty)
     return false;
   return BeginRenderBrushOverride(primitiveContext, renderContext);
 }
Esempio n. 9
0
    protected override bool BeginRenderBrushOverride(PrimitiveBuffer primitiveContext, RenderContext renderContext)
    {
      FrameworkElement fe = _preparedVisual;
      if (fe == null) return false;
      _visualTexture.AllocateRenderTarget((int) _vertsBounds.Width, (int) _vertsBounds.Height);
      _visualSurface.AllocateRenderTarget((int) _vertsBounds.Width, (int) _vertsBounds.Height);

      UpdateRenderTarget(fe);
      return base.BeginRenderBrushOverride(primitiveContext, renderContext);
    }
Esempio n. 10
0
    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);
    }
Esempio n. 11
0
 public static void DisposePrimitiveBuffer(ref PrimitiveBuffer _buffer)
 {
   if (_buffer != null)
     _buffer.Dispose();
   _buffer = null;
 }
Esempio n. 12
0
 public static void SetPrimitiveBuffer(ref PrimitiveBuffer _buffer, ref PositionColoredTextured[] verts, PrimitiveType type)
 {
   if (_buffer == null)
     _buffer = new PrimitiveBuffer();
   _buffer.Set(ref verts, type);
 }
    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;
        _gradientBrushTexture = BrushCache.Instance.GetGradientBrush(GradientStops);
        _effect = ContentManager.Instance.GetEffect("radialgradient");

        g_focus = new float[] { GradientOrigin.X, GradientOrigin.Y };
        g_center = new float[] { Center.X, Center.Y };
        g_radius = new float[] { (float) RadiusX, (float) RadiusY };

        if (MappingMode == BrushMappingMode.Absolute)
        {
          g_focus[0] /= _vertsBounds.Width;
          g_focus[1] /= _vertsBounds.Height;

          g_center[0] /= _vertsBounds.Width;
          g_center[1] /= _vertsBounds.Height;

          g_radius[0] /= _vertsBounds.Width;
          g_radius[1] /= _vertsBounds.Height;
        }
        g_relativetransform = RelativeTransform == null ? Matrix.Identity : Matrix.Invert(RelativeTransform.GetTransform());
      }

      _effect.Parameters[PARAM_RELATIVE_TRANSFORM] = g_relativetransform;
      _effect.Parameters[PARAM_TRANSFORM] = GetCachedFinalBrushTransform();
      _effect.Parameters[PARAM_FOCUS] = g_focus;
      _effect.Parameters[PARAM_CENTER] = g_center;
      _effect.Parameters[PARAM_RADIUS] = g_radius;
      _effect.Parameters[PARAM_OPACITY] = (float) (Opacity * renderContext.Opacity);

      GraphicsDevice.Device.SetSamplerState(0, SamplerState.AddressU, SpreadAddressMode);
      _effect.StartRender(_gradientBrushTexture.Texture, finalTransform);

      return true;
    }
Esempio n. 14
0
    protected override bool BeginRenderBrushOverride(PrimitiveBuffer primitiveContext, RenderContext renderContext)
    {
      ISharpDXVideoPlayer player;
      if (!GetPlayer(out player))
        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);
      }
      
      // Handling of multipass (3D) rendering, transformed rect contains the clipped area of the source image (i.e. left side in Side-By-Side mode).
      RectangleF tranformedRect;
      GraphicsDevice.RenderPipeline.GetVideoClip(_videoTextureClip, out tranformedRect);
      return _imageContext.StartRender(renderContext, _scaledVideoSize, _texture, tranformedRect, BorderColor, _lastFrameData);
    }
Esempio n. 15
0
    protected override bool BeginRenderBrushOverride(PrimitiveBuffer primitiveContext, RenderContext renderContext)
    {
      ISharpDXVideoPlayer player;
      if (!GetPlayer(out player))
        return false;

      if (!RefreshEffectParameters(player))
        return false;

      lock (player.SurfaceLock)
      {
        Texture texture = player.Texture;
        if (texture == null)
          return false;
        _texture = texture;
      }

      // Handling of multipass (3D) rendering, transformed rect contains the clipped area of the source image (i.e. left side in Side-By-Side mode).
      RectangleF tranformedRect;
      GraphicsDevice.RenderPipeline.GetVideoClip(_videoTextureClip, out tranformedRect);
      return _imageContext.StartRender(renderContext, _scaledVideoSize, _texture, tranformedRect, BorderColor, _lastFrameData);
    }