Roll src/third_party/skia 199ba8e:bb928a0
[chromium-blink-merge.git] / cc / blink / web_display_item_list_impl.cc
blobd682b2d2d12b976df5212b102c3610deef625478
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/resources/clip_display_item.h"
11 #include "cc/resources/drawing_display_item.h"
12 #include "cc/resources/filter_display_item.h"
13 #include "cc/resources/float_clip_display_item.h"
14 #include "cc/resources/transform_display_item.h"
15 #include "cc/resources/transparency_display_item.h"
16 #include "skia/ext/refptr.h"
17 #include "third_party/WebKit/public/platform/WebFloatRect.h"
18 #include "third_party/WebKit/public/platform/WebRect.h"
19 #include "third_party/skia/include/core/SkImageFilter.h"
20 #include "third_party/skia/include/core/SkPicture.h"
21 #include "third_party/skia/include/utils/SkMatrix44.h"
22 #include "ui/gfx/transform.h"
24 namespace cc_blink {
26 WebDisplayItemListImpl::WebDisplayItemListImpl()
27 : display_item_list_(cc::DisplayItemList::Create()) {
30 scoped_refptr<cc::DisplayItemList> WebDisplayItemListImpl::ToDisplayItemList() {
31 return display_item_list_;
34 void WebDisplayItemListImpl::appendDrawingItem(
35 SkPicture* picture,
36 const blink::WebFloatPoint& location) {
37 display_item_list_->AppendItem(
38 cc::DrawingDisplayItem::Create(skia::SharePtr(picture), location));
41 void WebDisplayItemListImpl::appendClipItem(
42 const blink::WebRect& clip_rect,
43 const blink::WebVector<SkRRect>& rounded_clip_rects) {
44 std::vector<SkRRect> rounded_rects;
45 for (size_t i = 0; i < rounded_clip_rects.size(); ++i) {
46 rounded_rects.push_back(rounded_clip_rects[i]);
48 display_item_list_->AppendItem(
49 cc::ClipDisplayItem::Create(clip_rect, rounded_rects));
52 void WebDisplayItemListImpl::appendEndClipItem() {
53 display_item_list_->AppendItem(cc::EndClipDisplayItem::Create());
56 void WebDisplayItemListImpl::appendFloatClipItem(
57 const blink::WebFloatRect& clip_rect) {
58 display_item_list_->AppendItem(cc::FloatClipDisplayItem::Create(clip_rect));
61 void WebDisplayItemListImpl::appendEndFloatClipItem() {
62 display_item_list_->AppendItem(cc::EndFloatClipDisplayItem::Create());
65 void WebDisplayItemListImpl::appendTransformItem(const SkMatrix44& matrix) {
66 gfx::Transform transform;
67 transform.matrix() = matrix;
68 display_item_list_->AppendItem(cc::TransformDisplayItem::Create(transform));
71 void WebDisplayItemListImpl::appendTransparencyItem(
72 float opacity,
73 blink::WebBlendMode blend_mode) {
74 display_item_list_->AppendItem(cc::TransparencyDisplayItem::Create(
75 opacity, BlendModeToSkia(blend_mode)));
78 void WebDisplayItemListImpl::appendEndTransformItem() {
79 display_item_list_->AppendItem(cc::EndTransformDisplayItem::Create());
82 void WebDisplayItemListImpl::appendEndTransparencyItem() {
83 display_item_list_->AppendItem(cc::EndTransparencyDisplayItem::Create());
86 void WebDisplayItemListImpl::appendFilterItem(
87 SkImageFilter* filter,
88 const blink::WebFloatRect& bounds) {
89 display_item_list_->AppendItem(
90 cc::FilterDisplayItem::Create(skia::SharePtr(filter), bounds));
93 void WebDisplayItemListImpl::appendEndFilterItem() {
94 display_item_list_->AppendItem(cc::EndFilterDisplayItem::Create());
97 WebDisplayItemListImpl::~WebDisplayItemListImpl() {
100 } // namespace cc_blink