Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flutter_boost_1.22.4
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
flutter_boost_1.22.4
Commits
7b50cfd5
Commit
7b50cfd5
authored
Nov 08, 2019
by
yangwu.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed Surface method 'release' not called
parent
1638a553
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
152 additions
and
1 deletion
+152
-1
android/src/main/java/com/idlefish/flutterboost/XFlutterTextureView.java
...n/java/com/idlefish/flutterboost/XFlutterTextureView.java
+151
-0
android/src/main/java/com/idlefish/flutterboost/XFlutterView.java
...src/main/java/com/idlefish/flutterboost/XFlutterView.java
+1
-1
No files found.
android/src/main/java/com/idlefish/flutterboost/XFlutterTextureView.java
0 → 100644
View file @
7b50cfd5
package
com.idlefish.flutterboost
;
import
android.content.Context
;
import
android.graphics.SurfaceTexture
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.util.AttributeSet
;
import
android.view.Surface
;
import
android.view.TextureView
;
import
io.flutter.Log
;
import
io.flutter.embedding.engine.renderer.FlutterRenderer
;
import
io.flutter.embedding.engine.renderer.OnFirstFrameRenderedListener
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Set
;
public
class
XFlutterTextureView
extends
TextureView
implements
FlutterRenderer
.
RenderSurface
{
private
static
final
String
TAG
=
"XFlutterTextureView"
;
private
boolean
isSurfaceAvailableForRendering
;
private
boolean
isAttachedToFlutterRenderer
;
@Nullable
private
FlutterRenderer
flutterRenderer
;
@NonNull
private
Set
<
OnFirstFrameRenderedListener
>
onFirstFrameRenderedListeners
;
private
final
SurfaceTextureListener
surfaceTextureListener
;
public
XFlutterTextureView
(
@NonNull
Context
context
)
{
this
(
context
,
(
AttributeSet
)
null
);
}
public
XFlutterTextureView
(
@NonNull
Context
context
,
@Nullable
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
this
.
isSurfaceAvailableForRendering
=
false
;
this
.
isAttachedToFlutterRenderer
=
false
;
this
.
onFirstFrameRenderedListeners
=
new
HashSet
();
this
.
surfaceTextureListener
=
new
SurfaceTextureListener
()
{
public
void
onSurfaceTextureAvailable
(
SurfaceTexture
surfaceTexture
,
int
width
,
int
height
)
{
Log
.
v
(
"FlutterTextureView"
,
"SurfaceTextureListener.onSurfaceTextureAvailable()"
);
XFlutterTextureView
.
this
.
isSurfaceAvailableForRendering
=
true
;
if
(
XFlutterTextureView
.
this
.
isAttachedToFlutterRenderer
)
{
XFlutterTextureView
.
this
.
connectSurfaceToRenderer
();
}
}
public
void
onSurfaceTextureSizeChanged
(
@NonNull
SurfaceTexture
surface
,
int
width
,
int
height
)
{
Log
.
v
(
"FlutterTextureView"
,
"SurfaceTextureListener.onSurfaceTextureSizeChanged()"
);
if
(
XFlutterTextureView
.
this
.
isAttachedToFlutterRenderer
)
{
XFlutterTextureView
.
this
.
changeSurfaceSize
(
width
,
height
);
}
}
public
void
onSurfaceTextureUpdated
(
@NonNull
SurfaceTexture
surface
)
{
}
public
boolean
onSurfaceTextureDestroyed
(
@NonNull
SurfaceTexture
surface
)
{
Log
.
v
(
"FlutterTextureView"
,
"SurfaceTextureListener.onSurfaceTextureDestroyed()"
);
XFlutterTextureView
.
this
.
isSurfaceAvailableForRendering
=
false
;
if
(
XFlutterTextureView
.
this
.
isAttachedToFlutterRenderer
)
{
XFlutterTextureView
.
this
.
disconnectSurfaceFromRenderer
();
}
return
true
;
}
};
this
.
init
();
}
private
void
init
()
{
this
.
setSurfaceTextureListener
(
this
.
surfaceTextureListener
);
}
public
void
attachToRenderer
(
@NonNull
FlutterRenderer
flutterRenderer
)
{
Log
.
v
(
"FlutterTextureView"
,
"Attaching to FlutterRenderer."
);
if
(
this
.
flutterRenderer
!=
null
)
{
Log
.
v
(
"FlutterTextureView"
,
"Already connected to a FlutterRenderer. Detaching from old one and attaching to new one."
);
this
.
flutterRenderer
.
detachFromRenderSurface
();
}
this
.
flutterRenderer
=
flutterRenderer
;
this
.
isAttachedToFlutterRenderer
=
true
;
if
(
this
.
isSurfaceAvailableForRendering
)
{
Log
.
v
(
"FlutterTextureView"
,
"Surface is available for rendering. Connecting FlutterRenderer to Android surface."
);
this
.
connectSurfaceToRenderer
();
}
}
public
void
detachFromRenderer
()
{
if
(
this
.
flutterRenderer
!=
null
)
{
if
(
this
.
getWindowToken
()
!=
null
)
{
Log
.
v
(
"FlutterTextureView"
,
"Disconnecting FlutterRenderer from Android surface."
);
this
.
disconnectSurfaceFromRenderer
();
}
this
.
flutterRenderer
=
null
;
this
.
isAttachedToFlutterRenderer
=
false
;
}
else
{
Log
.
w
(
"FlutterTextureView"
,
"detachFromRenderer() invoked when no FlutterRenderer was attached."
);
}
}
private
void
connectSurfaceToRenderer
()
{
if
(
this
.
flutterRenderer
!=
null
&&
this
.
getSurfaceTexture
()
!=
null
)
{
Surface
surface
=
new
Surface
(
this
.
getSurfaceTexture
());
this
.
flutterRenderer
.
surfaceCreated
(
surface
);
surface
.
release
();
}
else
{
throw
new
IllegalStateException
(
"connectSurfaceToRenderer() should only be called when flutterRenderer and getSurfaceTexture() are non-null."
);
}
}
private
void
changeSurfaceSize
(
int
width
,
int
height
)
{
if
(
this
.
flutterRenderer
==
null
)
{
throw
new
IllegalStateException
(
"changeSurfaceSize() should only be called when flutterRenderer is non-null."
);
}
else
{
Log
.
v
(
"FlutterTextureView"
,
"Notifying FlutterRenderer that Android surface size has changed to "
+
width
+
" x "
+
height
);
this
.
flutterRenderer
.
surfaceChanged
(
width
,
height
);
}
}
private
void
disconnectSurfaceFromRenderer
()
{
if
(
this
.
flutterRenderer
==
null
)
{
throw
new
IllegalStateException
(
"disconnectSurfaceFromRenderer() should only be called when flutterRenderer is non-null."
);
}
else
{
this
.
flutterRenderer
.
surfaceDestroyed
();
}
}
public
void
addOnFirstFrameRenderedListener
(
@NonNull
OnFirstFrameRenderedListener
listener
)
{
this
.
onFirstFrameRenderedListeners
.
add
(
listener
);
}
public
void
removeOnFirstFrameRenderedListener
(
@NonNull
OnFirstFrameRenderedListener
listener
)
{
this
.
onFirstFrameRenderedListeners
.
remove
(
listener
);
}
public
void
onFirstFrameRendered
()
{
Log
.
v
(
"FlutterTextureView"
,
"onFirstFrameRendered()"
);
Iterator
var1
=
this
.
onFirstFrameRenderedListeners
.
iterator
();
while
(
var1
.
hasNext
())
{
OnFirstFrameRenderedListener
listener
=
(
OnFirstFrameRenderedListener
)
var1
.
next
();
listener
.
onFirstFrameRendered
();
}
}
}
\ No newline at end of file
android/src/main/java/com/idlefish/flutterboost/XFlutterView.java
View file @
7b50cfd5
...
@@ -202,7 +202,7 @@ public class XFlutterView extends FrameLayout {
...
@@ -202,7 +202,7 @@ public class XFlutterView extends FrameLayout {
break
;
break
;
case
texture:
case
texture:
Log
.
v
(
TAG
,
"Internally using a FlutterTextureView."
);
Log
.
v
(
TAG
,
"Internally using a FlutterTextureView."
);
FlutterTextureView
flutterTextureView
=
new
FlutterTextureView
(
getContext
());
XFlutterTextureView
flutterTextureView
=
new
X
FlutterTextureView
(
getContext
());
renderSurface
=
flutterTextureView
;
renderSurface
=
flutterTextureView
;
addView
(
flutterTextureView
);
addView
(
flutterTextureView
);
break
;
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment