Skip to content

Instantly share code, notes, and snippets.

@Zoxc
Zoxc / gist:2585797
Created May 3, 2012 13:54
Parsing error comparison
> ::hi()
mirb:
Parsing Error: Can only reference constants when leaving out the lookup expression (Use ::Object to access non-constants)
Input[1]: ::hi()
~~~~~~
mri:
SyntaxError: (irb):6: syntax error, unexpected tIDENTIFIER, expecting tCONSTANT
::hi()
^
@Zoxc
Zoxc / gist:3681678
Created September 9, 2012 00:47
Wayland Color Management
- Reads from client buffers in weston must be converted to linear gamma. Client buffers can be presented to weston with sRGB or linear gamma.
The server-side wl_drm will use sRGB formats to convert it for weston if that's available.
Should the existing SHM/DRM formats be declared as having sRGB gamma? If so, should the premultiplied color format be linear_to_srgb(color * alpha) (the format OpenGL and pixman uses for sRGB)?
How should you pass on whether or not the compositor prefers linear gamma to wayland_drm_init in mesa? (This is needed to disable gamma correction for performance reasons)
Options:
- Replace the eglQueryWaylandBufferWL, eglCreateImageKHR sequence with:
EGLBoolean eglSetupWaylandBufferWL(EGLDisplay dpy, struct wl_buffer *buffer, const EGLint *attrib_list, EGLint *format, EGLint *planes, EGLImageKHR *images);
- Call an eglSetupWaylandBufferWL function before doing anything with a wl_buffer (but keep the eglQueryWaylandBufferWL, eglCreateImageKHR sequence)
- Add eglDisplayAt
@Zoxc
Zoxc / gist:5153662
Created March 13, 2013 16:13
Named constructors with new and delete as functions
# class is Scala or Haskell like traits or type classes
class Constructor[*Args] # Args is variadic
{
type Constructed
static construct(obj: *Constructed, args: Args): unit
}
class Destructable # All types have instance of this
{
@Zoxc
Zoxc / gist:5270635
Created March 29, 2013 12:51
OpenGL font rendering
#include <stdio.h>
#include <math.h>
#include <swl.h>
#include "gles.hpp"
#include <ft2build.h>
#include FT_FREETYPE_H
FT_Library library;
@Zoxc
Zoxc / gist:5566293
Last active December 17, 2015 06:29
Syntax for variable and field declarations
Trivial:
Type trailing with colon
global, other_global: int
yet_another_global: () -> string
func()
a, c: int
b := 4
Type trailing and var keyword
@Zoxc
Zoxc / gist:5765678
Last active December 18, 2015 09:59
Rendering on multiple threads with Wayland subsurfaces
mutex commit
atomic<int> render_complete_count
signal resizing_complete
apply_pending_state(surface) {
wl_surface_attach(surface, ...)
wl_surface_damage(surface, ...)
}
use "../core"
enum Token
None
Unknown
Id
struct Lexer
struct State
lexer *Lexer
@Zoxc
Zoxc / Caps.md
Last active July 23, 2016 07:47

Capability system

This is a sketch of a capability system which utilised data and operations in kernel mode.

There are 2 kernel objects used to support the capability system, Vat and Call. Cap is a global identifier of a capability consisting of a Vat reference and a vat defined number.

Messages

enum Message {

Remote procedure calls in Avery

Introduction

Avery's RPCs are based on capabilities. A capability is a reference to an object which the process has previously received. If you do not have a capability to an object, you cannot communicate with it.

You can do asynchronous calls to objects. These in calls, arguments and return values can contain both bytes and capabilities. If you send a capability to another process it gains access to it.

Objects belong to an event loop (a kernel object) and all messages sent to it is queued there.

@Zoxc
Zoxc / future.rs
Last active January 8, 2017 01:29
// A function pointer and some data to pass to the callback
pub struct Callback<R> {
pointer: fn (R, *const ()),
data: *const (),
}
// This is the trait implemented for generators
pub trait Future {
type Return;