OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_layer_tiling_set.h" | 5 #include "cc/resources/picture_layer_tiling_set.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 namespace cc { | 9 namespace cc { |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 class LargestToSmallestScaleFunctor { | 13 class LargestToSmallestScaleFunctor { |
14 public: | 14 public: |
15 bool operator() (PictureLayerTiling* left, PictureLayerTiling* right) { | 15 bool operator() (PictureLayerTiling* left, PictureLayerTiling* right) { |
16 return left->contents_scale() > right->contents_scale(); | 16 return left->contents_scale() > right->contents_scale(); |
17 } | 17 } |
18 }; | 18 }; |
19 | 19 |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 | 22 |
23 PictureLayerTilingSet::PictureLayerTilingSet( | 23 PictureLayerTilingSet::PictureLayerTilingSet( |
24 PictureLayerTilingClient* client, | 24 PictureLayerTilingClient* client, |
25 const gfx::Size& layer_bounds) | 25 gfx::Size layer_bounds) |
26 : client_(client), | 26 : client_(client), |
27 layer_bounds_(layer_bounds) { | 27 layer_bounds_(layer_bounds) { |
28 } | 28 } |
29 | 29 |
30 PictureLayerTilingSet::~PictureLayerTilingSet() { | 30 PictureLayerTilingSet::~PictureLayerTilingSet() { |
31 } | 31 } |
32 | 32 |
33 void PictureLayerTilingSet::SetClient(PictureLayerTilingClient* client) { | 33 void PictureLayerTilingSet::SetClient(PictureLayerTilingClient* client) { |
34 client_ = client; | 34 client_ = client; |
35 for (size_t i = 0; i < tilings_.size(); ++i) | 35 for (size_t i = 0; i < tilings_.size(); ++i) |
36 tilings_[i]->SetClient(client_); | 36 tilings_[i]->SetClient(client_); |
37 } | 37 } |
38 | 38 |
39 void PictureLayerTilingSet::SyncTilings( | 39 void PictureLayerTilingSet::SyncTilings( |
40 const PictureLayerTilingSet& other, | 40 const PictureLayerTilingSet& other, |
41 const gfx::Size& new_layer_bounds, | 41 gfx::Size new_layer_bounds, |
42 const Region& layer_invalidation, | 42 const Region& layer_invalidation, |
43 float minimum_contents_scale) { | 43 float minimum_contents_scale) { |
44 if (new_layer_bounds.IsEmpty()) { | 44 if (new_layer_bounds.IsEmpty()) { |
45 RemoveAllTilings(); | 45 RemoveAllTilings(); |
46 layer_bounds_ = new_layer_bounds; | 46 layer_bounds_ = new_layer_bounds; |
47 return; | 47 return; |
48 } | 48 } |
49 | 49 |
50 tilings_.reserve(other.tilings_.size()); | 50 tilings_.reserve(other.tilings_.size()); |
51 | 51 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 return *this; | 296 return *this; |
297 } | 297 } |
298 | 298 |
299 PictureLayerTilingSet::CoverageIterator::operator bool() const { | 299 PictureLayerTilingSet::CoverageIterator::operator bool() const { |
300 return current_tiling_ < static_cast<int>(set_->tilings_.size()) || | 300 return current_tiling_ < static_cast<int>(set_->tilings_.size()) || |
301 region_iter_.has_rect(); | 301 region_iter_.has_rect(); |
302 } | 302 } |
303 | 303 |
304 void PictureLayerTilingSet::UpdateTilePriorities( | 304 void PictureLayerTilingSet::UpdateTilePriorities( |
305 WhichTree tree, | 305 WhichTree tree, |
306 const gfx::Size& device_viewport, | 306 gfx::Size device_viewport, |
307 const gfx::Rect& viewport_in_content_space, | 307 const gfx::Rect& viewport_in_content_space, |
308 const gfx::Rect& visible_content_rect, | 308 const gfx::Rect& visible_content_rect, |
309 const gfx::Size& last_layer_bounds, | 309 gfx::Size last_layer_bounds, |
310 const gfx::Size& current_layer_bounds, | 310 gfx::Size current_layer_bounds, |
311 float last_layer_contents_scale, | 311 float last_layer_contents_scale, |
312 float current_layer_contents_scale, | 312 float current_layer_contents_scale, |
313 const gfx::Transform& last_screen_transform, | 313 const gfx::Transform& last_screen_transform, |
314 const gfx::Transform& current_screen_transform, | 314 const gfx::Transform& current_screen_transform, |
315 double current_frame_time_in_seconds, | 315 double current_frame_time_in_seconds, |
316 size_t max_tiles_for_interest_area) { | 316 size_t max_tiles_for_interest_area) { |
317 gfx::Rect viewport_in_layer_space = gfx::ScaleToEnclosingRect( | 317 gfx::Rect viewport_in_layer_space = gfx::ScaleToEnclosingRect( |
318 viewport_in_content_space, | 318 viewport_in_content_space, |
319 1.f / current_layer_contents_scale); | 319 1.f / current_layer_contents_scale); |
320 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( | 320 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } | 356 } |
357 | 357 |
358 size_t PictureLayerTilingSet::GPUMemoryUsageInBytes() const { | 358 size_t PictureLayerTilingSet::GPUMemoryUsageInBytes() const { |
359 size_t amount = 0; | 359 size_t amount = 0; |
360 for (size_t i = 0; i < tilings_.size(); ++i) | 360 for (size_t i = 0; i < tilings_.size(); ++i) |
361 amount += tilings_[i]->GPUMemoryUsageInBytes(); | 361 amount += tilings_[i]->GPUMemoryUsageInBytes(); |
362 return amount; | 362 return amount; |
363 } | 363 } |
364 | 364 |
365 } // namespace cc | 365 } // namespace cc |
OLD | NEW |