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

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: . 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 PicturePile::~PicturePile() { 187 PicturePile::~PicturePile() {
188 } 188 }
189 189
190 bool PicturePile::UpdateAndExpandInvalidation( 190 bool PicturePile::UpdateAndExpandInvalidation(
191 ContentLayerClient* painter, 191 ContentLayerClient* painter,
192 Region* invalidation, 192 Region* invalidation,
193 SkColor background_color, 193 SkColor background_color,
194 bool contents_opaque, 194 bool contents_opaque,
195 bool contents_fill_bounds_completely, 195 bool contents_fill_bounds_completely,
196 bool can_use_lcd_text,
196 const gfx::Size& layer_size, 197 const gfx::Size& layer_size,
197 const gfx::Rect& visible_layer_rect, 198 const gfx::Rect& visible_layer_rect,
198 int frame_number, 199 int frame_number,
199 Picture::RecordingMode recording_mode) { 200 Picture::RecordingMode recording_mode) {
200 background_color_ = background_color; 201 background_color_ = background_color;
201 contents_opaque_ = contents_opaque; 202 contents_opaque_ = contents_opaque;
202 contents_fill_bounds_completely_ = contents_fill_bounds_completely; 203 contents_fill_bounds_completely_ = contents_fill_bounds_completely;
204 bool can_use_lcd_text_changed = can_use_lcd_text_ != can_use_lcd_text;
205 can_use_lcd_text_ = can_use_lcd_text;
203 206
204 bool updated = false; 207 bool updated = false;
205 208
206 Region resize_invalidation; 209 Region synthetic_invalidation;
207 gfx::Size old_tiling_size = GetSize(); 210 gfx::Size old_tiling_size = GetSize();
208 if (old_tiling_size != layer_size) { 211 if (old_tiling_size != layer_size) {
209 tiling_.SetTilingSize(layer_size); 212 tiling_.SetTilingSize(layer_size);
210 updated = true; 213 updated = true;
211 } 214 }
215 if (can_use_lcd_text_changed) {
216 // When LCD text is enabled/disabled, we must drop any raster tiles for
217 // the pile, so they can be recreated in a manner consistent with the new
218 // setting. We do this with |synthetic_invalidation| since we don't need to
219 // do a new recording, just invalidate rastered content.
220 synthetic_invalidation.Union(gfx::Rect(GetSize()));
221 updated = true;
222 }
212 223
213 gfx::Rect interest_rect = visible_layer_rect; 224 gfx::Rect interest_rect = visible_layer_rect;
214 interest_rect.Inset(-pixel_record_distance_, -pixel_record_distance_); 225 interest_rect.Inset(-pixel_record_distance_, -pixel_record_distance_);
215 recorded_viewport_ = interest_rect; 226 recorded_viewport_ = interest_rect;
216 recorded_viewport_.Intersect(gfx::Rect(GetSize())); 227 recorded_viewport_.Intersect(gfx::Rect(GetSize()));
217 228
218 gfx::Rect interest_rect_over_tiles = 229 gfx::Rect interest_rect_over_tiles =
219 tiling_.ExpandRectToTileBounds(interest_rect); 230 tiling_.ExpandRectToTileBounds(interest_rect);
220 231
221 gfx::Size min_tiling_size( 232 gfx::Size min_tiling_size(
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 376
366 gfx::Rect left_rect(left, top, left_until - left, bottom - top); 377 gfx::Rect left_rect(left, top, left_until - left, bottom - top);
367 gfx::Rect right_rect(right_until, top, right - right_until, bottom - top); 378 gfx::Rect right_rect(right_until, top, right - right_until, bottom - top);
368 gfx::Rect top_rect(left, top, right - left, top_until - top); 379 gfx::Rect top_rect(left, top, right - left, top_until - top);
369 gfx::Rect bottom_rect( 380 gfx::Rect bottom_rect(
370 left, bottom_until, right - left, bottom - bottom_until); 381 left, bottom_until, right - left, bottom - bottom_until);
371 gfx::Rect exposed_rect(exposed_left, 382 gfx::Rect exposed_rect(exposed_left,
372 exposed_top, 383 exposed_top,
373 exposed_left_until - exposed_left, 384 exposed_left_until - exposed_left,
374 exposed_bottom - exposed_top); 385 exposed_bottom - exposed_top);
375 resize_invalidation.Union(left_rect); 386 synthetic_invalidation.Union(left_rect);
376 resize_invalidation.Union(right_rect); 387 synthetic_invalidation.Union(right_rect);
377 resize_invalidation.Union(top_rect); 388 synthetic_invalidation.Union(top_rect);
378 resize_invalidation.Union(bottom_rect); 389 synthetic_invalidation.Union(bottom_rect);
379 resize_invalidation.Union(exposed_rect); 390 synthetic_invalidation.Union(exposed_rect);
380 } 391 }
381 if (min_toss_y < tiling_.num_tiles_y()) { 392 if (min_toss_y < tiling_.num_tiles_y()) {
382 // The same thing occurs here as in the case above, but the invalidation 393 // The same thing occurs here as in the case above, but the invalidation
383 // rect is the bounding box around the bottom row of tiles in the min 394 // rect is the bounding box around the bottom row of tiles in the min
384 // pile. This would be tiles {o,r,u,x,a,d,g,j} in the above picture. 395 // pile. This would be tiles {o,r,u,x,a,d,g,j} in the above picture.
385 396
386 int top = tiling_.TilePositionY(min_toss_y); 397 int top = tiling_.TilePositionY(min_toss_y);
387 int bottom = top + tiling_.TileSizeY(min_toss_y); 398 int bottom = top + tiling_.TileSizeY(min_toss_y);
388 int left = min_tiling_rect_over_tiles.x(); 399 int left = min_tiling_rect_over_tiles.x();
389 int right = min_tiling_rect_over_tiles.right(); 400 int right = min_tiling_rect_over_tiles.right();
(...skipping 11 matching lines...) Expand all
401 412
402 gfx::Rect left_rect(left, top, left_until - left, bottom - top); 413 gfx::Rect left_rect(left, top, left_until - left, bottom - top);
403 gfx::Rect right_rect(right_until, top, right - right_until, bottom - top); 414 gfx::Rect right_rect(right_until, top, right - right_until, bottom - top);
404 gfx::Rect top_rect(left, top, right - left, top_until - top); 415 gfx::Rect top_rect(left, top, right - left, top_until - top);
405 gfx::Rect bottom_rect( 416 gfx::Rect bottom_rect(
406 left, bottom_until, right - left, bottom - bottom_until); 417 left, bottom_until, right - left, bottom - bottom_until);
407 gfx::Rect exposed_rect(exposed_left, 418 gfx::Rect exposed_rect(exposed_left,
408 exposed_top, 419 exposed_top,
409 exposed_right - exposed_left, 420 exposed_right - exposed_left,
410 exposed_top_until - exposed_top); 421 exposed_top_until - exposed_top);
411 resize_invalidation.Union(left_rect); 422 synthetic_invalidation.Union(left_rect);
412 resize_invalidation.Union(right_rect); 423 synthetic_invalidation.Union(right_rect);
413 resize_invalidation.Union(top_rect); 424 synthetic_invalidation.Union(top_rect);
414 resize_invalidation.Union(bottom_rect); 425 synthetic_invalidation.Union(bottom_rect);
415 resize_invalidation.Union(exposed_rect); 426 synthetic_invalidation.Union(exposed_rect);
416 } 427 }
417 } 428 }
418 429
419 // Detect cases where the full pile is invalidated, in this situation we 430 // Detect cases where the full pile is invalidated, in this situation we
420 // can just drop/invalidate everything. 431 // can just drop/invalidate everything.
421 if (invalidation->Contains(gfx::Rect(old_tiling_size)) || 432 if (invalidation->Contains(gfx::Rect(old_tiling_size)) ||
422 invalidation->Contains(gfx::Rect(GetSize()))) { 433 invalidation->Contains(gfx::Rect(GetSize()))) {
423 for (auto& it : picture_map_) 434 for (auto& it : picture_map_)
424 updated = it.second.Invalidate(frame_number) || updated; 435 updated = it.second.Invalidate(frame_number) || updated;
425 } else { 436 } else {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 // if it won't be re-recorded below. 478 // if it won't be re-recorded below.
468 DCHECK_IMPLIES(!tiling_.TileBounds(key.first, key.second) 479 DCHECK_IMPLIES(!tiling_.TileBounds(key.first, key.second)
469 .Intersects(interest_rect_over_tiles), 480 .Intersects(interest_rect_over_tiles),
470 invalidation_expanded_to_full_tiles.Contains( 481 invalidation_expanded_to_full_tiles.Contains(
471 tiling_.TileBounds(key.first, key.second))); 482 tiling_.TileBounds(key.first, key.second)));
472 } 483 }
473 } 484 }
474 invalidation->Union(invalidation_expanded_to_full_tiles); 485 invalidation->Union(invalidation_expanded_to_full_tiles);
475 } 486 }
476 487
477 invalidation->Union(resize_invalidation); 488 invalidation->Union(synthetic_invalidation);
478 489
479 // Make a list of all invalid tiles; we will attempt to 490 // Make a list of all invalid tiles; we will attempt to
480 // cluster these into multiple invalidation regions. 491 // cluster these into multiple invalidation regions.
481 std::vector<gfx::Rect> invalid_tiles; 492 std::vector<gfx::Rect> invalid_tiles;
482 bool include_borders = true; 493 bool include_borders = true;
483 for (TilingData::Iterator it(&tiling_, interest_rect, include_borders); it; 494 for (TilingData::Iterator it(&tiling_, interest_rect, include_borders); it;
484 ++it) { 495 ++it) {
485 const PictureMapKey& key = it.index(); 496 const PictureMapKey& key = it.index();
486 PictureInfo& info = picture_map_[key]; 497 PictureInfo& info = picture_map_[key];
487 498
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 const Picture* PicturePile::PictureInfo::GetPicture() const { 770 const Picture* PicturePile::PictureInfo::GetPicture() const {
760 return picture_.get(); 771 return picture_.get();
761 } 772 }
762 773
763 float PicturePile::PictureInfo::GetInvalidationFrequency() const { 774 float PicturePile::PictureInfo::GetInvalidationFrequency() const {
764 return invalidation_history_.count() / 775 return invalidation_history_.count() /
765 static_cast<float>(INVALIDATION_FRAMES_TRACKED); 776 static_cast<float>(INVALIDATION_FRAMES_TRACKED);
766 } 777 }
767 778
768 } // namespace cc 779 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698