| 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" |
| 11 #include "cc/debug/debug_colors.h" | 11 #include "cc/debug/debug_colors.h" |
| 12 #include "cc/resources/picture_pile_impl.h" | 12 #include "cc/resources/picture_pile_impl.h" |
| 13 #include "cc/resources/raster_source_helper.h" | 13 #include "cc/resources/raster_source_helper.h" |
| 14 #include "skia/ext/analysis_canvas.h" | 14 #include "skia/ext/analysis_canvas.h" |
| 15 #include "third_party/skia/include/core/SkCanvas.h" | 15 #include "third_party/skia/include/core/SkCanvas.h" |
| 16 #include "third_party/skia/include/core/SkPictureRecorder.h" | 16 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 17 #include "ui/gfx/geometry/rect_conversions.h" | 17 #include "ui/gfx/geometry/rect_conversions.h" |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 | 20 |
| 21 scoped_refptr<PicturePileImpl> PicturePileImpl::CreateFromPicturePile( | 21 scoped_refptr<PicturePileImpl> PicturePileImpl::CreateFromPicturePile( |
| 22 const PicturePile* other) { | 22 const PicturePile* other, |
| 23 return make_scoped_refptr(new PicturePileImpl(other)); | 23 bool can_use_lcd_text) { |
| 24 return make_scoped_refptr(new PicturePileImpl(other, can_use_lcd_text)); |
| 24 } | 25 } |
| 25 | 26 |
| 26 PicturePileImpl::PicturePileImpl() | 27 PicturePileImpl::PicturePileImpl() |
| 27 : background_color_(SK_ColorTRANSPARENT), | 28 : background_color_(SK_ColorTRANSPARENT), |
| 28 requires_clear_(true), | 29 requires_clear_(true), |
| 29 can_use_lcd_text_(false), | 30 can_use_lcd_text_(true), |
| 30 is_solid_color_(false), | 31 is_solid_color_(false), |
| 31 solid_color_(SK_ColorTRANSPARENT), | 32 solid_color_(SK_ColorTRANSPARENT), |
| 32 has_any_recordings_(false), | 33 has_any_recordings_(false), |
| 33 clear_canvas_with_debug_color_(false), | 34 clear_canvas_with_debug_color_(false), |
| 34 min_contents_scale_(0.f), | 35 min_contents_scale_(0.f), |
| 35 slow_down_raster_scale_factor_for_debug_(0), | 36 slow_down_raster_scale_factor_for_debug_(0), |
| 36 should_attempt_to_use_distance_field_text_(false) { | 37 should_attempt_to_use_distance_field_text_(false) { |
| 37 } | 38 } |
| 38 | 39 |
| 39 PicturePileImpl::PicturePileImpl(const PicturePile* other) | 40 PicturePileImpl::PicturePileImpl(const PicturePile* other, |
| 41 bool can_use_lcd_text) |
| 40 : picture_map_(other->picture_map_), | 42 : picture_map_(other->picture_map_), |
| 41 tiling_(other->tiling_), | 43 tiling_(other->tiling_), |
| 42 background_color_(other->background_color_), | 44 background_color_(other->background_color_), |
| 43 requires_clear_(other->requires_clear_), | 45 requires_clear_(other->requires_clear_), |
| 44 can_use_lcd_text_(other->can_use_lcd_text_), | 46 can_use_lcd_text_(can_use_lcd_text), |
| 45 is_solid_color_(other->is_solid_color_), | 47 is_solid_color_(other->is_solid_color_), |
| 46 solid_color_(other->solid_color_), | 48 solid_color_(other->solid_color_), |
| 47 recorded_viewport_(other->recorded_viewport_), | 49 recorded_viewport_(other->recorded_viewport_), |
| 48 has_any_recordings_(other->has_any_recordings_), | 50 has_any_recordings_(other->has_any_recordings_), |
| 49 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), | 51 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), |
| 50 min_contents_scale_(other->min_contents_scale_), | 52 min_contents_scale_(other->min_contents_scale_), |
| 51 slow_down_raster_scale_factor_for_debug_( | 53 slow_down_raster_scale_factor_for_debug_( |
| 52 other->slow_down_raster_scale_factor_for_debug_), | 54 other->slow_down_raster_scale_factor_for_debug_), |
| 53 should_attempt_to_use_distance_field_text_(false) { | 55 should_attempt_to_use_distance_field_text_(false) { |
| 54 } | 56 } |
| 55 | 57 |
| 58 PicturePileImpl::PicturePileImpl(const PicturePileImpl* other, |
| 59 bool can_use_lcd_text) |
| 60 : picture_map_(other->picture_map_), |
| 61 tiling_(other->tiling_), |
| 62 background_color_(other->background_color_), |
| 63 requires_clear_(other->requires_clear_), |
| 64 can_use_lcd_text_(can_use_lcd_text), |
| 65 is_solid_color_(other->is_solid_color_), |
| 66 solid_color_(other->solid_color_), |
| 67 recorded_viewport_(other->recorded_viewport_), |
| 68 has_any_recordings_(other->has_any_recordings_), |
| 69 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), |
| 70 min_contents_scale_(other->min_contents_scale_), |
| 71 slow_down_raster_scale_factor_for_debug_( |
| 72 other->slow_down_raster_scale_factor_for_debug_), |
| 73 should_attempt_to_use_distance_field_text_( |
| 74 other->should_attempt_to_use_distance_field_text_) { |
| 75 } |
| 76 |
| 56 PicturePileImpl::~PicturePileImpl() { | 77 PicturePileImpl::~PicturePileImpl() { |
| 57 } | 78 } |
| 58 | 79 |
| 59 void PicturePileImpl::PlaybackToSharedCanvas(SkCanvas* canvas, | 80 void PicturePileImpl::PlaybackToSharedCanvas(SkCanvas* canvas, |
| 60 const gfx::Rect& canvas_rect, | 81 const gfx::Rect& canvas_rect, |
| 61 float contents_scale) const { | 82 float contents_scale) const { |
| 62 RasterCommon(canvas, | 83 RasterCommon(canvas, |
| 63 NULL, | 84 NULL, |
| 64 canvas_rect, | 85 canvas_rect, |
| 65 contents_scale, | 86 contents_scale, |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 appended_pictures.insert(picture); | 397 appended_pictures.insert(picture); |
| 377 TracedValue::AppendIDRef(picture, pictures); | 398 TracedValue::AppendIDRef(picture, pictures); |
| 378 } | 399 } |
| 379 } | 400 } |
| 380 } | 401 } |
| 381 | 402 |
| 382 bool PicturePileImpl::CanUseLCDText() const { | 403 bool PicturePileImpl::CanUseLCDText() const { |
| 383 return can_use_lcd_text_; | 404 return can_use_lcd_text_; |
| 384 } | 405 } |
| 385 | 406 |
| 407 scoped_refptr<RasterSource> PicturePileImpl::CreateCloneWithoutLCDText() const { |
| 408 DCHECK(CanUseLCDText()); |
| 409 bool can_use_lcd_text = false; |
| 410 return scoped_refptr<RasterSource>( |
| 411 new PicturePileImpl(this, can_use_lcd_text)); |
| 412 } |
| 413 |
| 386 PicturePileImpl::PixelRefIterator::PixelRefIterator( | 414 PicturePileImpl::PixelRefIterator::PixelRefIterator( |
| 387 const gfx::Rect& content_rect, | 415 const gfx::Rect& content_rect, |
| 388 float contents_scale, | 416 float contents_scale, |
| 389 const PicturePileImpl* picture_pile) | 417 const PicturePileImpl* picture_pile) |
| 390 : picture_pile_(picture_pile), | 418 : picture_pile_(picture_pile), |
| 391 layer_rect_( | 419 layer_rect_( |
| 392 gfx::ScaleToEnclosingRect(content_rect, 1.f / contents_scale)), | 420 gfx::ScaleToEnclosingRect(content_rect, 1.f / contents_scale)), |
| 393 tile_iterator_(&picture_pile_->tiling_, | 421 tile_iterator_(&picture_pile_->tiling_, |
| 394 layer_rect_, | 422 layer_rect_, |
| 395 false /* include_borders */) { | 423 false /* include_borders */) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 for (const auto& map_pair : picture_map_) { | 466 for (const auto& map_pair : picture_map_) { |
| 439 const Picture* picture = map_pair.second.GetPicture(); | 467 const Picture* picture = map_pair.second.GetPicture(); |
| 440 if (picture && (processed_pictures.count(picture) == 0)) { | 468 if (picture && (processed_pictures.count(picture) == 0)) { |
| 441 picture->EmitTraceSnapshot(); | 469 picture->EmitTraceSnapshot(); |
| 442 processed_pictures.insert(picture); | 470 processed_pictures.insert(picture); |
| 443 } | 471 } |
| 444 } | 472 } |
| 445 } | 473 } |
| 446 | 474 |
| 447 } // namespace cc | 475 } // namespace cc |
| OLD | NEW |