| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/resources/picture_pile_base.h" | 5 #include "cc/resources/picture_pile_base.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 for (PictureMap::const_iterator it = other->picture_map_.begin(); | 80 for (PictureMap::const_iterator it = other->picture_map_.begin(); |
| 81 it != other->picture_map_.end(); | 81 it != other->picture_map_.end(); |
| 82 ++it) { | 82 ++it) { |
| 83 picture_map_[it->first] = it->second.CloneForThread(thread_index); | 83 picture_map_[it->first] = it->second.CloneForThread(thread_index); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 PicturePileBase::~PicturePileBase() { | 87 PicturePileBase::~PicturePileBase() { |
| 88 } | 88 } |
| 89 | 89 |
| 90 void PicturePileBase::Resize(const gfx::Size& new_size) { | 90 void PicturePileBase::Resize(gfx::Size new_size) { |
| 91 if (size() == new_size) | 91 if (size() == new_size) |
| 92 return; | 92 return; |
| 93 | 93 |
| 94 gfx::Size old_size = size(); | 94 gfx::Size old_size = size(); |
| 95 tiling_.SetTotalSize(new_size); | 95 tiling_.SetTotalSize(new_size); |
| 96 | 96 |
| 97 // Find all tiles that contain any pixels outside the new size. | 97 // Find all tiles that contain any pixels outside the new size. |
| 98 std::vector<PictureMapKey> to_erase; | 98 std::vector<PictureMapKey> to_erase; |
| 99 int min_toss_x = tiling_.FirstBorderTileXIndexFromSrcCoord( | 99 int min_toss_x = tiling_.FirstBorderTileXIndexFromSrcCoord( |
| 100 std::min(old_size.width(), new_size.width())); | 100 std::min(old_size.width(), new_size.width())); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 129 // pixels, since that's the minimum number of pixels to add so that resulting | 129 // pixels, since that's the minimum number of pixels to add so that resulting |
| 130 // content can be snapped to a four pixel aligned grid. | 130 // content can be snapped to a four pixel aligned grid. |
| 131 int buffer_pixels = static_cast<int>(ceil(1 / min_contents_scale) - 1); | 131 int buffer_pixels = static_cast<int>(ceil(1 / min_contents_scale) - 1); |
| 132 buffer_pixels = std::max(0, buffer_pixels); | 132 buffer_pixels = std::max(0, buffer_pixels); |
| 133 SetBufferPixels(buffer_pixels); | 133 SetBufferPixels(buffer_pixels); |
| 134 min_contents_scale_ = min_contents_scale; | 134 min_contents_scale_ = min_contents_scale; |
| 135 } | 135 } |
| 136 | 136 |
| 137 // static | 137 // static |
| 138 void PicturePileBase::ComputeTileGridInfo( | 138 void PicturePileBase::ComputeTileGridInfo( |
| 139 const gfx::Size& tile_grid_size, | 139 gfx::Size tile_grid_size, |
| 140 SkTileGridPicture::TileGridInfo* info) { | 140 SkTileGridPicture::TileGridInfo* info) { |
| 141 DCHECK(info); | 141 DCHECK(info); |
| 142 info->fTileInterval.set(tile_grid_size.width() - 2 * kTileGridBorderPixels, | 142 info->fTileInterval.set(tile_grid_size.width() - 2 * kTileGridBorderPixels, |
| 143 tile_grid_size.height() - 2 * kTileGridBorderPixels); | 143 tile_grid_size.height() - 2 * kTileGridBorderPixels); |
| 144 DCHECK_GT(info->fTileInterval.width(), 0); | 144 DCHECK_GT(info->fTileInterval.width(), 0); |
| 145 DCHECK_GT(info->fTileInterval.height(), 0); | 145 DCHECK_GT(info->fTileInterval.height(), 0); |
| 146 info->fMargin.set(kTileGridBorderPixels, kTileGridBorderPixels); | 146 info->fMargin.set(kTileGridBorderPixels, kTileGridBorderPixels); |
| 147 // Offset the tile grid coordinate space to take into account the fact | 147 // Offset the tile grid coordinate space to take into account the fact |
| 148 // that the top-most and left-most tiles do not have top and left borders | 148 // that the top-most and left-most tiles do not have top and left borders |
| 149 // respectively. | 149 // respectively. |
| 150 info->fOffset.set(-kTileGridBorderPixels, -kTileGridBorderPixels); | 150 info->fOffset.set(-kTileGridBorderPixels, -kTileGridBorderPixels); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void PicturePileBase::SetTileGridSize(const gfx::Size& tile_grid_size) { | 153 void PicturePileBase::SetTileGridSize(gfx::Size tile_grid_size) { |
| 154 ComputeTileGridInfo(tile_grid_size, &tile_grid_info_); | 154 ComputeTileGridInfo(tile_grid_size, &tile_grid_info_); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void PicturePileBase::SetBufferPixels(int new_buffer_pixels) { | 157 void PicturePileBase::SetBufferPixels(int new_buffer_pixels) { |
| 158 if (new_buffer_pixels == buffer_pixels()) | 158 if (new_buffer_pixels == buffer_pixels()) |
| 159 return; | 159 return; |
| 160 | 160 |
| 161 Clear(); | 161 Clear(); |
| 162 tiling_.SetBorderTexels(new_buffer_pixels); | 162 tiling_.SetBorderTexels(new_buffer_pixels); |
| 163 } | 163 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 info.picture_ = picture_->GetCloneForDrawingOnThread(thread_index); | 277 info.picture_ = picture_->GetCloneForDrawingOnThread(thread_index); |
| 278 return info; | 278 return info; |
| 279 } | 279 } |
| 280 | 280 |
| 281 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { | 281 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { |
| 282 return invalidation_history_.count() / | 282 return invalidation_history_.count() / |
| 283 static_cast<float>(INVALIDATION_FRAMES_TRACKED); | 283 static_cast<float>(INVALIDATION_FRAMES_TRACKED); |
| 284 } | 284 } |
| 285 | 285 |
| 286 } // namespace cc | 286 } // namespace cc |
| OLD | NEW |