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 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

@knoxHuang knoxHuang Nov 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

@@ -58,7 +58,6 @@ let VideoPlayerImpl = cc.Class({
this._ignorePause = false;

// update matrix cache
this._forceUpdate = true;
this._m00 = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@holycanvas holycanvas requested a review from PPpro November 8, 2019 02:42
scaleX /= dpr;
scaleY /= dpr;
let scaleX = 1 / dpr;
let scaleY = 1 / dpr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里可能还是要用 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

scaleX /= dpr;
scaleY /= dpr;
let scaleX = 1 / dpr;
let scaleY = 1 / dpr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

@PPpro
Copy link
Contributor

PPpro commented Nov 8, 2019

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

@holycanvas holycanvas merged commit de36207 into cocos:v2.2.1-release Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants