move RenderTexture out of Video
							parent
							
								
									491eafac76
								
							
						
					
					
						commit
						b648d1b1c3
					
				| 
						 | 
				
			
			@ -45,7 +45,6 @@ namespace MoonWorks.Video
 | 
			
		|||
		private int currentFrame;
 | 
			
		||||
 | 
			
		||||
		private GraphicsDevice GraphicsDevice;
 | 
			
		||||
		private Texture RenderTexture = null;
 | 
			
		||||
		private Texture yTexture = null;
 | 
			
		||||
		private Texture uTexture = null;
 | 
			
		||||
		private Texture vTexture = null;
 | 
			
		||||
| 
						 | 
				
			
			@ -115,16 +114,9 @@ namespace MoonWorks.Video
 | 
			
		|||
 | 
			
		||||
			InitializeTheoraStream();
 | 
			
		||||
 | 
			
		||||
			// FIXME: maybe we should store textures on a VideoPlayer to save memory
 | 
			
		||||
			if (Theorafile.tf_hasvideo(Handle) == 1)
 | 
			
		||||
			{
 | 
			
		||||
				RenderTexture = Texture.CreateTexture2D(
 | 
			
		||||
					GraphicsDevice,
 | 
			
		||||
					(uint) yWidth,
 | 
			
		||||
					(uint) yHeight,
 | 
			
		||||
					TextureFormat.R8G8B8A8,
 | 
			
		||||
					TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler
 | 
			
		||||
				);
 | 
			
		||||
 | 
			
		||||
				yTexture = Texture.CreateTexture2D(
 | 
			
		||||
					GraphicsDevice,
 | 
			
		||||
					(uint) yWidth,
 | 
			
		||||
| 
						 | 
				
			
			@ -214,16 +206,23 @@ namespace MoonWorks.Video
 | 
			
		|||
			State = VideoState.Stopped;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public Texture GetTexture()
 | 
			
		||||
		public void Render(Texture renderTexture)
 | 
			
		||||
		{
 | 
			
		||||
			if (RenderTexture == null)
 | 
			
		||||
			if (renderTexture == null)
 | 
			
		||||
			{
 | 
			
		||||
				throw new InvalidOperationException();
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			#if DEBUG
 | 
			
		||||
			if (renderTexture.Height != yHeight || renderTexture.Width != yWidth)
 | 
			
		||||
			{
 | 
			
		||||
				throw new ArgumentException("Render texture does not match video size!");
 | 
			
		||||
			}
 | 
			
		||||
			#endif
 | 
			
		||||
 | 
			
		||||
			if (State == VideoState.Stopped)
 | 
			
		||||
			{
 | 
			
		||||
				return RenderTexture;
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			timeElapsed += (timer.Elapsed.TotalMilliseconds - lastTimestamp) * PlaybackSpeed;
 | 
			
		||||
| 
						 | 
				
			
			@ -237,7 +236,7 @@ namespace MoonWorks.Video
 | 
			
		|||
					(IntPtr) yuvData,
 | 
			
		||||
					thisFrame - currentFrame
 | 
			
		||||
				) == 1 || currentFrame == -1) {
 | 
			
		||||
					UpdateTexture();
 | 
			
		||||
					UpdateTexture(renderTexture);
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				currentFrame = thisFrame;
 | 
			
		||||
| 
						 | 
				
			
			@ -270,11 +269,9 @@ namespace MoonWorks.Video
 | 
			
		|||
					State = VideoState.Stopped;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return RenderTexture;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		private void UpdateTexture()
 | 
			
		||||
		private void UpdateTexture(Texture renderTexture)
 | 
			
		||||
		{
 | 
			
		||||
			var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -287,7 +284,7 @@ namespace MoonWorks.Video
 | 
			
		|||
			);
 | 
			
		||||
 | 
			
		||||
			commandBuffer.BeginRenderPass(
 | 
			
		||||
				new ColorAttachmentInfo(RenderTexture, Color.Black)
 | 
			
		||||
				new ColorAttachmentInfo(renderTexture, Color.Black)
 | 
			
		||||
			);
 | 
			
		||||
 | 
			
		||||
			commandBuffer.BindGraphicsPipeline(GraphicsDevice.VideoPipeline);
 | 
			
		||||
| 
						 | 
				
			
			@ -327,7 +324,6 @@ namespace MoonWorks.Video
 | 
			
		|||
				if (disposing)
 | 
			
		||||
				{
 | 
			
		||||
					// dispose managed state (managed objects)
 | 
			
		||||
					RenderTexture.Dispose();
 | 
			
		||||
					yTexture.Dispose();
 | 
			
		||||
					uTexture.Dispose();
 | 
			
		||||
					vTexture.Dispose();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue