Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
368380cf
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
368380cf
编写于
1月 03, 2018
作者:
S
Sigurd Meldgaard
提交者:
GitHub
1月 03, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Apply transform to textures on android (#4486) (#4507)
* Apply transform to textures on android
上级
8ed270e5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
55 addition
and
5 deletion
+55
-5
shell/platform/android/android_external_texture_gl.cc
shell/platform/android/android_external_texture_gl.cc
+31
-5
shell/platform/android/android_external_texture_gl.h
shell/platform/android/android_external_texture_gl.h
+4
-0
shell/platform/android/platform_view_android_jni.cc
shell/platform/android/platform_view_android_jni.cc
+16
-0
shell/platform/android/platform_view_android_jni.h
shell/platform/android/platform_view_android_jni.h
+4
-0
未找到文件。
shell/platform/android/android_external_texture_gl.cc
浏览文件 @
368380cf
...
...
@@ -4,7 +4,6 @@
#include "flutter/shell/platform/android/android_external_texture_gl.h"
// #include <GLES/gl.h>
#include <GLES/glext.h>
#include "flutter/common/threads.h"
#include "flutter/shell/platform/android/platform_view_android_jni.h"
...
...
@@ -15,7 +14,7 @@ namespace shell {
AndroidExternalTextureGL
::
AndroidExternalTextureGL
(
int64_t
id
,
const
fml
::
jni
::
JavaObjectWeakGlobalRef
&
surfaceTexture
)
:
Texture
(
id
),
surface_texture_
(
surfaceTexture
)
{}
:
Texture
(
id
),
surface_texture_
(
surfaceTexture
)
,
transform
(
SkMatrix
::
I
())
{}
AndroidExternalTextureGL
::~
AndroidExternalTextureGL
()
=
default
;
...
...
@@ -44,16 +43,42 @@ void AndroidExternalTextureGL::Paint(SkCanvas& canvas, const SkRect& bounds) {
new_frame_ready_
=
false
;
}
GrGLTextureInfo
textureInfo
=
{
GL_TEXTURE_EXTERNAL_OES
,
texture_name_
};
GrBackendTexture
backendTexture
(
bounds
.
width
(),
bounds
.
height
(),
kRGBA_8888_GrPixelConfig
,
textureInfo
);
GrBackendTexture
backendTexture
(
1
,
1
,
kRGBA_8888_GrPixelConfig
,
textureInfo
);
sk_sp
<
SkImage
>
image
=
SkImage
::
MakeFromTexture
(
canvas
.
getGrContext
(),
backendTexture
,
kTopLeft_GrSurfaceOrigin
,
SkAlphaType
::
kPremul_SkAlphaType
,
nullptr
);
if
(
image
)
{
canvas
.
drawImage
(
image
,
bounds
.
x
(),
bounds
.
y
());
SkAutoCanvasRestore
autoRestore
(
&
canvas
,
true
);
canvas
.
translate
(
bounds
.
x
(),
bounds
.
y
());
canvas
.
scale
(
bounds
.
width
(),
bounds
.
height
());
if
(
!
transform
.
isIdentity
())
{
SkMatrix
transformAroundCenter
(
transform
);
transformAroundCenter
.
preTranslate
(
-
0.5
,
-
0.5
);
transformAroundCenter
.
postScale
(
1
,
-
1
);
transformAroundCenter
.
postTranslate
(
0.5
,
0.5
);
canvas
.
concat
(
transformAroundCenter
);
}
canvas
.
drawImage
(
image
,
0
,
0
);
}
}
void
AndroidExternalTextureGL
::
UpdateTransform
()
{
JNIEnv
*
env
=
fml
::
jni
::
AttachCurrentThread
();
fml
::
jni
::
ScopedJavaLocalRef
<
jobject
>
surfaceTexture
=
surface_texture_
.
get
(
env
);
jfloatArray
transformMatrix
=
env
->
NewFloatArray
(
16
);
SurfaceTextureGetTransformMatrix
(
env
,
surfaceTexture
.
obj
(),
transformMatrix
);
float
*
m
=
env
->
GetFloatArrayElements
(
transformMatrix
,
nullptr
);
SkScalar
matrix3
[]
=
{
m
[
0
],
m
[
1
],
m
[
2
],
//
m
[
4
],
m
[
5
],
m
[
6
],
//
m
[
8
],
m
[
9
],
m
[
10
],
//
};
env
->
ReleaseFloatArrayElements
(
transformMatrix
,
m
,
JNI_ABORT
);
transform
.
set9
(
matrix3
);
}
void
AndroidExternalTextureGL
::
OnGrContextDestroyed
()
{
ASSERT_IS_GPU_THREAD
;
if
(
state_
==
AttachmentState
::
attached
)
{
...
...
@@ -77,6 +102,7 @@ void AndroidExternalTextureGL::Update() {
surface_texture_
.
get
(
env
);
if
(
!
surfaceTexture
.
is_null
())
{
SurfaceTextureUpdateTexImage
(
env
,
surfaceTexture
.
obj
());
UpdateTransform
();
}
}
...
...
shell/platform/android/android_external_texture_gl.h
浏览文件 @
368380cf
...
...
@@ -35,6 +35,8 @@ class AndroidExternalTextureGL : public flow::Texture {
void
Detach
();
void
UpdateTransform
();
enum
class
AttachmentState
{
uninitialized
,
attached
,
detached
};
fml
::
jni
::
JavaObjectWeakGlobalRef
surface_texture_
;
...
...
@@ -45,6 +47,8 @@ class AndroidExternalTextureGL : public flow::Texture {
GLuint
texture_name_
=
0
;
SkMatrix
transform
;
FXL_DISALLOW_COPY_AND_ASSIGN
(
AndroidExternalTextureGL
);
};
...
...
shell/platform/android/platform_view_android_jni.cc
浏览文件 @
368380cf
...
...
@@ -90,6 +90,15 @@ void SurfaceTextureUpdateTexImage(JNIEnv* env, jobject obj) {
FXL_CHECK
(
CheckException
(
env
));
}
static
jmethodID
g_get_transform_matrix_method
=
nullptr
;
void
SurfaceTextureGetTransformMatrix
(
JNIEnv
*
env
,
jobject
obj
,
jfloatArray
result
)
{
ASSERT_IS_GPU_THREAD
;
env
->
CallVoidMethod
(
obj
,
g_get_transform_matrix_method
,
result
);
FXL_CHECK
(
CheckException
(
env
));
}
static
jmethodID
g_detach_from_gl_context_method
=
nullptr
;
void
SurfaceTextureDetachFromGLContext
(
JNIEnv
*
env
,
jobject
obj
)
{
ASSERT_IS_GPU_THREAD
;
...
...
@@ -502,6 +511,13 @@ bool PlatformViewAndroid::Register(JNIEnv* env) {
return
false
;
}
g_get_transform_matrix_method
=
env
->
GetMethodID
(
g_surface_texture_class
->
obj
(),
"getTransformMatrix"
,
"([F)V"
);
if
(
g_get_transform_matrix_method
==
nullptr
)
{
return
false
;
}
g_detach_from_gl_context_method
=
env
->
GetMethodID
(
g_surface_texture_class
->
obj
(),
"detachFromGLContext"
,
"()V"
);
...
...
shell/platform/android/platform_view_android_jni.h
浏览文件 @
368380cf
...
...
@@ -33,6 +33,10 @@ void SurfaceTextureAttachToGLContext(JNIEnv* env, jobject obj, jint textureId);
void
SurfaceTextureUpdateTexImage
(
JNIEnv
*
env
,
jobject
obj
);
void
SurfaceTextureGetTransformMatrix
(
JNIEnv
*
env
,
jobject
obj
,
jfloatArray
result
);
void
SurfaceTextureDetachFromGLContext
(
JNIEnv
*
env
,
jobject
obj
);
}
// namespace shell
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录