Skip to content

Commit

Permalink
Merge branch 'erik-650-png' into erik-700-barcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Corry committed Dec 5, 2023
2 parents 0d734e2 + 7684d46 commit fd496ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
18 changes: 6 additions & 12 deletions src/common.toit
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,22 @@ You can add and remove element objects to a Window. They will be drawn
and are overwritten by elements added later.
*/
interface Window:
add element /Element -> none
remove element /Element -> none
add element/Element -> none
remove element/Element -> none
remove_all -> none

// Called by elements that have been added to this.
child_invalidated_element x/int y/int w/int h/int ->none
// Called by elements that have been added to this.
child_invalidated_element x/int y/int w/int h/int -> none

/**
Something you can draw on a canvas. It could be a text string, a pixmap or
a geometric figure. They can be stacked up and will be drawn from back to
front, with transparency.
*/
abstract class ElementOrTexture_:
hash_code /int ::= random 0 0x10000000
change_tracker /Window? := null
hash_code/int ::= random 0 0x10000000
change_tracker/Window? := null

/**
Writes the image data to a canvas window.
Expand Down Expand Up @@ -61,13 +62,6 @@ abstract class Canvas:
abstract make_alpha_map -> Canvas
abstract make_alpha_map --padding/int -> Canvas

/*
A, C disjoint or one of them is empty 0
A subset of C, A not empty 1
C subset of A, C not empty 2
A identical to C and non-empty 3
*/

static DISJOINT ::= 0 // The area and the canvas are disjoint.
static AREA_IN_CANVAS ::= 1 // The area is a subset of the canvas.
static CANVAS_IN_AREA ::= 2 // The canvas is a subset of the area.
Expand Down
14 changes: 8 additions & 6 deletions src/pixel_display.toit
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ abstract class PixelDisplay implements Window:
transform_ /Transform

// By default the orientation is the natural orientation of the display driver.
// If $portrait is false, then a landscape orientation is used.
// If $portrait is true, then a portrait orientation is used, or in the case
// that the display driver is exactly square, a rotated orientation is used.
// The orientation is rotated by 180 degrees if $inverted is true.
/**
By default the orientation is the natural orientation of the display driver.
If $portrait is false, then a landscape orientation is used.
If $portrait is true, then a portrait orientation is used, or in the case
that the display driver is exactly square, a rotated orientation is used.
The orientation is rotated by 180 degrees if $inverted is true.
*/
constructor .driver_ --transform/Transform?=null --portrait/bool?=null --inverted/bool=false:
x_rounding_ = driver_.x_rounding
y_rounding_ = driver_.y_rounding
Expand Down Expand Up @@ -401,7 +403,7 @@ abstract class PixelDisplay implements Window:
idx := (top >> 6) * dirty_bytes_per_line_ + (left >> 3)
end_idx := ((round_up bottom 64) >> 6) * dirty_bytes_per_line_
dirty_accumulator_[0] = CLEAN_
blit dirty_[idx..end_idx] dirty_accumulator_ (right - left + 7) >> 3 --source_line_stride=dirty_bytes_per_line_ --destination_pixel_stride=0 --destination_line_stride=0 --operation=OR
blit dirty_[idx..end_idx] dirty_accumulator_ ((right - left + 7) >> 3) --source_line_stride=dirty_bytes_per_line_ --destination_pixel_stride=0 --destination_line_stride=0 --operation=OR
if dirty_accumulator_[0] & mask == CLEAN_:
continue

Expand Down

0 comments on commit fd496ce

Please sign in to comment.