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 #if defined(LEGACY_FUCHSIA_EMBEDDER)
17  context->child_scene_layer_exists_below = true;
18  CheckForChildLayerBelow(context);
19 #endif
20 
21  set_paint_bounds(SkRect::MakeXYWH(offset_.x(), offset_.y(), size_.width(),
22  size_.height()));
23 
24  if (context->view_embedder == nullptr) {
25  FML_LOG(ERROR) << "Trying to embed a platform view but the PrerollContext "
26  "does not support embedding";
27  return;
28  }
29  context->has_platform_view = true;
30  std::unique_ptr<EmbeddedViewParams> params =
31  std::make_unique<EmbeddedViewParams>(matrix, size_,
32  context->mutators_stack);
34  std::move(params));
35 }
36 
37 void PlatformViewLayer::Paint(PaintContext& context) const {
38  if (context.view_embedder == nullptr) {
39 #if !defined(LEGACY_FUCHSIA_EMBEDDER)
40  FML_LOG(ERROR) << "Trying to embed a platform view but the PaintContext "
41  "does not support embedding";
42 #endif
43  return;
44  }
45  SkCanvas* canvas = context.view_embedder->CompositeEmbeddedView(view_id_);
46  context.leaf_nodes_canvas = canvas;
47 }
48 
49 #if defined(LEGACY_FUCHSIA_EMBEDDER)
50 void PlatformViewLayer::UpdateScene(SceneUpdateContext& context) {
51  TRACE_EVENT0("flutter", "PlatformViewLayer::UpdateScene");
53  context.UpdateView(view_id_, offset_, size_);
54 }
55 #endif
56 
57 } // namespace flutter
ExternalViewEmbedder * view_embedder
Definition: layer.h:118
void Preroll(PrerollContext *context, const SkMatrix &matrix) override
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
#define FML_DCHECK(condition)
Definition: logging.h:86
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
bool needs_system_composite() const
Definition: layer.h:161
virtual void PrerollCompositeEmbeddedView(int view_id, std::unique_ptr< EmbeddedViewParams > params)=0
SkCanvas * leaf_nodes_canvas
Definition: layer.h:116
void set_paint_bounds(const SkRect &paint_bounds)
Definition: layer.h:170
void UpdateView(int64_t view_id, bool hit_testable, bool focusable)
PlatformViewLayer(const SkPoint &offset, const SkSize &size, int64_t view_id)
ExternalViewEmbedder * view_embedder
Definition: layer.h:46
MutatorsStack & mutators_stack
Definition: layer.h:47