Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
0e9b13fc
O
obs-studio
项目概览
尘离序散
/
obs-studio
与 Fork 源项目一致
从无法访问的项目Fork
通知
30
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obs-studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0e9b13fc
编写于
4月 12, 2014
作者:
J
jp9000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix style errors (please don't make me do this)
上级
b53e2a88
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
88 addition
and
87 deletion
+88
-87
libobs-d3d11/d3d11-subsystem.cpp
libobs-d3d11/d3d11-subsystem.cpp
+38
-31
libobs-opengl/gl-helpers.c
libobs-opengl/gl-helpers.c
+12
-12
libobs-opengl/gl-subsystem.c
libobs-opengl/gl-subsystem.c
+1
-2
libobs-opengl/gl-x11.c
libobs-opengl/gl-x11.c
+37
-42
未找到文件。
libobs-d3d11/d3d11-subsystem.cpp
浏览文件 @
0e9b13fc
...
...
@@ -959,7 +959,8 @@ void device_setcuberendertarget(device_t device, texture_t tex, int side,
device
->
context
->
OMSetRenderTargets
(
1
,
&
rt
,
zstencil
->
view
);
}
inline
void
gs_device
::
CopyTex
(
ID3D11Texture2D
*
dst
,
uint32_t
dst_x
,
uint32_t
dst_y
,
inline
void
gs_device
::
CopyTex
(
ID3D11Texture2D
*
dst
,
uint32_t
dst_x
,
uint32_t
dst_y
,
texture_t
src
,
uint32_t
src_x
,
uint32_t
src_y
,
uint32_t
src_w
,
uint32_t
src_h
)
{
...
...
@@ -968,22 +969,21 @@ inline void gs_device::CopyTex(ID3D11Texture2D *dst, uint32_t dst_x, uint32_t ds
gs_texture_2d
*
tex2d
=
static_cast
<
gs_texture_2d
*>
(
src
);
if
(
dst_x
==
0
&&
dst_y
==
0
&&
src_x
==
0
&&
src_y
==
0
&&
src_w
==
0
&&
src_h
==
0
)
{
if
(
dst_x
==
0
&&
dst_y
==
0
&&
src_x
==
0
&&
src_y
==
0
&&
src_w
==
0
&&
src_h
==
0
)
{
context
->
CopyResource
(
dst
,
tex2d
->
texture
);
}
else
{
}
else
{
D3D11_BOX
sbox
;
sbox
.
left
=
src_x
;
if
(
src_w
>
0
)
if
(
src_w
>
0
)
sbox
.
right
=
src_x
+
src_w
;
else
sbox
.
right
=
tex2d
->
width
-
1
;
sbox
.
top
=
src_y
;
if
(
src_h
>
0
)
if
(
src_h
>
0
)
sbox
.
bottom
=
src_y
+
src_h
;
else
sbox
.
bottom
=
tex2d
->
height
-
1
;
...
...
@@ -991,49 +991,56 @@ inline void gs_device::CopyTex(ID3D11Texture2D *dst, uint32_t dst_x, uint32_t ds
sbox
.
front
=
0
;
sbox
.
back
=
1
;
context
->
CopySubresourceRegion
(
dst
,
0
,
dst_x
,
dst_y
,
0
,
tex2d
->
texture
,
0
,
&
sbox
);
context
->
CopySubresourceRegion
(
dst
,
0
,
dst_x
,
dst_y
,
0
,
tex2d
->
texture
,
0
,
&
sbox
);
}
}
void
device_copy_texture_region
(
device_t
device
,
texture_t
dst
,
uint32_t
dst_x
,
uint32_t
dst_y
,
texture_t
src
,
uint32_t
src_x
,
uint32_t
src_y
,
uint32_t
src_w
,
uint32_t
src_h
)
texture_t
dst
,
uint32_t
dst_x
,
uint32_t
dst_y
,
texture_t
src
,
uint32_t
src_x
,
uint32_t
src_y
,
uint32_t
src_w
,
uint32_t
src_h
)
{
try
{
try
{
gs_texture_2d
*
src2d
=
static_cast
<
gs_texture_2d
*>
(
src
);
gs_texture_2d
*
dst2d
=
static_cast
<
gs_texture_2d
*>
(
dst
);
if
(
!
src
)
if
(
!
src
)
throw
"Source texture is NULL"
;
if
(
!
dst
)
if
(
!
dst
)
throw
"Destination texture is NULL"
;
if
(
src
->
type
!=
GS_TEXTURE_2D
||
dst
->
type
!=
GS_TEXTURE_2D
)
if
(
src
->
type
!=
GS_TEXTURE_2D
||
dst
->
type
!=
GS_TEXTURE_2D
)
throw
"Source and destination textures must be a 2D "
"textures"
;
if
(
dst
->
format
!=
src
->
format
)
"textures"
;
if
(
dst
->
format
!=
src
->
format
)
throw
"Source and destination formats do not match"
;
uint32_t
nw
=
(
uint32_t
)
src_w
?
(
uint32_t
)
src_w
:
(
src2d
->
width
-
src_x
);
uint32_t
nh
=
(
uint32_t
)
src_h
?
(
uint32_t
)
src_h
:
(
src2d
->
height
-
src_y
);
/* apparently casting to the same type that the variable
* already exists as is supposed to prevent some warning
* when used with the conditional operator? */
uint32_t
copyWidth
=
(
uint32_t
)
src_w
?
(
uint32_t
)
src_w
:
(
src2d
->
width
-
src_x
);
uint32_t
copyHeight
=
(
uint32_t
)
src_h
?
(
uint32_t
)
src_h
:
(
src2d
->
height
-
src_y
);
if
(
dst2d
->
width
-
dst_x
<
nw
||
dst2d
->
height
-
dst_y
<
nh
)
uint32_t
dstWidth
=
dst2d
->
width
-
dst_x
;
uint32_t
dstHeight
=
dst2d
->
height
-
dst_y
;
if
(
dstWidth
<
copyWidth
||
dstHeight
<
copyHeight
)
throw
"Destination texture region is not big "
"enough to hold the source region"
;
if
(
dst_x
==
0
&&
dst_y
==
0
&&
src_x
==
0
&&
src_y
==
0
&&
src_w
==
0
&&
src_h
==
0
)
{
nw
=
0
;
nh
=
0
;
if
(
dst_x
==
0
&&
dst_y
==
0
&&
src_x
==
0
&&
src_y
==
0
&&
src_w
==
0
&&
src_h
==
0
)
{
copyWidth
=
0
;
copyHeight
=
0
;
}
gs_texture_2d
*
tex2d
=
static_cast
<
gs_texture_2d
*>
(
dst
);
device
->
CopyTex
(
tex2d
->
texture
,
dst_x
,
dst_y
,
src
,
src_x
,
src_y
,
nw
,
nh
);
device
->
CopyTex
(
dst2d
->
texture
,
dst_x
,
dst_y
,
src
,
src_x
,
src_y
,
copyWidth
,
copyHeight
);
}
catch
(
const
char
*
error
)
{
}
catch
(
const
char
*
error
)
{
blog
(
LOG_ERROR
,
"device_copy_texture (D3D11): %s"
,
error
);
}
}
...
...
libobs-opengl/gl-helpers.c
浏览文件 @
0e9b13fc
...
...
@@ -43,6 +43,7 @@ bool gl_init_face(GLenum target, GLenum type, uint32_t num_levels,
if
(
data
)
data
++
;
size
/=
4
;
width
/=
2
;
height
/=
2
;
...
...
@@ -85,7 +86,8 @@ static bool gl_copy_fbo(struct gs_device *device,
if
(
!
gl_success
(
"glReadBuffer"
))
goto
fail
;
glCopyTexSubImage2D
(
dst_target
,
0
,
dst_x
,
dst_y
,
src_x
,
src_y
,
width
,
height
);
glCopyTexSubImage2D
(
dst_target
,
0
,
dst_x
,
dst_y
,
src_x
,
src_y
,
width
,
height
);
if
(
!
gl_success
(
"glCopyTexSubImage2D"
))
goto
fail
;
...
...
@@ -101,31 +103,29 @@ fail:
}
bool
gl_copy_texture
(
struct
gs_device
*
device
,
GLuint
dst
,
GLenum
dst_target
,
uint32_t
dst_x
,
uint32_t
dst_y
,
GLuint
src
,
GLenum
src_target
,
uint32_t
src_x
,
uint32_t
src_y
,
uint32_t
width
,
uint32_t
height
,
enum
gs_color_format
format
)
GLuint
dst
,
GLenum
dst_target
,
uint32_t
dst_x
,
uint32_t
dst_y
,
GLuint
src
,
GLenum
src_target
,
uint32_t
src_x
,
uint32_t
src_y
,
uint32_t
width
,
uint32_t
height
,
enum
gs_color_format
format
)
{
bool
success
=
false
;
if
(
device
->
copy_type
==
COPY_TYPE_ARB
)
{
glCopyImageSubData
(
src
,
src_target
,
0
,
src_x
,
src_y
,
0
,
dst
,
dst_target
,
0
,
dst_x
,
dst_y
,
0
,
dst
,
dst_target
,
0
,
dst_x
,
dst_y
,
0
,
width
,
height
,
1
);
success
=
gl_success
(
"glCopyImageSubData"
);
}
else
if
(
device
->
copy_type
==
COPY_TYPE_NV
)
{
glCopyImageSubDataNV
(
src
,
src_target
,
0
,
src_x
,
src_y
,
0
,
dst
,
dst_target
,
0
,
dst_x
,
dst_y
,
0
,
dst
,
dst_target
,
0
,
dst_x
,
dst_y
,
0
,
width
,
height
,
1
);
success
=
gl_success
(
"glCopyImageSubDataNV"
);
}
else
if
(
device
->
copy_type
==
COPY_TYPE_FBO_BLIT
)
{
if
(
gl_copy_fbo
(
device
,
dst
,
dst_target
,
dst_x
,
dst_y
,
src
,
src_target
,
src_x
,
src_y
,
width
,
height
,
format
))
success
=
true
;
else
success
=
gl_copy_fbo
(
device
,
dst
,
dst_target
,
dst_x
,
dst_y
,
src
,
src_target
,
src_x
,
src_y
,
width
,
height
,
format
);
if
(
!
success
)
blog
(
LOG_ERROR
,
"gl_copy_texture failed"
);
}
...
...
libobs-opengl/gl-subsystem.c
浏览文件 @
0e9b13fc
...
...
@@ -233,8 +233,7 @@ swapchain_t device_create_swapchain(device_t device, struct gs_init_data *info)
return
NULL
;
}
if
(
!
gl_platform_init_swapchain
(
swap
))
{
if
(
!
gl_platform_init_swapchain
(
swap
))
{
blog
(
LOG_ERROR
,
"gl_platform_init_swapchain failed"
);
swapchain_destroy
(
swap
);
return
NULL
;
...
...
libobs-opengl/gl-x11.c
浏览文件 @
0e9b13fc
...
...
@@ -26,10 +26,10 @@
static
const
int
fb_attribs
[]
=
{
/* Hardcoded for now... */
GLX_STENCIL_SIZE
,
8
,
GLX_DEPTH_SIZE
,
24
,
GLX_DEPTH_SIZE
,
24
,
GLX_BUFFER_SIZE
,
32
,
/* Color buffer depth */
GLX_DOUBLEBUFFER
,
T
rue
,
GLX_X_RENDERABLE
,
T
rue
,
GLX_DOUBLEBUFFER
,
t
rue
,
GLX_X_RENDERABLE
,
t
rue
,
GLX_RENDER_TYPE
,
GLX_RGBA_BIT
,
None
};
...
...
@@ -39,7 +39,7 @@ static const int ctx_attribs[] = {
GLX_CONTEXT_FLAGS_ARB
,
GLX_CONTEXT_DEBUG_BIT_ARB
,
#endif
GLX_CONTEXT_PROFILE_MASK_ARB
,
GLX_CONTEXT_CORE_PROFILE_BIT_ARB
,
None
,
None
,
};
struct
gl_windowinfo
{
...
...
@@ -69,7 +69,7 @@ extern struct gl_windowinfo *gl_windowinfo_create(struct gs_init_data *info)
return
wi
;
}
extern
void
gl_windowinfo_destroy
(
struct
gl_windowinfo
*
wi
)
extern
void
gl_windowinfo_destroy
(
struct
gl_windowinfo
*
wi
)
{
bfree
(
wi
);
}
...
...
@@ -123,9 +123,8 @@ static bool handle_x_error(Display *disp, const char *error_string)
{
XSync
(
disp
,
0
);
if
(
got_x_error
)
{
if
(
error_string
)
if
(
got_x_error
)
{
if
(
error_string
)
blog
(
LOG_ERROR
,
"%s"
,
error_string
);
got_x_error
=
false
;
...
...
@@ -145,6 +144,7 @@ struct gl_platform *gl_platform_create(device_t device,
GLXFBConfig
*
configs
;
XWindowAttributes
attrs
;
int
screen
;
int
major
=
0
,
minor
=
0
;
print_info_stuff
(
info
);
...
...
@@ -154,8 +154,7 @@ struct gl_platform *gl_platform_create(device_t device,
goto
fail0
;
}
if
(
!
XGetWindowAttributes
(
display
,
info
->
window
.
id
,
&
attrs
))
{
if
(
!
XGetWindowAttributes
(
display
,
info
->
window
.
id
,
&
attrs
))
{
blog
(
LOG_ERROR
,
"Failed getting window attributes"
);
goto
fail0
;
}
...
...
@@ -173,15 +172,12 @@ struct gl_platform *gl_platform_create(device_t device,
}
/* We require glX version 1.3 */
{
int
major
=
0
,
minor
=
0
;
glXQueryVersion
(
display
,
&
major
,
&
minor
);
if
(
major
<
1
||
(
major
==
1
&&
minor
<
3
))
{
blog
(
LOG_ERROR
,
"GLX version found: %i.%i
\n
Required: "
"1.3"
,
major
,
minor
);
goto
fail0
;
}
glXQueryVersion
(
display
,
&
major
,
&
minor
);
if
(
major
<
1
||
(
major
==
1
&&
minor
<
3
))
{
blog
(
LOG_ERROR
,
"GLX version found: %i.%i
\n
Required: "
"1.3"
,
major
,
minor
);
goto
fail0
;
}
if
(
!
glx_ext_ARB_create_context
)
{
...
...
@@ -192,12 +188,12 @@ struct gl_platform *gl_platform_create(device_t device,
configs
=
glXChooseFBConfig
(
display
,
screen
,
fb_attribs
,
&
num_configs
);
if
(
!
configs
)
{
if
(
!
configs
)
{
blog
(
LOG_ERROR
,
"Attribute list or screen is invalid."
);
goto
fail0
;
}
if
(
num_configs
==
0
)
{
if
(
num_configs
==
0
)
{
XFree
(
configs
);
blog
(
LOG_ERROR
,
"No framebuffer configurations found."
);
goto
fail0
;
...
...
@@ -212,18 +208,18 @@ struct gl_platform *gl_platform_create(device_t device,
/* We just use the first configuration found... as it does everything
* we want at the very least. */
plat
->
context
=
glXCreateContextAttribsARB
(
display
,
plat
->
fbcfg
,
NULL
,
T
rue
,
ctx_attribs
);
if
(
!
plat
->
context
)
{
t
rue
,
ctx_attribs
);
if
(
!
plat
->
context
)
{
blog
(
LOG_ERROR
,
"Failed to create OpenGL context."
);
goto
fail0
;
}
if
(
handle_x_error
(
display
,
"Failed to create OpenGL context."
))
if
(
handle_x_error
(
display
,
"Failed to create OpenGL context."
))
goto
fail2
;
device
->
plat
=
plat
;
plat
->
swap
.
device
=
device
;
plat
->
swap
.
device
=
device
;
plat
->
swap
.
info
.
window
.
id
=
info
->
window
.
id
;
plat
->
swap
.
info
.
window
.
display
=
display
;
plat
->
swap
.
info
.
format
=
GS_RGBA
;
...
...
@@ -234,10 +230,10 @@ struct gl_platform *gl_platform_create(device_t device,
plat
->
swap
.
info
.
cy
=
attrs
.
height
;
plat
->
swap
.
wi
=
gl_windowinfo_create
(
info
);
if
(
!
gl_platform_init_swapchain
(
&
plat
->
swap
))
if
(
!
gl_platform_init_swapchain
(
&
plat
->
swap
))
goto
fail2
;
if
(
!
glXMakeCurrent
(
display
,
plat
->
swap
.
wi
->
glxid
,
plat
->
context
))
{
if
(
!
glXMakeCurrent
(
display
,
plat
->
swap
.
wi
->
glxid
,
plat
->
context
))
{
blog
(
LOG_ERROR
,
"Failed to make context current."
);
goto
fail2
;
}
...
...
@@ -252,7 +248,7 @@ struct gl_platform *gl_platform_create(device_t device,
/* We assume later that cur_swap is already set. */
device
->
cur_swap
=
&
plat
->
swap
;
XSync
(
display
,
F
alse
);
XSync
(
display
,
f
alse
);
blog
(
LOG_INFO
,
"Created new platform data"
);
...
...
@@ -299,20 +295,19 @@ bool gl_platform_init_swapchain(struct gs_swap_chain *swap)
gl_platform_cleanup_swapchain
(
swap
);
if
(
!
XGetWindowAttributes
(
display
,
info
->
id
,
&
attrs
))
{
if
(
!
XGetWindowAttributes
(
display
,
info
->
id
,
&
attrs
))
{
blog
(
LOG_ERROR
,
"Failed getting window attributes"
);
goto
fail
;
}
vi
=
glXGetVisualFromFBConfig
(
display
,
plat
->
fbcfg
);
if
(
handle_x_error
(
display
,
"Failed to get visual from fb config."
))
if
(
handle_x_error
(
display
,
"Failed to get visual from fb config."
))
goto
fail
;
cmap
=
XCreateColormap
(
display
,
info
->
id
,
vi
->
visual
,
AllocNone
);
if
(
handle_x_error
(
display
,
"Failed creating colormap"
))
if
(
handle_x_error
(
display
,
"Failed creating colormap"
))
goto
fail
;
swa
.
colormap
=
cmap
;
...
...
@@ -324,12 +319,12 @@ bool gl_platform_init_swapchain(struct gs_swap_chain *swap)
CWBorderPixel
|
CWColormap
,
&
swa
);
XMapWindow
(
display
,
info
->
int_id
);
if
(
handle_x_error
(
display
,
"Failed creating intermediate X window"
))
if
(
handle_x_error
(
display
,
"Failed creating intermediate X window"
))
goto
fail
;
info
->
glxid
=
glXCreateWindow
(
display
,
plat
->
fbcfg
,
info
->
int_id
,
0
);
if
(
handle_x_error
(
display
,
"Failed creating intermediate GLX window"
))
if
(
handle_x_error
(
display
,
"Failed creating intermediate GLX window"
))
goto
fail
;
XFreeColormap
(
display
,
cmap
);
...
...
@@ -341,10 +336,10 @@ fail:
gl_platform_cleanup_swapchain
(
swap
);
if
(
cmap
)
if
(
cmap
)
XFreeColormap
(
display
,
cmap
);
if
(
vi
)
if
(
vi
)
XFree
(
vi
);
XSetErrorHandler
(
phandler
);
...
...
@@ -357,13 +352,13 @@ void gl_platform_cleanup_swapchain(struct gs_swap_chain *swap)
Display
*
display
=
swap
->
wi
->
display
;
struct
gl_windowinfo
*
info
=
swap
->
wi
;
if
(
!
info
)
if
(
!
info
)
return
;
if
(
info
->
glxid
)
if
(
info
->
glxid
)
glXDestroyWindow
(
display
,
info
->
glxid
);
if
(
info
->
int_id
)
if
(
info
->
int_id
)
XDestroyWindow
(
display
,
info
->
int_id
);
info
->
glxid
=
0
;
...
...
@@ -385,7 +380,7 @@ void device_leavecontext(device_t device)
{
Display
*
display
=
device
->
cur_swap
->
wi
->
display
;
if
(
!
glXMakeCurrent
(
display
,
None
,
NULL
))
{
if
(
!
glXMakeCurrent
(
display
,
None
,
NULL
))
{
blog
(
LOG_ERROR
,
"Failed to reset current context."
);
}
}
...
...
@@ -396,12 +391,12 @@ void gl_update(device_t device)
XID
window
=
device
->
cur_swap
->
wi
->
int_id
;
XResizeWindow
(
display
,
window
,
device
->
cur_swap
->
info
.
cx
,
device
->
cur_swap
->
info
.
cy
);
device
->
cur_swap
->
info
.
cx
,
device
->
cur_swap
->
info
.
cy
);
}
void
device_load_swapchain
(
device_t
device
,
swapchain_t
swap
)
{
if
(
!
swap
)
if
(
!
swap
)
swap
=
&
device
->
plat
->
swap
;
if
(
device
->
cur_swap
==
swap
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录