internal/atlas: rename functions: Area -> Region

This commit is contained in:
Hajime Hoshi 2022-03-20 04:20:23 +09:00
parent b59dd45239
commit cc574ad67e
4 changed files with 21 additions and 15 deletions

View File

@ -764,7 +764,7 @@ func (i *Image) Set(x, y int, clr color.Color) {
r, g, b, a := clr.RGBA()
pix := []byte{byte(r >> 8), byte(g >> 8), byte(b >> 8), byte(a >> 8)}
if err := i.image.ReplaceSmallAreaPixels(pix, x, y, 1, 1); err != nil {
if err := i.image.ReplaceSmallRegionPixels(pix, x, y, 1, 1); err != nil {
ui.SetError(err)
}
}
@ -815,8 +815,8 @@ func (i *Image) ReplacePixels(pixels []byte) {
// Do not need to copy pixels here.
// * In internal/mipmap, pixels are copied when necessary.
// * In internal/shareable, pixels are copied to make its paddings.
if err := i.image.ReplaceLargeAreaPixels(pixels, r.Min.X, r.Min.Y, r.Dx(), r.Dy()); err != nil {
// * In internal/atlas, pixels are copied to make its paddings.
if err := i.image.ReplaceLargeRegionPixels(pixels, r.Min.X, r.Min.Y, r.Dx(), r.Dy()); err != nil {
ui.SetError(err)
}
}

View File

@ -166,7 +166,10 @@ func (i *Image) DumpScreenshot(graphicsDriver graphicsdriver.Graphics, name stri
return i.img.DumpScreenshot(graphicsDriver, name, blackbg)
}
func (i *Image) ReplaceLargeAreaPixels(pix []byte, x, y, width, height int) error {
// ReplaceLargeRegionPixels replaces the pixels with the specified region.
// ReplaceLargeRegionPixels is used for a relatively large region.
// This call is not accumulated and send one draw call to replace pixels.
func (i *Image) ReplaceLargeRegionPixels(pix []byte, x, y, width, height int) error {
if l := 4 * width * height; len(pix) != l {
panic(fmt.Sprintf("buffered: len(pix) was %d but must be %d", len(pix), l))
}
@ -175,7 +178,7 @@ func (i *Image) ReplaceLargeAreaPixels(pix []byte, x, y, width, height int) erro
copied := make([]byte, len(pix))
copy(copied, pix)
if tryAddDelayedCommand(func() error {
i.ReplaceLargeAreaPixels(copied, x, y, width, height)
i.ReplaceLargeRegionPixels(copied, x, y, width, height)
return nil
}) {
return nil
@ -188,7 +191,10 @@ func (i *Image) ReplaceLargeAreaPixels(pix []byte, x, y, width, height int) erro
return nil
}
func (i *Image) ReplaceSmallAreaPixels(graphicsDriver graphicsdriver.Graphics, pix []byte, x, y, width, height int) error {
// ReplaceSmallRegionPixels replaces the pixels with the specified region.
// ReplaceSmallRegionPixels is used for a relatively small region.
// This call might be accumulated and send one draw call to replace pixels for the accumulated calls.
func (i *Image) ReplaceSmallRegionPixels(graphicsDriver graphicsdriver.Graphics, pix []byte, x, y, width, height int) error {
if l := 4 * width * height; len(pix) != l {
panic(fmt.Sprintf("buffered: len(pix) was %d but must be %d", len(pix), l))
}
@ -197,7 +203,7 @@ func (i *Image) ReplaceSmallAreaPixels(graphicsDriver graphicsdriver.Graphics, p
copied := make([]byte, len(pix))
copy(copied, pix)
if tryAddDelayedCommand(func() error {
i.ReplaceSmallAreaPixels(graphicsDriver, copied, x, y, width, height)
i.ReplaceSmallRegionPixels(graphicsDriver, copied, x, y, width, height)
return nil
}) {
return nil

View File

@ -71,16 +71,16 @@ func (m *Mipmap) DumpScreenshot(graphicsDriver graphicsdriver.Graphics, name str
return m.orig.DumpScreenshot(graphicsDriver, name, blackbg)
}
func (m *Mipmap) ReplaceLargeAreaPixels(pix []byte, x, y, width, height int) error {
if err := m.orig.ReplaceLargeAreaPixels(pix, x, y, width, height); err != nil {
func (m *Mipmap) ReplaceLargeRegionPixels(pix []byte, x, y, width, height int) error {
if err := m.orig.ReplaceLargeRegionPixels(pix, x, y, width, height); err != nil {
return err
}
m.disposeMipmaps()
return nil
}
func (m *Mipmap) ReplaceSmallAreaPixels(graphicsDriver graphicsdriver.Graphics, pix []byte, x, y, width, height int) error {
if err := m.orig.ReplaceSmallAreaPixels(graphicsDriver, pix, x, y, width, height); err != nil {
func (m *Mipmap) ReplaceSmallRegionPixels(graphicsDriver graphicsdriver.Graphics, pix []byte, x, y, width, height int) error {
if err := m.orig.ReplaceSmallRegionPixels(graphicsDriver, pix, x, y, width, height); err != nil {
return err
}
m.disposeMipmaps()

View File

@ -60,12 +60,12 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderImageNum]*Image, vertices []f
i.mipmap.DrawTriangles(srcMipmaps, vertices, indices, colorm, mode, filter, address, dstRegion, srcRegion, subimageOffsets, s, uniforms, evenOdd, canSkipMipmap)
}
func (i *Image) ReplaceLargeAreaPixels(pix []byte, x, y, width, height int) error {
return i.mipmap.ReplaceLargeAreaPixels(pix, x, y, width, height)
func (i *Image) ReplaceLargeRegionPixels(pix []byte, x, y, width, height int) error {
return i.mipmap.ReplaceLargeRegionPixels(pix, x, y, width, height)
}
func (i *Image) ReplaceSmallAreaPixels(pix []byte, x, y, width, height int) error {
return i.mipmap.ReplaceSmallAreaPixels(graphicsDriver(), pix, x, y, width, height)
func (i *Image) ReplaceSmallRegionPixels(pix []byte, x, y, width, height int) error {
return i.mipmap.ReplaceSmallRegionPixels(graphicsDriver(), pix, x, y, width, height)
}
func (i *Image) Pixels(x, y, width, height int) ([]byte, error) {