OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "cc/blink/web_display_item_list_impl.h" | |
6 | |
7 #include <vector> | |
8 | |
9 #include "cc/blink/web_blend_mode.h" | |
10 #include "cc/blink/web_filter_operations_impl.h" | |
11 #include "cc/resources/clip_display_item.h" | |
12 #include "cc/resources/clip_path_display_item.h" | |
13 #include "cc/resources/compositing_display_item.h" | |
14 #include "cc/resources/drawing_display_item.h" | |
15 #include "cc/resources/filter_display_item.h" | |
16 #include "cc/resources/float_clip_display_item.h" | |
17 #include "cc/resources/transform_display_item.h" | |
18 #include "skia/ext/refptr.h" | |
19 #include "third_party/WebKit/public/platform/WebFloatRect.h" | |
20 #include "third_party/WebKit/public/platform/WebRect.h" | |
21 #include "third_party/skia/include/core/SkColorFilter.h" | |
22 #include "third_party/skia/include/core/SkImageFilter.h" | |
23 #include "third_party/skia/include/core/SkPicture.h" | |
24 #include "third_party/skia/include/utils/SkMatrix44.h" | |
25 #include "ui/gfx/transform.h" | |
26 | |
27 namespace cc_blink { | |
28 | |
29 WebDisplayItemListImpl::WebDisplayItemListImpl() | |
30 : display_item_list_(cc::DisplayItemList::Create()) { | |
31 } | |
32 | |
33 scoped_refptr<cc::DisplayItemList> WebDisplayItemListImpl::ToDisplayItemList() { | |
34 return display_item_list_; | |
35 } | |
36 | |
37 void WebDisplayItemListImpl::appendDrawingItem(const SkPicture* picture) { | |
38 display_item_list_->AppendItem(cc::DrawingDisplayItem::Create( | |
39 skia::SharePtr(const_cast<SkPicture*>(picture)))); | |
40 } | |
41 | |
42 void WebDisplayItemListImpl::appendClipItem( | |
43 const blink::WebRect& clip_rect, | |
44 const blink::WebVector<SkRRect>& rounded_clip_rects) { | |
45 std::vector<SkRRect> rounded_rects; | |
46 for (size_t i = 0; i < rounded_clip_rects.size(); ++i) { | |
47 rounded_rects.push_back(rounded_clip_rects[i]); | |
48 } | |
49 display_item_list_->AppendItem( | |
50 cc::ClipDisplayItem::Create(clip_rect, rounded_rects)); | |
51 } | |
52 | |
53 void WebDisplayItemListImpl::appendEndClipItem() { | |
54 display_item_list_->AppendItem(cc::EndClipDisplayItem::Create()); | |
55 } | |
56 | |
57 void WebDisplayItemListImpl::appendClipPathItem(const SkPath& clip_path, | |
58 SkRegion::Op clip_op, | |
59 bool antialias) { | |
60 display_item_list_->AppendItem( | |
61 cc::ClipPathDisplayItem::Create(clip_path, clip_op, antialias)); | |
62 } | |
63 | |
64 void WebDisplayItemListImpl::appendEndClipPathItem() { | |
65 display_item_list_->AppendItem(cc::EndClipPathDisplayItem::Create()); | |
66 } | |
67 | |
68 void WebDisplayItemListImpl::appendFloatClipItem( | |
69 const blink::WebFloatRect& clip_rect) { | |
70 display_item_list_->AppendItem(cc::FloatClipDisplayItem::Create(clip_rect)); | |
71 } | |
72 | |
73 void WebDisplayItemListImpl::appendEndFloatClipItem() { | |
74 display_item_list_->AppendItem(cc::EndFloatClipDisplayItem::Create()); | |
75 } | |
76 | |
77 void WebDisplayItemListImpl::appendTransformItem(const SkMatrix44& matrix) { | |
78 gfx::Transform transform; | |
79 transform.matrix() = matrix; | |
80 display_item_list_->AppendItem(cc::TransformDisplayItem::Create(transform)); | |
81 } | |
82 | |
83 void WebDisplayItemListImpl::appendEndTransformItem() { | |
84 display_item_list_->AppendItem(cc::EndTransformDisplayItem::Create()); | |
85 } | |
86 | |
87 // TODO(pdr): Remove this once the blink-side callers have been removed. | |
88 void WebDisplayItemListImpl::appendCompositingItem( | |
89 float opacity, | |
90 SkXfermode::Mode xfermode, | |
91 SkColorFilter* color_filter) { | |
92 appendCompositingItem(opacity, xfermode, nullptr, color_filter); | |
93 } | |
94 | |
95 void WebDisplayItemListImpl::appendCompositingItem( | |
96 float opacity, | |
97 SkXfermode::Mode xfermode, | |
98 SkRect* bounds, | |
99 SkColorFilter* color_filter) { | |
100 display_item_list_->AppendItem(cc::CompositingDisplayItem::Create( | |
101 opacity, xfermode, bounds, skia::SharePtr(color_filter))); | |
102 } | |
103 | |
104 void WebDisplayItemListImpl::appendEndCompositingItem() { | |
105 display_item_list_->AppendItem(cc::EndCompositingDisplayItem::Create()); | |
106 } | |
107 | |
108 void WebDisplayItemListImpl::appendFilterItem( | |
109 const blink::WebFilterOperations& filters, | |
110 const blink::WebFloatRect& bounds) { | |
111 const WebFilterOperationsImpl& filters_impl = | |
112 static_cast<const WebFilterOperationsImpl&>(filters); | |
113 display_item_list_->AppendItem( | |
114 cc::FilterDisplayItem::Create(filters_impl.AsFilterOperations(), bounds)); | |
115 } | |
116 | |
117 void WebDisplayItemListImpl::appendEndFilterItem() { | |
118 display_item_list_->AppendItem(cc::EndFilterDisplayItem::Create()); | |
119 } | |
120 | |
121 void WebDisplayItemListImpl::appendScrollItem( | |
122 const blink::WebSize& scrollOffset, | |
123 ScrollContainerId) { | |
124 SkMatrix44 matrix; | |
125 matrix.setTranslate(-scrollOffset.width, -scrollOffset.height, 0); | |
126 appendTransformItem(matrix); | |
127 } | |
128 | |
129 void WebDisplayItemListImpl::appendEndScrollItem() { | |
130 appendEndTransformItem(); | |
131 } | |
132 | |
133 WebDisplayItemListImpl::~WebDisplayItemListImpl() { | |
134 } | |
135 | |
136 } // namespace cc_blink | |
OLD | NEW |