Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: cc/layers/picture_layer.cc

Issue 315393002: Record SkPicture with correct LCD text setting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better unittest Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "cc/layers/picture_layer.h" 5 #include "cc/layers/picture_layer.h"
6 6
7 #include "cc/layers/content_layer_client.h" 7 #include "cc/layers/content_layer_client.h"
8 #include "cc/layers/picture_layer_impl.h" 8 #include "cc/layers/picture_layer_impl.h"
9 #include "cc/trees/layer_tree_impl.h" 9 #include "cc/trees/layer_tree_impl.h"
10 #include "third_party/skia/include/core/SkPictureRecorder.h" 10 #include "third_party/skia/include/core/SkPictureRecorder.h"
11 #include "ui/gfx/rect_conversions.h" 11 #include "ui/gfx/rect_conversions.h"
12 12
13 namespace cc { 13 namespace cc {
14 14
15 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { 15 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) {
16 return make_scoped_refptr(new PictureLayer(client)); 16 return make_scoped_refptr(new PictureLayer(client));
17 } 17 }
18 18
19 PictureLayer::PictureLayer(ContentLayerClient* client) 19 PictureLayer::PictureLayer(ContentLayerClient* client)
20 : client_(client), 20 : client_(client),
21 pile_(make_scoped_refptr(new PicturePile())), 21 pile_(make_scoped_refptr(new PicturePile())),
22 instrumentation_object_tracker_(id()), 22 instrumentation_object_tracker_(id()),
23 is_mask_(false), 23 is_mask_(false),
24 update_source_frame_number_(-1) {} 24 use_lcd_text_(true),
25 update_source_frame_number_(-1) {
26 }
25 27
26 PictureLayer::~PictureLayer() { 28 PictureLayer::~PictureLayer() {
27 } 29 }
28 30
29 bool PictureLayer::DrawsContent() const { 31 bool PictureLayer::DrawsContent() const {
30 return Layer::DrawsContent() && client_; 32 return Layer::DrawsContent() && client_;
31 } 33 }
32 34
33 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { 35 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
34 return PictureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); 36 return PictureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 pending_invalidation_.Union(rect); 83 pending_invalidation_.Union(rect);
82 } 84 }
83 Layer::SetNeedsDisplayRect(layer_rect); 85 Layer::SetNeedsDisplayRect(layer_rect);
84 } 86 }
85 87
86 bool PictureLayer::Update(ResourceUpdateQueue* queue, 88 bool PictureLayer::Update(ResourceUpdateQueue* queue,
87 const OcclusionTracker<Layer>* occlusion) { 89 const OcclusionTracker<Layer>* occlusion) {
88 update_source_frame_number_ = layer_tree_host()->source_frame_number(); 90 update_source_frame_number_ = layer_tree_host()->source_frame_number();
89 bool updated = Layer::Update(queue, occlusion); 91 bool updated = Layer::Update(queue, occlusion);
90 92
93 UpdateUseLCDText();
94
91 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( 95 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect(
92 visible_content_rect(), 1.f / contents_scale_x()); 96 visible_content_rect(), 1.f / contents_scale_x());
93 97
94 gfx::Rect layer_rect = gfx::Rect(paint_properties().bounds); 98 gfx::Rect layer_rect = gfx::Rect(paint_properties().bounds);
95 99
96 if (last_updated_visible_content_rect_ == visible_content_rect() && 100 if (last_updated_visible_content_rect_ == visible_content_rect() &&
97 pile_->tiling_rect() == layer_rect && pending_invalidation_.IsEmpty()) { 101 pile_->tiling_rect() == layer_rect && pending_invalidation_.IsEmpty()) {
98 // Only early out if the visible content rect of this layer hasn't changed. 102 // Only early out if the visible content rect of this layer hasn't changed.
99 return updated; 103 return updated;
100 } 104 }
(...skipping 12 matching lines...) Expand all
113 if (layer_tree_host()->settings().using_synchronous_renderer_compositor) { 117 if (layer_tree_host()->settings().using_synchronous_renderer_compositor) {
114 // Workaround for http://crbug.com/235910 - to retain backwards compat 118 // Workaround for http://crbug.com/235910 - to retain backwards compat
115 // the full page content must always be provided in the picture layer. 119 // the full page content must always be provided in the picture layer.
116 visible_layer_rect = gfx::Rect(bounds()); 120 visible_layer_rect = gfx::Rect(bounds());
117 } 121 }
118 DCHECK(client_); 122 DCHECK(client_);
119 updated |= pile_->Update(client_, 123 updated |= pile_->Update(client_,
120 SafeOpaqueBackgroundColor(), 124 SafeOpaqueBackgroundColor(),
121 contents_opaque(), 125 contents_opaque(),
122 client_->FillsBoundsCompletely(), 126 client_->FillsBoundsCompletely(),
127 use_lcd_text_,
123 pile_invalidation_, 128 pile_invalidation_,
124 visible_layer_rect, 129 visible_layer_rect,
125 update_source_frame_number_, 130 update_source_frame_number_,
126 RecordingMode(), 131 RecordingMode(),
127 rendering_stats_instrumentation()); 132 rendering_stats_instrumentation());
128 last_updated_visible_content_rect_ = visible_content_rect(); 133 last_updated_visible_content_rect_ = visible_content_rect();
129 134
130 if (updated) { 135 if (updated) {
131 SetNeedsPushProperties(); 136 SetNeedsPushProperties();
132 } else { 137 } else {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 return skia::RefPtr<SkPicture>(); 170 return skia::RefPtr<SkPicture>();
166 171
167 int width = bounds().width(); 172 int width = bounds().width();
168 int height = bounds().height(); 173 int height = bounds().height();
169 gfx::RectF opaque; 174 gfx::RectF opaque;
170 175
171 SkPictureRecorder recorder; 176 SkPictureRecorder recorder;
172 SkCanvas* canvas = recorder.beginRecording(width, height, NULL, 0); 177 SkCanvas* canvas = recorder.beginRecording(width, height, NULL, 0);
173 client_->PaintContents(canvas, 178 client_->PaintContents(canvas,
174 gfx::Rect(width, height), 179 gfx::Rect(width, height),
180 use_lcd_text_,
175 &opaque, 181 &opaque,
176 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); 182 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED);
177 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); 183 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording());
178 return picture; 184 return picture;
179 } 185 }
180 186
181 bool PictureLayer::IsSuitableForGpuRasterization() const { 187 bool PictureLayer::IsSuitableForGpuRasterization() const {
182 return pile_->is_suitable_for_gpu_rasterization(); 188 return pile_->is_suitable_for_gpu_rasterization();
183 } 189 }
184 190
185 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { 191 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) {
186 benchmark->RunOnLayer(this); 192 benchmark->RunOnLayer(this);
187 } 193 }
188 194
195 void PictureLayer::UpdateUseLCDText() {
196 if (use_lcd_text_ == can_use_lcd_text())
197 return;
198
199 // LCD text starts out enabled and can only be disabled.
200 if (!use_lcd_text_)
201 return;
202
203 use_lcd_text_ = can_use_lcd_text();
204 if (client_->PaintsLCDText())
205 SetNeedsDisplay();
enne (OOO) 2014/06/10 18:46:09 Re: "The ui::layer will still not be invalidated"
alokp 2014/06/10 20:54:43 Not if PaintsLCDText returns false.
206 }
207
189 } // namespace cc 208 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698