Skip to content

Commit

Permalink
Implement unobstructed Platform Views on iOS (flutter#17049)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Garcia committed Mar 20, 2020
1 parent 49f8dba commit 2627634
Show file tree
Hide file tree
Showing 19 changed files with 839 additions and 124 deletions.
5 changes: 4 additions & 1 deletion flow/embedded_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@

namespace flutter {

bool ExternalViewEmbedder::SubmitFrame(GrContext* context) {
bool ExternalViewEmbedder::SubmitFrame(GrContext* context,
SkCanvas* background_canvas) {
return false;
};

void ExternalViewEmbedder::FinishFrame(){};

void MutatorsStack::PushClipRect(const SkRect& rect) {
std::shared_ptr<Mutator> element = std::make_shared<Mutator>(rect);
vector_.push_back(element);
Expand Down
5 changes: 4 additions & 1 deletion flow/embedded_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@ class ExternalViewEmbedder {
// Must be called on the UI thread.
virtual SkCanvas* CompositeEmbeddedView(int view_id) = 0;

virtual bool SubmitFrame(GrContext* context);
virtual bool SubmitFrame(GrContext* context, SkCanvas* background_canvas);

// This is called after submitting the embedder frame and the surface frame.
virtual void FinishFrame();

FML_DISALLOW_COPY_AND_ASSIGN(ExternalViewEmbedder);

Expand Down
2 changes: 1 addition & 1 deletion flow/layers/picture_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void PictureLayer::Paint(PaintContext& context) const {
return;
}
}
context.leaf_nodes_canvas->drawPicture(picture());
picture()->playback(context.leaf_nodes_canvas);
}

} // namespace flutter
3 changes: 0 additions & 3 deletions flow/layers/picture_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ TEST_F(PictureLayerTest, SimplePicture) {
1, MockCanvas::SetMatrixData{RasterCache::GetIntegralTransCTM(
layer_offset_matrix)}},
#endif
MockCanvas::DrawCall{
1, MockCanvas::DrawPictureData{mock_picture->serialize(), SkPaint(),
SkMatrix()}},
MockCanvas::DrawCall{1, MockCanvas::RestoreData{0}}});
EXPECT_EQ(mock_canvas().draw_calls(), expected_draw_calls);
}
Expand Down
12 changes: 10 additions & 2 deletions shell/common/rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,17 @@ RasterStatus Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) {
if (raster_status == RasterStatus::kFailed) {
return raster_status;
}
frame->Submit();
if (external_view_embedder != nullptr) {
external_view_embedder->SubmitFrame(surface_->GetContext());
external_view_embedder->SubmitFrame(surface_->GetContext(),
root_surface_canvas);
// The external view embedder may mutate the root surface canvas while
// submitting the frame.
// Therefore, submit the final frame after asking the external view
// embedder to submit the frame.
frame->Submit();
external_view_embedder->FinishFrame();
} else {
frame->Submit();
}

FireNextFrameCallbackIfPresent();
Expand Down
Loading

0 comments on commit 2627634

Please sign in to comment.