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/picture_layer.h"
9 #include "cc/playback/display_item_list_settings.h"
10 #include "third_party/WebKit/public/platform/WebContentLayerClient.h"
11 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
12 #include "third_party/WebKit/public/platform/WebFloatRect.h"
13 #include "third_party/WebKit/public/platform/WebRect.h"
14 #include "third_party/WebKit/public/platform/WebSize.h"
15 #include "third_party/skia/include/utils/SkMatrix44.h"
17 using cc::PictureLayer
;
21 static blink::WebContentLayerClient::PaintingControlSetting
23 cc::ContentLayerClient::PaintingControlSetting painting_control
) {
24 switch (painting_control
) {
25 case cc::ContentLayerClient::PAINTING_BEHAVIOR_NORMAL
:
26 return blink::WebContentLayerClient::PaintDefaultBehavior
;
27 case cc::ContentLayerClient::DISPLAY_LIST_CONSTRUCTION_DISABLED
:
28 return blink::WebContentLayerClient::DisplayListConstructionDisabled
;
29 case cc::ContentLayerClient::DISPLAY_LIST_CACHING_DISABLED
:
30 return blink::WebContentLayerClient::DisplayListCachingDisabled
;
31 case cc::ContentLayerClient::DISPLAY_LIST_PAINTING_DISABLED
:
32 return blink::WebContentLayerClient::DisplayListPaintingDisabled
;
35 return blink::WebContentLayerClient::PaintDefaultBehavior
;
38 WebContentLayerImpl::WebContentLayerImpl(blink::WebContentLayerClient
* client
)
40 layer_
= make_scoped_ptr(new WebLayerImpl(
41 PictureLayer::Create(WebLayerImpl::LayerSettings(), this)));
42 layer_
->layer()->SetIsDrawable(true);
45 WebContentLayerImpl::~WebContentLayerImpl() {
46 static_cast<PictureLayer
*>(layer_
->layer())->ClearClient();
49 blink::WebLayer
* WebContentLayerImpl::layer() {
53 void WebContentLayerImpl::setDoubleSided(bool double_sided
) {
54 layer_
->layer()->SetDoubleSided(double_sided
);
57 void WebContentLayerImpl::setDrawCheckerboardForMissingTiles(bool enable
) {
58 layer_
->layer()->SetDrawCheckerboardForMissingTiles(enable
);
61 void WebContentLayerImpl::PaintContents(
63 const gfx::Rect
& clip
,
64 cc::ContentLayerClient::PaintingControlSetting painting_control
) {
68 client_
->paintContents(canvas
, clip
, PaintingControlToWeb(painting_control
));
71 scoped_refptr
<cc::DisplayItemList
>
72 WebContentLayerImpl::PaintContentsToDisplayList(
73 const gfx::Rect
& clip
,
74 cc::ContentLayerClient::PaintingControlSetting painting_control
) {
75 cc::DisplayItemListSettings settings
;
76 settings
.use_cached_picture
= true;
78 scoped_refptr
<cc::DisplayItemList
> display_list
=
79 cc::DisplayItemList::Create(clip
, settings
);
81 WebDisplayItemListImpl
list(display_list
.get());
82 client_
->paintContents(&list
, clip
, PaintingControlToWeb(painting_control
));
84 display_list
->Finalize();
88 bool WebContentLayerImpl::FillsBoundsCompletely() const {
92 } // namespace cc_blink