Commit 8071a82d authored by Adam Barth's avatar Adam Barth Committed by GitHub

Isolate Mozart dependencies (#6194)

This patch removes the Mozart dependencies from object.dart and
layer.dart, which will make it easier for us to move the Mozart
dependencies purely into the Fuchsia tree.
parent 9b35ebf0
...@@ -20,6 +20,7 @@ import 'package:mojo/mojo/service_provider.mojom.dart' as mojom; ...@@ -20,6 +20,7 @@ import 'package:mojo/mojo/service_provider.mojom.dart' as mojom;
import 'box.dart'; import 'box.dart';
import 'object.dart'; import 'object.dart';
import 'layer.dart';
mojom.ViewProxy _initViewProxy() { mojom.ViewProxy _initViewProxy() {
int viewHandle = ui.MojoServices.takeView(); int viewHandle = ui.MojoServices.takeView();
...@@ -308,8 +309,15 @@ class RenderChildView extends RenderBox { ...@@ -308,8 +309,15 @@ class RenderChildView extends RenderBox {
@override @override
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
assert(needsCompositing); assert(needsCompositing);
if (_child?._viewInfo != null) if (_child?._viewInfo != null) {
context.pushChildScene(offset, scale, _physicalWidth, _physicalHeight, _child._viewInfo.sceneToken); context.addLayer(new ChildSceneLayer(
offset: offset,
devicePixelRatio: scale,
physicalWidth: _physicalWidth,
physicalHeight: _physicalHeight,
sceneToken: _child._viewInfo.sceneToken.value
));
}
assert(() { assert(() {
if (_view == null) { if (_view == null) {
context.canvas.drawRect(offset & size, new Paint()..color = const Color(0xFF0000FF)); context.canvas.drawRect(offset & size, new Paint()..color = const Color(0xFF0000FF));
......
...@@ -8,7 +8,6 @@ import 'dart:ui' show Offset; ...@@ -8,7 +8,6 @@ import 'dart:ui' show Offset;
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:flutter_services/mojo/gfx/composition/scene_token.dart' as mojom;
import 'debug.dart'; import 'debug.dart';
...@@ -161,7 +160,7 @@ class ChildSceneLayer extends Layer { ...@@ -161,7 +160,7 @@ class ChildSceneLayer extends Layer {
int physicalHeight; int physicalHeight;
/// The composited scene that will contain the content rendered by the child. /// The composited scene that will contain the content rendered by the child.
mojom.SceneToken sceneToken; int sceneToken;
@override @override
void addToScene(ui.SceneBuilder builder, Offset layerOffset) { void addToScene(ui.SceneBuilder builder, Offset layerOffset) {
...@@ -170,7 +169,7 @@ class ChildSceneLayer extends Layer { ...@@ -170,7 +169,7 @@ class ChildSceneLayer extends Layer {
devicePixelRatio, devicePixelRatio,
physicalWidth, physicalWidth,
physicalHeight, physicalHeight,
sceneToken.value sceneToken
); );
} }
...@@ -180,7 +179,7 @@ class ChildSceneLayer extends Layer { ...@@ -180,7 +179,7 @@ class ChildSceneLayer extends Layer {
description.add('offset: $offset'); description.add('offset: $offset');
description.add('physicalWidth: $physicalWidth'); description.add('physicalWidth: $physicalWidth');
description.add('physicalHeight: $physicalHeight'); description.add('physicalHeight: $physicalHeight');
description.add('sceneToken.value: ${sceneToken.value}'); description.add('sceneToken: $sceneToken');
} }
} }
......
...@@ -10,7 +10,6 @@ import 'package:flutter/gestures.dart'; ...@@ -10,7 +10,6 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:flutter_services/mojo/gfx/composition/scene_token.dart' as mojom;
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'debug.dart'; import 'debug.dart';
...@@ -217,39 +216,18 @@ class PaintingContext { ...@@ -217,39 +216,18 @@ class PaintingContext {
_currentLayer?.willChangeHint = true; _currentLayer?.willChangeHint = true;
} }
/// Adds a performance overlay to the scene. /// Adds a composited layer to the recording.
/// ///
/// * `offset` is the offset from the origin of the canvas' coordinate system /// After calling this function, the [canvas] property will change to refer to
/// to the origin of the caller's coordinate system. /// a new [Canvas] that draws on top of the given layer.
/// * `optionsMask` is a mask is created by shifting 1 by the index of the ///
/// specific [PerformanceOverlayOption] to enable. /// A [RenderObject] that uses this function is very likely to require its
/// * `rasterizerThreshold` is an integer specifying the number of frame /// [RenderObject.needsCompositing] property to return true. That informs
/// intervals that the rasterizer must miss before it decides that the frame /// ancestor render objects that this render object will include a composited
/// is suitable for capturing an SkPicture trace for further analysis. /// layer, which causes them to use composited clips, for example.
/// * `size` is the size of the overlay to draw. The upper left corner of the void addLayer(Layer layer) {
/// overlay will be placed at the origin of the caller's coodinate system.
///
/// Performance overlays are always composited because they display data that
/// isn't available until the compositing phase.
void pushPerformanceOverlay(Offset offset, int optionsMask, int rasterizerThreshold, Size size) {
_stopRecordingIfNeeded();
_appendLayer(new PerformanceOverlayLayer(
overlayRect: new Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height),
optionsMask: optionsMask,
rasterizerThreshold: rasterizerThreshold
));
}
/// (mojo-only) Draws content from another process.
void pushChildScene(Offset offset, double devicePixelRatio, int physicalWidth, int physicalHeight, mojom.SceneToken sceneToken) {
_stopRecordingIfNeeded(); _stopRecordingIfNeeded();
_appendLayer(new ChildSceneLayer( _appendLayer(layer);
offset: offset,
devicePixelRatio: devicePixelRatio,
physicalWidth: physicalWidth,
physicalHeight: physicalHeight,
sceneToken: sceneToken
));
} }
/// Clip further painting using a rectangle. /// Clip further painting using a rectangle.
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'box.dart'; import 'box.dart';
import 'object.dart'; import 'object.dart';
import 'layer.dart';
/// The options that control whether the performance overlay displays certain /// The options that control whether the performance overlay displays certain
/// aspects of the compositor. /// aspects of the compositor.
...@@ -136,6 +137,10 @@ class RenderPerformanceOverlay extends RenderBox { ...@@ -136,6 +137,10 @@ class RenderPerformanceOverlay extends RenderBox {
@override @override
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
assert(needsCompositing); assert(needsCompositing);
context.pushPerformanceOverlay(offset, optionsMask, rasterizerThreshold, size); context.addLayer(new PerformanceOverlayLayer(
overlayRect: new Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height),
optionsMask: optionsMask,
rasterizerThreshold: rasterizerThreshold
));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment