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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,6 @@ let VideoPlayerImpl = cc.Class({ | |
this._ignorePause = false; | ||
|
||
// update matrix cache | ||
this._forceUpdate = true; | ||
this._m00 = 0; | ||
this._m01 = 0; | ||
this._m04 = 0; | ||
|
@@ -139,13 +138,11 @@ let VideoPlayerImpl = cc.Class({ | |
|
||
if (this._visible) { | ||
video.style.visibility = 'visible'; | ||
this._forceUpdate = true; | ||
} | ||
else { | ||
video.style.visibility = 'hidden'; | ||
video.pause(); | ||
this._playing = false; | ||
this._forceUpdate = false; | ||
} | ||
}, | ||
|
||
|
@@ -446,12 +443,11 @@ let VideoPlayerImpl = cc.Class({ | |
|
||
let renderCamera = cc.Camera._findRendererCamera(node); | ||
if (renderCamera) { | ||
renderCamera.worldMatrixToScreen(_mat4_temp, _mat4_temp, cc.visibleRect.width, cc.visibleRect.height); | ||
renderCamera.worldMatrixToScreen(_mat4_temp, _mat4_temp, cc.game.canvas.width, cc.game.canvas.height); | ||
} | ||
|
||
let _mat4_tempm = _mat4_temp.m; | ||
if (!this._forceUpdate && | ||
this._m00 === _mat4_tempm[0] && this._m01 === _mat4_tempm[1] && | ||
if (this._m00 === _mat4_tempm[0] && this._m01 === _mat4_tempm[1] && | ||
this._m04 === _mat4_tempm[4] && this._m05 === _mat4_tempm[5] && | ||
this._m12 === _mat4_tempm[12] && this._m13 === _mat4_tempm[13] && | ||
this._w === node._contentSize.width && this._h === node._contentSize.height) { | ||
|
@@ -468,11 +464,9 @@ let VideoPlayerImpl = cc.Class({ | |
this._w = node._contentSize.width; | ||
this._h = node._contentSize.height; | ||
|
||
let scaleX = cc.view._scaleX, scaleY = cc.view._scaleY; | ||
let dpr = cc.view._devicePixelRatio; | ||
|
||
scaleX /= dpr; | ||
scaleY /= dpr; | ||
let scaleX = 1 / dpr; | ||
let scaleY = 1 / dpr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里可能还是要用 |
||
|
||
let container = cc.game.container; | ||
let a = _mat4_tempm[0] * scaleX, b = _mat4_tempm[1], c = _mat4_tempm[4], d = _mat4_tempm[5] * scaleY; | ||
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果 canvas 组件是其他适配模式的话,可能还是得考虑 viewport 的偏移量 |
||
|
||
let tx = _mat4_tempm[12] * scaleX - appx + offsetX, ty = _mat4_tempm[13] * scaleY - appy + offsetY; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,6 @@ let WebViewImpl = cc.Class({ | |
this._listener = null; | ||
|
||
// update matrix cache | ||
this._forceUpdate = true; | ||
this._m00 = 0; | ||
this._m01 = 0; | ||
this._m04 = 0; | ||
|
@@ -66,7 +65,6 @@ let WebViewImpl = cc.Class({ | |
else { | ||
div.style.visibility = 'hidden'; | ||
} | ||
this._forceUpdate = true; | ||
}, | ||
|
||
_updateSize (w, h) { | ||
|
@@ -344,14 +342,14 @@ let WebViewImpl = cc.Class({ | |
if (!this._div || !this._visible) return; | ||
|
||
node.getWorldMatrix(_mat4_temp); | ||
|
||
let renderCamera = cc.Camera._findRendererCamera(node); | ||
if (renderCamera) { | ||
renderCamera.worldMatrixToScreen(_mat4_temp, _mat4_temp, cc.visibleRect.width, cc.visibleRect.height); | ||
renderCamera.worldMatrixToScreen(_mat4_temp, _mat4_temp, cc.game.canvas.width, cc.game.canvas.height); | ||
} | ||
|
||
let _mat4_tempm = _mat4_temp.m; | ||
if (!this._forceUpdate && | ||
this._m00 === _mat4_tempm[0] && this._m01 === _mat4_tempm[1] && | ||
if (this._m00 === _mat4_tempm[0] && this._m01 === _mat4_tempm[1] && | ||
this._m04 === _mat4_tempm[4] && this._m05 === _mat4_tempm[5] && | ||
this._m12 === _mat4_tempm[12] && this._m13 === _mat4_tempm[13] && | ||
this._w === node._contentSize.width && this._h === node._contentSize.height) { | ||
|
@@ -368,26 +366,22 @@ let WebViewImpl = cc.Class({ | |
this._w = node._contentSize.width; | ||
this._h = node._contentSize.height; | ||
|
||
let scaleX = cc.view._scaleX, scaleY = cc.view._scaleY; | ||
let dpr = cc.view._devicePixelRatio; | ||
|
||
scaleX /= dpr; | ||
scaleY /= dpr; | ||
let scaleX = 1 / dpr; | ||
let scaleY = 1 / dpr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上 |
||
|
||
let container = cc.game.container; | ||
let a = _mat4_tempm[0] * scaleX, b = _mat4_tempm[1], c = _mat4_tempm[4], d = _mat4_tempm[5] * scaleY; | ||
|
||
let offsetX = container && container.style.paddingLeft ? parseInt(container.style.paddingLeft) : 0; | ||
let offsetY = container && container.style.paddingBottom ? parseInt(container.style.paddingBottom) : 0; | ||
this._updateSize(this._w, this._h); | ||
let w = this._div.clientWidth * scaleX; | ||
let h = this._div.clientHeight * scaleY; | ||
let w = this._w * scaleX; | ||
let h = this._h * scaleY; | ||
|
||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上 |
||
|
||
let tx = _mat4_tempm[12] * scaleX - appx + offsetX, ty = _mat4_tempm[13] * scaleY - appy + offsetY; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看了一下代码发现,在隐藏 videoplayer 的时,updateMatrix 是不会执行的,所以没必要设置该属性,进行移除