ProfilePolicyConnectorFactory: Refactoring from Profile to BrowserContext.
[chromium-blink-merge.git] / cc / blink / web_display_item_list_impl.cc
blobdc1d4309df7a599938015438cf5c53b2398ffbb7
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.
5 #include "cc/blink/web_display_item_list_impl.h"
7 #include <vector>
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/drawing_display_item.h"
14 #include "cc/resources/filter_display_item.h"
15 #include "cc/resources/float_clip_display_item.h"
16 #include "cc/resources/transform_display_item.h"
17 #include "cc/resources/transparency_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/SkImageFilter.h"
22 #include "third_party/skia/include/core/SkPicture.h"
23 #include "third_party/skia/include/utils/SkMatrix44.h"
24 #include "ui/gfx/transform.h"
26 namespace cc_blink {
28 WebDisplayItemListImpl::WebDisplayItemListImpl()
29 : display_item_list_(cc::DisplayItemList::Create()) {
32 scoped_refptr<cc::DisplayItemList> WebDisplayItemListImpl::ToDisplayItemList() {
33 return display_item_list_;
36 void WebDisplayItemListImpl::appendDrawingItem(const SkPicture* picture) {
37 display_item_list_->AppendItem(cc::DrawingDisplayItem::Create(
38 skia::SharePtr(const_cast<SkPicture*>(picture)), gfx::PointF(0, 0)));
41 void WebDisplayItemListImpl::appendDrawingItem(
42 SkPicture* picture,
43 const blink::WebFloatPoint& location) {
44 display_item_list_->AppendItem(
45 cc::DrawingDisplayItem::Create(skia::SharePtr(picture), location));
48 void WebDisplayItemListImpl::appendClipItem(
49 const blink::WebRect& clip_rect,
50 const blink::WebVector<SkRRect>& rounded_clip_rects) {
51 std::vector<SkRRect> rounded_rects;
52 for (size_t i = 0; i < rounded_clip_rects.size(); ++i) {
53 rounded_rects.push_back(rounded_clip_rects[i]);
55 display_item_list_->AppendItem(
56 cc::ClipDisplayItem::Create(clip_rect, rounded_rects));
59 void WebDisplayItemListImpl::appendEndClipItem() {
60 display_item_list_->AppendItem(cc::EndClipDisplayItem::Create());
63 void WebDisplayItemListImpl::appendClipPathItem(const SkPath& clip_path,
64 SkRegion::Op clip_op,
65 bool antialias) {
66 display_item_list_->AppendItem(
67 cc::ClipPathDisplayItem::Create(clip_path, clip_op, antialias));
70 void WebDisplayItemListImpl::appendEndClipPathItem() {
71 display_item_list_->AppendItem(cc::EndClipPathDisplayItem::Create());
74 void WebDisplayItemListImpl::appendFloatClipItem(
75 const blink::WebFloatRect& clip_rect) {
76 display_item_list_->AppendItem(cc::FloatClipDisplayItem::Create(clip_rect));
79 void WebDisplayItemListImpl::appendEndFloatClipItem() {
80 display_item_list_->AppendItem(cc::EndFloatClipDisplayItem::Create());
83 void WebDisplayItemListImpl::appendTransformItem(const SkMatrix44& matrix) {
84 gfx::Transform transform;
85 transform.matrix() = matrix;
86 display_item_list_->AppendItem(cc::TransformDisplayItem::Create(transform));
89 void WebDisplayItemListImpl::appendTransparencyItem(
90 float opacity,
91 blink::WebBlendMode blend_mode) {
92 display_item_list_->AppendItem(cc::TransparencyDisplayItem::Create(
93 opacity, BlendModeToSkia(blend_mode)));
96 void WebDisplayItemListImpl::appendEndTransformItem() {
97 display_item_list_->AppendItem(cc::EndTransformDisplayItem::Create());
100 void WebDisplayItemListImpl::appendEndTransparencyItem() {
101 display_item_list_->AppendItem(cc::EndTransparencyDisplayItem::Create());
104 #if FILTER_DISPLAY_ITEM_USES_FILTER_OPERATIONS
105 void WebDisplayItemListImpl::appendFilterItem(
106 const blink::WebFilterOperations& filters,
107 const blink::WebFloatRect& bounds) {
108 const WebFilterOperationsImpl& filters_impl =
109 static_cast<const WebFilterOperationsImpl&>(filters);
110 display_item_list_->AppendItem(
111 cc::FilterDisplayItem::Create(filters_impl.AsFilterOperations(), bounds));
113 #else
114 void WebDisplayItemListImpl::appendFilterItem(
115 SkImageFilter* filter,
116 const blink::WebFloatRect& bounds) {
117 cc::FilterOperations filter_operations;
118 filter_operations.Append(
119 cc::FilterOperation::CreateReferenceFilter(skia::SharePtr(filter)));
120 display_item_list_->AppendItem(
121 cc::FilterDisplayItem::Create(filter_operations, bounds));
123 #endif
125 void WebDisplayItemListImpl::appendEndFilterItem() {
126 display_item_list_->AppendItem(cc::EndFilterDisplayItem::Create());
129 WebDisplayItemListImpl::~WebDisplayItemListImpl() {
132 } // namespace cc_blink