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.
This commit is contained in:
parent
c464dd5d2d
commit
9480a3e591
@ -2113,6 +2113,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
|
||||
if (!_needsCompositingBitsUpdate)
|
||||
return;
|
||||
final bool oldNeedsCompositing = _needsCompositing;
|
||||
_needsCompositing = false;
|
||||
visitChildren((RenderObject child) {
|
||||
child._updateCompositingBits();
|
||||
if (child.needsCompositing)
|
||||
|
@ -1286,6 +1286,7 @@ class RenderPhysicalModel extends _RenderCustomClip<RRect> {
|
||||
if (elevation == value)
|
||||
return;
|
||||
_elevation = value;
|
||||
markNeedsCompositingBitsUpdate();
|
||||
markNeedsPaint();
|
||||
}
|
||||
|
||||
@ -1325,6 +1326,11 @@ class RenderPhysicalModel extends _RenderCustomClip<RRect> {
|
||||
static final Paint _defaultPaint = new Paint();
|
||||
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
|
||||
void paint(PaintingContext context, Offset offset) {
|
||||
if (child != null) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@ -29,4 +30,43 @@ void main() {
|
||||
layout(makeFittedBox(), constraints: new BoxConstraints.tight(Size.zero), phase: EnginePhase.paint);
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user