Browse Source

Missing file

Nikita Tsukanov 8 years ago
parent
commit
5125784af5
1 changed files with 10 additions and 10 deletions
  1. 10 10
      src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs

+ 10 - 10
src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs

@@ -135,17 +135,17 @@ namespace Avalonia.Direct2D1
 
         public IRenderTarget CreateRenderTarget(IEnumerable<object> surfaces)
         {
-            var nativeWindow = surfaces?.OfType<IPlatformHandle>().FirstOrDefault();
-            if (nativeWindow != null)
+            foreach (var s in surfaces)
             {
-                if(nativeWindow.HandleDescriptor != "HWND")
-                    throw new NotSupportedException("Don't know how to create a Direct2D1 renderer from " + nativeWindow.HandleDescriptor);
-                return new HwndRenderTarget(nativeWindow);
-            }
-            var external = surfaces?.OfType<IExternalDirect2DRenderTargetSurface>();
-            if (external != null)
-            {
-                
+                if (s is IPlatformHandle nativeWindow)
+                {
+                    if (nativeWindow.HandleDescriptor != "HWND")
+                        throw new NotSupportedException("Don't know how to create a Direct2D1 renderer from " +
+                                                        nativeWindow.HandleDescriptor);
+                    return new HwndRenderTarget(nativeWindow);
+                }
+                if (s is IExternalDirect2DRenderTargetSurface external)
+                    return new ExternalRenderTarget(external, s_dwfactory);
             }
             throw new NotSupportedException("Don't know how to create a Direct2D1 renderer from any of provided surfaces");
         }