blob: 0d64b57d11cecc53c332c9f000d88d9414c7052c (
plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright 2014 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 "third_party/blink/renderer/platform/graphics/paint/clip_display_item.h"
#include "cc/paint/display_item_list.h"
#include "third_party/blink/renderer/platform/geometry/float_rounded_rect.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/skia/include/core/SkScalar.h"
namespace blink {
void ClipDisplayItem::Replay(GraphicsContext& context) const {
context.Save();
// RoundedInnerRectClipper only cares about rounded-rect clips,
// and passes an "infinite" rect clip; there is no reason to apply this clip.
// TODO(fmalita): convert RoundedInnerRectClipper to a better suited
// DisplayItem so we don't have to special-case its semantics.
if (clip_rect_ != LayoutRect::InfiniteIntRect())
context.ClipRect(clip_rect_, kAntiAliased);
for (const FloatRoundedRect& rounded_rect : rounded_rect_clips_)
context.ClipRoundedRect(rounded_rect);
}
void ClipDisplayItem::AppendToDisplayItemList(const FloatSize&,
cc::DisplayItemList& list) const {
list.StartPaint();
list.push<cc::SaveOp>();
list.push<cc::ClipRectOp>(clip_rect_, SkClipOp::kIntersect,
/*antialias=*/true);
for (const FloatRoundedRect& rrect : rounded_rect_clips_) {
SkRRect skrrect = rrect;
if (skrrect.isRect()) {
list.push<cc::ClipRectOp>(skrrect.rect(), SkClipOp::kIntersect,
/*antialias=*/true);
} else {
list.push<cc::ClipRRectOp>(skrrect, SkClipOp::kIntersect,
/*antialias=*/true);
}
}
list.EndPaintOfPairedBegin();
}
void EndClipDisplayItem::Replay(GraphicsContext& context) const {
context.Restore();
}
void EndClipDisplayItem::AppendToDisplayItemList(
const FloatSize&,
cc::DisplayItemList& list) const {
list.StartPaint();
list.push<cc::RestoreOp>();
list.EndPaintOfPairedEnd();
}
#if DCHECK_IS_ON()
void ClipDisplayItem::PropertiesAsJSON(JSONObject& json) const {
DisplayItem::PropertiesAsJSON(json);
json.SetString("clipRect", clip_rect_.ToString());
}
#endif
} // namespace blink
|