Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Implement perspective rotation (#11821)
Browse files Browse the repository at this point in the history
  • Loading branch information
myroot committed Aug 18, 2020
1 parent 5747553 commit 996cb60
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
20 changes: 20 additions & 0 deletions Xamarin.Forms.Platform.Tizen/Extensions/EvasMapExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Runtime.InteropServices;
using ElmSharp;

namespace Xamarin.Forms.Platform.Tizen
{
public static class EvasMapExtensions
{
public static void Perspective3D(this EvasMap map, int px, int py, int z0, int foc)
{
var mapType = typeof(EvasMap);
var propInfo = mapType.GetProperty("Handle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var handle = (IntPtr)propInfo.GetValue(map);
evas_map_util_3d_perspective(handle, px, py, z0, foc);
}

[DllImport("libevas.so.1")]
static extern void evas_map_util_3d_perspective(IntPtr map, int px, int py, int z0, int foc);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using ElmSharp;
using ElmSharp.Accessible;
using ElmSharp.Wearable;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Platform.Tizen.Native;
using EFocusDirection = ElmSharp.FocusDirection;
Expand Down Expand Up @@ -1018,6 +1017,10 @@ void ApplyRotation(EvasMap map, ERect geometry, ref bool changed)
{
map.Rotate3D(rotationX, rotationY, rotationZ, (int)(geometry.X + geometry.Width * anchorX),
(int)(geometry.Y + geometry.Height * anchorY), 0);
// the last argument is focal length, it determine the strength of distortion. We compared it with the Android implementation
map.Perspective3D(geometry.X + geometry.Width / 2, geometry.Y + geometry.Height / 2, 0, (int)(1.3 * Math.Max(geometry.Height, geometry.Width)));
// Need to unset clip because perspective 3d rotation is going beyond the container bound
NativeView.SetClip(null);
changed = true;
}
}
Expand Down

0 comments on commit 996cb60

Please sign in to comment.