| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package mtldriver |
| 8 |
|
| 9 |
import ( |
| 10 |
"image" |
| 11 |
"image/color" |
| 12 |
|
| 13 |
"golang.org/x/exp/shiny/screen" |
| 14 |
"golang.org/x/image/draw" |
| 15 |
) |
| 16 |
|
| 17 |
|
| 18 |
type textureImpl struct { |
| 19 |
rgba *image.RGBA |
| 20 |
} |
| 21 |
|
| 22 |
func (*textureImpl) Release() {} |
| 23 |
func (t *textureImpl) Size() image.Point { return t.rgba.Rect.Max } |
| 24 |
func (t *textureImpl) Bounds() image.Rectangle { return t.rgba.Rect } |
| 25 |
|
| 26 |
func (t *textureImpl) Upload(dp image.Point, src screen.Buffer, sr image.Rectangle) { |
| 27 |
draw.Draw(t.rgba, sr.Sub(sr.Min).Add(dp), src.RGBA(), sr.Min, draw.Src) |
| 28 |
} |
| 29 |
|
| 30 |
func (t *textureImpl) Fill(dr image.Rectangle, src color.Color, op draw.Op) { |
| 31 |
draw.Draw(t.rgba, dr, &image.Uniform{src}, image.Point{}, op) |
| 32 |
} |