forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clip_rect_layer.cc
47 lines (33 loc) · 1.31 KB
/
clip_rect_layer.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// 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_rect_layer.h"
namespace flow {
ClipRectLayer::ClipRectLayer() = default;
ClipRectLayer::~ClipRectLayer() = default;
void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
SkRect child_paint_bounds = SkRect::MakeEmpty();
PrerollChildren(context, matrix, &child_paint_bounds);
if (child_paint_bounds.intersect(clip_rect_)) {
set_paint_bounds(child_paint_bounds);
}
}
#if defined(OS_FUCHSIA)
void ClipRectLayer::UpdateScene(SceneUpdateContext& context) {
FXL_DCHECK(needs_system_composite());
scenic_lib::Rectangle shape(context.session(), // session
clip_rect_.width(), // width
clip_rect_.height() // height
);
SceneUpdateContext::Clip clip(context, shape, clip_rect_);
UpdateSceneChildren(context);
}
#endif // defined(OS_FUCHSIA)
void ClipRectLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "ClipRectLayer::Paint");
FXL_DCHECK(needs_painting());
SkAutoCanvasRestore save(&context.canvas, true);
context.canvas.clipRect(paint_bounds());
PaintChildren(context);
}
} // namespace flow