Skip to content

Instantly share code, notes, and snippets.

View ardera's full-sized avatar

Hannes Winkler ardera

View GitHub Profile
@ardera
ardera / find_latest_working_flutter_gallery_commit.sh
Last active January 13, 2023 13:33
Finds the latest working flutter gallery commit for a given flutter SDK. For usage, see comments below.
@ardera
ardera / mouse_cursor.dart
Last active November 9, 2022 01:49
flutter software mouse cursor
class MouseCursorPainter extends CustomPainter {
MouseCursorPainter({required this.offset, this.factor = 64.0});
final Offset offset;
final double factor;
@override
void paint(Canvas canvas, Size size) {
final path = ui.Path()
..moveTo(offset.dx, offset.dy)
@ardera
ardera / dither.dart
Last active May 27, 2022 18:43
Simple dithering in flutter using a RepaintBoundary to capture the screen contents and a GLSL shader and some blue noise picture to apply the dithering. (Also contains another approach using colorfilters which I couldn't get fully working)
import 'dart:async';
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:tuple/tuple.dart';
@ardera
ardera / minimal_embedder.c
Last active June 21, 2023 08:52
minimal embedder reproducing the flutter 2.2 embedder vsync issue. Compile with `-lsystemd` and `-lflutter_engine`. The asset bundle of the default flutter create app should be inside `/tmp/hello_world`, the `icudtl.dat` inside `/usr/lib/`.
#define _GNU_SOURCE
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <pthread.h>
#include <errno.h>
#include <sys/eventfd.h>
@ardera
ardera / flutter_touch_position_overlay.dart
Created December 19, 2020 23:29
A simple flutter widget for viewing where the screen is being touched.
class TouchPositionPainter extends CustomPainter {
TouchPositionPainter(this.points);
final Set<Offset> points;
static final _whitePaint = Paint()
..color = Colors.white
..style = PaintingStyle.fill;
static final _blackPaint = Paint()
@ardera
ardera / drm_plane_test.c
Last active June 9, 2020 11:41
Reproduction of a `drmModeSetPlane` issue of the raspbian linux kernel (https://github.com/raspberrypi/linux/issues/3661). This time with two planes being drawn into concurrently.
#include <fcntl.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
@ardera
ardera / build_flutter_engine.sh
Created February 19, 2020 14:00
My script for building the flutter engine binaries for Raspberry Pi using LLVM 9, LLVM 10, libcxx, libcxxabi & GNU binutils.
#!/bin/bash
function prettyEcho {
_date=$(date '+%d.%m.%Y %X')
echo -e "[$_date] \e[92m$1\e[0m"
echo "[$_date] $1" >> /home/hannes/develd/upgrade.log
}
function prettyTime {
time (($@) && echo "run-time:")
@ardera
ardera / fakedevicepixelratio.dart
Created November 8, 2019 00:48
A simple flutter widget that can simulate/fake a different pixel ratio for all it's children. Can be the root widget, i.e. the widget given to runApp(). Useful for when your device/emulator doesn't properly calculate the devicePixelRatio.
import 'package:flutter/widgets.dart';
class FakeDevicePixelRatio extends StatelessWidget {
final num fakeDevicePixelRatio;
final Widget child;
FakeDevicePixelRatio({this.fakeDevicePixelRatio, this.child}) : assert(fakeDevicePixelRatio != null);
@override
Widget build(BuildContext context) {