Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
liujiuri
engine
提交
287d187e
E
engine
项目概览
liujiuri
/
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,发现更多精彩内容 >>
提交
287d187e
编写于
3月 24, 2016
作者:
A
Adam Barth
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add GLFW platform to //sky/shell
上级
76dfd240
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
298 addition
and
5 deletion
+298
-5
skia/BUILD.gn
skia/BUILD.gn
+9
-1
skia/ext/GrGLCreateNativeInterface_glfw.cpp
skia/ext/GrGLCreateNativeInterface_glfw.cpp
+27
-0
sky/shell/BUILD.gn
sky/shell/BUILD.gn
+17
-1
sky/shell/platform/glfw/init_glfw.cc
sky/shell/platform/glfw/init_glfw.cc
+50
-0
sky/shell/platform/glfw/init_glfw.h
sky/shell/platform/glfw/init_glfw.h
+16
-0
sky/shell/platform/glfw/platform_view_glfw.cc
sky/shell/platform/glfw/platform_view_glfw.cc
+34
-0
sky/shell/platform/glfw/platform_view_glfw.h
sky/shell/platform/glfw/platform_view_glfw.h
+30
-0
sky/shell/platform/glfw/window_impl.cc
sky/shell/platform/glfw/window_impl.cc
+65
-0
sky/shell/platform/glfw/window_impl.h
sky/shell/platform/glfw/window_impl.h
+39
-0
sky/shell/platform/linux/main_linux.cc
sky/shell/platform/linux/main_linux.cc
+11
-3
未找到文件。
skia/BUILD.gn
浏览文件 @
287d187e
...
...
@@ -338,7 +338,7 @@ component("skia") {
"//third_party/skia/src/fonts/SkGScalerContext.h",
]
if (is_ios || is_mac || is_android) {
if (is_ios || is_mac || is_android
|| use_glfw
) {
sources -= [
"//third_party/skia/src/gpu/gl/GrGLCreateNativeInterface_none.cpp"
]
...
...
@@ -357,6 +357,10 @@ component("skia") {
sources += [
"//third_party/skia/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp"
]
} else if (use_glfw) {
sources += [
"//skia/ext/GrGLCreateNativeInterface_glfw.cpp"
]
}
set_sources_assignment_filter(sources_assignment_filter)
...
...
@@ -522,6 +526,10 @@ component("skia") {
configs -= [ "//build/config/compiler:optimize" ]
configs += [ "//build/config/compiler:optimize_max" ]
}
if (use_glfw) {
deps += [ "//third_party/glfw" ]
}
}
# Separated out so it can be compiled with different flags for SSE.
...
...
skia/ext/GrGLCreateNativeInterface_glfw.cpp
0 → 100644
浏览文件 @
287d187e
/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gl/GrGLInterface.h"
#include "gl/GrGLAssembleInterface.h"
#include "gl/GrGLUtil.h"
#include "GLFW/glfw3.h"
static
GrGLFuncPtr
glfw_get
(
void
*
ctx
,
const
char
name
[])
{
SkASSERT
(
nullptr
==
ctx
);
SkASSERT
(
glfwGetCurrentContext
());
return
glfwGetProcAddress
(
name
);
}
const
GrGLInterface
*
GrGLCreateNativeInterface
()
{
if
(
nullptr
==
glfwGetCurrentContext
())
{
return
nullptr
;
}
return
GrGLAssembleInterface
(
nullptr
,
glfw_get
);
}
sky/shell/BUILD.gn
浏览文件 @
287d187e
...
...
@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/ui.gni")
source_set("common") {
sources = [
"gpu/picture_serializer.cc",
...
...
@@ -400,7 +402,6 @@ if (is_android) {
sources = [
"platform/linux/main_linux.cc",
"platform/linux/platform_view_linux.cc",
]
deps = [
...
...
@@ -411,6 +412,21 @@ if (is_android) {
":gpu_direct",
":testing",
]
if (use_glfw) {
sources += [
"//sky/shell/platform/glfw/init_glfw.cc",
"//sky/shell/platform/glfw/init_glfw.h",
"//sky/shell/platform/glfw/platform_view_glfw.cc",
"//sky/shell/platform/glfw/platform_view_glfw.h",
"//sky/shell/platform/glfw/window_impl.cc",
"//sky/shell/platform/glfw/window_impl.h",
]
deps += [ "//third_party/glfw" ]
} else {
sources += [ "platform/linux/platform_view_linux.cc" ]
}
}
} else if (is_mac) {
import("//build/config/mac/rules.gni")
...
...
sky/shell/platform/glfw/init_glfw.cc
0 → 100644
浏览文件 @
287d187e
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/shell/platform/glfw/init_glfw.h"
#include <GLFW/glfw3.h>
#include <memory>
#include <string>
#include "base/command_line.h"
#include "sky/shell/platform/glfw/platform_view_glfw.h"
#include "sky/shell/platform/glfw/window_impl.h"
#include "sky/shell/switches.h"
#include "ui/gl/gl_surface.h"
namespace
sky
{
namespace
shell
{
bool
InitInteractive
()
{
base
::
CommandLine
&
command_line
=
*
base
::
CommandLine
::
ForCurrentProcess
();
std
::
string
bundle_path
=
command_line
.
GetSwitchValueASCII
(
sky
::
shell
::
switches
::
kFLX
);
if
(
bundle_path
.
empty
())
return
false
;
if
(
!
glfwInit
())
return
false
;
GLFWwindow
*
window
=
glfwCreateWindow
(
640
,
480
,
"Flutter"
,
NULL
,
NULL
);
if
(
!
window
)
{
glfwTerminate
();
return
false
;
}
glfwMakeContextCurrent
(
window
);
CHECK
(
gfx
::
GLSurface
::
InitializeOneOff
());
glfwMakeContextCurrent
(
NULL
);
std
::
string
script_uri
=
std
::
string
(
"file://"
)
+
bundle_path
;
// TODO(abarth): Listen for a GLFW callback to delete this window.
(
new
WindowImpl
(
window
))
->
RunFromBundle
(
script_uri
,
bundle_path
);
return
true
;
}
}
// namespace shell
}
// namespace sky
sky/shell/platform/glfw/init_glfw.h
0 → 100644
浏览文件 @
287d187e
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKY_SHELL_PLATFORM_GLFW_INIT_GLFW_H_
#define SKY_SHELL_PLATFORM_GLFW_INIT_GLFW_H_
namespace
sky
{
namespace
shell
{
bool
InitInteractive
();
}
// namespace shell
}
// namespace sky
#endif // SKY_SHELL_PLATFORM_GLFW_INIT_GLFW_H_
sky/shell/platform/glfw/platform_view_glfw.cc
0 → 100644
浏览文件 @
287d187e
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/shell/platform/glfw/platform_view_glfw.h"
#include "sky/shell/gpu/direct/surface_notifications_direct.h"
namespace
sky
{
namespace
shell
{
PlatformView
*
PlatformView
::
Create
(
const
Config
&
config
)
{
return
new
PlatformViewGLFW
(
config
);
}
PlatformViewGLFW
::
PlatformViewGLFW
(
const
Config
&
config
)
:
PlatformView
(
config
),
window_
(
gfx
::
kNullAcceleratedWidget
)
{}
PlatformViewGLFW
::~
PlatformViewGLFW
()
{}
void
PlatformViewGLFW
::
SurfaceCreated
(
gfx
::
AcceleratedWidget
widget
)
{
DCHECK
(
window_
==
gfx
::
kNullAcceleratedWidget
);
window_
=
widget
;
SurfaceNotificationsDirect
::
NotifyCreated
(
config_
,
window_
);
}
void
PlatformViewGLFW
::
SurfaceDestroyed
()
{
DCHECK
(
window_
!=
gfx
::
kNullAcceleratedWidget
);
window_
=
gfx
::
kNullAcceleratedWidget
;
SurfaceNotificationsDirect
::
NotifyDestroyed
(
config_
);
}
}
// namespace shell
}
// namespace sky
sky/shell/platform/glfw/platform_view_glfw.h
0 → 100644
浏览文件 @
287d187e
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKY_SHELL_PLATFORM_GLFW_PLATFORM_VIEW_GLFW_H_
#define SKY_SHELL_PLATFORM_GLFW_PLATFORM_VIEW_GLFW_H_
#include "sky/shell/platform_view.h"
namespace
sky
{
namespace
shell
{
class
PlatformViewGLFW
:
public
PlatformView
{
public:
explicit
PlatformViewGLFW
(
const
Config
&
config
);
~
PlatformViewGLFW
()
override
;
void
SurfaceCreated
(
gfx
::
AcceleratedWidget
widget
);
void
SurfaceDestroyed
(
void
);
private:
gfx
::
AcceleratedWidget
window_
;
DISALLOW_COPY_AND_ASSIGN
(
PlatformViewGLFW
);
};
}
// namespace shell
}
// namespace sky
#endif // SKY_SHELL_PLATFORM_GLFW_PLATFORM_VIEW_GLFW_H_
sky/shell/platform/glfw/window_impl.cc
0 → 100644
浏览文件 @
287d187e
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/shell/platform/glfw/window_impl.h"
#include <GLFW/glfw3.h>
#include "sky/shell/platform/glfw/platform_view_glfw.h"
#include "sky/shell/shell.h"
namespace
sky
{
namespace
shell
{
namespace
{
WindowImpl
*
ToImpl
(
GLFWwindow
*
window
)
{
return
static_cast
<
WindowImpl
*>
(
glfwGetWindowUserPointer
(
window
));
}
void
OnWindowSizeChanged
(
GLFWwindow
*
window
,
int
width
,
int
height
)
{
ToImpl
(
window
)
->
UpdateViewportMetrics
(
width
,
height
);
}
}
// namespace
WindowImpl
::
WindowImpl
(
GLFWwindow
*
window
)
:
window_
(
window
),
shell_view_
(
new
ShellView
(
Shell
::
Shared
()))
{
glfwSetWindowUserPointer
(
window_
,
this
);
auto
platform_view
=
static_cast
<
sky
::
shell
::
PlatformViewGLFW
*>
(
shell_view_
->
view
());
platform_view
->
SurfaceCreated
(
window
);
platform_view
->
ConnectToEngine
(
mojo
::
GetProxy
(
&
engine_
));
int
width
=
0
;
int
height
=
0
;
glfwGetWindowSize
(
window_
,
&
width
,
&
height
);
UpdateViewportMetrics
(
width
,
height
);
glfwSetWindowSizeCallback
(
window_
,
OnWindowSizeChanged
);
}
WindowImpl
::~
WindowImpl
()
{
shell_view_
.
reset
();
glfwDestroyWindow
(
window_
);
window_
=
nullptr
;
}
void
WindowImpl
::
RunFromBundle
(
const
std
::
string
&
script_uri
,
const
std
::
string
&
bundle_path
)
{
engine_
->
RunFromBundle
(
script_uri
,
bundle_path
);
}
void
WindowImpl
::
UpdateViewportMetrics
(
int
width
,
int
height
)
{
auto
metrics
=
sky
::
ViewportMetrics
::
New
();
metrics
->
physical_width
=
width
;
metrics
->
physical_height
=
height
;
// TODO(abarth): There doesn't appear to be a way to get the device pixel
// ratio from GLFW.
metrics
->
device_pixel_ratio
=
1.0
;
engine_
->
OnViewportMetricsChanged
(
metrics
.
Pass
());
}
}
// namespace shell
}
// namespace sky
sky/shell/platform/glfw/window_impl.h
0 → 100644
浏览文件 @
287d187e
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKY_SHELL_PLATFORM_GLFW_WINDOW_IMPL_H_
#define SKY_SHELL_PLATFORM_GLFW_WINDOW_IMPL_H_
#include <memory>
#include <string>
#include "sky/services/engine/sky_engine.mojom.h"
#include "sky/shell/platform_view.h"
#include "sky/shell/shell_view.h"
namespace
sky
{
namespace
shell
{
class
WindowImpl
{
public:
explicit
WindowImpl
(
GLFWwindow
*
window
);
~
WindowImpl
();
void
RunFromBundle
(
const
std
::
string
&
script_uri
,
const
std
::
string
&
bundle_path
);
void
UpdateViewportMetrics
(
int
width
,
int
height
);
private:
GLFWwindow
*
window_
;
std
::
unique_ptr
<
ShellView
>
shell_view_
;
sky
::
SkyEnginePtr
engine_
;
DISALLOW_COPY_AND_ASSIGN
(
WindowImpl
);
};
}
// namespace shell
}
// namespace sky
#endif // SKY_SHELL_PLATFORM_GLFW_WINDOW_IMPL_H_
sky/shell/platform/linux/main_linux.cc
浏览文件 @
287d187e
...
...
@@ -14,6 +14,10 @@
#include "sky/shell/switches.h"
#include "sky/shell/testing/testing.h"
#if defined(USE_GLFW)
#include "sky/shell/platform/glfw/init_glfw.h"
#endif
int
main
(
int
argc
,
const
char
*
argv
[])
{
base
::
AtExitManager
exit_manager
;
base
::
CommandLine
::
Init
(
argc
,
argv
);
...
...
@@ -26,12 +30,16 @@ int main(int argc, const char* argv[]) {
}
base
::
MessageLoop
message_loop
;
mojo
::
embedder
::
Init
(
mojo
::
embedder
::
CreateSimplePlatformSupport
());
sky
::
shell
::
Shell
::
InitStandalone
();
if
(
!
sky
::
shell
::
InitForTesting
())
{
bool
running
=
false
;
#if defined(USE_GLFW)
if
(
!
command_line
.
HasSwitch
(
sky
::
shell
::
switches
::
kNonInteractive
))
running
=
sky
::
shell
::
InitInteractive
();
#endif
if
(
!
running
&&
!
sky
::
shell
::
InitForTesting
())
{
sky
::
shell
::
switches
::
PrintUsage
(
"sky_shell"
);
return
1
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录