Module: graphics.backend.surface
Source: ./graphics/backend/surface.reef
Overview
graphics/backend/surface.reef - Rendering surface (passive-object hierarchy) Part of reef-stdlib graphics module
Surface is the base class. MemorySurface is an in-memory pixel buffer. FramebufferSurface is the same backing store today, but overrides end_frame (present) so a Surface-typed reference dispatches. The old SurfaceType tag is kept only as a factory discriminator for create_surface. Prefixed surface_* functions are wrappers around methods so existing call sites (canvas, ui, gameui) keep compiling.
Types
BlendMode (enum)
Variants:
OverSourceDestClearSourceOverDestOverSourceInDestInSourceOutDestOutSourceAtopDestAtopXorAddMultiplyScreen
SurfaceType (enum)
Variants:
MemoryFramebuffer
Objects
Surface
Fields:
| Name | Type |
|---|---|
width |
int |
height |
int |
format |
image.PixelFormat |
pixels |
image.Image |
clip_x |
int |
clip_y |
int |
clip_width |
int |
clip_height |
int |
clip_enabled |
bool |
blend_mode |
BlendMode |
proc init(width: int, height: int, format: image.PixelFormat, pixels: image.Image)
Methods:
shared fn kind(): string
shared fn get_width(): int
shared fn get_height(): int
shared fn get_format(): image.PixelFormat
shared fn get_pixels(): image.Image
exclusive proc begin_frame()
exclusive proc end_frame()
exclusive proc clear(c: core.Color)
exclusive proc fill_rect(r: core.Rect, c: core.Color)
exclusive proc stroke_rect(r: core.Rect, c: core.Color, width: float)
exclusive proc fill_path(p: path.Path, pnt: paint.Paint, t: transform.Transform, rule: paint.FillRule)
exclusive proc stroke_path(p: path.Path, pnt: paint.Paint, style: paint.StrokeStyle, t: transform.Transform)
exclusive proc draw_image(img: image.Image, x: int, y: int)
exclusive proc draw_image_scaled(img: image.Image, dst: core.Rect)
exclusive proc draw_image_rect(img: image.Image, src: core.Rect, dst: core.Rect)
exclusive proc set_clip(r: core.Rect)
exclusive proc reset_clip()
shared fn get_pixel(x: int, y: int): core.Color
exclusive proc set_pixel(x: int, y: int, c: core.Color)
MemorySurface
Extends: Surface
proc init(width: int, height: int, format: image.PixelFormat, pixels: image.Image)
Methods:
override shared fn kind(): string
FramebufferSurface
Extends: Surface
Fields:
| Name | Type |
|---|---|
presented |
int |
proc init(width: int, height: int, format: image.PixelFormat, pixels: image.Image)
Methods:
override shared fn kind(): string
override exclusive proc end_frame()
shared fn present_count(): int
Functions
fn blend_mode_over(): BlendMode
Blend mode constructors
fn blend_mode_source(): BlendMode
fn blend_mode_dest(): BlendMode
fn blend_mode_source_over(): BlendMode
fn blend_mode_dest_over(): BlendMode
fn blend_mode_source_in(): BlendMode
fn blend_mode_dest_in(): BlendMode
fn blend_mode_source_out(): BlendMode
fn blend_mode_dest_out(): BlendMode
fn blend_mode_source_atop(): BlendMode
fn blend_mode_dest_atop(): BlendMode
fn blend_mode_xor(): BlendMode
fn blend_mode_add(): BlendMode
fn blend_mode_multiply(): BlendMode
fn blend_mode_screen(): BlendMode
fn fill_rule_even_odd(): paint.FillRule
fn fill_rule_non_zero(): paint.FillRule
fn create_surface(surf_type: SurfaceType, width: int, height: int, format: image.PixelFormat, pixels: image.Image): Surface
fn create_framebuffer_surface(width: int, height: int): Surface
fn surface_tag(s: Surface): string
typecase arms are a bare type name (not module-qualified), so the
hierarchy test lives here. Callers in other modules use is/as.
fn surface_width(s: Surface): int
fn surface_height(s: Surface): int
fn surface_format(s: Surface): image.PixelFormat
fn surface_get_pixel(s: Surface, x: int, y: int): core.Color
fn surface_pixels(s: Surface): image.Image
fn blend_colors(src: core.Color, dst: core.Color, mode: BlendMode): core.Color
Blend two colors using specified blend mode
fn blend_over(src: core.Color, dst: core.Color): core.Color
Porter-Duff "over" composition: src over dst
fn blend_source_in(src: core.Color, dst: core.Color): core.Color
Source in: src where dst is opaque
fn blend_source_out(src: core.Color, dst: core.Color): core.Color
Source out: src where dst is transparent
fn blend_source_atop(src: core.Color, dst: core.Color): core.Color
Source atop: src atop dst
fn blend_xor(src: core.Color, dst: core.Color): core.Color
XOR: exclusive or
fn blend_add(src: core.Color, dst: core.Color): core.Color
Additive blending
fn blend_multiply(src: core.Color, dst: core.Color): core.Color
Multiply blending
fn blend_screen(src: core.Color, dst: core.Color): core.Color
Screen blending: 1 - (1-src) * (1-dst)
fn clamp_byte(v: int): uint8
Clamp int to byte range and convert
Procedures
proc surface_begin_frame(s: Surface)
proc surface_end_frame(s: Surface)
proc surface_clear(s: Surface, c: core.Color)
proc surface_fill_rect(s: Surface, r: core.Rect, c: core.Color)
proc surface_stroke_rect(s: Surface, r: core.Rect, c: core.Color, width: float)
proc surface_fill_path(s: Surface, p: path.Path, pnt: paint.Paint, t: transform.Transform, rule: paint.FillRule)
proc surface_stroke_path(s: Surface, p: path.Path, pnt: paint.Paint, style: paint.StrokeStyle, t: transform.Transform)
proc surface_draw_image(s: Surface, img: image.Image, x: int, y: int)
proc surface_draw_image_scaled(s: Surface, img: image.Image, dst: core.Rect)
proc surface_draw_image_rect(s: Surface, img: image.Image, src: core.Rect, dst: core.Rect)
proc surface_set_clip(s: Surface, r: core.Rect)
proc surface_reset_clip(s: Surface)
proc surface_set_pixel(s: Surface, x: int, y: int, c: core.Color)
Generated by reefc doc