| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/compositor_bindings/web_content_layer_impl.h" | 5 #include "webkit/compositor_bindings/web_content_layer_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "cc/content_layer.h" | 8 #include "cc/content_layer.h" |
| 9 #include "cc/picture_layer.h" | 9 #include "cc/picture_layer.h" |
| 10 #include "cc/switches.h" | 10 #include "cc/switches.h" |
| 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebContentLayerClie
nt.h" | 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebContentLayerClie
nt.h" |
| 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h" | 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h" |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h" | 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h" |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" | 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" |
| 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
| 16 #include "third_party/skia/include/utils/SkMatrix44.h" | 16 #include "third_party/skia/include/utils/SkMatrix44.h" |
| 17 | 17 |
| 18 using namespace cc; | 18 using namespace cc; |
| 19 | 19 |
| 20 namespace WebKit { | 20 namespace WebKit { |
| 21 | 21 |
| 22 static bool usingPictureLayer() { | 22 static bool usingPictureLayer() { |
| 23 return cc::switches::IsImplSidePaintingEnabled(); | 23 return cc::switches::IsImplSidePaintingEnabled(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 WebContentLayerImpl::WebContentLayerImpl(WebContentLayerClient* client) | 26 WebContentLayerImpl::WebContentLayerImpl(WebContentLayerClient* client) |
| 27 : client_(client) { | 27 : client_(client) { |
| 28 if (usingPictureLayer()) | 28 if (usingPictureLayer()) |
| 29 layer_ = make_scoped_ptr(new WebLayerImpl(PictureLayer::create(this))); | 29 layer_ = make_scoped_ptr(new WebLayerImpl(PictureLayer::Create(this))); |
| 30 else | 30 else |
| 31 layer_ = make_scoped_ptr(new WebLayerImpl(ContentLayer::create(this))); | 31 layer_ = make_scoped_ptr(new WebLayerImpl(ContentLayer::Create(this))); |
| 32 layer_->layer()->setIsDrawable(true); | 32 layer_->layer()->SetIsDrawable(true); |
| 33 } | 33 } |
| 34 | 34 |
| 35 WebContentLayerImpl::~WebContentLayerImpl() { | 35 WebContentLayerImpl::~WebContentLayerImpl() { |
| 36 if (usingPictureLayer()) | 36 if (usingPictureLayer()) |
| 37 static_cast<PictureLayer*>(layer_->layer())->clearClient(); | 37 static_cast<PictureLayer*>(layer_->layer())->clearClient(); |
| 38 else | 38 else |
| 39 static_cast<ContentLayer*>(layer_->layer())->clearClient(); | 39 static_cast<ContentLayer*>(layer_->layer())->clearClient(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 WebLayer* WebContentLayerImpl::layer() { return layer_.get(); } | 42 WebLayer* WebContentLayerImpl::layer() { return layer_.get(); } |
| 43 | 43 |
| 44 void WebContentLayerImpl::setDoubleSided(bool double_sided) { | 44 void WebContentLayerImpl::setDoubleSided(bool double_sided) { |
| 45 layer_->layer()->setDoubleSided(double_sided); | 45 layer_->layer()->SetDoubleSided(double_sided); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void WebContentLayerImpl::setBoundsContainPageScale( | 48 void WebContentLayerImpl::setBoundsContainPageScale( |
| 49 bool bounds_contain_page_scale) { | 49 bool bounds_contain_page_scale) { |
| 50 return layer_->layer()->setBoundsContainPageScale(bounds_contain_page_scale); | 50 return layer_->layer()->SetBoundsContainPageScale(bounds_contain_page_scale); |
| 51 } | 51 } |
| 52 | 52 |
| 53 bool WebContentLayerImpl::boundsContainPageScale() const { | 53 bool WebContentLayerImpl::boundsContainPageScale() const { |
| 54 return layer_->layer()->boundsContainPageScale(); | 54 return layer_->layer()->bounds_contain_page_scale(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void WebContentLayerImpl::setAutomaticallyComputeRasterScale(bool automatic) { | 57 void WebContentLayerImpl::setAutomaticallyComputeRasterScale(bool automatic) { |
| 58 layer_->layer()->setAutomaticallyComputeRasterScale(automatic); | 58 layer_->layer()->SetAutomaticallyComputeRasterScale(automatic); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // TODO(alokp): Remove this function from WebContentLayer API. | 61 // TODO(alokp): Remove this function from WebContentLayer API. |
| 62 void WebContentLayerImpl::setUseLCDText(bool enable) {} | 62 void WebContentLayerImpl::setUseLCDText(bool enable) {} |
| 63 | 63 |
| 64 void WebContentLayerImpl::setDrawCheckerboardForMissingTiles(bool enable) { | 64 void WebContentLayerImpl::setDrawCheckerboardForMissingTiles(bool enable) { |
| 65 layer_->layer()->setDrawCheckerboardForMissingTiles(enable); | 65 layer_->layer()->SetDrawCheckerboardForMissingTiles(enable); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void WebContentLayerImpl::paintContents(SkCanvas* canvas, | 68 void WebContentLayerImpl::paintContents(SkCanvas* canvas, |
| 69 const gfx::Rect& clip, | 69 const gfx::Rect& clip, |
| 70 gfx::RectF& opaque) { | 70 gfx::RectF& opaque) { |
| 71 if (!client_) | 71 if (!client_) |
| 72 return; | 72 return; |
| 73 | 73 |
| 74 WebFloatRect web_opaque; | 74 WebFloatRect web_opaque; |
| 75 client_->paintContents( | 75 client_->paintContents( |
| 76 canvas, clip, layer_->layer()->canUseLCDText(), web_opaque); | 76 canvas, clip, layer_->layer()->can_use_lcd_text(), web_opaque); |
| 77 opaque = web_opaque; | 77 opaque = web_opaque; |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace WebKit | 80 } // namespace WebKit |
| OLD | NEW |