| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "sky/viewer/cc/web_content_layer_impl.h" | |
| 6 | |
| 7 #include "cc/layers/content_layer.h" | |
| 8 #include "cc/layers/picture_layer.h" | |
| 9 #include "sky/engine/public/platform/WebContentLayerClient.h" | |
| 10 #include "sky/engine/public/platform/WebFloatPoint.h" | |
| 11 #include "sky/engine/public/platform/WebFloatRect.h" | |
| 12 #include "sky/engine/public/platform/WebRect.h" | |
| 13 #include "sky/engine/public/platform/WebSize.h" | |
| 14 #include "third_party/skia/include/utils/SkMatrix44.h" | |
| 15 | |
| 16 using cc::ContentLayer; | |
| 17 using cc::PictureLayer; | |
| 18 | |
| 19 namespace sky_viewer_cc { | |
| 20 | |
| 21 WebContentLayerImpl::WebContentLayerImpl(blink::WebContentLayerClient* client) | |
| 22 : client_(client) { | |
| 23 if (WebLayerImpl::UsingPictureLayer()) | |
| 24 layer_ = make_scoped_ptr(new WebLayerImpl(PictureLayer::Create(this))); | |
| 25 else | |
| 26 layer_ = make_scoped_ptr(new WebLayerImpl(ContentLayer::Create(this))); | |
| 27 layer_->layer()->SetIsDrawable(true); | |
| 28 } | |
| 29 | |
| 30 WebContentLayerImpl::~WebContentLayerImpl() { | |
| 31 if (WebLayerImpl::UsingPictureLayer()) | |
| 32 static_cast<PictureLayer*>(layer_->layer())->ClearClient(); | |
| 33 else | |
| 34 static_cast<ContentLayer*>(layer_->layer())->ClearClient(); | |
| 35 } | |
| 36 | |
| 37 blink::WebLayer* WebContentLayerImpl::layer() { | |
| 38 return layer_.get(); | |
| 39 } | |
| 40 | |
| 41 void WebContentLayerImpl::setDoubleSided(bool double_sided) { | |
| 42 layer_->layer()->SetDoubleSided(double_sided); | |
| 43 } | |
| 44 | |
| 45 void WebContentLayerImpl::setDrawCheckerboardForMissingTiles(bool enable) { | |
| 46 layer_->layer()->SetDrawCheckerboardForMissingTiles(enable); | |
| 47 } | |
| 48 | |
| 49 void WebContentLayerImpl::PaintContents( | |
| 50 SkCanvas* canvas, | |
| 51 const gfx::Rect& clip, | |
| 52 ContentLayerClient::GraphicsContextStatus graphics_context_status) { | |
| 53 if (!client_) | |
| 54 return; | |
| 55 | |
| 56 blink::WebFloatRect web_opaque; | |
| 57 bool can_use_lcd_text = false; | |
| 58 client_->paintContents( | |
| 59 canvas, clip, can_use_lcd_text, web_opaque, | |
| 60 graphics_context_status == ContentLayerClient::GRAPHICS_CONTEXT_ENABLED | |
| 61 ? blink::WebContentLayerClient::GraphicsContextEnabled | |
| 62 : blink::WebContentLayerClient::GraphicsContextDisabled); | |
| 63 } | |
| 64 | |
| 65 bool WebContentLayerImpl::FillsBoundsCompletely() const { | |
| 66 return false; | |
| 67 } | |
| 68 | |
| 69 } // namespace sky_viewer_cc | |
| OLD | NEW |