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

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: Fixed build break 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/test/fake_content_layer.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 489 // Calling PrepareToUpdate() calls into WebKit to paint, which may have the
483 // side effect of disabling compositing, which causes our reference to the 490 // 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 491 // 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 492 // the SkCanvas until the paint finishes, so we grab a local reference here to
486 // hold the updater alive until the paint completes. 493 // hold the updater alive until the paint completes.
487 scoped_refptr<LayerUpdater> protector(Updater()); 494 scoped_refptr<LayerUpdater> protector(Updater());
488 gfx::Rect painted_opaque_rect; 495 gfx::Rect painted_opaque_rect;
489 Updater()->PrepareToUpdate(paint_rect, 496 Updater()->PrepareToUpdate(paint_rect,
490 tiler_->tile_size(), 497 tiler_->tile_size(),
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 gfx::Rect prepaint_rect = visible_content_rect(); 911 gfx::Rect prepaint_rect = visible_content_rect();
905 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, 912 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns,
906 -tiler_->tile_size().height() * kPrepaintRows); 913 -tiler_->tile_size().height() * kPrepaintRows);
907 gfx::Rect content_rect(content_bounds()); 914 gfx::Rect content_rect(content_bounds());
908 prepaint_rect.Intersect(content_rect); 915 prepaint_rect.Intersect(content_rect);
909 916
910 return prepaint_rect; 917 return prepaint_rect;
911 } 918 }
912 919
913 } // namespace cc 920 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/tiled_layer.h ('k') | cc/test/fake_content_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698