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
1 change: 1 addition & 0 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# More information at:
# * https://github.com/flutter/cocoon/blob/master/CI_YAML.md
enabled_branches:
- flutter-2.6-candidate.3
- master
- dev
- beta
Expand Down
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ vars = {
'skia_git': 'https://skia.googlesource.com',
# OCMock is for testing only so there is no google clone
'ocmock_git': 'https://github.com/erikdoe/ocmock.git',
'skia_revision': '31012fa353c87bd8476d30c6d56a3b179183cbcb',
'skia_revision': 'd61d0f29408f7e97d494365d5f16e32e69a204f7',

# WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY
# See `lib/web_ui/README.md` for how to roll CanvasKit to a new version.
Expand Down
2 changes: 1 addition & 1 deletion ci/licenses_golden/licenses_skia
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Signature: d12ea47d692f698ae079dcb8997a296a
Signature: 9410887ded78518c80a13738873500fd

UNUSED LICENSES:

Expand Down
8 changes: 6 additions & 2 deletions flow/compositor_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ enum class RasterStatus {
kEnqueuePipeline,
// Failed to rasterize the frame.
kFailed,
// Layer tree was discarded due to LayerTreeDiscardCallback
kDiscarded
// Layer tree was discarded due to LayerTreeDiscardCallback or inability to
// access the GPU.
kDiscarded,
// Drawing was yielded to allow the correct thread to draw as a result of the
// RasterThreadMerger.
kYielded,
};

class CompositorContext {
Expand Down
6 changes: 2 additions & 4 deletions flow/embedded_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

namespace flutter {

void ExternalViewEmbedder::SubmitFrame(
GrDirectContext* context,
std::unique_ptr<SurfaceFrame> frame,
const std::shared_ptr<const fml::SyncSwitch>& gpu_disable_sync_switch) {
void ExternalViewEmbedder::SubmitFrame(GrDirectContext* context,
std::unique_ptr<SurfaceFrame> frame) {
frame->Submit();
};

Expand Down
7 changes: 2 additions & 5 deletions flow/embedded_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "flutter/flow/surface_frame.h"
#include "flutter/fml/memory/ref_counted.h"
#include "flutter/fml/raster_thread_merger.h"
#include "flutter/fml/synchronization/sync_switch.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkPoint.h"
Expand Down Expand Up @@ -313,10 +312,8 @@ class ExternalViewEmbedder {
// This method can mutate the root Skia canvas before submitting the frame.
//
// It can also allocate frames for overlay surfaces to compose hybrid views.
virtual void SubmitFrame(
GrDirectContext* context,
std::unique_ptr<SurfaceFrame> frame,
const std::shared_ptr<const fml::SyncSwitch>& gpu_disable_sync_switch);
virtual void SubmitFrame(GrDirectContext* context,
std::unique_ptr<SurfaceFrame> frame);

// This method provides the embedder a way to do additional tasks after
// |SubmitFrame|. For example, merge task runners if `should_resubmit_frame`
Expand Down
4 changes: 4 additions & 0 deletions flow/surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ bool Surface::ClearRenderContext() {
return false;
}

bool Surface::AllowsDrawingWhenGpuDisabled() const {
return true;
}

} // namespace flutter
2 changes: 2 additions & 0 deletions flow/surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Surface {

virtual bool ClearRenderContext();

virtual bool AllowsDrawingWhenGpuDisabled() const;

private:
FML_DISALLOW_COPY_AND_ASSIGN(Surface);
};
Expand Down
38 changes: 33 additions & 5 deletions shell/common/rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void Rasterizer::DrawLastLayerTree(
DrawToSurface(*frame_timings_recorder, *last_layer_tree_);
}

void Rasterizer::Draw(
RasterStatus Rasterizer::Draw(
std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder,
std::shared_ptr<Pipeline<flutter::LayerTree>> pipeline,
LayerTreeDiscardCallback discardCallback) {
Expand All @@ -156,7 +156,7 @@ void Rasterizer::Draw(
if (raster_thread_merger_ &&
!raster_thread_merger_->IsOnRasterizingThread()) {
// we yield and let this frame be serviced on the right thread.
return;
return RasterStatus::kYielded;
}
FML_DCHECK(delegate_.GetTaskRunners()
.GetRasterTaskRunner()
Expand Down Expand Up @@ -217,6 +217,8 @@ void Rasterizer::Draw(
default:
break;
}

return raster_status;
}

namespace {
Expand Down Expand Up @@ -385,6 +387,8 @@ RasterStatus Rasterizer::DoDraw(
raster_status == RasterStatus::kSkipAndRetry) {
resubmitted_layer_tree_ = std::move(layer_tree);
return raster_status;
} else if (raster_status == RasterStatus::kDiscarded) {
return raster_status;
}

if (persistent_cache->IsDumpingSkp() &&
Expand Down Expand Up @@ -465,6 +469,31 @@ RasterStatus Rasterizer::DrawToSurface(
TRACE_EVENT0("flutter", "Rasterizer::DrawToSurface");
FML_DCHECK(surface_);

RasterStatus raster_status;
if (surface_->AllowsDrawingWhenGpuDisabled()) {
raster_status = DrawToSurfaceUnsafe(frame_timings_recorder, layer_tree);
} else {
delegate_.GetIsGpuDisabledSyncSwitch()->Execute(
fml::SyncSwitch::Handlers()
.SetIfTrue([&] { raster_status = RasterStatus::kDiscarded; })
.SetIfFalse([&] {
raster_status =
DrawToSurfaceUnsafe(frame_timings_recorder, layer_tree);
}));
}

return raster_status;
}

/// Unsafe because it assumes we have access to the GPU which isn't the case
/// when iOS is backgrounded, for example.
/// \see Rasterizer::DrawToSurface
RasterStatus Rasterizer::DrawToSurfaceUnsafe(
FrameTimingsRecorder& frame_timings_recorder,
flutter::LayerTree& layer_tree) {
TRACE_EVENT0("flutter", "Rasterizer::DrawToSurfaceUnsafe");
FML_DCHECK(surface_);

compositor_context_->ui_time().SetLapTime(
frame_timings_recorder.GetBuildDuration());

Expand Down Expand Up @@ -512,9 +541,8 @@ RasterStatus Rasterizer::DrawToSurface(
if (external_view_embedder_ &&
(!raster_thread_merger_ || raster_thread_merger_->IsMerged())) {
FML_DCHECK(!frame->IsSubmitted());
external_view_embedder_->SubmitFrame(
surface_->GetContext(), std::move(frame),
delegate_.GetIsGpuDisabledSyncSwitch());
external_view_embedder_->SubmitFrame(surface_->GetContext(),
std::move(frame));
} else {
frame->Submit();
}
Expand Down
10 changes: 7 additions & 3 deletions shell/common/rasterizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@ class Rasterizer final : public SnapshotDelegate {
/// @param[in] discardCallback if specified and returns true, the layer tree
/// is discarded instead of being rendered
///
void Draw(std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder,
std::shared_ptr<Pipeline<flutter::LayerTree>> pipeline,
LayerTreeDiscardCallback discardCallback = NoDiscard);
RasterStatus Draw(
std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder,
std::shared_ptr<Pipeline<flutter::LayerTree>> pipeline,
LayerTreeDiscardCallback discardCallback = NoDiscard);

//----------------------------------------------------------------------------
/// @brief The type of the screenshot to obtain of the previously
Expand Down Expand Up @@ -492,6 +493,9 @@ class Rasterizer final : public SnapshotDelegate {
RasterStatus DrawToSurface(FrameTimingsRecorder& frame_timings_recorder,
flutter::LayerTree& layer_tree);

RasterStatus DrawToSurfaceUnsafe(FrameTimingsRecorder& frame_timings_recorder,
flutter::LayerTree& layer_tree);

void FireNextFrameCallbackIfPresent();

static bool NoDiscard(const flutter::LayerTree& layer_tree) { return false; }
Expand Down
Loading