Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed video player and webview transform #5684

Merged
merged 3 commits into from Nov 8, 2019

Conversation

@knoxHuang
Copy link
Contributor

knoxHuang commented Nov 6, 2019

Re: cocos-creator/2d-tasks#2050 cocos-creator/2d-tasks#2053

Changes:

  • 完善 vide player 与 webview transform 的计算(由 2youyou2 修复)
  • 修复在编辑器下 vide player 勾选 isFullscreen,编辑器会被全屏
@@ -440,18 +440,17 @@ let VideoPlayerImpl = cc.Class({
},

updateMatrix (node) {
if (!this._video || !this._visible || this._fullScreenEnabled) return;
if (!this._video || !this._visible || this._fullScreenEnabled || !this._forceUpdate) return;

This comment has been minimized.

Copy link
@2youyou2

2youyou2 Nov 6, 2019

Contributor

不对吧,你这不是只有 _forceUpdate 才会更新了。
如果只是 position 改变了,没必要调用 _forceUpdate 吧

This comment has been minimized.

Copy link
@knoxHuang

knoxHuang Nov 6, 2019

Author Contributor

如果放在原来的位置的话,会一直去计算 transform,那怕 _mat4_tempm 数值没变化也会一直计算

_forceUpdate 只在 video player 隐藏的时候才会为 false
image

knoxHuang added 2 commits Nov 6, 2019
@@ -58,7 +58,6 @@ let VideoPlayerImpl = cc.Class({
this._ignorePause = false;

// update matrix cache
this._forceUpdate = true;
this._m00 = 0;

This comment has been minimized.

Copy link
@knoxHuang

knoxHuang Nov 6, 2019

Author Contributor

看了一下代码发现,在隐藏 videoplayer 的时,updateMatrix 是不会执行的,所以没必要设置该属性,进行移除

@holycanvas holycanvas requested a review from umbrellaPP Nov 8, 2019
scaleX /= dpr;
scaleY /= dpr;
let scaleX = 1 / dpr;
let scaleY = 1 / dpr;

This comment has been minimized.

Copy link
@umbrellaPP

umbrellaPP Nov 8, 2019

Contributor

这里可能还是要用 let scaleX = cc.view._scaleX / dpr
不同 canvas 适配模式,可能 scaleY scaleX 不一定为 1

@@ -496,9 +490,6 @@ let VideoPlayerImpl = cc.Class({
let appx = (w * _mat4_tempm[0]) * node._anchorPoint.x;
let appy = (h * _mat4_tempm[5]) * node._anchorPoint.y;

let viewport = cc.view._viewportRect;
offsetX += viewport.x / dpr;
offsetY += viewport.y / dpr;

This comment has been minimized.

Copy link
@umbrellaPP

umbrellaPP Nov 8, 2019

Contributor

如果 canvas 组件是其他适配模式的话,可能还是得考虑 viewport 的偏移量

scaleX /= dpr;
scaleY /= dpr;
let scaleX = 1 / dpr;
let scaleY = 1 / dpr;

This comment has been minimized.

Copy link
@umbrellaPP

umbrellaPP Nov 8, 2019

Contributor

同上

let appx = (w * _mat4_tempm[0]) * node._anchorPoint.x;
let appy = (h * _mat4_tempm[5]) * node._anchorPoint.y;

let viewport = cc.view._viewportRect;
offsetX += viewport.x / dpr;
offsetY += viewport.y / dpr;

This comment has been minimized.

Copy link
@umbrellaPP

umbrellaPP Nov 8, 2019

Contributor

同上

@umbrellaPP

This comment has been minimized.

Copy link
Contributor

umbrellaPP commented Nov 8, 2019

已经在 camera 变换里计算了 scale 和 viewport 偏移,那就没问题了

@holycanvas holycanvas merged commit de36207 into cocos-creator:v2.2.1-release Nov 8, 2019
1 check passed
1 check passed
ci/circleci: test Your tests passed on CircleCI!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.