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

Side by Side Diff: cc/resources/picture_pile.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: initvar 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/resources/picture_pile.h" 5 #include "cc/resources/picture_pile.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 return vertical_density; 157 return vertical_density;
158 } 158 }
159 159
160 } // namespace 160 } // namespace
161 161
162 namespace cc { 162 namespace cc {
163 163
164 PicturePile::PicturePile() 164 PicturePile::PicturePile()
165 : min_contents_scale_(0), 165 : min_contents_scale_(0),
166 slow_down_raster_scale_factor_for_debug_(0), 166 slow_down_raster_scale_factor_for_debug_(0),
167 can_use_lcd_text_(true),
167 has_any_recordings_(false), 168 has_any_recordings_(false),
168 is_solid_color_(false), 169 is_solid_color_(false),
169 solid_color_(SK_ColorTRANSPARENT), 170 solid_color_(SK_ColorTRANSPARENT),
170 pixel_record_distance_(kPixelDistanceToRecord), 171 pixel_record_distance_(kPixelDistanceToRecord),
171 is_suitable_for_gpu_rasterization_(true) { 172 is_suitable_for_gpu_rasterization_(true) {
172 tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize)); 173 tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize));
173 tile_grid_info_.fTileInterval.setEmpty(); 174 tile_grid_info_.fTileInterval.setEmpty();
174 tile_grid_info_.fMargin.setEmpty(); 175 tile_grid_info_.fMargin.setEmpty();
175 tile_grid_info_.fOffset.setZero(); 176 tile_grid_info_.fOffset.setZero();
176 } 177 }
177 178
178 PicturePile::~PicturePile() { 179 PicturePile::~PicturePile() {
179 } 180 }
180 181
181 bool PicturePile::UpdateAndExpandInvalidation( 182 bool PicturePile::UpdateAndExpandInvalidation(
182 ContentLayerClient* painter, 183 ContentLayerClient* painter,
183 Region* invalidation, 184 Region* invalidation,
185 bool can_use_lcd_text,
184 const gfx::Size& layer_size, 186 const gfx::Size& layer_size,
185 const gfx::Rect& visible_layer_rect, 187 const gfx::Rect& visible_layer_rect,
186 int frame_number, 188 int frame_number,
187 Picture::RecordingMode recording_mode) { 189 Picture::RecordingMode recording_mode) {
190 bool can_use_lcd_text_changed = can_use_lcd_text_ != can_use_lcd_text;
191 can_use_lcd_text_ = can_use_lcd_text;
192
188 bool updated = false; 193 bool updated = false;
189 194
190 Region resize_invalidation; 195 Region synthetic_invalidation;
191 gfx::Size old_tiling_size = GetSize(); 196 gfx::Size old_tiling_size = GetSize();
192 if (old_tiling_size != layer_size) { 197 if (old_tiling_size != layer_size) {
193 tiling_.SetTilingSize(layer_size); 198 tiling_.SetTilingSize(layer_size);
194 updated = true; 199 updated = true;
195 } 200 }
201 if (can_use_lcd_text_changed) {
202 // When LCD text is enabled/disabled, we must drop any raster tiles for
203 // the pile, so they can be recreated in a manner consistent with the new
204 // setting. We do this with |synthetic_invalidation| since we don't need to
205 // do a new recording, just invalidate rastered content.
206 synthetic_invalidation.Union(gfx::Rect(GetSize()));
207 updated = true;
208 }
196 209
197 gfx::Rect interest_rect = visible_layer_rect; 210 gfx::Rect interest_rect = visible_layer_rect;
198 interest_rect.Inset(-pixel_record_distance_, -pixel_record_distance_); 211 interest_rect.Inset(-pixel_record_distance_, -pixel_record_distance_);
199 recorded_viewport_ = interest_rect; 212 recorded_viewport_ = interest_rect;
200 recorded_viewport_.Intersect(gfx::Rect(GetSize())); 213 recorded_viewport_.Intersect(gfx::Rect(GetSize()));
201 214
202 gfx::Rect interest_rect_over_tiles = 215 gfx::Rect interest_rect_over_tiles =
203 tiling_.ExpandRectToTileBounds(interest_rect); 216 tiling_.ExpandRectToTileBounds(interest_rect);
204 217
205 gfx::Size min_tiling_size( 218 gfx::Size min_tiling_size(
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 362
350 gfx::Rect left_rect(left, top, left_until - left, bottom - top); 363 gfx::Rect left_rect(left, top, left_until - left, bottom - top);
351 gfx::Rect right_rect(right_until, top, right - right_until, bottom - top); 364 gfx::Rect right_rect(right_until, top, right - right_until, bottom - top);
352 gfx::Rect top_rect(left, top, right - left, top_until - top); 365 gfx::Rect top_rect(left, top, right - left, top_until - top);
353 gfx::Rect bottom_rect( 366 gfx::Rect bottom_rect(
354 left, bottom_until, right - left, bottom - bottom_until); 367 left, bottom_until, right - left, bottom - bottom_until);
355 gfx::Rect exposed_rect(exposed_left, 368 gfx::Rect exposed_rect(exposed_left,
356 exposed_top, 369 exposed_top,
357 exposed_left_until - exposed_left, 370 exposed_left_until - exposed_left,
358 exposed_bottom - exposed_top); 371 exposed_bottom - exposed_top);
359 resize_invalidation.Union(left_rect); 372 synthetic_invalidation.Union(left_rect);
360 resize_invalidation.Union(right_rect); 373 synthetic_invalidation.Union(right_rect);
361 resize_invalidation.Union(top_rect); 374 synthetic_invalidation.Union(top_rect);
362 resize_invalidation.Union(bottom_rect); 375 synthetic_invalidation.Union(bottom_rect);
363 resize_invalidation.Union(exposed_rect); 376 synthetic_invalidation.Union(exposed_rect);
364 } 377 }
365 if (min_toss_y < tiling_.num_tiles_y()) { 378 if (min_toss_y < tiling_.num_tiles_y()) {
366 // The same thing occurs here as in the case above, but the invalidation 379 // The same thing occurs here as in the case above, but the invalidation
367 // rect is the bounding box around the bottom row of tiles in the min 380 // rect is the bounding box around the bottom row of tiles in the min
368 // pile. This would be tiles {o,r,u,x,a,d,g,j} in the above picture. 381 // pile. This would be tiles {o,r,u,x,a,d,g,j} in the above picture.
369 382
370 int top = tiling_.TilePositionY(min_toss_y); 383 int top = tiling_.TilePositionY(min_toss_y);
371 int bottom = top + tiling_.TileSizeY(min_toss_y); 384 int bottom = top + tiling_.TileSizeY(min_toss_y);
372 int left = min_tiling_rect_over_tiles.x(); 385 int left = min_tiling_rect_over_tiles.x();
373 int right = min_tiling_rect_over_tiles.right(); 386 int right = min_tiling_rect_over_tiles.right();
(...skipping 11 matching lines...) Expand all
385 398
386 gfx::Rect left_rect(left, top, left_until - left, bottom - top); 399 gfx::Rect left_rect(left, top, left_until - left, bottom - top);
387 gfx::Rect right_rect(right_until, top, right - right_until, bottom - top); 400 gfx::Rect right_rect(right_until, top, right - right_until, bottom - top);
388 gfx::Rect top_rect(left, top, right - left, top_until - top); 401 gfx::Rect top_rect(left, top, right - left, top_until - top);
389 gfx::Rect bottom_rect( 402 gfx::Rect bottom_rect(
390 left, bottom_until, right - left, bottom - bottom_until); 403 left, bottom_until, right - left, bottom - bottom_until);
391 gfx::Rect exposed_rect(exposed_left, 404 gfx::Rect exposed_rect(exposed_left,
392 exposed_top, 405 exposed_top,
393 exposed_right - exposed_left, 406 exposed_right - exposed_left,
394 exposed_top_until - exposed_top); 407 exposed_top_until - exposed_top);
395 resize_invalidation.Union(left_rect); 408 synthetic_invalidation.Union(left_rect);
396 resize_invalidation.Union(right_rect); 409 synthetic_invalidation.Union(right_rect);
397 resize_invalidation.Union(top_rect); 410 synthetic_invalidation.Union(top_rect);
398 resize_invalidation.Union(bottom_rect); 411 synthetic_invalidation.Union(bottom_rect);
399 resize_invalidation.Union(exposed_rect); 412 synthetic_invalidation.Union(exposed_rect);
400 } 413 }
401 } 414 }
402 415
403 // Detect cases where the full pile is invalidated, in this situation we 416 // Detect cases where the full pile is invalidated, in this situation we
404 // can just drop/invalidate everything. 417 // can just drop/invalidate everything.
405 if (invalidation->Contains(gfx::Rect(old_tiling_size)) || 418 if (invalidation->Contains(gfx::Rect(old_tiling_size)) ||
406 invalidation->Contains(gfx::Rect(GetSize()))) { 419 invalidation->Contains(gfx::Rect(GetSize()))) {
407 for (auto& it : picture_map_) 420 for (auto& it : picture_map_)
408 updated = it.second.Invalidate(frame_number) || updated; 421 updated = it.second.Invalidate(frame_number) || updated;
409 } else { 422 } else {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 // if it won't be re-recorded below. 464 // if it won't be re-recorded below.
452 DCHECK_IMPLIES(!tiling_.TileBounds(key.first, key.second) 465 DCHECK_IMPLIES(!tiling_.TileBounds(key.first, key.second)
453 .Intersects(interest_rect_over_tiles), 466 .Intersects(interest_rect_over_tiles),
454 invalidation_expanded_to_full_tiles.Contains( 467 invalidation_expanded_to_full_tiles.Contains(
455 tiling_.TileBounds(key.first, key.second))); 468 tiling_.TileBounds(key.first, key.second)));
456 } 469 }
457 } 470 }
458 invalidation->Union(invalidation_expanded_to_full_tiles); 471 invalidation->Union(invalidation_expanded_to_full_tiles);
459 } 472 }
460 473
461 invalidation->Union(resize_invalidation); 474 invalidation->Union(synthetic_invalidation);
462 475
463 // Make a list of all invalid tiles; we will attempt to 476 // Make a list of all invalid tiles; we will attempt to
464 // cluster these into multiple invalidation regions. 477 // cluster these into multiple invalidation regions.
465 std::vector<gfx::Rect> invalid_tiles; 478 std::vector<gfx::Rect> invalid_tiles;
466 bool include_borders = true; 479 bool include_borders = true;
467 for (TilingData::Iterator it(&tiling_, interest_rect, include_borders); it; 480 for (TilingData::Iterator it(&tiling_, interest_rect, include_borders); it;
468 ++it) { 481 ++it) {
469 const PictureMapKey& key = it.index(); 482 const PictureMapKey& key = it.index();
470 PictureInfo& info = picture_map_[key]; 483 PictureInfo& info = picture_map_[key];
471 484
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 const Picture* PicturePile::PictureInfo::GetPicture() const { 752 const Picture* PicturePile::PictureInfo::GetPicture() const {
740 return picture_.get(); 753 return picture_.get();
741 } 754 }
742 755
743 float PicturePile::PictureInfo::GetInvalidationFrequency() const { 756 float PicturePile::PictureInfo::GetInvalidationFrequency() const {
744 return invalidation_history_.count() / 757 return invalidation_history_.count() /
745 static_cast<float>(INVALIDATION_FRAMES_TRACKED); 758 static_cast<float>(INVALIDATION_FRAMES_TRACKED);
746 } 759 }
747 760
748 } // namespace cc 761 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698