Flutter Engine
platform_view_layer.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "flutter/flow/layers/platform_view_layer.h"
6 
7 namespace flutter {
8 
10  const SkSize& size,
11  int64_t view_id)
12  : offset_(offset), size_(size), view_id_(view_id) {}
13 
15  const SkMatrix& matrix) {
16  set_paint_bounds(SkRect::MakeXYWH(offset_.x(), offset_.y(), size_.width(),
17  size_.height()));
18 
19  if (context->view_embedder == nullptr) {
20  FML_LOG(ERROR) << "Trying to embed a platform view but the PrerollContext "
21  "does not support embedding";
22  return;
23  }
24  context->has_platform_view = true;
26  std::unique_ptr<EmbeddedViewParams> params =
27  std::make_unique<EmbeddedViewParams>(matrix, size_,
28  context->mutators_stack);
30  std::move(params));
31 }
32 
33 void PlatformViewLayer::Paint(PaintContext& context) const {
34  if (context.view_embedder == nullptr) {
35  FML_LOG(ERROR) << "Trying to embed a platform view but the PaintContext "
36  "does not support embedding";
37  return;
38  }
39  SkCanvas* canvas = context.view_embedder->CompositeEmbeddedView(view_id_);
40  context.leaf_nodes_canvas = canvas;
41 }
42 
43 } // namespace flutter
void set_subtree_has_platform_view(bool value)
Definition: layer.h:219
ExternalViewEmbedder * view_embedder
Definition: layer.h:147
void Preroll(PrerollContext *context, const SkMatrix &matrix) override
void Paint(PaintContext &context) const override
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
#define FML_LOG(severity)
Definition: logging.h:65
virtual SkCanvas * CompositeEmbeddedView(int view_id)=0
virtual void PrerollCompositeEmbeddedView(int view_id, std::unique_ptr< EmbeddedViewParams > params)=0
SkCanvas * leaf_nodes_canvas
Definition: layer.h:145
void set_paint_bounds(const SkRect &paint_bounds)
Definition: layer.h:240
PlatformViewLayer(const SkPoint &offset, const SkSize &size, int64_t view_id)
ExternalViewEmbedder * view_embedder
Definition: layer.h:45
MutatorsStack & mutators_stack
Definition: layer.h:46