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

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

Issue 565043002: cc: Remove the opaque rect return-parameter from ContentLayerClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: contentlayerclientopaque: build Created 6 years, 3 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_unittest.cc ('k') | cc/layers/tiled_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 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 if (!tile->valid_for_frame) { 214 if (!tile->valid_for_frame) {
215 // Invalidated tiles are set so they can get different debug colors. 215 // Invalidated tiles are set so they can get different debug colors.
216 tiled_layer->PushInvalidTile(i, j); 216 tiled_layer->PushInvalidTile(i, j);
217 continue; 217 continue;
218 } 218 }
219 219
220 tiled_layer->PushTileProperties( 220 tiled_layer->PushTileProperties(
221 i, 221 i,
222 j, 222 j,
223 tile->managed_resource()->resource_id(), 223 tile->managed_resource()->resource_id(),
224 tile->opaque_rect(),
225 tile->managed_resource()->contents_swizzled()); 224 tile->managed_resource()->contents_swizzled());
226 } 225 }
227 for (std::vector<UpdatableTile*>::const_iterator iter = invalid_tiles.begin(); 226 for (std::vector<UpdatableTile*>::const_iterator iter = invalid_tiles.begin();
228 iter != invalid_tiles.end(); 227 iter != invalid_tiles.end();
229 ++iter) 228 ++iter)
230 tiler_->TakeTile((*iter)->i(), (*iter)->j()); 229 tiler_->TakeTile((*iter)->i(), (*iter)->j());
231 230
232 // TiledLayer must push properties every frame, since viewport state and 231 // TiledLayer must push properties every frame, since viewport state and
233 // occlusion from anywhere in the tree can change what the layer decides to 232 // occlusion from anywhere in the tree can change what the layer decides to
234 // push to the impl tree. 233 // push to the impl tree.
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 paint_properties().bounds.height() / 469 paint_properties().bounds.height() /
471 static_cast<float>(content_bounds().height()); 470 static_cast<float>(content_bounds().height());
472 update_rect_ = gfx::ScaleRect(update_rect, width_scale, height_scale); 471 update_rect_ = gfx::ScaleRect(update_rect, width_scale, height_scale);
473 472
474 // Calling PrepareToUpdate() calls into WebKit to paint, which may have the 473 // Calling PrepareToUpdate() calls into WebKit to paint, which may have the
475 // side effect of disabling compositing, which causes our reference to the 474 // side effect of disabling compositing, which causes our reference to the
476 // texture updater to be deleted. However, we can't free the memory backing 475 // texture updater to be deleted. However, we can't free the memory backing
477 // the SkCanvas until the paint finishes, so we grab a local reference here to 476 // the SkCanvas until the paint finishes, so we grab a local reference here to
478 // hold the updater alive until the paint completes. 477 // hold the updater alive until the paint completes.
479 scoped_refptr<LayerUpdater> protector(Updater()); 478 scoped_refptr<LayerUpdater> protector(Updater());
480 gfx::Rect painted_opaque_rect; 479 Updater()->PrepareToUpdate(
481 Updater()->PrepareToUpdate(paint_rect, 480 paint_rect, tiler_->tile_size(), 1.f / width_scale, 1.f / height_scale);
482 tiler_->tile_size(),
483 1.f / width_scale,
484 1.f / height_scale,
485 &painted_opaque_rect);
486 481
487 for (int j = top; j <= bottom; ++j) { 482 for (int j = top; j <= bottom; ++j) {
488 for (int i = left; i <= right; ++i) { 483 for (int i = left; i <= right; ++i) {
489 UpdatableTile* tile = TileAt(i, j); 484 UpdatableTile* tile = TileAt(i, j);
490 DCHECK(tile); // Did SetTexturePriorites get skipped? 485 DCHECK(tile); // Did SetTexturePriorites get skipped?
491 // TODO(enne): This should not ever be null. 486 // TODO(enne): This should not ever be null.
492 if (!tile) 487 if (!tile)
493 continue; 488 continue;
494 489
495 gfx::Rect tile_rect = tiler_->tile_bounds(i, j); 490 gfx::Rect tile_rect = tiler_->tile_bounds(i, j);
496 491
497 // Use update_rect as the above loop copied the dirty rect for this frame 492 // Use update_rect as the above loop copied the dirty rect for this frame
498 // to update_rect. 493 // to update_rect.
499 gfx::Rect dirty_rect = tile->update_rect; 494 gfx::Rect dirty_rect = tile->update_rect;
500 if (dirty_rect.IsEmpty()) 495 if (dirty_rect.IsEmpty())
501 continue; 496 continue;
502 497
503 // Save what was painted opaque in the tile. Keep the old area if the
504 // paint didn't touch it, and didn't paint some other part of the tile
505 // opaque.
506 gfx::Rect tile_painted_rect = gfx::IntersectRects(tile_rect, paint_rect);
507 gfx::Rect tile_painted_opaque_rect =
508 gfx::IntersectRects(tile_rect, painted_opaque_rect);
509 if (!tile_painted_rect.IsEmpty()) {
510 gfx::Rect paint_inside_tile_opaque_rect =
511 gfx::IntersectRects(tile->opaque_rect(), tile_painted_rect);
512 bool paint_inside_tile_opaque_rect_is_non_opaque =
513 !paint_inside_tile_opaque_rect.IsEmpty() &&
514 !tile_painted_opaque_rect.Contains(paint_inside_tile_opaque_rect);
515 bool opaque_paint_not_inside_tile_opaque_rect =
516 !tile_painted_opaque_rect.IsEmpty() &&
517 !tile->opaque_rect().Contains(tile_painted_opaque_rect);
518
519 if (paint_inside_tile_opaque_rect_is_non_opaque ||
520 opaque_paint_not_inside_tile_opaque_rect)
521 tile->set_opaque_rect(tile_painted_opaque_rect);
522 }
523
524 // source_rect starts as a full-sized tile with border texels included. 498 // source_rect starts as a full-sized tile with border texels included.
525 gfx::Rect source_rect = tiler_->TileRect(tile); 499 gfx::Rect source_rect = tiler_->TileRect(tile);
526 source_rect.Intersect(dirty_rect); 500 source_rect.Intersect(dirty_rect);
527 // Paint rect not guaranteed to line up on tile boundaries, so 501 // Paint rect not guaranteed to line up on tile boundaries, so
528 // make sure that source_rect doesn't extend outside of it. 502 // make sure that source_rect doesn't extend outside of it.
529 source_rect.Intersect(paint_rect); 503 source_rect.Intersect(paint_rect);
530 504
531 tile->update_rect = source_rect; 505 tile->update_rect = source_rect;
532 506
533 if (source_rect.IsEmpty()) 507 if (source_rect.IsEmpty())
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 tile_rect, 610 tile_rect,
637 draws_to_root, 611 draws_to_root,
638 small_animated_layer, 612 small_animated_layer,
639 tile->managed_resource()); 613 tile->managed_resource());
640 } 614 }
641 } 615 }
642 616
643 SimpleEnclosedRegion TiledLayer::VisibleContentOpaqueRegion() const { 617 SimpleEnclosedRegion TiledLayer::VisibleContentOpaqueRegion() const {
644 if (skips_draw_) 618 if (skips_draw_)
645 return SimpleEnclosedRegion(); 619 return SimpleEnclosedRegion();
646 if (contents_opaque()) 620 return Layer::VisibleContentOpaqueRegion();
647 return SimpleEnclosedRegion(visible_content_rect());
648 return tiler_->OpaqueRegionInContentRect(visible_content_rect());
649 } 621 }
650 622
651 void TiledLayer::ResetUpdateState() { 623 void TiledLayer::ResetUpdateState() {
652 skips_draw_ = false; 624 skips_draw_ = false;
653 failed_update_ = false; 625 failed_update_ = false;
654 626
655 LayerTilingData::TileMap::const_iterator end = tiler_->tiles().end(); 627 LayerTilingData::TileMap::const_iterator end = tiler_->tiles().end();
656 for (LayerTilingData::TileMap::const_iterator iter = tiler_->tiles().begin(); 628 for (LayerTilingData::TileMap::const_iterator iter = tiler_->tiles().begin();
657 iter != end; 629 iter != end;
658 ++iter) { 630 ++iter) {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 gfx::Rect prepaint_rect = visible_content_rect(); 864 gfx::Rect prepaint_rect = visible_content_rect();
893 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, 865 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns,
894 -tiler_->tile_size().height() * kPrepaintRows); 866 -tiler_->tile_size().height() * kPrepaintRows);
895 gfx::Rect content_rect(content_bounds()); 867 gfx::Rect content_rect(content_bounds());
896 prepaint_rect.Intersect(content_rect); 868 prepaint_rect.Intersect(content_rect);
897 869
898 return prepaint_rect; 870 return prepaint_rect;
899 } 871 }
900 872
901 } // namespace cc 873 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_unittest.cc ('k') | cc/layers/tiled_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698