未验证 提交 a15bc1be 编写于 作者: H Harry Terkelsen 提交者: GitHub

[CanvasKit] Dispose the overlay surface when a platform view is disposed (#19546)

上级 3fe5edf8
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
part of engine;
/// This composites HTML views into the [ui.Scene].
......@@ -255,7 +254,8 @@ class HtmlViewEmbedder {
final CkPath path = CkPath();
path.addRRect(mutator.rrect!);
_ensureSvgPathDefs();
html.Element pathDefs = _svgPathDefs!.querySelector('#sk_path_defs')!;
html.Element pathDefs =
_svgPathDefs!.querySelector('#sk_path_defs')!;
_clipPathCount += 1;
html.Element newClipPath =
html.Element.html('<clipPath id="svgClip$_clipPathCount">'
......@@ -266,7 +266,8 @@ class HtmlViewEmbedder {
} else if (mutator.path != null) {
final CkPath path = mutator.path as CkPath;
_ensureSvgPathDefs();
html.Element pathDefs = _svgPathDefs!.querySelector('#sk_path_defs')!;
html.Element pathDefs =
_svgPathDefs!.querySelector('#sk_path_defs')!;
_clipPathCount += 1;
html.Element newClipPath =
html.Element.html('<clipPath id="svgClip$_clipPathCount">'
......@@ -369,6 +370,8 @@ class HtmlViewEmbedder {
if (_overlays[viewId] != null) {
final Overlay overlay = _overlays[viewId]!;
overlay.surface.htmlElement?.remove();
overlay.surface.htmlElement = null;
overlay.skSurface?.dispose();
}
_overlays.remove(viewId);
_currentCompositionParams.remove(viewId);
......@@ -402,10 +405,10 @@ class EmbeddedViewParams {
if (identical(this, other)) {
return true;
}
return other is EmbeddedViewParams
&& other.offset == offset
&& other.size == size
&& other.mutators == mutators;
return other is EmbeddedViewParams &&
other.offset == offset &&
other.size == size &&
other.mutators == mutators;
}
int get hashCode => ui.hashValues(offset, size, mutators);
......@@ -524,8 +527,8 @@ class MutatorsStack extends Iterable<Mutator> {
if (identical(other, this)) {
return true;
}
return other is MutatorsStack
&& _listEquals<Mutator>(other._mutators, _mutators);
return other is MutatorsStack &&
_listEquals<Mutator>(other._mutators, _mutators);
}
int get hashCode => ui.hashList(_mutators);
......
......@@ -134,7 +134,7 @@ class Surface {
}
bool _presentSurface() {
canvasKit.callMethod('setCurrentContext', <dynamic>[_surface!.context]);
canvasKit.callMethod('setCurrentContext', <int>[_surface!.context]);
_surface!.getCanvas().flush();
return true;
}
......@@ -159,8 +159,16 @@ class CkSurface {
int height() => _surface.callMethod('height');
void dispose() {
if (_isDisposed) {
return;
}
// Only resources from the current context can be disposed.
canvasKit.callMethod('setCurrentContext', <int>[_glContext]);
_surface.callMethod('dispose');
_grContext.callMethod('releaseResourcesAndAbandonContext');
_grContext.callMethod('delete');
_isDisposed = true;
}
bool _isDisposed = false;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册