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