shareable: Rename variables

This commit is contained in:
Hajime Hoshi 2018-07-22 04:32:36 +09:00
parent a6edb90898
commit 09dcba40ab
2 changed files with 8 additions and 8 deletions

View File

@ -92,7 +92,7 @@ type Image struct {
backend *backend backend *backend
node *packing.Node node *packing.Node
sharedCount int countForShare int
} }
func (i *Image) isShared() bool { func (i *Image) isShared() bool {
@ -182,7 +182,7 @@ func (i *Image) QuadVertices(sx0, sy0, sx1, sy1 int, a, b, c, d, tx, ty float32)
return graphicsutil.QuadVertices(w, h, sx0+dx, sy0+dy, sx1+dx, sy1+dy, a, b, c, d, tx, ty) return graphicsutil.QuadVertices(w, h, sx0+dx, sy0+dy, sx1+dx, sy1+dy, a, b, c, d, tx, ty)
} }
const ReshareCount = 10 const MaxCountForShare = 10
func (i *Image) DrawImage(img *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) { func (i *Image) DrawImage(img *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) {
backendsM.Lock() backendsM.Lock()
@ -208,12 +208,12 @@ func (i *Image) DrawImage(img *Image, vertices []float32, indices []uint16, colo
i.backend.restorable.DrawImage(img.backend.restorable, vertices, indices, colorm, mode, filter) i.backend.restorable.DrawImage(img.backend.restorable, vertices, indices, colorm, mode, filter)
i.sharedCount = 0 i.countForShare = 0
if !img.isShared() && img.shareable() { if !img.isShared() && img.shareable() {
img.sharedCount++ img.countForShare++
if img.sharedCount >= ReshareCount { if img.countForShare >= MaxCountForShare {
img.forceShared() img.forceShared()
img.sharedCount = 0 img.countForShare = 0
} }
} }
} }

View File

@ -150,7 +150,7 @@ func TestReshared(t *testing.T) {
} }
// Use img1 as a render source. // Use img1 as a render source.
for i := 0; i < ReshareCount-1; i++ { for i := 0; i < MaxCountForShare-1; i++ {
img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest) img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
want := false want := false
if got := img1.IsSharedForTesting(); got != want { if got := img1.IsSharedForTesting(); got != want {