Include all dupe types (event when value is zero) in scan stats.
[chromium-blink-merge.git] / cc / blink / web_content_layer_impl.cc
blob98ff60b945efd53c0cb96a669e5ca1148d1b9748
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_content_layer_impl.h"
7 #include "cc/blink/web_display_item_list_impl.h"
8 #include "cc/layers/content_layer.h"
9 #include "cc/layers/picture_layer.h"
10 #include "cc/playback/display_item_list_settings.h"
11 #include "third_party/WebKit/public/platform/WebContentLayerClient.h"
12 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
13 #include "third_party/WebKit/public/platform/WebFloatRect.h"
14 #include "third_party/WebKit/public/platform/WebRect.h"
15 #include "third_party/WebKit/public/platform/WebSize.h"
16 #include "third_party/skia/include/utils/SkMatrix44.h"
18 using cc::ContentLayer;
19 using cc::PictureLayer;
21 namespace cc_blink {
23 static blink::WebContentLayerClient::PaintingControlSetting
24 PaintingControlToWeb(
25 cc::ContentLayerClient::PaintingControlSetting painting_control) {
26 switch (painting_control) {
27 case cc::ContentLayerClient::PAINTING_BEHAVIOR_NORMAL:
28 return blink::WebContentLayerClient::PaintDefaultBehavior;
29 case cc::ContentLayerClient::DISPLAY_LIST_CONSTRUCTION_DISABLED:
30 return blink::WebContentLayerClient::DisplayListConstructionDisabled;
31 case cc::ContentLayerClient::DISPLAY_LIST_CACHING_DISABLED:
32 return blink::WebContentLayerClient::DisplayListCachingDisabled;
33 case cc::ContentLayerClient::DISPLAY_LIST_PAINTING_DISABLED:
34 return blink::WebContentLayerClient::DisplayListPaintingDisabled;
36 NOTREACHED();
37 return blink::WebContentLayerClient::PaintDefaultBehavior;
40 WebContentLayerImpl::WebContentLayerImpl(blink::WebContentLayerClient* client)
41 : client_(client) {
42 if (WebLayerImpl::UsingPictureLayer())
43 layer_ = make_scoped_ptr(new WebLayerImpl(
44 PictureLayer::Create(WebLayerImpl::LayerSettings(), this)));
45 else
46 layer_ = make_scoped_ptr(new WebLayerImpl(
47 ContentLayer::Create(WebLayerImpl::LayerSettings(), this)));
48 layer_->layer()->SetIsDrawable(true);
51 WebContentLayerImpl::~WebContentLayerImpl() {
52 if (WebLayerImpl::UsingPictureLayer())
53 static_cast<PictureLayer*>(layer_->layer())->ClearClient();
54 else
55 static_cast<ContentLayer*>(layer_->layer())->ClearClient();
58 blink::WebLayer* WebContentLayerImpl::layer() {
59 return layer_.get();
62 void WebContentLayerImpl::setDoubleSided(bool double_sided) {
63 layer_->layer()->SetDoubleSided(double_sided);
66 void WebContentLayerImpl::setDrawCheckerboardForMissingTiles(bool enable) {
67 layer_->layer()->SetDrawCheckerboardForMissingTiles(enable);
70 void WebContentLayerImpl::PaintContents(
71 SkCanvas* canvas,
72 const gfx::Rect& clip,
73 cc::ContentLayerClient::PaintingControlSetting painting_control) {
74 if (!client_)
75 return;
77 client_->paintContents(canvas, clip, PaintingControlToWeb(painting_control));
80 scoped_refptr<cc::DisplayItemList>
81 WebContentLayerImpl::PaintContentsToDisplayList(
82 const gfx::Rect& clip,
83 cc::ContentLayerClient::PaintingControlSetting painting_control) {
84 cc::DisplayItemListSettings settings;
85 settings.use_cached_picture = true;
87 scoped_refptr<cc::DisplayItemList> display_list =
88 cc::DisplayItemList::Create(clip, settings);
89 if (client_) {
90 WebDisplayItemListImpl list(display_list.get());
91 client_->paintContents(&list, clip, PaintingControlToWeb(painting_control));
93 display_list->Finalize();
94 return display_list;
97 bool WebContentLayerImpl::FillsBoundsCompletely() const {
98 return false;
101 } // namespace cc_blink