Remove dependencies on internal/graphics from ebiten

This commit is contained in:
Hajime Hoshi 2017-08-06 21:24:10 +09:00
parent c0ecb7a386
commit 1fb7e123c2
6 changed files with 23 additions and 10 deletions

View File

@ -17,7 +17,6 @@ package ebiten
import ( import (
"math" "math"
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/restorable" "github.com/hajimehoshi/ebiten/internal/restorable"
"github.com/hajimehoshi/ebiten/internal/ui" "github.com/hajimehoshi/ebiten/internal/ui"
) )
@ -76,7 +75,7 @@ func (c *graphicsContext) SetSize(screenWidth, screenHeight int, screenScale flo
func (c *graphicsContext) initializeIfNeeded() error { func (c *graphicsContext) initializeIfNeeded() error {
if !c.initialized { if !c.initialized {
if err := graphics.Reset(); err != nil { if err := restorable.Reset(); err != nil {
return err return err
} }
c.initialized = true c.initialized = true
@ -100,7 +99,7 @@ func drawWithFittingScale(dst *Image, src *Image) {
func (c *graphicsContext) drawToDefaultRenderTarget() error { func (c *graphicsContext) drawToDefaultRenderTarget() error {
_ = c.screen.Clear() _ = c.screen.Clear()
drawWithFittingScale(c.screen, c.offscreen2) drawWithFittingScale(c.screen, c.offscreen2)
if err := graphics.FlushCommands(); err != nil { if err := restorable.FlushCommands(); err != nil {
return err return err
} }
return nil return nil
@ -141,7 +140,7 @@ func (c *graphicsContext) restoreIfNeeded() error {
if !r { if !r {
return nil return nil
} }
if err := graphics.Reset(); err != nil { if err := restorable.Reset(); err != nil {
return err return err
} }
if err := restorable.Restore(); err != nil { if err := restorable.Restore(); err != nil {

View File

@ -17,12 +17,12 @@
package ebiten package ebiten
import ( import (
"github.com/hajimehoshi/ebiten/internal/graphics" "github.com/hajimehoshi/ebiten/internal/restorable"
) )
func (c *graphicsContext) needsRestoring() (bool, error) { func (c *graphicsContext) needsRestoring() (bool, error) {
// FlushCommands is required because c.offscreen.impl might not have an actual texture. // FlushCommands is required because c.offscreen.impl might not have an actual texture.
if err := graphics.FlushCommands(); err != nil { if err := restorable.FlushCommands(); err != nil {
return false, err return false, err
} }
return c.offscreen.restorable.IsInvalidated(), nil return c.offscreen.restorable.IsInvalidated(), nil

View File

@ -20,7 +20,6 @@ import (
"image/color" "image/color"
"runtime" "runtime"
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/math" "github.com/hajimehoshi/ebiten/internal/math"
"github.com/hajimehoshi/ebiten/internal/opengl" "github.com/hajimehoshi/ebiten/internal/opengl"
"github.com/hajimehoshi/ebiten/internal/restorable" "github.com/hajimehoshi/ebiten/internal/restorable"
@ -284,7 +283,7 @@ func newImageWithScreenFramebuffer(width, height int, offsetX, offsetY float64)
return i return i
} }
const MaxImageSize = graphics.MaxImageSize const MaxImageSize = restorable.MaxImageSize
func checkSize(width, height int) { func checkSize(width, height int) {
if width <= 0 { if width <= 0 {

View File

@ -26,6 +26,12 @@ import (
"github.com/hajimehoshi/ebiten/internal/opengl" "github.com/hajimehoshi/ebiten/internal/opengl"
) )
const MaxImageSize = graphics.MaxImageSize
func QuadVertexSizeInBytes() int {
return graphics.QuadVertexSizeInBytes()
}
type drawImageHistoryItem struct { type drawImageHistoryItem struct {
image *Image image *Image
vertices []float32 vertices []float32

View File

@ -15,6 +15,7 @@
package restorable package restorable
import ( import (
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/sync" "github.com/hajimehoshi/ebiten/internal/sync"
) )
@ -164,3 +165,11 @@ func (i *images) clearVolatileImages() {
img.clearIfVolatile() img.clearIfVolatile()
} }
} }
func Reset() error {
return graphics.Reset()
}
func FlushCommands() error {
return graphics.FlushCommands()
}

View File

@ -16,7 +16,7 @@ package ebiten
import ( import (
"github.com/hajimehoshi/ebiten/internal/affine" "github.com/hajimehoshi/ebiten/internal/affine"
"github.com/hajimehoshi/ebiten/internal/graphics" "github.com/hajimehoshi/ebiten/internal/restorable"
) )
// texelAdjustment represents a number to be used to adjust texel. // texelAdjustment represents a number to be used to adjust texel.
@ -26,7 +26,7 @@ import (
const texelAdjustment = 256 const texelAdjustment = 256
var ( var (
quadFloat32Num = graphics.QuadVertexSizeInBytes() / 4 quadFloat32Num = restorable.QuadVertexSizeInBytes() / 4
theVerticesBackend = &verticesBackend{} theVerticesBackend = &verticesBackend{}
) )