mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
// Copyright 2015 The Chromium 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/clip_path_layer.h"
|
|
|
|
#if defined(OS_FUCHSIA)
|
|
#include "apps/mozart/lib/skia/type_converters.h"
|
|
#include "apps/mozart/services/composition/nodes.fidl.h"
|
|
#endif // defined(OS_FUCHSIA)
|
|
|
|
namespace flow {
|
|
|
|
ClipPathLayer::ClipPathLayer() {}
|
|
|
|
ClipPathLayer::~ClipPathLayer() {}
|
|
|
|
void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
|
|
PrerollChildren(context, matrix);
|
|
if (!context->child_paint_bounds.intersect(clip_path_.getBounds()))
|
|
context->child_paint_bounds.setEmpty();
|
|
set_paint_bounds(context->child_paint_bounds);
|
|
}
|
|
|
|
#if defined(OS_FUCHSIA)
|
|
|
|
void ClipPathLayer::UpdateScene(SceneUpdateContext& context,
|
|
mozart::Node* container) {
|
|
auto node = mozart::Node::New();
|
|
node->content_clip = mozart::RectF::From(clip_path_.getBounds());
|
|
UpdateSceneChildrenInsideNode(context, container, std::move(node));
|
|
}
|
|
|
|
#endif // defined(OS_FUCHSIA)
|
|
|
|
void ClipPathLayer::Paint(PaintContext& context) {
|
|
TRACE_EVENT0("flutter", "ClipPathLayer::Paint");
|
|
FTL_DCHECK(!needs_system_composite());
|
|
|
|
Layer::AutoSaveLayer save(context, paint_bounds(), nullptr);
|
|
context.canvas.clipPath(clip_path_, true);
|
|
PaintChildren(context);
|
|
}
|
|
|
|
} // namespace flow
|