|
@@ -58,14 +58,9 @@ Class Image Extends Resource
|
|
|
|
|
|
Local texture:=New Texture( pixmap,textureFlags )
|
|
Local texture:=New Texture( pixmap,textureFlags )
|
|
|
|
|
|
- Init( texture,shader )
|
|
|
|
-
|
|
|
|
- AddDependancy( texture )
|
|
|
|
- End
|
|
|
|
-
|
|
|
|
- Method New( width:Int,height:Int,textureFlags:TextureFlags=null,shader:Shader=Null )
|
|
|
|
|
|
+ Discarded+=texture.Release
|
|
|
|
|
|
- Self.New( width,height,PixelFormat.RGBA8,textureFlags,shader )
|
|
|
|
|
|
+ Init( texture,shader )
|
|
End
|
|
End
|
|
|
|
|
|
Method New( width:Int,height:Int,format:PixelFormat,textureFlags:TextureFlags=Null,shader:Shader=Null )
|
|
Method New( width:Int,height:Int,format:PixelFormat,textureFlags:TextureFlags=Null,shader:Shader=Null )
|
|
@@ -74,17 +69,20 @@ Class Image Extends Resource
|
|
|
|
|
|
Local texture:=New Texture( width,height,format,textureFlags )
|
|
Local texture:=New Texture( width,height,format,textureFlags )
|
|
|
|
|
|
|
|
+ Discarded+=texture.Release
|
|
|
|
+
|
|
Init( texture,shader )
|
|
Init( texture,shader )
|
|
|
|
+ End
|
|
|
|
+
|
|
|
|
+ Method New( width:Int,height:Int,textureFlags:TextureFlags=null,shader:Shader=Null )
|
|
|
|
|
|
- AddDependancy( texture )
|
|
|
|
|
|
+ Self.New( width,height,PixelFormat.RGBA8,textureFlags,shader )
|
|
End
|
|
End
|
|
|
|
|
|
Method New( image:Image )
|
|
Method New( image:Image )
|
|
|
|
|
|
Init( image._textures[0],image._rect,image._shader )
|
|
Init( image._textures[0],image._rect,image._shader )
|
|
|
|
|
|
- image.AddDependancy( Self )
|
|
|
|
-
|
|
|
|
For Local i:=1 Until 4
|
|
For Local i:=1 Until 4
|
|
SetTexture( i,image.GetTexture( i ) )
|
|
SetTexture( i,image.GetTexture( i ) )
|
|
Next
|
|
Next
|
|
@@ -100,8 +98,6 @@ Class Image Extends Resource
|
|
|
|
|
|
Init( image._textures[0],rect+image._rect.Origin,image._shader )
|
|
Init( image._textures[0],rect+image._rect.Origin,image._shader )
|
|
|
|
|
|
- image.AddDependancy( Self )
|
|
|
|
-
|
|
|
|
For Local i:=1 Until 4
|
|
For Local i:=1 Until 4
|
|
SetTexture( i,image.GetTexture( i ) )
|
|
SetTexture( i,image.GetTexture( i ) )
|
|
Next
|
|
Next
|
|
@@ -336,10 +332,8 @@ Class Image Extends Resource
|
|
If Not shader shader=mojo.graphics.Shader.GetShader( "sprite" )
|
|
If Not shader shader=mojo.graphics.Shader.GetShader( "sprite" )
|
|
|
|
|
|
Local image:=New Image( pixmap,Null,shader )
|
|
Local image:=New Image( pixmap,Null,shader )
|
|
-
|
|
|
|
- image.OnDiscarded+=Lambda()
|
|
|
|
- pixmap.Discard()
|
|
|
|
- End
|
|
|
|
|
|
+
|
|
|
|
+ image.Discarded+=pixmap.Release
|
|
|
|
|
|
Return image
|
|
Return image
|
|
End
|
|
End
|
|
@@ -367,12 +361,11 @@ Class Image Extends Resource
|
|
If Not shader shader=graphics.Shader.GetShader( "bump" )
|
|
If Not shader shader=graphics.Shader.GetShader( "bump" )
|
|
|
|
|
|
Local image:=New Image( texture0,shader )
|
|
Local image:=New Image( texture0,shader )
|
|
- image.SetTexture( 1,texture1 )
|
|
|
|
|
|
+
|
|
|
|
+ image.Discarded+=texture0.Release
|
|
|
|
+ image.Discarded+=texture1.Release
|
|
|
|
|
|
- image.OnDiscarded+=Lambda()
|
|
|
|
- If texture0 texture0.Discard()
|
|
|
|
- If texture1 texture1.Discard()
|
|
|
|
- End
|
|
|
|
|
|
+ image.SetTexture( 1,texture1 )
|
|
|
|
|
|
Return image
|
|
Return image
|
|
End
|
|
End
|
|
@@ -395,7 +388,7 @@ Class Image Extends Resource
|
|
|
|
|
|
Local tpixmap:=pixmap
|
|
Local tpixmap:=pixmap
|
|
pixmap=pixmap.Convert( PixelFormat.IA16 )
|
|
pixmap=pixmap.Convert( PixelFormat.IA16 )
|
|
- tpixmap.Discard()
|
|
|
|
|
|
+ tpixmap.Release()
|
|
|
|
|
|
'Copy A->I
|
|
'Copy A->I
|
|
For Local y:=0 Until pixmap.Height
|
|
For Local y:=0 Until pixmap.Height
|
|
@@ -410,7 +403,7 @@ Class Image Extends Resource
|
|
|
|
|
|
Local tpixmap:=pixmap
|
|
Local tpixmap:=pixmap
|
|
pixmap=pixmap.Convert( PixelFormat.IA16 )
|
|
pixmap=pixmap.Convert( PixelFormat.IA16 )
|
|
- tpixmap.Discard()
|
|
|
|
|
|
+ tpixmap.Release()
|
|
|
|
|
|
'Copy I->A
|
|
'Copy I->A
|
|
For Local y:=0 Until pixmap.Height
|
|
For Local y:=0 Until pixmap.Height
|
|
@@ -425,7 +418,7 @@ Class Image Extends Resource
|
|
|
|
|
|
Local tpixmap:=pixmap
|
|
Local tpixmap:=pixmap
|
|
pixmap=pixmap.Convert( PixelFormat.RGBA32 )
|
|
pixmap=pixmap.Convert( PixelFormat.RGBA32 )
|
|
- tpixmap.Discard()
|
|
|
|
|
|
+ tpixmap.Release()
|
|
|
|
|
|
'Copy Max(R,G,B)->A
|
|
'Copy Max(R,G,B)->A
|
|
For Local y:=0 Until pixmap.Height
|
|
For Local y:=0 Until pixmap.Height
|
|
@@ -442,18 +435,13 @@ Class Image Extends Resource
|
|
|
|
|
|
Local image:=New Image( texture,shader )
|
|
Local image:=New Image( texture,shader )
|
|
|
|
|
|
- image.OnDiscarded+=Lambda()
|
|
|
|
- pixmap.Discard()
|
|
|
|
- End
|
|
|
|
-
|
|
|
|
Return image
|
|
Return image
|
|
End
|
|
End
|
|
-
|
|
|
|
|
|
+
|
|
Private
|
|
Private
|
|
|
|
|
|
Field _shader:Shader
|
|
Field _shader:Shader
|
|
Field _material:UniformBlock
|
|
Field _material:UniformBlock
|
|
-
|
|
|
|
Field _textures:=New Texture[4]
|
|
Field _textures:=New Texture[4]
|
|
Field _blendMode:BlendMode
|
|
Field _blendMode:BlendMode
|
|
Field _color:Color
|
|
Field _color:Color
|
|
@@ -482,8 +470,6 @@ Class Image Extends Resource
|
|
_shader=shader
|
|
_shader=shader
|
|
_material=New UniformBlock( 2 )
|
|
_material=New UniformBlock( 2 )
|
|
|
|
|
|
- AddDependancy( _material )
|
|
|
|
-
|
|
|
|
SetTexture( 0,texture )
|
|
SetTexture( 0,texture )
|
|
|
|
|
|
BlendMode=BlendMode.None
|
|
BlendMode=BlendMode.None
|
|
@@ -538,11 +524,14 @@ Class ResourceManager Extension
|
|
|
|
|
|
Local image:=Cast<Image>( OpenResource( slug ) )
|
|
Local image:=Cast<Image>( OpenResource( slug ) )
|
|
If image Return image
|
|
If image Return image
|
|
-
|
|
|
|
|
|
+
|
|
Local texture:=OpenTexture( path,Null )
|
|
Local texture:=OpenTexture( path,Null )
|
|
- If texture image=New Image( texture,shader )
|
|
|
|
|
|
+ If Not texture Return Null
|
|
|
|
|
|
|
|
+ image=New Image( texture,shader )
|
|
|
|
+
|
|
AddResource( slug,image )
|
|
AddResource( slug,image )
|
|
|
|
+
|
|
Return image
|
|
Return image
|
|
End
|
|
End
|
|
|
|
|