Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions flow/compositor_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,17 @@ CompositorContext::ScopedFrame::~ScopedFrame() {
context_.EndFrame(*this, instrumentation_enabled_);
}

bool CompositorContext::ScopedFrame::Raster(flutter::LayerTree& layer_tree,
bool ignore_raster_cache) {
RasterStatus CompositorContext::ScopedFrame::Raster(
flutter::LayerTree& layer_tree,
bool ignore_raster_cache) {
layer_tree.Preroll(*this, ignore_raster_cache);
// Clearing canvas after preroll reduces one render target switch when preroll
// paints some raster cache.
if (canvas()) {
canvas()->clear(SK_ColorTRANSPARENT);
}
layer_tree.Paint(*this, ignore_raster_cache);
return true;
return RasterStatus::kSuccess;
}

void CompositorContext::OnGrContextCreated() {
Expand Down
5 changes: 4 additions & 1 deletion flow/compositor_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace flutter {

class LayerTree;

enum class RasterStatus { kSuccess, kFailed };

class CompositorContext {
public:
class ScopedFrame {
Expand All @@ -45,7 +47,8 @@ class CompositorContext {

GrContext* gr_context() const { return gr_context_; }

virtual bool Raster(LayerTree& layer_tree, bool ignore_raster_cache);
virtual RasterStatus Raster(LayerTree& layer_tree,
bool ignore_raster_cache);

private:
CompositorContext& context_;
Expand Down
16 changes: 10 additions & 6 deletions shell/common/rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void Rasterizer::DoDraw(std::unique_ptr<flutter::LayerTree> layer_tree) {
PersistentCache* persistent_cache = PersistentCache::GetCacheForProcess();
persistent_cache->ResetStoredNewShaders();

if (DrawToSurface(*layer_tree)) {
if (DrawToSurface(*layer_tree) == RasterStatus::kSuccess) {
last_layer_tree_ = std::move(layer_tree);
}

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

bool Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) {
RasterStatus Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) {
FML_DCHECK(surface_);

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

if (frame == nullptr) {
return false;
return RasterStatus::kFailed;
}

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

if (compositor_frame && compositor_frame->Raster(layer_tree, false)) {
if (compositor_frame) {
RasterStatus raster_status = compositor_frame->Raster(layer_tree, false);
if (raster_status == RasterStatus::kFailed) {
return raster_status;
}
frame->Submit();
if (external_view_embedder != nullptr) {
external_view_embedder->SubmitFrame(surface_->GetContext());
Expand All @@ -241,10 +245,10 @@ bool Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) {
if (surface_->GetContext())
surface_->GetContext()->performDeferredCleanup(kSkiaCleanupExpiration);

return true;
return raster_status;
}

return false;
return RasterStatus::kFailed;
}

static sk_sp<SkData> SerializeTypeface(SkTypeface* typeface, void* ctx) {
Expand Down
2 changes: 1 addition & 1 deletion shell/common/rasterizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Rasterizer final : public SnapshotDelegate {

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

bool DrawToSurface(flutter::LayerTree& layer_tree);
RasterStatus DrawToSurface(flutter::LayerTree& layer_tree);

void FireNextFrameCallbackIfPresent();

Expand Down
8 changes: 4 additions & 4 deletions shell/platform/fuchsia/flutter/compositor_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame {
private:
SessionConnection& session_connection_;

bool Raster(flutter::LayerTree& layer_tree,
bool ignore_raster_cache) override {
flutter::RasterStatus Raster(flutter::LayerTree& layer_tree,
bool ignore_raster_cache) override {
if (!session_connection_.has_metrics()) {
return true;
return flutter::RasterStatus::kSuccess;
}

{
Expand All @@ -52,7 +52,7 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame {
session_connection_.Present(*this);
}

return true;
return flutter::RasterStatus::kSuccess;
}

FML_DISALLOW_COPY_AND_ASSIGN(ScopedFrame);
Expand Down