| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // | 121 // |
| 122 // For example, if a 1/4 contents scale is used, then that would be 3 buffer | 122 // For example, if a 1/4 contents scale is used, then that would be 3 buffer |
| 123 // pixels, since that's the minimum number of pixels to add so that resulting | 123 // pixels, since that's the minimum number of pixels to add so that resulting |
| 124 // content can be snapped to a four pixel aligned grid. | 124 // content can be snapped to a four pixel aligned grid. |
| 125 int buffer_pixels = static_cast<int>(ceil(1 / min_contents_scale) - 1); | 125 int buffer_pixels = static_cast<int>(ceil(1 / min_contents_scale) - 1); |
| 126 buffer_pixels = std::max(0, buffer_pixels); | 126 buffer_pixels = std::max(0, buffer_pixels); |
| 127 SetBufferPixels(buffer_pixels); | 127 SetBufferPixels(buffer_pixels); |
| 128 min_contents_scale_ = min_contents_scale; | 128 min_contents_scale_ = min_contents_scale; |
| 129 } | 129 } |
| 130 | 130 |
| 131 void PicturePileBase::SetTileGridSize(gfx::Size tile_grid_size) { | 131 // static |
| 132 tile_grid_info_.fTileInterval.set( | 132 void PicturePileBase::ComputeTileGridInfo( |
| 133 tile_grid_size.width() - 2 * kTileGridBorderPixels, | 133 gfx::Size tile_grid_size, |
| 134 tile_grid_size.height() - 2 * kTileGridBorderPixels); | 134 SkTileGridPicture::TileGridInfo* info) { |
| 135 DCHECK_GT(tile_grid_info_.fTileInterval.width(), 0); | 135 DCHECK(info); |
| 136 DCHECK_GT(tile_grid_info_.fTileInterval.height(), 0); | 136 info->fTileInterval.set(tile_grid_size.width() - 2 * kTileGridBorderPixels, |
| 137 tile_grid_info_.fMargin.set(kTileGridBorderPixels, | 137 tile_grid_size.height() - 2 * kTileGridBorderPixels); |
| 138 kTileGridBorderPixels); | 138 DCHECK_GT(info->fTileInterval.width(), 0); |
| 139 DCHECK_GT(info->fTileInterval.height(), 0); |
| 140 info->fMargin.set(kTileGridBorderPixels, kTileGridBorderPixels); |
| 139 // Offset the tile grid coordinate space to take into account the fact | 141 // Offset the tile grid coordinate space to take into account the fact |
| 140 // that the top-most and left-most tiles do not have top and left borders | 142 // that the top-most and left-most tiles do not have top and left borders |
| 141 // respectively. | 143 // respectively. |
| 142 tile_grid_info_.fOffset.set(-kTileGridBorderPixels, | 144 info->fOffset.set(-kTileGridBorderPixels, -kTileGridBorderPixels); |
| 143 -kTileGridBorderPixels); | 145 } |
| 146 |
| 147 void PicturePileBase::SetTileGridSize(gfx::Size tile_grid_size) { |
| 148 ComputeTileGridInfo(tile_grid_size, &tile_grid_info_); |
| 144 } | 149 } |
| 145 | 150 |
| 146 void PicturePileBase::SetBufferPixels(int new_buffer_pixels) { | 151 void PicturePileBase::SetBufferPixels(int new_buffer_pixels) { |
| 147 if (new_buffer_pixels == buffer_pixels()) | 152 if (new_buffer_pixels == buffer_pixels()) |
| 148 return; | 153 return; |
| 149 | 154 |
| 150 Clear(); | 155 Clear(); |
| 151 tiling_.SetBorderTexels(new_buffer_pixels); | 156 tiling_.SetBorderTexels(new_buffer_pixels); |
| 152 } | 157 } |
| 153 | 158 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 227 |
| 223 PicturePileBase::PictureInfo PicturePileBase::PictureInfo::CloneForThread( | 228 PicturePileBase::PictureInfo PicturePileBase::PictureInfo::CloneForThread( |
| 224 int thread_index) const { | 229 int thread_index) const { |
| 225 PictureInfo info = *this; | 230 PictureInfo info = *this; |
| 226 if (picture.get()) | 231 if (picture.get()) |
| 227 info.picture = picture->GetCloneForDrawingOnThread(thread_index); | 232 info.picture = picture->GetCloneForDrawingOnThread(thread_index); |
| 228 return info; | 233 return info; |
| 229 } | 234 } |
| 230 | 235 |
| 231 } // namespace cc | 236 } // namespace cc |
| OLD | NEW |