Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update shader warm-up for recent Skia changes (#37955)
The update is copied from an update we made to a Google-internal client: cl/260202900 The update will save 1 shader compilation. This should help solve our regression: #31203 More regressions on iOS might be introduced later by flutter/engine#9813 (comment) Unfortunately, we didn't rebase our benchmarks so such regressions were not detected. Hence to fully solve #31203, we might need to revert some change in flutter/engine#9813 to make iOS shader warm-up happen on the GPU thread again.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter/painting.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
class TestCanvas implements Canvas { | ||
TestCanvas([this.invocations]); | ||
|
||
final List<Invocation> invocations; | ||
|
||
@override | ||
void noSuchMethod(Invocation invocation) { | ||
invocations?.add(invocation); | ||
} | ||
} | ||
|
||
void main() { | ||
test('DefaultShaderWarmUp has expected canvas invocations', () { | ||
final List<Invocation> invocations = <Invocation>[]; | ||
final TestCanvas canvas = TestCanvas(invocations); | ||
const DefaultShaderWarmUp s = DefaultShaderWarmUp(); | ||
s.warmUpOnCanvas(canvas); | ||
|
||
bool hasDrawRectAfterClipRRect = false; | ||
for (int i = 0; i < invocations.length - 1; i += 1) { | ||
if (invocations[i].memberName == #clipRRect && invocations[i + 1].memberName == #drawRect) { | ||
hasDrawRectAfterClipRRect = true; | ||
break; | ||
} | ||
} | ||
|
||
expect(hasDrawRectAfterClipRRect, true); | ||
}); | ||
} |