Commit 9480a3e5 authored by Jeff Brown's avatar Jeff Brown Committed by Chinmay Garde

Use Fuchsia system compositor for physical model layers. (#11164)

On Fuchsia, the system compositor is responsible for drawing shadows
for physical model layers with non-zero elevation.

Also fixed a bug where _needsCompositing was not being cleared prior
to updating it.
parent c464dd5d
...@@ -2113,6 +2113,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -2113,6 +2113,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
if (!_needsCompositingBitsUpdate) if (!_needsCompositingBitsUpdate)
return; return;
final bool oldNeedsCompositing = _needsCompositing; final bool oldNeedsCompositing = _needsCompositing;
_needsCompositing = false;
visitChildren((RenderObject child) { visitChildren((RenderObject child) {
child._updateCompositingBits(); child._updateCompositingBits();
if (child.needsCompositing) if (child.needsCompositing)
......
...@@ -1286,6 +1286,7 @@ class RenderPhysicalModel extends _RenderCustomClip<RRect> { ...@@ -1286,6 +1286,7 @@ class RenderPhysicalModel extends _RenderCustomClip<RRect> {
if (elevation == value) if (elevation == value)
return; return;
_elevation = value; _elevation = value;
markNeedsCompositingBitsUpdate();
markNeedsPaint(); markNeedsPaint();
} }
...@@ -1325,6 +1326,11 @@ class RenderPhysicalModel extends _RenderCustomClip<RRect> { ...@@ -1325,6 +1326,11 @@ class RenderPhysicalModel extends _RenderCustomClip<RRect> {
static final Paint _defaultPaint = new Paint(); static final Paint _defaultPaint = new Paint();
static final Paint _transparentPaint = new Paint()..color = const Color(0x00000000); static final Paint _transparentPaint = new Paint()..color = const Color(0x00000000);
// On Fuchsia, the system compositor is responsible for drawing shadows
// for physical model layers with non-zero elevation.
@override
bool get alwaysNeedsCompositing => _elevation != 0.0 && defaultTargetPlatform == TargetPlatform.fuchsia;
@override @override
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
if (child != null) { if (child != null) {
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
...@@ -29,4 +30,43 @@ void main() { ...@@ -29,4 +30,43 @@ void main() {
layout(makeFittedBox(), constraints: new BoxConstraints.tight(Size.zero), phase: EnginePhase.paint); layout(makeFittedBox(), constraints: new BoxConstraints.tight(Size.zero), phase: EnginePhase.paint);
expect(painted, equals(false)); expect(painted, equals(false));
}); });
test('RenderPhysicalModel compositing on Fuchsia', () {
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
final root = new RenderPhysicalModel(color: new Color(0xffff00ff));
layout(root, phase: EnginePhase.composite);
expect(root.needsCompositing, isFalse);
// On Fuchsia, the system compositor is responsible for drawing shadows
// for physical model layers with non-zero elevation.
root.elevation = 1.0;
pumpFrame(phase: EnginePhase.composite);
expect(root.needsCompositing, isTrue);
root.elevation = 0.0;
pumpFrame(phase: EnginePhase.composite);
expect(root.needsCompositing, isFalse);
debugDefaultTargetPlatformOverride = null;
});
test('RenderPhysicalModel compositing on non-Fuchsia', () {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final root = new RenderPhysicalModel(color: new Color(0xffff00ff));
layout(root, phase: EnginePhase.composite);
expect(root.needsCompositing, isFalse);
// On non-Fuchsia platforms, Flutter draws its own shadows.
root.elevation = 1.0;
pumpFrame(phase: EnginePhase.composite);
expect(root.needsCompositing, isFalse);
root.elevation = 0.0;
pumpFrame(phase: EnginePhase.composite);
expect(root.needsCompositing, isFalse);
debugDefaultTargetPlatformOverride = null;
});
} }
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