Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
296902b8
E
engine
项目概览
qq_34031325
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
未验证
提交
296902b8
编写于
1月 21, 2021
作者:
G
gaaclarke
提交者:
GitHub
1月 21, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implemented GetMainContext() for opengl (#23634)
上级
c8ffb20c
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
58 addition
and
48 deletion
+58
-48
shell/gpu/gpu_surface_gl.cc
shell/gpu/gpu_surface_gl.cc
+17
-21
shell/gpu/gpu_surface_gl.h
shell/gpu/gpu_surface_gl.h
+5
-3
shell/platform/darwin/ios/framework/Source/FlutterEngineTest_mrc.mm
...form/darwin/ios/framework/Source/FlutterEngineTest_mrc.mm
+2
-4
shell/platform/darwin/ios/ios_context_gl.h
shell/platform/darwin/ios/ios_context_gl.h
+9
-6
shell/platform/darwin/ios/ios_context_gl.mm
shell/platform/darwin/ios/ios_context_gl.mm
+11
-7
shell/platform/darwin/ios/ios_surface_gl.mm
shell/platform/darwin/ios/ios_surface_gl.mm
+9
-1
shell/platform/darwin/ios/ios_surface_metal.mm
shell/platform/darwin/ios/ios_surface_metal.mm
+4
-4
shell/platform/darwin/ios/platform_view_ios.mm
shell/platform/darwin/ios/platform_view_ios.mm
+1
-1
shell/platform/embedder/embedder_surface_gl.cc
shell/platform/embedder/embedder_surface_gl.cc
+0
-1
未找到文件。
shell/gpu/gpu_surface_gl.cc
浏览文件 @
296902b8
...
...
@@ -34,16 +34,13 @@ static const int kGrCacheMaxCount = 8192;
// system channel.
static
const
size_t
kGrCacheMaxByteSize
=
24
*
(
1
<<
20
);
GPUSurfaceGL
::
GPUSurfaceGL
(
GPUSurfaceGLDelegate
*
delegate
,
bool
render_to_surface
)
:
delegate_
(
delegate
),
render_to_surface_
(
render_to_surface
),
weak_factory_
(
this
)
{
auto
context_switch
=
delegate_
->
GLContextMakeCurrent
();
sk_sp
<
GrDirectContext
>
GPUSurfaceGL
::
MakeGLContext
(
GPUSurfaceGLDelegate
*
delegate
)
{
auto
context_switch
=
delegate
->
GLContextMakeCurrent
();
if
(
!
context_switch
->
GetResult
())
{
FML_LOG
(
ERROR
)
<<
"Could not make the context current to setup the gr context."
;
return
;
return
nullptr
;
}
GrContextOptions
options
;
...
...
@@ -64,32 +61,31 @@ GPUSurfaceGL::GPUSurfaceGL(GPUSurfaceGLDelegate* delegate,
// TODO(goderbauer): remove option when skbug.com/7523 is fixed.
// A similar work-around is also used in shell/common/io_manager.cc.
options
.
fDisableGpuYUVConversion
=
true
;
auto
context
=
GrDirectContext
::
MakeGL
(
delegate
->
GetGLInterface
(),
options
);
auto
context
=
GrDirectContext
::
MakeGL
(
delegate_
->
GetGLInterface
(),
options
);
if
(
context
==
nullptr
)
{
if
(
!
context
)
{
FML_LOG
(
ERROR
)
<<
"Failed to setup Skia Gr context."
;
return
;
return
nullptr
;
}
context_
=
std
::
move
(
context
);
context_
->
setResourceCacheLimits
(
kGrCacheMaxCount
,
kGrCacheMaxByteSize
);
context_owner_
=
true
;
valid_
=
true
;
context
->
setResourceCacheLimits
(
kGrCacheMaxCount
,
kGrCacheMaxByteSize
);
std
::
vector
<
PersistentCache
::
SkSLCache
>
caches
=
PersistentCache
::
GetCacheForProcess
()
->
LoadSkSLs
();
int
compiled_count
=
0
;
for
(
const
auto
&
cache
:
caches
)
{
compiled_count
+=
context
_
->
precompileShader
(
*
cache
.
first
,
*
cache
.
second
);
compiled_count
+=
context
->
precompileShader
(
*
cache
.
first
,
*
cache
.
second
);
}
FML_LOG
(
INFO
)
<<
"Found "
<<
caches
.
size
()
<<
" SkSL shaders; precompiled "
<<
compiled_count
;
delegate_
->
GLContextClearCurrent
();
return
context
;
}
GPUSurfaceGL
::
GPUSurfaceGL
(
GPUSurfaceGLDelegate
*
delegate
,
bool
render_to_surface
)
:
GPUSurfaceGL
(
MakeGLContext
(
delegate
),
delegate
,
render_to_surface
)
{
context_owner_
=
true
;
}
GPUSurfaceGL
::
GPUSurfaceGL
(
sk_sp
<
GrDirectContext
>
gr_context
,
...
...
@@ -97,6 +93,7 @@ GPUSurfaceGL::GPUSurfaceGL(sk_sp<GrDirectContext> gr_context,
bool
render_to_surface
)
:
delegate_
(
delegate
),
context_
(
gr_context
),
context_owner_
(
false
),
render_to_surface_
(
render_to_surface
),
weak_factory_
(
this
)
{
auto
context_switch
=
delegate_
->
GLContextMakeCurrent
();
...
...
@@ -109,7 +106,6 @@ GPUSurfaceGL::GPUSurfaceGL(sk_sp<GrDirectContext> gr_context,
delegate_
->
GLContextClearCurrent
();
valid_
=
true
;
context_owner_
=
false
;
}
GPUSurfaceGL
::~
GPUSurfaceGL
()
{
...
...
shell/gpu/gpu_surface_gl.h
浏览文件 @
296902b8
...
...
@@ -20,6 +20,8 @@ namespace flutter {
class
GPUSurfaceGL
:
public
Surface
{
public:
static
sk_sp
<
GrDirectContext
>
MakeGLContext
(
GPUSurfaceGLDelegate
*
delegate
);
GPUSurfaceGL
(
GPUSurfaceGLDelegate
*
delegate
,
bool
render_to_surface
);
// Creates a new GL surface reusing an existing GrDirectContext.
...
...
@@ -53,13 +55,13 @@ class GPUSurfaceGL : public Surface {
sk_sp
<
GrDirectContext
>
context_
;
sk_sp
<
SkSurface
>
onscreen_surface_
;
/// FBO backing the current `onscreen_surface_`.
uint32_t
fbo_id_
;
bool
context_owner_
;
uint32_t
fbo_id_
=
0
;
bool
context_owner_
=
false
;
// TODO(38466): Refactor GPU surface APIs take into account the fact that an
// external view embedder may want to render to the root surface. This is a
// hack to make avoid allocating resources for the root surface when an
// external view embedder is present.
const
bool
render_to_surface_
;
const
bool
render_to_surface_
=
true
;
bool
valid_
=
false
;
fml
::
TaskRunnerAffineWeakPtrFactory
<
GPUSurfaceGL
>
weak_factory_
;
...
...
shell/platform/darwin/ios/framework/Source/FlutterEngineTest_mrc.mm
浏览文件 @
296902b8
...
...
@@ -33,10 +33,8 @@ FLUTTER_ASSERT_NOT_ARC
std
::
shared_ptr
<
flutter
::
IOSContext
>
engine_context
=
[
engine
iosPlatformView
]
->
GetIosContext
();
std
::
shared_ptr
<
flutter
::
IOSContext
>
spawn_context
=
[
spawn
iosPlatformView
]
->
GetIosContext
();
XCTAssertEqual
(
engine_context
,
spawn_context
);
// If this assert fails it means we may be using the software or OpenGL
// renderer when we were expecting Metal. For software rendering, this is
// expected to be nullptr. For OpenGL, implementing this is an outstanding
// change see https://github.com/flutter/flutter/issues/73744.
// If this assert fails it means we may be using the software. For software rendering, this is
// expected to be nullptr.
XCTAssertTrue
(
engine_context
->
GetMainContext
()
!=
nullptr
);
XCTAssertEqual
(
engine_context
->
GetMainContext
(),
spawn_context
->
GetMainContext
());
[
engine
release
];
...
...
shell/platform/darwin/ios/ios_context_gl.h
浏览文件 @
296902b8
...
...
@@ -25,16 +25,11 @@ class IOSContextGL final : public IOSContext {
std
::
unique_ptr
<
IOSRenderTargetGL
>
CreateRenderTarget
(
fml
::
scoped_nsobject
<
CAEAGLLayer
>
layer
);
private:
fml
::
scoped_nsobject
<
EAGLContext
>
context_
;
fml
::
scoped_nsobject
<
EAGLContext
>
resource_context_
;
void
SetMainContext
(
const
sk_sp
<
GrDirectContext
>&
main_context
);
// |IOSContext|
sk_sp
<
GrDirectContext
>
CreateResourceContext
()
override
;
// |IOSContext|
sk_sp
<
GrDirectContext
>
GetMainContext
()
const
override
;
// |IOSContext|
std
::
unique_ptr
<
GLContextResult
>
MakeCurrent
()
override
;
...
...
@@ -43,6 +38,14 @@ class IOSContextGL final : public IOSContext {
int64_t
texture_id
,
fml
::
scoped_nsobject
<
NSObject
<
FlutterTexture
>>
texture
)
override
;
// |IOSContext|
sk_sp
<
GrDirectContext
>
GetMainContext
()
const
override
;
private:
fml
::
scoped_nsobject
<
EAGLContext
>
context_
;
fml
::
scoped_nsobject
<
EAGLContext
>
resource_context_
;
sk_sp
<
GrDirectContext
>
main_context_
;
FML_DISALLOW_COPY_AND_ASSIGN
(
IOSContextGL
);
};
...
...
shell/platform/darwin/ios/ios_context_gl.mm
浏览文件 @
296902b8
...
...
@@ -7,6 +7,7 @@
#import <OpenGLES/EAGL.h>
#include "flutter/shell/common/shell_io_manager.h"
#include "flutter/shell/gpu/gpu_surface_gl.h"
#include "flutter/shell/gpu/gpu_surface_gl_delegate.h"
#import "flutter/shell/platform/darwin/ios/ios_external_texture_gl.h"
...
...
@@ -24,7 +25,11 @@ IOSContextGL::IOSContextGL() {
}
}
IOSContextGL
::~
IOSContextGL
()
=
default
;
IOSContextGL
::~
IOSContextGL
()
{
if
(
main_context_
)
{
main_context_
->
releaseResourcesAndAbandonContext
();
}
}
std
::
unique_ptr
<
IOSRenderTargetGL
>
IOSContextGL
::
CreateRenderTarget
(
fml
::
scoped_nsobject
<
CAEAGLLayer
>
layer
)
{
...
...
@@ -45,12 +50,11 @@ sk_sp<GrDirectContext> IOSContextGL::CreateResourceContext() {
// |IOSContext|
sk_sp
<
GrDirectContext
>
IOSContextGL
::
GetMainContext
()
const
{
/// TODO(73744): Currently the GPUSurfaceGL creates the main context for
/// OpenGL. With Metal the IOSContextMetal creates the main context and is
/// shared across surfaces. We should refactor the OpenGL Context/Surfaces to
/// behave like the Metal equivalents. Until then engines in the same group
/// will have a heavier memory cost if they are using OpenGL.
return
nullptr
;
return
main_context_
;
}
void
IOSContextGL
::
SetMainContext
(
const
sk_sp
<
GrDirectContext
>&
main_context
)
{
main_context_
=
main_context
;
}
// |IOSContext|
...
...
shell/platform/darwin/ios/ios_surface_gl.mm
浏览文件 @
296902b8
...
...
@@ -38,8 +38,16 @@ void IOSSurfaceGL::UpdateStorageSizeIfNecessary() {
std
::
unique_ptr
<
Surface
>
IOSSurfaceGL
::
CreateGPUSurface
(
GrDirectContext
*
gr_context
)
{
if
(
gr_context
)
{
return
std
::
make_unique
<
GPUSurfaceGL
>
(
sk_ref_sp
(
gr_context
),
this
,
true
);
}
else
{
IOSContextGL
*
gl_context
=
CastToGLContext
(
GetContext
());
sk_sp
<
GrDirectContext
>
context
=
gl_context
->
GetMainContext
();
if
(
!
context
)
{
context
=
GPUSurfaceGL
::
MakeGLContext
(
this
);
gl_context
->
SetMainContext
(
context
);
}
return
std
::
make_unique
<
GPUSurfaceGL
>
(
context
,
this
,
true
);
}
return
std
::
make_unique
<
GPUSurfaceGL
>
(
this
,
true
);
}
// |GPUSurfaceGLDelegate|
...
...
shell/platform/darwin/ios/ios_surface_metal.mm
浏览文件 @
296902b8
...
...
@@ -40,10 +40,10 @@ void IOSSurfaceMetal::UpdateStorageSizeIfNecessary() {
}
// |IOSSurface|
std
::
unique_ptr
<
Surface
>
IOSSurfaceMetal
::
CreateGPUSurface
(
GrDirectContext
*
/* unused */
)
{
auto
metal_context
=
CastToMetalContext
(
GetContext
()
);
return
std
::
make_unique
<
GPUSurfaceMetal
>
(
this
,
// layer
metal_context
->
GetMainContext
(
)
// context
std
::
unique_ptr
<
Surface
>
IOSSurfaceMetal
::
CreateGPUSurface
(
GrDirectContext
*
context
)
{
FML_DCHECK
(
context
);
return
std
::
make_unique
<
GPUSurfaceMetal
>
(
this
,
// layer
sk_ref_sp
(
context
)
// context
);
}
...
...
shell/platform/darwin/ios/platform_view_ios.mm
浏览文件 @
296902b8
...
...
@@ -148,7 +148,7 @@ std::unique_ptr<Surface> PlatformViewIOS::CreateRenderingSurface() {
"has no ViewController."
;
return
nullptr
;
}
return
ios_surface_
->
CreateGPUSurface
();
return
ios_surface_
->
CreateGPUSurface
(
ios_context_
->
GetMainContext
().
get
()
);
}
// |PlatformView|
...
...
shell/platform/embedder/embedder_surface_gl.cc
浏览文件 @
296902b8
...
...
@@ -80,7 +80,6 @@ std::unique_ptr<Surface> EmbedderSurfaceGL::CreateGPUSurface() {
const
bool
render_to_surface
=
!
external_view_embedder_
;
return
std
::
make_unique
<
GPUSurfaceGL
>
(
this
,
// GPU surface GL delegate
render_to_surface
// render to surface
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录