This commit is contained in:
王志勋 2025-11-04 16:59:49 +08:00
parent 8536a5808a
commit 2e27bd5491
1 changed files with 19 additions and 22 deletions

View File

@ -294,32 +294,29 @@ namespace RenderHeads.Media.AVProVideo.Editor
GL.sRGBWrite = false; GL.sRGBWrite = false;
RenderTexture rt2 = null; RenderTexture rt2 = null;
// TODO: move this all into VideoRender as a resolve method Material materialResolve = new Material(Shader.Find(VideoRender.Shader_Resolve));
{ VideoRender.SetupVerticalFlipMaterial(materialResolve, _thumbnailPlayer.RequiresVerticalFlip());
Material materialResolve = new Material(Shader.Find(VideoRender.Shader_Resolve)); VideoRender.SetupAlphaPackedMaterial(materialResolve, _thumbnailPlayer.GetTextureAlphaPacking());
VideoRender.SetupVerticalFlipMaterial(materialResolve, _thumbnailPlayer.RequiresVerticalFlip()); VideoRender.SetupGammaMaterial(materialResolve, !_thumbnailPlayer.PlayerSupportsLinearColorSpace());
VideoRender.SetupAlphaPackedMaterial(materialResolve, _thumbnailPlayer.GetTextureAlphaPacking());
VideoRender.SetupGammaMaterial(materialResolve, !_thumbnailPlayer.PlayerSupportsLinearColorSpace());
RenderTexture prev = RenderTexture.active; RenderTexture prev = RenderTexture.active;
// Scale to fit and downsample // Scale to fit and downsample
rt2 = RenderTexture.GetTemporary(128, 128, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB); rt2 = RenderTexture.GetTemporary(128, 128, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
RenderTexture.active = rt2; RenderTexture.active = rt2;
GL.Clear(false, true, new Color(0f, 0f, 0f, 0f)); GL.Clear(false, true, new Color(0f, 0f, 0f, 0f));
ScaleMode scaleMode = ScaleMode.ScaleToFit; ScaleMode scaleMode = ScaleMode.ScaleToFit;
if (_zoomToFill) if (_zoomToFill)
{ {
scaleMode = ScaleMode.ScaleAndCrop; scaleMode = ScaleMode.ScaleAndCrop;
} }
VideoRender.DrawTexture(new Rect(0f, 0f, 128f, 128f), _thumbnailPlayer.GetTexture(), scaleMode, _thumbnailPlayer.GetTextureAlphaPacking(), _thumbnailPlayer.GetTexturePixelAspectRatio(), materialResolve); VideoRender.DrawTexture(new Rect(0f, 0f, 128f, 128f), _thumbnailPlayer.GetTexture(), scaleMode, _thumbnailPlayer.GetTextureAlphaPacking(), _thumbnailPlayer.GetTexturePixelAspectRatio(), materialResolve);
RenderTexture.active = prev; RenderTexture.active = prev;
Material.DestroyImmediate(materialResolve); materialResolve = null; Material.DestroyImmediate(materialResolve); materialResolve = null;
}
Texture2D readTexture = new Texture2D(128, 128, TextureFormat.RGBA32, true, false);
Texture2D readTexture = new Texture2D(128, 128, TextureFormat.RGBA32, true, false);
Helper.GetReadableTexture(rt2, readTexture); Helper.GetReadableTexture(rt2, readTexture);
MediaReference mediaRef = (this.targets[_targetIndex]) as MediaReference; MediaReference mediaRef = (this.targets[_targetIndex]) as MediaReference;
mediaRef.GeneratePreview(readTexture); mediaRef.GeneratePreview(readTexture);