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 = 1 / draw_properties().contents_scale_x; | 465 float width_scale = |
466 float height_scale = 1 / draw_properties().contents_scale_y; | 466 paint_properties().bounds.width() / |
| 467 static_cast<float>(content_bounds().width()); |
| 468 float height_scale = |
| 469 paint_properties().bounds.height() / |
| 470 static_cast<float>(content_bounds().height()); |
467 update_rect_ = gfx::ScaleRect(update_rect, width_scale, height_scale); | 471 update_rect_ = gfx::ScaleRect(update_rect, width_scale, height_scale); |
468 | 472 |
469 // Calling PrepareToUpdate() calls into WebKit to paint, which may have the | 473 // Calling PrepareToUpdate() calls into WebKit to paint, which may have the |
470 // side effect of disabling compositing, which causes our reference to the | 474 // side effect of disabling compositing, which causes our reference to the |
471 // 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 |
472 // 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 |
473 // hold the updater alive until the paint completes. | 477 // hold the updater alive until the paint completes. |
474 scoped_refptr<LayerUpdater> protector(Updater()); | 478 scoped_refptr<LayerUpdater> protector(Updater()); |
475 Updater()->PrepareToUpdate(content_bounds(), | 479 Updater()->PrepareToUpdate( |
476 paint_rect, | 480 paint_rect, tiler_->tile_size(), 1.f / width_scale, 1.f / height_scale); |
477 tiler_->tile_size(), | |
478 1.f / width_scale, | |
479 1.f / height_scale); | |
480 | 481 |
481 for (int j = top; j <= bottom; ++j) { | 482 for (int j = top; j <= bottom; ++j) { |
482 for (int i = left; i <= right; ++i) { | 483 for (int i = left; i <= right; ++i) { |
483 UpdatableTile* tile = TileAt(i, j); | 484 UpdatableTile* tile = TileAt(i, j); |
484 DCHECK(tile); // Did SetTexturePriorites get skipped? | 485 DCHECK(tile); // Did SetTexturePriorites get skipped? |
485 // TODO(enne): This should not ever be null. | 486 // TODO(enne): This should not ever be null. |
486 if (!tile) | 487 if (!tile) |
487 continue; | 488 continue; |
488 | 489 |
489 gfx::Rect tile_rect = tiler_->tile_bounds(i, j); | 490 gfx::Rect tile_rect = tiler_->tile_bounds(i, j); |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 gfx::Rect prepaint_rect = visible_content_rect(); | 864 gfx::Rect prepaint_rect = visible_content_rect(); |
864 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, | 865 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, |
865 -tiler_->tile_size().height() * kPrepaintRows); | 866 -tiler_->tile_size().height() * kPrepaintRows); |
866 gfx::Rect content_rect(content_bounds()); | 867 gfx::Rect content_rect(content_bounds()); |
867 prepaint_rect.Intersect(content_rect); | 868 prepaint_rect.Intersect(content_rect); |
868 | 869 |
869 return prepaint_rect; | 870 return prepaint_rect; |
870 } | 871 } |
871 | 872 |
872 } // namespace cc | 873 } // namespace cc |
OLD | NEW |