mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
For https://github.com/flutter/flutter/issues/33807 We still need to make layers' children immutable for full immutability. That will require us to change the SceneBuilder API to build the layer bottom up instead of top down (post-order traversal instead of pre-order traversal).
46 lines
1.6 KiB
C++
46 lines
1.6 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/flow/layers/platform_view_layer.h"
|
|
|
|
namespace flutter {
|
|
|
|
PlatformViewLayer::PlatformViewLayer(const SkPoint& offset,
|
|
const SkSize& size,
|
|
int64_t view_id)
|
|
: offset_(offset), size_(size), view_id_(view_id) {}
|
|
|
|
PlatformViewLayer::~PlatformViewLayer() = default;
|
|
|
|
void PlatformViewLayer::Preroll(PrerollContext* context,
|
|
const SkMatrix& matrix) {
|
|
set_paint_bounds(SkRect::MakeXYWH(offset_.x(), offset_.y(), size_.width(),
|
|
size_.height()));
|
|
|
|
if (context->view_embedder == nullptr) {
|
|
FML_LOG(ERROR) << "Trying to embed a platform view but the PrerollContext "
|
|
"does not support embedding";
|
|
return;
|
|
}
|
|
context->view_embedder->PrerollCompositeEmbeddedView(view_id_);
|
|
}
|
|
|
|
void PlatformViewLayer::Paint(PaintContext& context) const {
|
|
if (context.view_embedder == nullptr) {
|
|
FML_LOG(ERROR) << "Trying to embed a platform view but the PaintContext "
|
|
"does not support embedding";
|
|
return;
|
|
}
|
|
EmbeddedViewParams params;
|
|
SkMatrix transform = context.leaf_nodes_canvas->getTotalMatrix();
|
|
params.offsetPixels =
|
|
SkPoint::Make(transform.getTranslateX(), transform.getTranslateY());
|
|
params.sizePoints = size_;
|
|
|
|
SkCanvas* canvas =
|
|
context.view_embedder->CompositeEmbeddedView(view_id_, params);
|
|
context.leaf_nodes_canvas = canvas;
|
|
}
|
|
} // namespace flutter
|