Add comments

This commit is contained in:
Hajime Hoshi 2018-03-01 02:49:45 +09:00
parent 676a023a30
commit 1a898dd1b9
2 changed files with 6 additions and 0 deletions

View File

@ -27,6 +27,8 @@ import (
// If origImg is a paletted image, an optimized copying method is used.
//
// CopyImage is used only internally but it is exposed for testing.
//
// TODO: CopyImage should return []byte (#521)
func CopyImage(origImg image.Image) *image.RGBA {
size := origImg.Bounds().Size()
w, h := size.X, size.Y

View File

@ -164,7 +164,11 @@ func (i *Image) ReplacePixels(pixels []byte, x, y, width, height int) {
if x < 0 || y < 0 || w <= x || h <= y || x+width <= 0 || y+height <= 0 || w < x+width || h < y+height {
panic(fmt.Sprintf("restorable: out of range x: %d, y: %d, width: %d, height: %d", x, y, width, height))
}
// TODO: Avoid making other images stale if possible.
// For this purpuse, images should remember which part of that is used for DrawImage.
theImages.makeStaleIfDependingOn(i)
i.image.ReplacePixels(pixels, x, y, width, height)
// Copy the pixels so that this works even p is modified just after ReplacePixels.