Skip to content

Commit f56e3f3

Browse files
committed
[BREAKING] ae.utils.graphics: Constness fixes
Make opIndex[x, y] callable with const objects. Changes required: - If you have a view using DirectView and implementing the scanline method, ensure it is callable with a const this.
1 parent 6348a29 commit f56e3f3

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

utils/graphics/gdi.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct GDICanvas(COLOR)
5555
int w, h;
5656
COLOR* pixels;
5757

58-
COLOR[] scanline(int y)
58+
inout(COLOR)[] scanline(int y) inout
5959
{
6060
assert(y>=0 && y<h);
6161
return pixels[w*y..w*(y+1)];

utils/graphics/image.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct ImageRef(COLOR)
3232
COLOR* pixels;
3333

3434
/// Returns an array for the pixels at row y.
35-
COLOR[] scanline(int y)
35+
inout(COLOR)[] scanline(int y) inout
3636
{
3737
assert(y>=0 && y<h, "Scanline out-of-bounds");
3838
assert(pitch, "Pitch not set");
@@ -75,7 +75,7 @@ struct Image(COLOR)
7575
COLOR[] pixels;
7676

7777
/// Returns an array for the pixels at row y.
78-
COLOR[] scanline(int y)
78+
inout(COLOR)[] scanline(int y) inout
7979
{
8080
assert(y>=0 && y<h, "Scanline out-of-bounds");
8181
auto start = w*y;

utils/graphics/view.d

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ enum isDirectView(T) =
4444
/// existing direct view primitives.
4545
mixin template DirectView()
4646
{
47-
alias COLOR = typeof(scanline(0)[0]);
47+
import std.traits : Unqual;
48+
alias COLOR = Unqual!(typeof(scanline(0)[0]));
4849

4950
/// Implements the view[x, y] operator.
50-
ref COLOR opIndex(int x, int y)
51+
ref inout(COLOR) opIndex(int x, int y) inout
5152
{
5253
return scanline(y)[x];
5354
}

0 commit comments

Comments
 (0)