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
;
23 static blink::WebContentLayerClient::PaintingControlSetting
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
;
37 return blink::WebContentLayerClient::PaintDefaultBehavior
;
40 WebContentLayerImpl::WebContentLayerImpl(blink::WebContentLayerClient
* client
)
42 if (WebLayerImpl::UsingPictureLayer())
43 layer_
= make_scoped_ptr(new WebLayerImpl(
44 PictureLayer::Create(WebLayerImpl::LayerSettings(), this)));
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();
55 static_cast<ContentLayer
*>(layer_
->layer())->ClearClient();
58 blink::WebLayer
* WebContentLayerImpl::layer() {
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(
72 const gfx::Rect
& clip
,
73 cc::ContentLayerClient::PaintingControlSetting painting_control
) {
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
);
90 WebDisplayItemListImpl
list(display_list
.get());
91 client_
->paintContents(&list
, clip
, PaintingControlToWeb(painting_control
));
93 display_list
->Finalize();
97 bool WebContentLayerImpl::FillsBoundsCompletely() const {
101 } // namespace cc_blink