| 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/renderer/compositor_bindings/web_content_layer_impl.h" | 5 #include "webkit/renderer/compositor_bindings/web_content_layer_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "cc/base/switches.h" | 8 #include "cc/base/switches.h" |
| 9 #include "cc/layers/content_layer.h" | 9 #include "cc/layers/content_layer.h" |
| 10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
| 11 #include "third_party/WebKit/public/platform/WebContentLayerClient.h" | 11 #include "third_party/WebKit/public/platform/WebContentLayerClient.h" |
| 12 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 12 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
| 13 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 13 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
| 14 #include "third_party/WebKit/public/platform/WebRect.h" | 14 #include "third_party/WebKit/public/platform/WebRect.h" |
| 15 #include "third_party/WebKit/public/platform/WebSize.h" | 15 #include "third_party/WebKit/public/platform/WebSize.h" |
| 16 #include "third_party/skia/include/utils/SkMatrix44.h" | 16 #include "third_party/skia/include/utils/SkMatrix44.h" |
| 17 | 17 |
| 18 using cc::ContentLayer; | 18 using cc::ContentLayer; |
| 19 using cc::PictureLayer; | 19 using cc::PictureLayer; |
| 20 | 20 |
| 21 namespace webkit { | 21 namespace webkit { |
| 22 | 22 |
| 23 static bool usingPictureLayer() { | 23 static bool usingPictureLayer() { |
| 24 return cc::switches::IsImplSidePaintingEnabled(); | 24 return cc::switches::IsImplSidePaintingEnabled(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 WebContentLayerImpl::WebContentLayerImpl(WebKit::WebContentLayerClient* client) | 27 WebContentLayerImpl::WebContentLayerImpl(blink::WebContentLayerClient* client) |
| 28 : client_(client), | 28 : client_(client), |
| 29 ignore_lcd_text_change_(false) { | 29 ignore_lcd_text_change_(false) { |
| 30 if (usingPictureLayer()) | 30 if (usingPictureLayer()) |
| 31 layer_ = make_scoped_ptr(new WebLayerImpl(PictureLayer::Create(this))); | 31 layer_ = make_scoped_ptr(new WebLayerImpl(PictureLayer::Create(this))); |
| 32 else | 32 else |
| 33 layer_ = make_scoped_ptr(new WebLayerImpl(ContentLayer::Create(this))); | 33 layer_ = make_scoped_ptr(new WebLayerImpl(ContentLayer::Create(this))); |
| 34 layer_->layer()->SetIsDrawable(true); | 34 layer_->layer()->SetIsDrawable(true); |
| 35 can_use_lcd_text_ = layer_->layer()->can_use_lcd_text(); | 35 can_use_lcd_text_ = layer_->layer()->can_use_lcd_text(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 WebContentLayerImpl::~WebContentLayerImpl() { | 38 WebContentLayerImpl::~WebContentLayerImpl() { |
| 39 if (usingPictureLayer()) | 39 if (usingPictureLayer()) |
| 40 static_cast<PictureLayer*>(layer_->layer())->ClearClient(); | 40 static_cast<PictureLayer*>(layer_->layer())->ClearClient(); |
| 41 else | 41 else |
| 42 static_cast<ContentLayer*>(layer_->layer())->ClearClient(); | 42 static_cast<ContentLayer*>(layer_->layer())->ClearClient(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 WebKit::WebLayer* WebContentLayerImpl::layer() { return layer_.get(); } | 45 blink::WebLayer* WebContentLayerImpl::layer() { return layer_.get(); } |
| 46 | 46 |
| 47 void WebContentLayerImpl::setDoubleSided(bool double_sided) { | 47 void WebContentLayerImpl::setDoubleSided(bool double_sided) { |
| 48 layer_->layer()->SetDoubleSided(double_sided); | 48 layer_->layer()->SetDoubleSided(double_sided); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void WebContentLayerImpl::setDrawCheckerboardForMissingTiles(bool enable) { | 51 void WebContentLayerImpl::setDrawCheckerboardForMissingTiles(bool enable) { |
| 52 layer_->layer()->SetDrawCheckerboardForMissingTiles(enable); | 52 layer_->layer()->SetDrawCheckerboardForMissingTiles(enable); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void WebContentLayerImpl::PaintContents(SkCanvas* canvas, | 55 void WebContentLayerImpl::PaintContents(SkCanvas* canvas, |
| 56 gfx::Rect clip, | 56 gfx::Rect clip, |
| 57 gfx::RectF* opaque) { | 57 gfx::RectF* opaque) { |
| 58 if (!client_) | 58 if (!client_) |
| 59 return; | 59 return; |
| 60 | 60 |
| 61 WebKit::WebFloatRect web_opaque; | 61 blink::WebFloatRect web_opaque; |
| 62 // For picture layers, always record with LCD text. PictureLayerImpl | 62 // For picture layers, always record with LCD text. PictureLayerImpl |
| 63 // will turn this off later during rasterization. | 63 // will turn this off later during rasterization. |
| 64 bool use_lcd_text = usingPictureLayer() || can_use_lcd_text_; | 64 bool use_lcd_text = usingPictureLayer() || can_use_lcd_text_; |
| 65 client_->paintContents(canvas, clip, use_lcd_text, web_opaque); | 65 client_->paintContents(canvas, clip, use_lcd_text, web_opaque); |
| 66 *opaque = web_opaque; | 66 *opaque = web_opaque; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void WebContentLayerImpl::DidChangeLayerCanUseLCDText() { | 69 void WebContentLayerImpl::DidChangeLayerCanUseLCDText() { |
| 70 // It is important to make this comparison because the LCD text status | 70 // It is important to make this comparison because the LCD text status |
| 71 // here can get out of sync with that in the layer. | 71 // here can get out of sync with that in the layer. |
| 72 if (can_use_lcd_text_ == layer_->layer()->can_use_lcd_text()) | 72 if (can_use_lcd_text_ == layer_->layer()->can_use_lcd_text()) |
| 73 return; | 73 return; |
| 74 | 74 |
| 75 // LCD text cannot be enabled once disabled. | 75 // LCD text cannot be enabled once disabled. |
| 76 if (layer_->layer()->can_use_lcd_text() && ignore_lcd_text_change_) | 76 if (layer_->layer()->can_use_lcd_text() && ignore_lcd_text_change_) |
| 77 return; | 77 return; |
| 78 | 78 |
| 79 can_use_lcd_text_ = layer_->layer()->can_use_lcd_text(); | 79 can_use_lcd_text_ = layer_->layer()->can_use_lcd_text(); |
| 80 ignore_lcd_text_change_ = true; | 80 ignore_lcd_text_change_ = true; |
| 81 layer_->invalidate(); | 81 layer_->invalidate(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace webkit | 84 } // namespace webkit |
| OLD | NEW |