You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hardware accelerated canvases may have any matrix when passed to a View or Drawable, as it is implementation defined where in the hierarchy such canvases are created. It is recommended in such cases to either draw contents irrespective of the current matrix, or to track relevant transform state outside of the canvas.
When hardware acceleration is enabled, a View's drawing commands are recorded in a display list. At this point, a call to getMatrix() will only return the matrix built by the View itself. Any operation performed by the parents will not be taken into account (and cannot be taken into account, a display list can be generated before a View even have a parent.)
在
Canvas.getMatrix()
中有标记这个方法被废弃,因为:同时在这个Issue Tracker里,有开发者反馈:在开启硬件加速之后,做这样一个无害操作
canvas.setMatrix(canvas.getMatrix())
居然会改变Canvas
的状态,也就是getMatrix()
和setMatrix()
不对应谷歌员工对此的回复是:
谷歌员工的解释补充了源码注释里一些晦涩的地方,整个机制看上去还是比较合理的,但我在进行验证的时候,却发现开启硬件加速后,无害操作
canvas.setMatrix(canvas.getMatrix())
并没有改变Canvas
的状态(是在一个有状态栏标题栏的页面中,理论上父view对子view的canvas有平移操作),非常奇怪而且运行Issue Tracker里开发者提供的代码,也能正常工作,没有出现该开发者描述的问题,如下图:
(运行环境为Android 8.0 虚拟机,并且能看到
canvas.isHardwareAccelerated
返回true也就是开启了硬件加速)The text was updated successfully, but these errors were encountered: