mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Rename methods in the MutatorsStack to Pascal case to match standard cpp style Refactor the operator== for Mutator class
74 lines
2.6 KiB
C++
74 lines
2.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/clip_rrect_layer.h"
|
|
|
|
namespace flutter {
|
|
|
|
ClipRRectLayer::ClipRRectLayer(const SkRRect& clip_rrect, Clip clip_behavior)
|
|
: clip_rrect_(clip_rrect), clip_behavior_(clip_behavior) {
|
|
FML_DCHECK(clip_behavior != Clip::none);
|
|
}
|
|
|
|
ClipRRectLayer::~ClipRRectLayer() = default;
|
|
|
|
void ClipRRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
|
|
SkRect previous_cull_rect = context->cull_rect;
|
|
SkRect clip_rrect_bounds = clip_rrect_.getBounds();
|
|
if (context->cull_rect.intersect(clip_rrect_bounds)) {
|
|
context->mutators_stack.PushClipRRect(clip_rrect_);
|
|
SkRect child_paint_bounds = SkRect::MakeEmpty();
|
|
PrerollChildren(context, matrix, &child_paint_bounds);
|
|
|
|
if (child_paint_bounds.intersect(clip_rrect_bounds)) {
|
|
set_paint_bounds(child_paint_bounds);
|
|
}
|
|
context->mutators_stack.Pop();
|
|
}
|
|
context->cull_rect = previous_cull_rect;
|
|
}
|
|
|
|
#if defined(OS_FUCHSIA)
|
|
|
|
void ClipRRectLayer::UpdateScene(SceneUpdateContext& context) {
|
|
FML_DCHECK(needs_system_composite());
|
|
|
|
// TODO(SCN-137): Need to be able to express the radii as vectors.
|
|
scenic::RoundedRectangle shape(
|
|
context.session(), // session
|
|
clip_rrect_.width(), // width
|
|
clip_rrect_.height(), // height
|
|
clip_rrect_.radii(SkRRect::kUpperLeft_Corner).x(), // top_left_radius
|
|
clip_rrect_.radii(SkRRect::kUpperRight_Corner).x(), // top_right_radius
|
|
clip_rrect_.radii(SkRRect::kLowerRight_Corner)
|
|
.x(), // bottom_right_radius
|
|
clip_rrect_.radii(SkRRect::kLowerLeft_Corner).x() // bottom_left_radius
|
|
);
|
|
|
|
// TODO(liyuqian): respect clip_behavior_
|
|
SceneUpdateContext::Clip clip(context, shape, clip_rrect_.getBounds());
|
|
UpdateSceneChildren(context);
|
|
}
|
|
|
|
#endif // defined(OS_FUCHSIA)
|
|
|
|
void ClipRRectLayer::Paint(PaintContext& context) const {
|
|
TRACE_EVENT0("flutter", "ClipRRectLayer::Paint");
|
|
FML_DCHECK(needs_painting());
|
|
|
|
SkAutoCanvasRestore save(context.internal_nodes_canvas, true);
|
|
context.internal_nodes_canvas->clipRRect(clip_rrect_,
|
|
clip_behavior_ != Clip::hardEdge);
|
|
|
|
if (clip_behavior_ == Clip::antiAliasWithSaveLayer) {
|
|
context.internal_nodes_canvas->saveLayer(paint_bounds(), nullptr);
|
|
}
|
|
PaintChildren(context);
|
|
if (clip_behavior_ == Clip::antiAliasWithSaveLayer) {
|
|
context.internal_nodes_canvas->restore();
|
|
}
|
|
}
|
|
|
|
} // namespace flutter
|