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

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

Issue 85143002: Dirty rects always contain full tiles with delegated rendering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years 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/tiled_layer.h ('k') | cc/resources/bitmap_content_layer_updater.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/tiled_layer.h" 5 #include "cc/layers/tiled_layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 const OcclusionTracker* occlusion, 327 const OcclusionTracker* occlusion,
328 bool* updated) { 328 bool* updated) {
329 CreateUpdaterIfNeeded(); 329 CreateUpdaterIfNeeded();
330 330
331 bool ignore_occlusions = !occlusion; 331 bool ignore_occlusions = !occlusion;
332 if (!HaveTexturesForTiles(left, top, right, bottom, ignore_occlusions)) { 332 if (!HaveTexturesForTiles(left, top, right, bottom, ignore_occlusions)) {
333 failed_update_ = true; 333 failed_update_ = true;
334 return false; 334 return false;
335 } 335 }
336 336
337 gfx::Rect paint_rect = 337 gfx::Rect update_rect;
338 MarkTilesForUpdate(left, top, right, bottom, ignore_occlusions); 338 gfx::Rect paint_rect;
339 MarkTilesForUpdate(
340 &update_rect, &paint_rect, left, top, right, bottom, ignore_occlusions);
339 341
340 if (occlusion) 342 if (occlusion)
341 occlusion->overdraw_metrics()->DidPaint(paint_rect); 343 occlusion->overdraw_metrics()->DidPaint(paint_rect);
342 344
343 if (paint_rect.IsEmpty()) 345 if (paint_rect.IsEmpty())
344 return true; 346 return true;
345 347
346 *updated = true; 348 *updated = true;
347 UpdateTileTextures( 349 UpdateTileTextures(
348 paint_rect, left, top, right, bottom, queue, occlusion); 350 update_rect, paint_rect, left, top, right, bottom, queue, occlusion);
349 return true; 351 return true;
350 } 352 }
351 353
352 void TiledLayer::MarkOcclusionsAndRequestTextures( 354 void TiledLayer::MarkOcclusionsAndRequestTextures(
353 int left, 355 int left,
354 int top, 356 int top,
355 int right, 357 int right,
356 int bottom, 358 int bottom,
357 const OcclusionTracker* occlusion) { 359 const OcclusionTracker* occlusion) {
358 // There is some difficult dependancies between occlusions, recording 360 // There is some difficult dependancies between occlusions, recording
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 if (tile->occluded && !ignore_occlusions) 417 if (tile->occluded && !ignore_occlusions)
416 continue; 418 continue;
417 419
418 if (!tile->managed_resource()->can_acquire_backing_texture()) 420 if (!tile->managed_resource()->can_acquire_backing_texture())
419 return false; 421 return false;
420 } 422 }
421 } 423 }
422 return true; 424 return true;
423 } 425 }
424 426
425 gfx::Rect TiledLayer::MarkTilesForUpdate(int left, 427 void TiledLayer::MarkTilesForUpdate(gfx::Rect* update_rect,
426 int top, 428 gfx::Rect* paint_rect,
427 int right, 429 int left,
428 int bottom, 430 int top,
429 bool ignore_occlusions) { 431 int right,
430 gfx::Rect paint_rect; 432 int bottom,
433 bool ignore_occlusions) {
431 for (int j = top; j <= bottom; ++j) { 434 for (int j = top; j <= bottom; ++j) {
432 for (int i = left; i <= right; ++i) { 435 for (int i = left; i <= right; ++i) {
433 UpdatableTile* tile = TileAt(i, j); 436 UpdatableTile* tile = TileAt(i, j);
434 DCHECK(tile); // Did SetTexturePriorites get skipped? 437 DCHECK(tile); // Did SetTexturePriorites get skipped?
435 // TODO(enne): This should not ever be null. 438 // TODO(enne): This should not ever be null.
436 if (!tile) 439 if (!tile)
437 continue; 440 continue;
438 if (tile->occluded && !ignore_occlusions) 441 if (tile->occluded && !ignore_occlusions)
439 continue; 442 continue;
443
444 // Prepare update rect from original dirty rects
445 update_rect->Union(tile->dirty_rect);
446
440 // TODO(reveman): Decide if partial update should be allowed based on cost 447 // TODO(reveman): Decide if partial update should be allowed based on cost
441 // of update. https://bugs.webkit.org/show_bug.cgi?id=77376 448 // of update. https://bugs.webkit.org/show_bug.cgi?id=77376
442 if (tile->is_dirty() && 449 if (tile->is_dirty() &&
443 !layer_tree_host()->AlwaysUsePartialTextureUpdates()) { 450 !layer_tree_host()->AlwaysUsePartialTextureUpdates()) {
444 // If we get a partial update, we use the same texture, otherwise return 451 // If we get a partial update, we use the same texture, otherwise return
445 // the current texture backing, so we don't update visible textures 452 // the current texture backing, so we don't update visible textures
446 // non-atomically. If the current backing is in-use, it won't be 453 // non-atomically. If the current backing is in-use, it won't be
447 // deleted until after the commit as the texture manager will not allow 454 // deleted until after the commit as the texture manager will not allow
448 // deletion or recycling of in-use textures. 455 // deletion or recycling of in-use textures.
449 if (TileOnlyNeedsPartialUpdate(tile) && 456 if (TileOnlyNeedsPartialUpdate(tile) &&
450 layer_tree_host()->RequestPartialTextureUpdate()) { 457 layer_tree_host()->RequestPartialTextureUpdate()) {
451 tile->partial_update = true; 458 tile->partial_update = true;
452 } else { 459 } else {
453 tile->dirty_rect = tiler_->TileRect(tile); 460 tile->dirty_rect = tiler_->TileRect(tile);
454 tile->managed_resource()->ReturnBackingTexture(); 461 tile->managed_resource()->ReturnBackingTexture();
455 } 462 }
456 } 463 }
457 464
458 paint_rect.Union(tile->dirty_rect); 465 paint_rect->Union(tile->dirty_rect);
459 tile->MarkForUpdate(); 466 tile->MarkForUpdate();
460 } 467 }
461 } 468 }
462 return paint_rect;
463 } 469 }
464 470
465 void TiledLayer::UpdateTileTextures(gfx::Rect paint_rect, 471 void TiledLayer::UpdateTileTextures(gfx::Rect update_rect,
472 gfx::Rect paint_rect,
466 int left, 473 int left,
467 int top, 474 int top,
468 int right, 475 int right,
469 int bottom, 476 int bottom,
470 ResourceUpdateQueue* queue, 477 ResourceUpdateQueue* queue,
471 const OcclusionTracker* occlusion) { 478 const OcclusionTracker* occlusion) {
472 // The update_rect should be in layer space. So we have to convert the 479 // The update_rect should be in layer space. So we have to convert the
473 // paint_rect from content space to layer space. 480 // paint_rect from content space to layer space.
474 float width_scale = 481 float width_scale =
475 paint_properties().bounds.width() / 482 paint_properties().bounds.width() /
476 static_cast<float>(content_bounds().width()); 483 static_cast<float>(content_bounds().width());
477 float height_scale = 484 float height_scale =
478 paint_properties().bounds.height() / 485 paint_properties().bounds.height() /
479 static_cast<float>(content_bounds().height()); 486 static_cast<float>(content_bounds().height());
480 update_rect_ = gfx::ScaleRect(paint_rect, width_scale, height_scale); 487 update_rect_ = gfx::ScaleRect(update_rect, width_scale, height_scale);
481 488
482 // Calling PrepareToUpdate() calls into WebKit to paint, which may have the
483 // side effect of disabling compositing, which causes our reference to the
484 // texture updater to be deleted. However, we can't free the memory backing
485 // the SkCanvas until the paint finishes, so we grab a local reference here to
486 // hold the updater alive until the paint completes.
487 scoped_refptr<LayerUpdater> protector(Updater());
488 gfx::Rect painted_opaque_rect; 489 gfx::Rect painted_opaque_rect;
489 Updater()->PrepareToUpdate(paint_rect, 490 if (!update_rect.IsEmpty()) {
enne (OOO) 2013/11/25 20:59:48 I'm not sure this can ever happen. I'd prefer a D
prashant.n 2013/11/26 04:56:06 Yes, true, this will never happen. I'll remove thi
490 tiler_->tile_size(), 491 // Calling PrepareToUpdate() calls into WebKit to paint, which may have the
491 1.f / width_scale, 492 // side effect of disabling compositing, which causes our reference to the
492 1.f / height_scale, 493 // texture updater to be deleted. However, we can't free the memory backing
493 &painted_opaque_rect); 494 // the SkCanvas until the paint finishes, so we grab a local reference here
495 // to hold the updater alive until the paint completes.
496 scoped_refptr<LayerUpdater> protector(Updater());
497 Updater()->PrepareToUpdate(update_rect,
enne (OOO) 2013/11/25 20:59:48 Re: point #2, I think this is wrong. You need the
prashant.n 2013/11/26 04:56:06 In TiledLayer::TileOnlyNeedsPartialUpdate(), we ch
danakj 2013/11/26 16:08:39 I agree, it should only be the update_rect_ that c
498 paint_rect,
499 tiler_->tile_size(),
500 1.f / width_scale,
501 1.f / height_scale,
502 &painted_opaque_rect);
503 }
494 504
495 for (int j = top; j <= bottom; ++j) { 505 for (int j = top; j <= bottom; ++j) {
496 for (int i = left; i <= right; ++i) { 506 for (int i = left; i <= right; ++i) {
497 UpdatableTile* tile = TileAt(i, j); 507 UpdatableTile* tile = TileAt(i, j);
498 DCHECK(tile); // Did SetTexturePriorites get skipped? 508 DCHECK(tile); // Did SetTexturePriorites get skipped?
499 // TODO(enne): This should not ever be null. 509 // TODO(enne): This should not ever be null.
500 if (!tile) 510 if (!tile)
501 continue; 511 continue;
502 512
503 gfx::Rect tile_rect = tiler_->tile_bounds(i, j); 513 gfx::Rect tile_rect = tiler_->tile_bounds(i, j);
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 gfx::Rect prepaint_rect = visible_content_rect(); 914 gfx::Rect prepaint_rect = visible_content_rect();
905 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, 915 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns,
906 -tiler_->tile_size().height() * kPrepaintRows); 916 -tiler_->tile_size().height() * kPrepaintRows);
907 gfx::Rect content_rect(content_bounds()); 917 gfx::Rect content_rect(content_bounds());
908 prepaint_rect.Intersect(content_rect); 918 prepaint_rect.Intersect(content_rect);
909 919
910 return prepaint_rect; 920 return prepaint_rect;
911 } 921 }
912 922
913 } // namespace cc 923 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/tiled_layer.h ('k') | cc/resources/bitmap_content_layer_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698