summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/MeasureSpecFactory.cs
blob: 9ab854c563841a5e79a1aeb08f7e244f8bee4521 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using Android.Views;

namespace Xamarin.Forms.Platform.Android
{
	internal static class MeasureSpecFactory
	{
		public static int GetSize(int measureSpec)
		{
			const int modeMask = 0x3 << 30;
			return measureSpec & ~modeMask;
		}

		// Literally does the same thing as the android code, 1000x faster because no bridge cross
		// benchmarked by calling 1,000,000 times in a loop on actual device
		public static int MakeMeasureSpec(int size, MeasureSpecMode mode)
		{
			return size + (int)mode;
		}
	}
}