OLD | NEW |
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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 void TiledLayer::UpdateTileTextures(const gfx::Rect& update_rect, | 455 void TiledLayer::UpdateTileTextures(const gfx::Rect& update_rect, |
456 const gfx::Rect& paint_rect, | 456 const gfx::Rect& paint_rect, |
457 int left, | 457 int left, |
458 int top, | 458 int top, |
459 int right, | 459 int right, |
460 int bottom, | 460 int bottom, |
461 ResourceUpdateQueue* queue, | 461 ResourceUpdateQueue* queue, |
462 const OcclusionTracker<Layer>* occlusion) { | 462 const OcclusionTracker<Layer>* occlusion) { |
463 // The update_rect should be in layer space. So we have to convert the | 463 // The update_rect should be in layer space. So we have to convert the |
464 // paint_rect from content space to layer space. | 464 // paint_rect from content space to layer space. |
465 float width_scale = | 465 float width_scale = 1 / draw_properties().contents_scale_x; |
466 paint_properties().bounds.width() / | 466 float height_scale = 1 / draw_properties().contents_scale_y; |
467 static_cast<float>(content_bounds().width()); | |
468 float height_scale = | |
469 paint_properties().bounds.height() / | |
470 static_cast<float>(content_bounds().height()); | |
471 update_rect_ = gfx::ScaleRect(update_rect, width_scale, height_scale); | 467 update_rect_ = gfx::ScaleRect(update_rect, width_scale, height_scale); |
472 | 468 |
473 // Calling PrepareToUpdate() calls into WebKit to paint, which may have the | 469 // Calling PrepareToUpdate() calls into WebKit to paint, which may have the |
474 // side effect of disabling compositing, which causes our reference to the | 470 // side effect of disabling compositing, which causes our reference to the |
475 // texture updater to be deleted. However, we can't free the memory backing | 471 // texture updater to be deleted. However, we can't free the memory backing |
476 // the SkCanvas until the paint finishes, so we grab a local reference here to | 472 // the SkCanvas until the paint finishes, so we grab a local reference here to |
477 // hold the updater alive until the paint completes. | 473 // hold the updater alive until the paint completes. |
478 scoped_refptr<LayerUpdater> protector(Updater()); | 474 scoped_refptr<LayerUpdater> protector(Updater()); |
479 Updater()->PrepareToUpdate( | 475 Updater()->PrepareToUpdate(content_bounds(), |
480 paint_rect, tiler_->tile_size(), 1.f / width_scale, 1.f / height_scale); | 476 paint_rect, |
| 477 tiler_->tile_size(), |
| 478 1.f / width_scale, |
| 479 1.f / height_scale); |
481 | 480 |
482 for (int j = top; j <= bottom; ++j) { | 481 for (int j = top; j <= bottom; ++j) { |
483 for (int i = left; i <= right; ++i) { | 482 for (int i = left; i <= right; ++i) { |
484 UpdatableTile* tile = TileAt(i, j); | 483 UpdatableTile* tile = TileAt(i, j); |
485 DCHECK(tile); // Did SetTexturePriorites get skipped? | 484 DCHECK(tile); // Did SetTexturePriorites get skipped? |
486 // TODO(enne): This should not ever be null. | 485 // TODO(enne): This should not ever be null. |
487 if (!tile) | 486 if (!tile) |
488 continue; | 487 continue; |
489 | 488 |
490 gfx::Rect tile_rect = tiler_->tile_bounds(i, j); | 489 gfx::Rect tile_rect = tiler_->tile_bounds(i, j); |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 gfx::Rect prepaint_rect = visible_content_rect(); | 863 gfx::Rect prepaint_rect = visible_content_rect(); |
865 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, | 864 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, |
866 -tiler_->tile_size().height() * kPrepaintRows); | 865 -tiler_->tile_size().height() * kPrepaintRows); |
867 gfx::Rect content_rect(content_bounds()); | 866 gfx::Rect content_rect(content_bounds()); |
868 prepaint_rect.Intersect(content_rect); | 867 prepaint_rect.Intersect(content_rect); |
869 | 868 |
870 return prepaint_rect; | 869 return prepaint_rect; |
871 } | 870 } |
872 | 871 |
873 } // namespace cc | 872 } // namespace cc |
OLD | NEW |