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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // | 110 // |
111 // For example, if a 1/4 contents scale is used, then that would be 3 buffer | 111 // For example, if a 1/4 contents scale is used, then that would be 3 buffer |
112 // pixels, since that's the minimum number of pixels to add so that resulting | 112 // pixels, since that's the minimum number of pixels to add so that resulting |
113 // content can be snapped to a four pixel aligned grid. | 113 // content can be snapped to a four pixel aligned grid. |
114 int buffer_pixels = static_cast<int>(ceil(1 / min_contents_scale) - 1); | 114 int buffer_pixels = static_cast<int>(ceil(1 / min_contents_scale) - 1); |
115 buffer_pixels = std::max(0, buffer_pixels); | 115 buffer_pixels = std::max(0, buffer_pixels); |
116 SetBufferPixels(buffer_pixels); | 116 SetBufferPixels(buffer_pixels); |
117 min_contents_scale_ = min_contents_scale; | 117 min_contents_scale_ = min_contents_scale; |
118 } | 118 } |
119 | 119 |
120 void PicturePileBase::SetTileGridSize(const gfx::Size& tile_grid_size) { | 120 void PicturePileBase::SetTileGridSize(gfx::Size tile_grid_size) { |
121 tile_grid_info_.fTileInterval.set( | 121 tile_grid_info_.fTileInterval.set( |
122 tile_grid_size.width() - 2 * kTileGridBorderPixels, | 122 tile_grid_size.width() - 2 * kTileGridBorderPixels, |
123 tile_grid_size.height() - 2 * kTileGridBorderPixels); | 123 tile_grid_size.height() - 2 * kTileGridBorderPixels); |
124 DCHECK_GT(tile_grid_info_.fTileInterval.width(), 0); | 124 DCHECK_GT(tile_grid_info_.fTileInterval.width(), 0); |
125 DCHECK_GT(tile_grid_info_.fTileInterval.height(), 0); | 125 DCHECK_GT(tile_grid_info_.fTileInterval.height(), 0); |
126 tile_grid_info_.fMargin.set(kTileGridBorderPixels, | 126 tile_grid_info_.fMargin.set(kTileGridBorderPixels, |
127 kTileGridBorderPixels); | 127 kTileGridBorderPixels); |
128 // Offset the tile grid coordinate space to take into account the fact | 128 // Offset the tile grid coordinate space to take into account the fact |
129 // that the top-most and left-most tiles do not have top and left borders | 129 // that the top-most and left-most tiles do not have top and left borders |
130 // respectively. | 130 // respectively. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 bool PicturePileBase::CanRaster(float contents_scale, gfx::Rect content_rect) { | 167 bool PicturePileBase::CanRaster(float contents_scale, gfx::Rect content_rect) { |
168 if (tiling_.total_size().IsEmpty()) | 168 if (tiling_.total_size().IsEmpty()) |
169 return false; | 169 return false; |
170 gfx::Rect layer_rect = gfx::ToEnclosingRect( | 170 gfx::Rect layer_rect = gfx::ToEnclosingRect( |
171 gfx::ScaleRect(content_rect, 1.f / contents_scale)); | 171 gfx::ScaleRect(content_rect, 1.f / contents_scale)); |
172 layer_rect.Intersect(gfx::Rect(tiling_.total_size())); | 172 layer_rect.Intersect(gfx::Rect(tiling_.total_size())); |
173 return recorded_region_.Contains(layer_rect); | 173 return recorded_region_.Contains(layer_rect); |
174 } | 174 } |
175 | 175 |
176 } // namespace cc | 176 } // namespace cc |
OLD | NEW |