| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <limits> | 6 #include <limits> |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "cc/base/region.h" | 10 #include "cc/base/region.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 layer_rect.Intersect(gfx::Rect(tiling_.tiling_size())); | 292 layer_rect.Intersect(gfx::Rect(tiling_.tiling_size())); |
| 293 | 293 |
| 294 skia::AnalysisCanvas canvas(layer_rect.width(), layer_rect.height()); | 294 skia::AnalysisCanvas canvas(layer_rect.width(), layer_rect.height()); |
| 295 | 295 |
| 296 RasterForAnalysis(&canvas, layer_rect, 1.0f); | 296 RasterForAnalysis(&canvas, layer_rect, 1.0f); |
| 297 | 297 |
| 298 analysis->is_solid_color = canvas.GetColorIfSolid(&analysis->solid_color); | 298 analysis->is_solid_color = canvas.GetColorIfSolid(&analysis->solid_color); |
| 299 } | 299 } |
| 300 | 300 |
| 301 void PicturePileImpl::GatherPixelRefs( | 301 void PicturePileImpl::GatherPixelRefs( |
| 302 const gfx::Rect& content_rect, | 302 const gfx::Rect& layer_rect, |
| 303 float contents_scale, | |
| 304 std::vector<skia::PositionPixelRef>* pixel_refs) const { | 303 std::vector<skia::PositionPixelRef>* pixel_refs) const { |
| 305 DCHECK_EQ(0u, pixel_refs->size()); | 304 DCHECK_EQ(0u, pixel_refs->size()); |
| 306 for (PixelRefIterator iter(content_rect, contents_scale, this); iter; | 305 for (PixelRefIterator iter(layer_rect, this); iter; ++iter) { |
| 307 ++iter) { | |
| 308 pixel_refs->push_back(*iter); | 306 pixel_refs->push_back(*iter); |
| 309 } | 307 } |
| 310 } | 308 } |
| 311 | 309 |
| 312 bool PicturePileImpl::CoversRect(const gfx::Rect& content_rect, | 310 bool PicturePileImpl::CoversRect(const gfx::Rect& layer_rect) const { |
| 313 float contents_scale) const { | |
| 314 if (tiling_.tiling_size().IsEmpty()) | 311 if (tiling_.tiling_size().IsEmpty()) |
| 315 return false; | 312 return false; |
| 316 gfx::Rect layer_rect = | 313 gfx::Rect bounded_rect = layer_rect; |
| 317 gfx::ScaleToEnclosingRect(content_rect, 1.f / contents_scale); | 314 bounded_rect.Intersect(gfx::Rect(tiling_.tiling_size())); |
| 318 layer_rect.Intersect(gfx::Rect(tiling_.tiling_size())); | |
| 319 | 315 |
| 320 // Common case inside of viewport to avoid the slower map lookups. | 316 // Common case inside of viewport to avoid the slower map lookups. |
| 321 if (recorded_viewport_.Contains(layer_rect)) { | 317 if (recorded_viewport_.Contains(bounded_rect)) { |
| 322 // Sanity check that there are no false positives in recorded_viewport_. | 318 // Sanity check that there are no false positives in recorded_viewport_. |
| 323 DCHECK(CanRasterSlowTileCheck(layer_rect)); | 319 DCHECK(CanRasterSlowTileCheck(bounded_rect)); |
| 324 return true; | 320 return true; |
| 325 } | 321 } |
| 326 | 322 |
| 327 return CanRasterSlowTileCheck(layer_rect); | 323 return CanRasterSlowTileCheck(bounded_rect); |
| 328 } | 324 } |
| 329 | 325 |
| 330 gfx::Size PicturePileImpl::GetSize() const { | 326 gfx::Size PicturePileImpl::GetSize() const { |
| 331 return tiling_.tiling_size(); | 327 return tiling_.tiling_size(); |
| 332 } | 328 } |
| 333 | 329 |
| 334 bool PicturePileImpl::IsSolidColor() const { | 330 bool PicturePileImpl::IsSolidColor() const { |
| 335 return is_solid_color_; | 331 return is_solid_color_; |
| 336 } | 332 } |
| 337 | 333 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 } | 391 } |
| 396 | 392 |
| 397 scoped_refptr<RasterSource> PicturePileImpl::CreateCloneWithoutLCDText() const { | 393 scoped_refptr<RasterSource> PicturePileImpl::CreateCloneWithoutLCDText() const { |
| 398 DCHECK(CanUseLCDText()); | 394 DCHECK(CanUseLCDText()); |
| 399 bool can_use_lcd_text = false; | 395 bool can_use_lcd_text = false; |
| 400 return scoped_refptr<RasterSource>( | 396 return scoped_refptr<RasterSource>( |
| 401 new PicturePileImpl(this, can_use_lcd_text)); | 397 new PicturePileImpl(this, can_use_lcd_text)); |
| 402 } | 398 } |
| 403 | 399 |
| 404 PicturePileImpl::PixelRefIterator::PixelRefIterator( | 400 PicturePileImpl::PixelRefIterator::PixelRefIterator( |
| 405 const gfx::Rect& content_rect, | 401 const gfx::Rect& layer_rect, |
| 406 float contents_scale, | |
| 407 const PicturePileImpl* picture_pile) | 402 const PicturePileImpl* picture_pile) |
| 408 : picture_pile_(picture_pile), | 403 : picture_pile_(picture_pile), |
| 409 layer_rect_( | 404 layer_rect_(layer_rect), |
| 410 gfx::ScaleToEnclosingRect(content_rect, 1.f / contents_scale)), | |
| 411 tile_iterator_(&picture_pile_->tiling_, | 405 tile_iterator_(&picture_pile_->tiling_, |
| 412 layer_rect_, | 406 layer_rect_, |
| 413 false /* include_borders */) { | 407 false /* include_borders */) { |
| 414 // Early out if there isn't a single tile. | 408 // Early out if there isn't a single tile. |
| 415 if (!tile_iterator_) | 409 if (!tile_iterator_) |
| 416 return; | 410 return; |
| 417 | 411 |
| 418 AdvanceToTilePictureWithPixelRefs(); | 412 AdvanceToTilePictureWithPixelRefs(); |
| 419 } | 413 } |
| 420 | 414 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 for (const auto& map_pair : picture_map_) { | 450 for (const auto& map_pair : picture_map_) { |
| 457 const Picture* picture = map_pair.second.get(); | 451 const Picture* picture = map_pair.second.get(); |
| 458 if (processed_pictures.count(picture) == 0) { | 452 if (processed_pictures.count(picture) == 0) { |
| 459 picture->EmitTraceSnapshot(); | 453 picture->EmitTraceSnapshot(); |
| 460 processed_pictures.insert(picture); | 454 processed_pictures.insert(picture); |
| 461 } | 455 } |
| 462 } | 456 } |
| 463 } | 457 } |
| 464 | 458 |
| 465 } // namespace cc | 459 } // namespace cc |
| OLD | NEW |