mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
parent
d906dc3a21
commit
21ef462c37
@ -105,7 +105,8 @@ func (b *backend) tryAlloc(width, height int) (*packing.Node, bool) {
|
|||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
b.restorable = b.restorable.Extend(b.page.Size())
|
w, h := b.page.Size()
|
||||||
|
b.restorable = b.restorable.Extend(w, h)
|
||||||
|
|
||||||
return n, true
|
return n, true
|
||||||
}
|
}
|
||||||
@ -652,7 +653,7 @@ func (i *Image) allocate(forbiddenBackends []*backend, asSource bool) {
|
|||||||
}
|
}
|
||||||
// A screen image doesn't have a padding.
|
// A screen image doesn't have a padding.
|
||||||
i.backend = &backend{
|
i.backend = &backend{
|
||||||
restorable: restorable.NewImage(i.width, i.height, restorable.ImageTypeScreen),
|
restorable: restorable.NewImage(i.width, i.height, true),
|
||||||
}
|
}
|
||||||
theBackends = append(theBackends, i.backend)
|
theBackends = append(theBackends, i.backend)
|
||||||
return
|
return
|
||||||
@ -667,7 +668,7 @@ func (i *Image) allocate(forbiddenBackends []*backend, asSource bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
i.backend = &backend{
|
i.backend = &backend{
|
||||||
restorable: restorable.NewImage(wp, hp, restorable.ImageTypeRegular),
|
restorable: restorable.NewImage(wp, hp, false),
|
||||||
source: asSource && i.imageType == ImageTypeRegular,
|
source: asSource && i.imageType == ImageTypeRegular,
|
||||||
}
|
}
|
||||||
theBackends = append(theBackends, i.backend)
|
theBackends = append(theBackends, i.backend)
|
||||||
@ -713,7 +714,7 @@ loop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
b := &backend{
|
b := &backend{
|
||||||
restorable: restorable.NewImage(width, height, restorable.ImageTypeRegular),
|
restorable: restorable.NewImage(width, height, false),
|
||||||
page: packing.NewPage(width, height, maxSize),
|
page: packing.NewPage(width, height, maxSize),
|
||||||
source: asSource,
|
source: asSource,
|
||||||
}
|
}
|
||||||
|
@ -23,16 +23,6 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ImageType int
|
|
||||||
|
|
||||||
const (
|
|
||||||
// ImageTypeRegular indicates the image is a regular image.
|
|
||||||
ImageTypeRegular ImageType = iota
|
|
||||||
|
|
||||||
// ImageTypeScreen indicates the image is used as an actual screen.
|
|
||||||
ImageTypeScreen
|
|
||||||
)
|
|
||||||
|
|
||||||
// Image represents an image.
|
// Image represents an image.
|
||||||
type Image struct {
|
type Image struct {
|
||||||
// Image is the underlying image.
|
// Image is the underlying image.
|
||||||
@ -42,8 +32,6 @@ type Image struct {
|
|||||||
|
|
||||||
width int
|
width int
|
||||||
height int
|
height int
|
||||||
|
|
||||||
imageType ImageType
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewImage creates an emtpy image with the given size.
|
// NewImage creates an emtpy image with the given size.
|
||||||
@ -51,12 +39,11 @@ type Image struct {
|
|||||||
// The returned image is cleared.
|
// The returned image is cleared.
|
||||||
//
|
//
|
||||||
// Note that Dispose is not called automatically.
|
// Note that Dispose is not called automatically.
|
||||||
func NewImage(width, height int, imageType ImageType) *Image {
|
func NewImage(width, height int, screen bool) *Image {
|
||||||
i := &Image{
|
i := &Image{
|
||||||
Image: graphicscommand.NewImage(width, height, imageType == ImageTypeScreen),
|
Image: graphicscommand.NewImage(width, height, screen),
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
imageType: imageType,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This needs to use 'InternalSize' to render the whole region, or edges are unexpectedly cleared on some
|
// This needs to use 'InternalSize' to render the whole region, or edges are unexpectedly cleared on some
|
||||||
@ -74,7 +61,8 @@ func (i *Image) Extend(width, height int) *Image {
|
|||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
newImg := NewImage(width, height, i.imageType)
|
// Assume that the screen image is never extended.
|
||||||
|
newImg := NewImage(width, height, false)
|
||||||
|
|
||||||
// Use DrawTriangles instead of WritePixels because the image i might be stale and not have its pixels
|
// Use DrawTriangles instead of WritePixels because the image i might be stale and not have its pixels
|
||||||
// information.
|
// information.
|
||||||
|
Loading…
Reference in New Issue
Block a user