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

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

Issue 684543006: cc: Toggle LCD text at raster time instead of record time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lcdraster: bettertestsyay Created 6 years, 1 month 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
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 "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "cc/layers/content_layer_client.h" 8 #include "cc/layers/content_layer_client.h"
9 #include "cc/layers/picture_layer_impl.h" 9 #include "cc/layers/picture_layer_impl.h"
10 #include "cc/trees/layer_tree_impl.h" 10 #include "cc/trees/layer_tree_impl.h"
11 #include "third_party/skia/include/core/SkPictureRecorder.h" 11 #include "third_party/skia/include/core/SkPictureRecorder.h"
12 #include "ui/gfx/geometry/rect_conversions.h" 12 #include "ui/gfx/geometry/rect_conversions.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { 16 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) {
17 return make_scoped_refptr(new PictureLayer(client)); 17 return make_scoped_refptr(new PictureLayer(client));
18 } 18 }
19 19
20 PictureLayer::PictureLayer(ContentLayerClient* client) 20 PictureLayer::PictureLayer(ContentLayerClient* client)
21 : client_(client), 21 : client_(client),
22 instrumentation_object_tracker_(id()), 22 instrumentation_object_tracker_(id()),
23 update_source_frame_number_(-1), 23 update_source_frame_number_(-1),
24 can_use_lcd_text_last_frame_(can_use_lcd_text()) { 24 can_use_lcd_text_for_update_(false),
25 ignore_lcd_text_change_(false) {
25 } 26 }
26 27
27 PictureLayer::~PictureLayer() { 28 PictureLayer::~PictureLayer() {
28 } 29 }
29 30
30 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { 31 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
31 return PictureLayerImpl::Create(tree_impl, id()); 32 return PictureLayerImpl::Create(tree_impl, id());
32 } 33 }
33 34
34 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { 35 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 visible_layer_rect = gfx::Rect(layer_size); 120 visible_layer_rect = gfx::Rect(layer_size);
120 } 121 }
121 122
122 // UpdateAndExpandInvalidation will give us an invalidation that covers 123 // UpdateAndExpandInvalidation will give us an invalidation that covers
123 // anything not explicitly recorded in this frame. We give this region 124 // anything not explicitly recorded in this frame. We give this region
124 // to the impl side so that it drops tiles that may not have a recording 125 // to the impl side so that it drops tiles that may not have a recording
125 // for them. 126 // for them.
126 DCHECK(client_); 127 DCHECK(client_);
127 updated |= pile_.UpdateAndExpandInvalidation( 128 updated |= pile_.UpdateAndExpandInvalidation(
128 client_, &pile_invalidation_, SafeOpaqueBackgroundColor(), 129 client_, &pile_invalidation_, SafeOpaqueBackgroundColor(),
129 contents_opaque(), client_->FillsBoundsCompletely(), layer_size, 130 contents_opaque(), client_->FillsBoundsCompletely(),
130 visible_layer_rect, update_source_frame_number_, 131 can_use_lcd_text_for_update_, layer_size, visible_layer_rect,
131 Picture::RECORD_NORMALLY); 132 update_source_frame_number_, Picture::RECORD_NORMALLY);
132 last_updated_visible_content_rect_ = visible_content_rect(); 133 last_updated_visible_content_rect_ = visible_content_rect();
133 134
134 if (updated) { 135 if (updated) {
135 SetNeedsPushProperties(); 136 SetNeedsPushProperties();
136 } else { 137 } else {
137 // If this invalidation did not affect the pile, then it can be cleared as 138 // If this invalidation did not affect the pile, then it can be cleared as
138 // an optimization. 139 // an optimization.
139 pile_invalidation_.Clear(); 140 pile_invalidation_.Clear();
140 } 141 }
141 142
142 return updated; 143 return updated;
143 } 144 }
144 145
145 void PictureLayer::SetIsMask(bool is_mask) { 146 void PictureLayer::SetIsMask(bool is_mask) {
146 pile_.set_is_mask(is_mask); 147 pile_.set_is_mask(is_mask);
147 } 148 }
148 149
149 bool PictureLayer::SupportsLCDText() const { 150 bool PictureLayer::SupportsLCDText() const {
150 return true; 151 return true;
151 } 152 }
152 153
153 void PictureLayer::UpdateCanUseLCDText() { 154 void PictureLayer::UpdateCanUseLCDText() {
154 if (can_use_lcd_text_last_frame_ == can_use_lcd_text()) 155 if (can_use_lcd_text_for_update_ == can_use_lcd_text())
156 return;
157 // Once LCD text decision has been made, only allow it to be disabled.
158 if (can_use_lcd_text() && ignore_lcd_text_change_)
155 return; 159 return;
156 160
157 can_use_lcd_text_last_frame_ = can_use_lcd_text(); 161 can_use_lcd_text_for_update_ = can_use_lcd_text();
158 if (client_) 162 ignore_lcd_text_change_ = true;
159 client_->DidChangeLayerCanUseLCDText(); 163 SetNeedsDisplay();
160 } 164 }
161 165
162 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { 166 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const {
163 // We could either flatten the PicturePile into a single SkPicture, 167 // We could either flatten the PicturePile into a single SkPicture,
164 // or paint a fresh one depending on what we intend to do with the 168 // or paint a fresh one depending on what we intend to do with the
165 // picture. For now we just paint a fresh one to get consistent results. 169 // picture. For now we just paint a fresh one to get consistent results.
166 if (!DrawsContent()) 170 if (!DrawsContent())
167 return skia::RefPtr<SkPicture>(); 171 return skia::RefPtr<SkPicture>();
168 172
169 int width = bounds().width(); 173 int width = bounds().width();
(...skipping 19 matching lines...) Expand all
189 193
190 bool PictureLayer::HasDrawableContent() const { 194 bool PictureLayer::HasDrawableContent() const {
191 return client_ && Layer::HasDrawableContent(); 195 return client_ && Layer::HasDrawableContent();
192 } 196 }
193 197
194 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { 198 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) {
195 benchmark->RunOnLayer(this); 199 benchmark->RunOnLayer(this);
196 } 200 }
197 201
198 } // namespace cc 202 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698