Adding Peter Thatcher to the owners file.
[chromium-blink-merge.git] / cc / blink / web_display_item_list_impl.cc
blobf9afded7b924328fa18aaf939183717874dc6a56
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_filter_operations_impl.h"
10 #include "cc/resources/clip_display_item.h"
11 #include "cc/resources/clip_path_display_item.h"
12 #include "cc/resources/compositing_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 "skia/ext/refptr.h"
18 #include "third_party/WebKit/public/platform/WebFloatRect.h"
19 #include "third_party/WebKit/public/platform/WebRect.h"
20 #include "third_party/skia/include/core/SkColorFilter.h"
21 #include "third_party/skia/include/core/SkPicture.h"
22 #include "third_party/skia/include/utils/SkMatrix44.h"
23 #include "ui/gfx/transform.h"
25 namespace cc_blink {
27 WebDisplayItemListImpl::WebDisplayItemListImpl()
28 : display_item_list_(cc::DisplayItemList::Create()) {
31 scoped_refptr<cc::DisplayItemList> WebDisplayItemListImpl::ToDisplayItemList() {
32 return display_item_list_;
35 void WebDisplayItemListImpl::appendDrawingItem(const SkPicture* picture) {
36 display_item_list_->AppendItem(cc::DrawingDisplayItem::Create(
37 skia::SharePtr(const_cast<SkPicture*>(picture))));
40 void WebDisplayItemListImpl::appendClipItem(
41 const blink::WebRect& clip_rect,
42 const blink::WebVector<SkRRect>& rounded_clip_rects) {
43 std::vector<SkRRect> rounded_rects;
44 for (size_t i = 0; i < rounded_clip_rects.size(); ++i) {
45 rounded_rects.push_back(rounded_clip_rects[i]);
47 display_item_list_->AppendItem(
48 cc::ClipDisplayItem::Create(clip_rect, rounded_rects));
51 void WebDisplayItemListImpl::appendEndClipItem() {
52 display_item_list_->AppendItem(cc::EndClipDisplayItem::Create());
55 void WebDisplayItemListImpl::appendClipPathItem(const SkPath& clip_path,
56 SkRegion::Op clip_op,
57 bool antialias) {
58 display_item_list_->AppendItem(
59 cc::ClipPathDisplayItem::Create(clip_path, clip_op, antialias));
62 void WebDisplayItemListImpl::appendEndClipPathItem() {
63 display_item_list_->AppendItem(cc::EndClipPathDisplayItem::Create());
66 void WebDisplayItemListImpl::appendFloatClipItem(
67 const blink::WebFloatRect& clip_rect) {
68 display_item_list_->AppendItem(cc::FloatClipDisplayItem::Create(clip_rect));
71 void WebDisplayItemListImpl::appendEndFloatClipItem() {
72 display_item_list_->AppendItem(cc::EndFloatClipDisplayItem::Create());
75 void WebDisplayItemListImpl::appendTransformItem(const SkMatrix44& matrix) {
76 gfx::Transform transform;
77 transform.matrix() = matrix;
78 display_item_list_->AppendItem(cc::TransformDisplayItem::Create(transform));
81 void WebDisplayItemListImpl::appendEndTransformItem() {
82 display_item_list_->AppendItem(cc::EndTransformDisplayItem::Create());
85 void WebDisplayItemListImpl::appendCompositingItem(
86 float opacity,
87 SkXfermode::Mode xfermode,
88 SkRect* bounds,
89 SkColorFilter* color_filter) {
90 display_item_list_->AppendItem(cc::CompositingDisplayItem::Create(
91 opacity, xfermode, bounds, skia::SharePtr(color_filter)));
94 void WebDisplayItemListImpl::appendEndCompositingItem() {
95 display_item_list_->AppendItem(cc::EndCompositingDisplayItem::Create());
98 void WebDisplayItemListImpl::appendFilterItem(
99 const blink::WebFilterOperations& filters,
100 const blink::WebFloatRect& bounds) {
101 const WebFilterOperationsImpl& filters_impl =
102 static_cast<const WebFilterOperationsImpl&>(filters);
103 display_item_list_->AppendItem(
104 cc::FilterDisplayItem::Create(filters_impl.AsFilterOperations(), bounds));
107 void WebDisplayItemListImpl::appendEndFilterItem() {
108 display_item_list_->AppendItem(cc::EndFilterDisplayItem::Create());
111 void WebDisplayItemListImpl::appendScrollItem(
112 const blink::WebSize& scrollOffset,
113 ScrollContainerId) {
114 SkMatrix44 matrix;
115 matrix.setTranslate(-scrollOffset.width, -scrollOffset.height, 0);
116 appendTransformItem(matrix);
119 void WebDisplayItemListImpl::appendEndScrollItem() {
120 appendEndTransformItem();
123 WebDisplayItemListImpl::~WebDisplayItemListImpl() {
126 } // namespace cc_blink