OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/graphics/paint/ClipDisplayItem.h" | 5 #include "platform/graphics/paint/ClipDisplayItem.h" |
6 | 6 |
7 #include "platform/geometry/FloatRoundedRect.h" | 7 #include "platform/geometry/FloatRoundedRect.h" |
8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
9 #include "public/platform/WebDisplayItemList.h" | 9 #include "public/platform/WebDisplayItemList.h" |
10 #include "third_party/skia/include/core/SkScalar.h" | 10 #include "third_party/skia/include/core/SkScalar.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 void ClipDisplayItem::Replay(GraphicsContext& context) const { | 14 void ClipDisplayItem::Replay(GraphicsContext& context) const { |
15 context.Save(); | 15 context.Save(); |
16 | 16 |
17 // RoundedInnerRectClipper only cares about rounded-rect clips, | 17 // RoundedInnerRectClipper only cares about rounded-rect clips, |
18 // and passes an "infinite" rect clip; there is no reason to apply this clip. | 18 // and passes an "infinite" rect clip; there is no reason to apply this clip. |
19 // TODO(fmalita): convert RoundedInnerRectClipper to a better suited | 19 // TODO(fmalita): convert RoundedInnerRectClipper to a better suited |
20 // DisplayItem so we don't have to special-case its semantics. | 20 // DisplayItem so we don't have to special-case its semantics. |
21 if (clip_rect_ != LayoutRect::InfiniteIntRect()) | 21 if (clip_rect_ != LayoutRect::InfiniteIntRect()) |
22 context.ClipRect(clip_rect_, kAntiAliased); | 22 context.ClipRect(clip_rect_, kAntiAliased); |
23 | 23 |
24 for (const FloatRoundedRect& rounded_rect : rounded_rect_clips_) | 24 for (const FloatRoundedRect& rounded_rect : rounded_rect_clips_) |
25 context.ClipRoundedRect(rounded_rect); | 25 context.ClipRoundedRect(rounded_rect); |
26 } | 26 } |
27 | 27 |
28 void ClipDisplayItem::AppendToWebDisplayItemList( | 28 void ClipDisplayItem::AppendToWebDisplayItemList( |
29 const IntRect& visual_rect, | 29 const LayoutSize&, |
30 WebDisplayItemList* list) const { | 30 WebDisplayItemList* list) const { |
31 WebVector<SkRRect> web_rounded_rects(rounded_rect_clips_.size()); | 31 WebVector<SkRRect> web_rounded_rects(rounded_rect_clips_.size()); |
32 for (size_t i = 0; i < rounded_rect_clips_.size(); ++i) | 32 for (size_t i = 0; i < rounded_rect_clips_.size(); ++i) |
33 web_rounded_rects[i] = rounded_rect_clips_[i]; | 33 web_rounded_rects[i] = rounded_rect_clips_[i]; |
34 | 34 |
35 list->AppendClipItem(clip_rect_, web_rounded_rects); | 35 list->AppendClipItem(clip_rect_, web_rounded_rects); |
36 } | 36 } |
37 | 37 |
38 void EndClipDisplayItem::Replay(GraphicsContext& context) const { | 38 void EndClipDisplayItem::Replay(GraphicsContext& context) const { |
39 context.Restore(); | 39 context.Restore(); |
40 } | 40 } |
41 | 41 |
42 void EndClipDisplayItem::AppendToWebDisplayItemList( | 42 void EndClipDisplayItem::AppendToWebDisplayItemList( |
43 const IntRect& visual_rect, | 43 const LayoutSize&, |
44 WebDisplayItemList* list) const { | 44 WebDisplayItemList* list) const { |
45 list->AppendEndClipItem(); | 45 list->AppendEndClipItem(); |
46 } | 46 } |
47 | 47 |
48 #ifndef NDEBUG | 48 #ifndef NDEBUG |
49 void ClipDisplayItem::DumpPropertiesAsDebugString( | 49 void ClipDisplayItem::DumpPropertiesAsDebugString( |
50 WTF::StringBuilder& string_builder) const { | 50 WTF::StringBuilder& string_builder) const { |
51 DisplayItem::DumpPropertiesAsDebugString(string_builder); | 51 DisplayItem::DumpPropertiesAsDebugString(string_builder); |
52 string_builder.Append(WTF::String::Format( | 52 string_builder.Append(WTF::String::Format( |
53 ", clipRect: [%d,%d,%d,%d]", clip_rect_.X(), clip_rect_.Y(), | 53 ", clipRect: [%d,%d,%d,%d]", clip_rect_.X(), clip_rect_.Y(), |
54 clip_rect_.Width(), clip_rect_.Height())); | 54 clip_rect_.Width(), clip_rect_.Height())); |
55 } | 55 } |
56 #endif | 56 #endif |
57 | 57 |
58 } // namespace blink | 58 } // namespace blink |
OLD | NEW |