From b8e8d723776bca7cced159144be97a82b165516b Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 7 Jun 2022 23:45:35 +0900 Subject: [PATCH] internal/restorable: rename ImageTypeScreenFramebuffer -> ImageTypeScreen --- internal/atlas/image.go | 2 +- internal/restorable/image.go | 16 ++++++++-------- internal/restorable/images.go | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/atlas/image.go b/internal/atlas/image.go index d349217c6..6d46fc2b2 100644 --- a/internal/atlas/image.go +++ b/internal/atlas/image.go @@ -760,7 +760,7 @@ func (i *Image) allocate(putOnAtlas bool) { if i.screen { // A screen image doesn't have a padding. i.backend = &backend{ - restorable: restorable.NewImage(i.width, i.height, restorable.ImageTypeScreenFramebuffer), + restorable: restorable.NewImage(i.width, i.height, restorable.ImageTypeScreen), } return } diff --git a/internal/restorable/image.go b/internal/restorable/image.go index 33a2201bf..1e05bfc5a 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -86,8 +86,8 @@ const ( // ImageTypeRegular indicates the image is a regular image. ImageTypeRegular ImageType = iota - // ImageTypeScreenFramebuffer indicates the image is used as an actual screen. - ImageTypeScreenFramebuffer + // ImageTypeScreen indicates the image is used as an actual screen. + ImageTypeScreen // ImageTypeVolatile indicates the image is cleared whenever a frame starts. ImageTypeVolatile @@ -155,7 +155,7 @@ func NewImage(width, height int, imageType ImageType) *Image { } i := &Image{ - image: graphicscommand.NewImage(width, height, imageType == ImageTypeScreenFramebuffer), + image: graphicscommand.NewImage(width, height, imageType == ImageTypeScreen), width: width, height: height, imageType: imageType, @@ -313,7 +313,7 @@ func (i *Image) ReplacePixels(pixels []byte, mask []byte, x, y, width, height in i.image.ReplacePixels(make([]byte, 4*width*height), nil, x, y, width, height) } - if !NeedsRestoring() || i.imageType == ImageTypeScreenFramebuffer || i.imageType == ImageTypeVolatile { + if !NeedsRestoring() || i.imageType == ImageTypeScreen || i.imageType == ImageTypeVolatile { i.makeStale() return } @@ -387,7 +387,7 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderImageNum]*Image, offsets [gra } } - if srcstale || i.imageType == ImageTypeScreenFramebuffer || !NeedsRestoring() || i.imageType == ImageTypeVolatile { + if srcstale || i.imageType == ImageTypeScreen || !NeedsRestoring() || i.imageType == ImageTypeVolatile { i.makeStale() } else { i.appendDrawTrianglesHistory(srcs, offsets, vertices, indices, colorm, mode, filter, address, dstRegion, srcRegion, shader, uniforms, evenOdd) @@ -412,7 +412,7 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderImageNum]*Image, offsets [gra // appendDrawTrianglesHistory appends a draw-image history item to the image. func (i *Image) appendDrawTrianglesHistory(srcs [graphics.ShaderImageNum]*Image, offsets [graphics.ShaderImageNum - 1][2]float32, vertices []float32, indices []uint16, colorm affine.ColorM, mode graphicsdriver.CompositeMode, filter graphicsdriver.Filter, address graphicsdriver.Address, dstRegion, srcRegion graphicsdriver.Region, shader *Shader, uniforms [][]float32, evenOdd bool) { - if i.stale || i.imageType == ImageTypeVolatile || i.imageType == ImageTypeScreenFramebuffer { + if i.stale || i.imageType == ImageTypeVolatile || i.imageType == ImageTypeScreen { return } // TODO: Would it be possible to merge draw image history items? @@ -518,7 +518,7 @@ func (i *Image) resolveStale(graphicsDriver graphicsdriver.Graphics) error { if i.imageType == ImageTypeVolatile { return nil } - if i.imageType == ImageTypeScreenFramebuffer { + if i.imageType == ImageTypeScreen { return nil } if !i.stale { @@ -580,7 +580,7 @@ func (i *Image) restore(graphicsDriver graphicsdriver.Graphics) error { // Do not dispose the image here. The image should be already disposed. switch i.imageType { - case ImageTypeScreenFramebuffer: + case ImageTypeScreen: // The screen image should also be recreated because framebuffer might // be changed. i.image = graphicscommand.NewImage(w, h, true) diff --git a/internal/restorable/images.go b/internal/restorable/images.go index 52e1335a9..deba5818f 100644 --- a/internal/restorable/images.go +++ b/internal/restorable/images.go @@ -94,7 +94,7 @@ func RestoreIfNeeded(graphicsDriver graphicsdriver.Graphics) error { // This assumes that if there is one image that is invalidated, all images are invalidated. for img := range theImages.images { // The screen image might not have a texture. Skip this. - if img.imageType == ImageTypeScreenFramebuffer { + if img.imageType == ImageTypeScreen { continue } var err error