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

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

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « cc/layers/picture_layer.h ('k') | cc/layers/picture_layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/resources/display_list_recording_source.h" 10 #include "cc/resources/display_list_recording_source.h"
11 #include "cc/resources/picture_pile.h" 11 #include "cc/resources/picture_pile.h"
12 #include "cc/trees/layer_tree_impl.h" 12 #include "cc/trees/layer_tree_impl.h"
13 #include "third_party/skia/include/core/SkPictureRecorder.h" 13 #include "third_party/skia/include/core/SkPictureRecorder.h"
14 #include "ui/gfx/geometry/rect_conversions.h" 14 #include "ui/gfx/geometry/rect_conversions.h"
15 15
16 namespace cc { 16 namespace cc {
17 17
18 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { 18 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) {
19 return make_scoped_refptr(new PictureLayer(client)); 19 return make_scoped_refptr(new PictureLayer(client));
20 } 20 }
21 21
22 PictureLayer::PictureLayer(ContentLayerClient* client) 22 PictureLayer::PictureLayer(ContentLayerClient* client)
23 : client_(client), 23 : client_(client),
24 instrumentation_object_tracker_(id()), 24 instrumentation_object_tracker_(id()),
25 update_source_frame_number_(-1), 25 update_source_frame_number_(-1),
26 can_use_lcd_text_for_update_(true),
26 is_mask_(false), 27 is_mask_(false),
27 nearest_neighbor_(false) { 28 nearest_neighbor_(false) {
28 } 29 }
29 30
30 PictureLayer::PictureLayer(ContentLayerClient* client, 31 PictureLayer::PictureLayer(ContentLayerClient* client,
31 scoped_ptr<RecordingSource> source) 32 scoped_ptr<RecordingSource> source)
32 : PictureLayer(client) { 33 : PictureLayer(client) {
33 recording_source_ = source.Pass(); 34 recording_source_ = source.Pass();
34 } 35 }
35 36
(...skipping 25 matching lines...) Expand all
61 if (update_source_frame_number_ != source_frame_number && 62 if (update_source_frame_number_ != source_frame_number &&
62 recording_source_bounds != impl_bounds) { 63 recording_source_bounds != impl_bounds) {
63 // Update may not get called for the layer (if it's not in the viewport 64 // Update may not get called for the layer (if it's not in the viewport
64 // for example, even though it has resized making the recording source no 65 // for example, even though it has resized making the recording source no
65 // longer valid. In this case just destroy the recording source. 66 // longer valid. In this case just destroy the recording source.
66 recording_source_->SetEmptyBounds(); 67 recording_source_->SetEmptyBounds();
67 } 68 }
68 69
69 layer_impl->SetNearestNeighbor(nearest_neighbor_); 70 layer_impl->SetNearestNeighbor(nearest_neighbor_);
70 71
71 // Preserve lcd text settings from the current raster source.
72 bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText();
73 scoped_refptr<RasterSource> raster_source = 72 scoped_refptr<RasterSource> raster_source =
74 recording_source_->CreateRasterSource(can_use_lcd_text); 73 recording_source_->CreateRasterSource();
75 layer_impl->UpdateRasterSource(raster_source, &recording_invalidation_, 74 layer_impl->UpdateRasterSource(raster_source, &recording_invalidation_,
76 nullptr); 75 nullptr);
77 DCHECK(recording_invalidation_.IsEmpty()); 76 DCHECK(recording_invalidation_.IsEmpty());
78 } 77 }
79 78
80 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { 79 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) {
81 Layer::SetLayerTreeHost(host); 80 Layer::SetLayerTreeHost(host);
82 if (host) { 81 if (host) {
83 if (!recording_source_) { 82 if (!recording_source_) {
84 if (host->settings().use_display_lists) { 83 if (host->settings().use_display_lists) {
(...skipping 16 matching lines...) Expand all
101 gfx::IntersectRects(layer_rect, gfx::Rect(bounds()))); 100 gfx::IntersectRects(layer_rect, gfx::Rect(bounds())));
102 } 101 }
103 Layer::SetNeedsDisplayRect(layer_rect); 102 Layer::SetNeedsDisplayRect(layer_rect);
104 } 103 }
105 104
106 bool PictureLayer::Update(ResourceUpdateQueue* queue, 105 bool PictureLayer::Update(ResourceUpdateQueue* queue,
107 const OcclusionTracker<Layer>* occlusion) { 106 const OcclusionTracker<Layer>* occlusion) {
108 update_source_frame_number_ = layer_tree_host()->source_frame_number(); 107 update_source_frame_number_ = layer_tree_host()->source_frame_number();
109 bool updated = Layer::Update(queue, occlusion); 108 bool updated = Layer::Update(queue, occlusion);
110 109
110 bool can_use_lcd_text_changed = UpdateCanUseLCDText();
111
111 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( 112 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect(
112 visible_content_rect(), 1.f / contents_scale_x()); 113 visible_content_rect(), 1.f / contents_scale_x());
113 gfx::Size layer_size = paint_properties().bounds; 114 gfx::Size layer_size = paint_properties().bounds;
114 115
115 if (last_updated_visible_content_rect_ == visible_content_rect() && 116 if (last_updated_visible_content_rect_ == visible_content_rect() &&
116 recording_source_->GetSize() == layer_size && 117 recording_source_->GetSize() == layer_size && !can_use_lcd_text_changed &&
117 pending_invalidation_.IsEmpty()) { 118 pending_invalidation_.IsEmpty()) {
118 // Only early out if the visible content rect of this layer hasn't changed. 119 // Only early out if the visible content rect of this layer hasn't changed.
119 return updated; 120 return updated;
120 } 121 }
121 122
122 recording_source_->SetBackgroundColor(SafeOpaqueBackgroundColor()); 123 recording_source_->SetBackgroundColor(SafeOpaqueBackgroundColor());
123 recording_source_->SetRequiresClear(!contents_opaque() && 124 recording_source_->SetRequiresClear(!contents_opaque() &&
124 !client_->FillsBoundsCompletely()); 125 !client_->FillsBoundsCompletely());
125 126
126 TRACE_EVENT1("cc", "PictureLayer::Update", 127 TRACE_EVENT1("cc", "PictureLayer::Update",
(...skipping 12 matching lines...) Expand all
139 // the full page content must always be provided in the picture layer. 140 // the full page content must always be provided in the picture layer.
140 visible_layer_rect = gfx::Rect(layer_size); 141 visible_layer_rect = gfx::Rect(layer_size);
141 } 142 }
142 143
143 // UpdateAndExpandInvalidation will give us an invalidation that covers 144 // UpdateAndExpandInvalidation will give us an invalidation that covers
144 // anything not explicitly recorded in this frame. We give this region 145 // anything not explicitly recorded in this frame. We give this region
145 // to the impl side so that it drops tiles that may not have a recording 146 // to the impl side so that it drops tiles that may not have a recording
146 // for them. 147 // for them.
147 DCHECK(client_); 148 DCHECK(client_);
148 updated |= recording_source_->UpdateAndExpandInvalidation( 149 updated |= recording_source_->UpdateAndExpandInvalidation(
149 client_, &recording_invalidation_, layer_size, visible_layer_rect, 150 client_, &recording_invalidation_, can_use_lcd_text_for_update_,
150 update_source_frame_number_, RecordingSource::RECORD_NORMALLY); 151 layer_size, visible_layer_rect, update_source_frame_number_,
152 RecordingSource::RECORD_NORMALLY);
151 last_updated_visible_content_rect_ = visible_content_rect(); 153 last_updated_visible_content_rect_ = visible_content_rect();
152 154
153 if (updated) { 155 if (updated) {
154 SetNeedsPushProperties(); 156 SetNeedsPushProperties();
155 } else { 157 } else {
156 // If this invalidation did not affect the recording source, then it can be 158 // If this invalidation did not affect the recording source, then it can be
157 // cleared as an optimization. 159 // cleared as an optimization.
158 recording_invalidation_.Clear(); 160 recording_invalidation_.Clear();
159 } 161 }
160 162
161 return updated; 163 return updated;
162 } 164 }
163 165
164 void PictureLayer::SetIsMask(bool is_mask) { 166 void PictureLayer::SetIsMask(bool is_mask) {
165 is_mask_ = is_mask; 167 is_mask_ = is_mask;
166 } 168 }
167 169
170 bool PictureLayer::SupportsLCDText() const {
171 return true;
172 }
173
174 bool PictureLayer::UpdateCanUseLCDText() {
175 if (!can_use_lcd_text_for_update_)
176 return false; // Don't allow the LCD text state to change once disabled.
177 if (can_use_lcd_text_for_update_ == can_use_lcd_text())
178 return false;
179
180 can_use_lcd_text_for_update_ = can_use_lcd_text();
181 return true;
182 }
183
168 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { 184 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const {
169 // We could either flatten the RecordingSource into a single SkPicture, 185 // We could either flatten the RecordingSource into a single SkPicture,
170 // or paint a fresh one depending on what we intend to do with the 186 // or paint a fresh one depending on what we intend to do with the
171 // picture. For now we just paint a fresh one to get consistent results. 187 // picture. For now we just paint a fresh one to get consistent results.
172 if (!DrawsContent()) 188 if (!DrawsContent())
173 return skia::RefPtr<SkPicture>(); 189 return skia::RefPtr<SkPicture>();
174 190
175 int width = bounds().width(); 191 int width = bounds().width();
176 int height = bounds().height(); 192 int height = bounds().height();
177 193
(...skipping 24 matching lines...) Expand all
202 218
203 bool PictureLayer::HasDrawableContent() const { 219 bool PictureLayer::HasDrawableContent() const {
204 return client_ && Layer::HasDrawableContent(); 220 return client_ && Layer::HasDrawableContent();
205 } 221 }
206 222
207 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { 223 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) {
208 benchmark->RunOnLayer(this); 224 benchmark->RunOnLayer(this);
209 } 225 }
210 226
211 } // namespace cc 227 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer.h ('k') | cc/layers/picture_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698