mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
gpu: avoid pointers of pathData
Save allocations by using pathData instead of *pathData. Signed-off-by: Viktor <viktor.ogeman@gmail.com>
This commit is contained in:
+3
-3
@@ -26,7 +26,7 @@ type opCache struct {
|
||||
}
|
||||
|
||||
type opCacheValue struct {
|
||||
data *pathData
|
||||
data pathData
|
||||
bounds f32.Rectangle
|
||||
key ops.Key
|
||||
keep bool
|
||||
@@ -120,9 +120,9 @@ func (r *opCache) frame() {
|
||||
if v.keep {
|
||||
continue
|
||||
}
|
||||
if v.data != nil {
|
||||
if v.data.data != nil {
|
||||
v.data.release()
|
||||
r.cache[i].data = nil
|
||||
r.cache[i].data.data = nil
|
||||
}
|
||||
delete(r.index, v.key)
|
||||
r.freelist = append(r.freelist, i)
|
||||
|
||||
+1
-1
@@ -318,7 +318,7 @@ func (g *GPU) Collect(viewport image.Point, frameOps *op.Ops) {
|
||||
g.cleanupTimer = g.timers.newTimer()
|
||||
}
|
||||
for _, p := range g.drawOps.pathOps {
|
||||
if v, exists := g.drawOps.pathCache.get(p.pathKey); !exists || v.data == nil {
|
||||
if v, exists := g.drawOps.pathCache.get(p.pathKey); !exists || v.data.data == nil {
|
||||
data := buildPath(g.ctx, p.pathVerts)
|
||||
g.drawOps.pathCache.put(p.pathKey, opCacheValue{
|
||||
data: data,
|
||||
|
||||
+5
-5
@@ -289,18 +289,18 @@ func (c *coverer) release() {
|
||||
c.layout.Release()
|
||||
}
|
||||
|
||||
func buildPath(ctx backend.Device, p []byte) *pathData {
|
||||
func buildPath(ctx backend.Device, p []byte) pathData {
|
||||
buf, err := ctx.NewImmutableBuffer(backend.BufferBindingVertices, p)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &pathData{
|
||||
return pathData{
|
||||
ncurves: len(p) / vertStride,
|
||||
data: buf,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *pathData) release() {
|
||||
func (p pathData) release() {
|
||||
p.data.Release()
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ func (p *pather) begin(sizes []image.Point) {
|
||||
p.stenciler.begin(sizes)
|
||||
}
|
||||
|
||||
func (p *pather) stencilPath(bounds image.Rectangle, offset f32.Point, uv image.Point, data *pathData) {
|
||||
func (p *pather) stencilPath(bounds image.Rectangle, offset f32.Point, uv image.Point, data pathData) {
|
||||
p.stenciler.stencilPath(bounds, offset, uv, data)
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ func (s *stenciler) begin(sizes []image.Point) {
|
||||
s.ctx.BindIndexBuffer(s.indexBuf)
|
||||
}
|
||||
|
||||
func (s *stenciler) stencilPath(bounds image.Rectangle, offset f32.Point, uv image.Point, data *pathData) {
|
||||
func (s *stenciler) stencilPath(bounds image.Rectangle, offset f32.Point, uv image.Point, data pathData) {
|
||||
s.ctx.Viewport(uv.X, uv.Y, bounds.Dx(), bounds.Dy())
|
||||
// Transform UI coordinates to OpenGL coordinates.
|
||||
texSize := f32.Point{X: float32(bounds.Dx()), Y: float32(bounds.Dy())}
|
||||
|
||||
Reference in New Issue
Block a user