Debian Codegraph @

shiny/driver/mtldriver/texture.go

raw symbols SCIP
1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build darwin && cgo
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 // textureImpl implements screen.Texture.
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 }