Esempio n. 1
0
        protected override void OnCreate(Bundle bundle)
        {
            CrushReportEmail = Resources.GetString(Resource.String.CrushReportEmail);
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);
            InitButtonBar();

            _adView = FindViewById<AdView>(Resource.Id.adView);
            InitAdView();

            _horizontalScrollView = FindViewById<HorizontalScrollView>(Resource.Id.horizontalScrollView);
            _formulaTextView = FindViewById<TextView>(Resource.Id.formulaTextView);
            _renderTimeTextView = FindViewById<TextView>(Resource.Id.renderTimeTextView);
            _imageView = FindViewById<ImageView>(Resource.Id.imageView);
            _coresCountTextView = FindViewById<TextView>(Resource.Id.coresCountTextView);
            TextView sizeTextView = FindViewById<TextView>(Resource.Id.sizeTextView);
            TextView launcherTextView = FindViewById<TextView>(Resource.Id.launcherTextView);
            _technicalInfoLayout = FindViewById<LinearLayout>(Resource.Id.technicalInfoLayout);

            launcherTextView.Text = "launcher: " + IntentShortcuts.GetLauncherPackageName(this);
            WallpaperManager wallpaperManager = WallpaperManager.GetInstance(this);
            Point wallpaperSize = wallpaperManager.GetDesiredSize(WindowManager.DefaultDisplay, Resources.Configuration);
            Size imageSize = new Size(wallpaperSize.X, wallpaperSize.Y);
            sizeTextView.Text = "image size: " + imageSize.Width + "x" + imageSize.Height;
            _workflow = new FormulaRenderWorkflow(new FormulaRenderArgumentsGenerationParams(), imageSize, s => new AndroidFormulaBitmap(s));
            
            if (_workflow.FormulaRenderArguments != null)
                _formulaTextView.Text = _workflow.FormulaRenderArguments.ToString();

            _wallpaperFileManager = new AndroidWallpaperFileManager(this);

            AdjustButtons();
            ClearImage();
        }
Esempio n. 2
0
 public AndroidFormulaBitmap(Size size)
     : base(size)
 {
     _pixelsBuffer = new int[size.Square];
     Bitmap immutableBitmap = Bitmap.CreateBitmap(size.Width, size.Height, Bitmap.Config.Argb8888);
     PlatformBitmap = _bitmap = immutableBitmap.Copy(Bitmap.Config.Argb8888, true);
     immutableBitmap.Recycle();
 }
Esempio n. 3
0
 public SizeControl()
 {
     Orientation = Orientation.Horizontal;
     _widthTextBox = new TextBox { Width = 50, Height = 20};
     Children.Add(_widthTextBox);
     _heightTextBox = new TextBox { Width = 50, Height = 20 };
     Children.Add(_heightTextBox);
     Size = new Size();
 }
Esempio n. 4
0
 public FormulaRenderWorkflow(FormulaRenderArgumentsGenerationParams generationParams, Size imageSize, FormulaRenderArgumentsGoodnessAnalyzer formulaRenderArgumentsGoodnessAnalyzer,
     Func<Size, FormulaBitmap> createFormulaBitmap, Random random)
 {
     GenerationParams = generationParams;
     _formulaRenderArgumentsGoodnessAnalyzer = formulaRenderArgumentsGoodnessAnalyzer;
     _createFormulaBitmap = createFormulaBitmap;
     _random = random;
     _reevaluateValues = true;
     ImageSize = imageSize;
 }
Esempio n. 5
0
 public FormulaRenderResult(Size size)
 {
     Size = size;
     int l = size.Width*size.Height;
     EvaluatedValuesBuffer = new float[l];
     ColorTranformedValuesBuffer = new float[l];
     RedChannel = new byte[l];
     GreenChannel = new byte[l];
     BlueChannel = new byte[l];
 }
Esempio n. 6
0
        public static void Render(FormulaTree formulaTree, Range[] ranges, Size imageSize, ColorTransformation colorTransformation,
            bool reevaluateValues, int threadsCount, FormulaRenderResult formulaRenderResult)
        {
            using (ProgressReporter.CreateScope())
            {
                double evaluationSpan = 0;
                if (reevaluateValues)
                {
                    evaluationSpan = 0.93;
                    using (ProgressReporter.CreateScope(evaluationSpan))
                    {
                        EvaluateFormula(formulaTree, ranges, imageSize, threadsCount, formulaRenderResult.EvaluatedValuesBuffer);
                    }
                }

                using (ProgressReporter.CreateScope(1 - evaluationSpan))
                {
                    Render(colorTransformation, formulaRenderResult, threadsCount);
                }
            }
        }
 public FormulaRenderArgumentsGoodnessAnalyzer(int minVariablesCount)
 {
     MinVariablesCount = minVariablesCount;
     Size emptynessCheckImageSize = new Size(8, 8);
        _formulaRenderResult = new FormulaRenderResult(emptynessCheckImageSize);
 }
Esempio n. 8
0
 public FormulaRenderWorkflow(FormulaRenderArgumentsGenerationParams generationParams, Size imageSize, Func<Size, FormulaBitmap> createFormulaBitmap)
     : this(generationParams, imageSize, new FormulaRenderArgumentsGoodnessAnalyzer(generationParams.DimensionCountBounds.Low), createFormulaBitmap, new Random())
 {
 }
Esempio n. 9
0
        private static void EvaluateFormula(FormulaTree formulaTree, Range[] ranges, Size areaSize, int threadsCount, float[] evaluatedValuesBuffer)
        {
            Stopwatch evaluationStopwatch = new Stopwatch();
            evaluationStopwatch.Start();

            if (evaluatedValuesBuffer.Length != areaSize.Square)
                throw new ArgumentException("Result buffer size isn't equal to ranges area size.", "evaluatedValuesBuffer");

            int xCount = areaSize.Width;
            int yCount = areaSize.Height;

            if (threadsCount < 1)
                threadsCount = 1;

            ranges = ranges.Select((r, i) => new Range(r.Start, r.End, i % 2 == 0 ? areaSize.Width : areaSize.Height)).ToArray();
            const int progressSteps = 100;
            using (ProgressReporter.CreateScope(progressSteps))
            {
                int steps = 0;
                double lastProgress = 0;
                double progress = 0;
                ProgressObserver progressObserver = new ProgressObserver(p => progress = p.Progress);

                Task[] tasks = new Task[threadsCount];
                int yStepCount = yCount/threadsCount;
                for (int i = 0; i < threadsCount; i++)
                {
                    int li = i;
                    tasks[i] = Task.Run(() =>
                    {
                        FormulaTree ft = li == 0 ? formulaTree : FormulaTreeSerializer.Deserialize(FormulaTreeSerializer.Serialize(formulaTree));
                        int yStart = li * yStepCount;
                        ProgressReporter.Subscribe(progressObserver);
                        ft.EvaluateRangesIn2DProjection(ranges, xCount, yStart, yStepCount,
                            evaluatedValuesBuffer);
                    });
                }

                while (tasks.Any(t => t.Status != TaskStatus.RanToCompletion && t.Status != TaskStatus.Faulted && t.Status != TaskStatus.Canceled))
                {
                    Task.WaitAny(tasks, 100);
                    double progressCopy = progress;
                    int inc = (int)((progressCopy - lastProgress) * progressSteps);
                    if (inc > 0)
                    {
                        for (int i = 0; i < inc && steps < progressSteps; i++)
                        {
                            ProgressReporter.Increase();
                            steps++;
                        }
                        lastProgress = progress;
                    }
                }
                Task.WaitAll();
            }

            //double x = 1;
            //double y = 2;
            //double z = 3;
            //double w = 4;
            //double x1 = -1;
            //double y1 = -2;
            //double z1 = -3;
            //double w1 = -4;
            //Stopwatch stopwatch2 = new Stopwatch();
            //stopwatch2.Start();
            //double[] arr = new double[Ranges[0].Count*Ranges[1].Count];
            //for (int i = 0; i < arr.Length; i++)
            //{
            //    arr[i] = Math.Sqrt((Math.Sin(x) * Math.Sin(y) + Math.Sin(z) * Math.Sin(w)) * (Math.Sin(x1) * Math.Sin(y1) + Math.Sin(z1) * Math.Sin(w1)));
            //    x += 0.1;
            //    y += 0.1;
            //    z += 0.1;
            //    w += 0.1;
            //    x1 += 0.3;
            //    y1 += 0.3;
            //    z1 += 0.3;
            //    w1 += 0.3;
            //}
            //stopwatch2.Stop();

            evaluationStopwatch.Stop();
        }
Esempio n. 10
0
 public FormulaBitmapMock(Size size)
     : base(size)
 {
 }
Esempio n. 11
0
 protected FormulaBitmap(Size size)
 {
     Size = size;
 }