Skip to content

Commit 7f828dd

Browse files
authored
Raster now returns an enum rather than boolean (#9661)
This is part of a bigger change that will facilitate us to act on this `RasterStatus`. The specific case is where after pre-roll we might decide to want to merge the threads and re-submit the frame -- `RasterStatus::kResubmit` can then let us achieve this result.
1 parent 11b6afe commit 7f828dd

5 files changed

Lines changed: 23 additions & 15 deletions

File tree

‎flow/compositor_context.cc‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,17 @@ CompositorContext::ScopedFrame::~ScopedFrame() {
6060
context_.EndFrame(*this, instrumentation_enabled_);
6161
}
6262

63-
bool CompositorContext::ScopedFrame::Raster(flutter::LayerTree& layer_tree,
64-
bool ignore_raster_cache) {
63+
RasterStatus CompositorContext::ScopedFrame::Raster(
64+
flutter::LayerTree& layer_tree,
65+
bool ignore_raster_cache) {
6566
layer_tree.Preroll(*this, ignore_raster_cache);
6667
// Clearing canvas after preroll reduces one render target switch when preroll
6768
// paints some raster cache.
6869
if (canvas()) {
6970
canvas()->clear(SK_ColorTRANSPARENT);
7071
}
7172
layer_tree.Paint(*this, ignore_raster_cache);
72-
return true;
73+
return RasterStatus::kSuccess;
7374
}
7475

7576
void CompositorContext::OnGrContextCreated() {

‎flow/compositor_context.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ namespace flutter {
2020

2121
class LayerTree;
2222

23+
enum class RasterStatus { kSuccess, kFailed };
24+
2325
class CompositorContext {
2426
public:
2527
class ScopedFrame {
@@ -45,7 +47,8 @@ class CompositorContext {
4547

4648
GrContext* gr_context() const { return gr_context_; }
4749

48-
virtual bool Raster(LayerTree& layer_tree, bool ignore_raster_cache);
50+
virtual RasterStatus Raster(LayerTree& layer_tree,
51+
bool ignore_raster_cache);
4952

5053
private:
5154
CompositorContext& context_;

‎shell/common/rasterizer.cc‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ void Rasterizer::DoDraw(std::unique_ptr<flutter::LayerTree> layer_tree) {
187187
PersistentCache* persistent_cache = PersistentCache::GetCacheForProcess();
188188
persistent_cache->ResetStoredNewShaders();
189189

190-
if (DrawToSurface(*layer_tree)) {
190+
if (DrawToSurface(*layer_tree) == RasterStatus::kSuccess) {
191191
last_layer_tree_ = std::move(layer_tree);
192192
}
193193

@@ -205,13 +205,13 @@ void Rasterizer::DoDraw(std::unique_ptr<flutter::LayerTree> layer_tree) {
205205
delegate_.OnFrameRasterized(timing);
206206
}
207207

208-
bool Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) {
208+
RasterStatus Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) {
209209
FML_DCHECK(surface_);
210210

211211
auto frame = surface_->AcquireFrame(layer_tree.frame_size());
212212

213213
if (frame == nullptr) {
214-
return false;
214+
return RasterStatus::kFailed;
215215
}
216216

217217
// There is no way for the compositor to know how long the layer tree
@@ -231,7 +231,11 @@ bool Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) {
231231
surface_->GetContext(), canvas, external_view_embedder,
232232
surface_->GetRootTransformation(), true);
233233

234-
if (compositor_frame && compositor_frame->Raster(layer_tree, false)) {
234+
if (compositor_frame) {
235+
RasterStatus raster_status = compositor_frame->Raster(layer_tree, false);
236+
if (raster_status == RasterStatus::kFailed) {
237+
return raster_status;
238+
}
235239
frame->Submit();
236240
if (external_view_embedder != nullptr) {
237241
external_view_embedder->SubmitFrame(surface_->GetContext());
@@ -241,10 +245,10 @@ bool Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) {
241245
if (surface_->GetContext())
242246
surface_->GetContext()->performDeferredCleanup(kSkiaCleanupExpiration);
243247

244-
return true;
248+
return raster_status;
245249
}
246250

247-
return false;
251+
return RasterStatus::kFailed;
248252
}
249253

250254
static sk_sp<SkData> SerializeTypeface(SkTypeface* typeface, void* ctx) {

‎shell/common/rasterizer.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class Rasterizer final : public SnapshotDelegate {
116116

117117
void DoDraw(std::unique_ptr<flutter::LayerTree> layer_tree);
118118

119-
bool DrawToSurface(flutter::LayerTree& layer_tree);
119+
RasterStatus DrawToSurface(flutter::LayerTree& layer_tree);
120120

121121
void FireNextFrameCallbackIfPresent();
122122

‎shell/platform/fuchsia/flutter/compositor_context.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame {
2525
private:
2626
SessionConnection& session_connection_;
2727

28-
bool Raster(flutter::LayerTree& layer_tree,
29-
bool ignore_raster_cache) override {
28+
flutter::RasterStatus Raster(flutter::LayerTree& layer_tree,
29+
bool ignore_raster_cache) override {
3030
if (!session_connection_.has_metrics()) {
31-
return true;
31+
return flutter::RasterStatus::kSuccess;
3232
}
3333

3434
{
@@ -52,7 +52,7 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame {
5252
session_connection_.Present(*this);
5353
}
5454

55-
return true;
55+
return flutter::RasterStatus::kSuccess;
5656
}
5757

5858
FML_DISALLOW_COPY_AND_ASSIGN(ScopedFrame);

0 commit comments

Comments
 (0)