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 { | |
20 | |
21 #ifdef NDEBUG | |
22 const bool kDefaultClearCanvasSetting = false; | |
23 #else | |
24 const bool kDefaultClearCanvasSetting = true; | |
25 #endif | |
26 | |
27 } // namespace | |
28 | |
29 namespace cc { | 19 namespace cc { |
30 | 20 |
31 scoped_refptr<PicturePileImpl> PicturePileImpl::CreateFromPicturePile( | 21 scoped_refptr<PicturePileImpl> PicturePileImpl::CreateFromPicturePile( |
32 const PicturePile* other) { | 22 const PicturePile* other) { |
33 return make_scoped_refptr(new PicturePileImpl(other)); | 23 return make_scoped_refptr(new PicturePileImpl(other)); |
34 } | 24 } |
35 | 25 |
36 PicturePileImpl::PicturePileImpl() | 26 PicturePileImpl::PicturePileImpl() |
37 : background_color_(SK_ColorTRANSPARENT), | 27 : background_color_(SK_ColorTRANSPARENT), |
38 requires_clear_(true), | 28 requires_clear_(true), |
39 can_use_lcd_text_(false), | 29 can_use_lcd_text_(false), |
40 is_solid_color_(false), | 30 is_solid_color_(false), |
41 solid_color_(SK_ColorTRANSPARENT), | 31 solid_color_(SK_ColorTRANSPARENT), |
42 has_any_recordings_(false), | 32 has_any_recordings_(false), |
43 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), | 33 clear_canvas_with_debug_color_(false), |
44 min_contents_scale_(0.f), | 34 min_contents_scale_(0.f), |
45 slow_down_raster_scale_factor_for_debug_(0), | 35 slow_down_raster_scale_factor_for_debug_(0), |
46 should_attempt_to_use_distance_field_text_(false) { | 36 should_attempt_to_use_distance_field_text_(false) { |
47 } | 37 } |
48 | 38 |
49 PicturePileImpl::PicturePileImpl(const PicturePile* other) | 39 PicturePileImpl::PicturePileImpl(const PicturePile* other) |
50 : picture_map_(other->picture_map_), | 40 : picture_map_(other->picture_map_), |
51 tiling_(other->tiling_), | 41 tiling_(other->tiling_), |
52 background_color_(SK_ColorTRANSPARENT), | 42 background_color_(other->background_color_), |
53 requires_clear_(true), | 43 requires_clear_(other->requires_clear_), |
54 can_use_lcd_text_(other->can_use_lcd_text_), | 44 can_use_lcd_text_(other->can_use_lcd_text_), |
55 is_solid_color_(other->is_solid_color_), | 45 is_solid_color_(other->is_solid_color_), |
56 solid_color_(other->solid_color_), | 46 solid_color_(other->solid_color_), |
57 recorded_viewport_(other->recorded_viewport_), | 47 recorded_viewport_(other->recorded_viewport_), |
58 has_any_recordings_(other->has_any_recordings_), | 48 has_any_recordings_(other->has_any_recordings_), |
59 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), | 49 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), |
60 min_contents_scale_(other->min_contents_scale_), | 50 min_contents_scale_(other->min_contents_scale_), |
61 slow_down_raster_scale_factor_for_debug_( | 51 slow_down_raster_scale_factor_for_debug_( |
62 other->slow_down_raster_scale_factor_for_debug_), | 52 other->slow_down_raster_scale_factor_for_debug_), |
63 should_attempt_to_use_distance_field_text_(false) { | 53 should_attempt_to_use_distance_field_text_(false) { |
64 } | 54 } |
65 | 55 |
66 PicturePileImpl::~PicturePileImpl() { | 56 PicturePileImpl::~PicturePileImpl() { |
67 } | 57 } |
68 | 58 |
69 void PicturePileImpl::PlaybackToSharedCanvas(SkCanvas* canvas, | 59 void PicturePileImpl::PlaybackToSharedCanvas(SkCanvas* canvas, |
(...skipping 11 matching lines...) Expand all Loading... |
81 float contents_scale) const { | 71 float contents_scale) const { |
82 RasterCommon(canvas, canvas, canvas_rect, contents_scale, true); | 72 RasterCommon(canvas, canvas, canvas_rect, contents_scale, true); |
83 } | 73 } |
84 | 74 |
85 void PicturePileImpl::PlaybackToCanvas(SkCanvas* canvas, | 75 void PicturePileImpl::PlaybackToCanvas(SkCanvas* canvas, |
86 const gfx::Rect& canvas_rect, | 76 const gfx::Rect& canvas_rect, |
87 float contents_scale) const { | 77 float contents_scale) const { |
88 RasterSourceHelper::PrepareForPlaybackToCanvas( | 78 RasterSourceHelper::PrepareForPlaybackToCanvas( |
89 canvas, canvas_rect, gfx::Rect(tiling_.tiling_size()), contents_scale, | 79 canvas, canvas_rect, gfx::Rect(tiling_.tiling_size()), contents_scale, |
90 background_color_, clear_canvas_with_debug_color_, requires_clear_); | 80 background_color_, clear_canvas_with_debug_color_, requires_clear_); |
91 | |
92 RasterCommon(canvas, | 81 RasterCommon(canvas, |
93 NULL, | 82 NULL, |
94 canvas_rect, | 83 canvas_rect, |
95 contents_scale, | 84 contents_scale, |
96 false); | 85 false); |
97 } | 86 } |
98 | 87 |
99 void PicturePileImpl::CoalesceRasters(const gfx::Rect& canvas_rect, | 88 void PicturePileImpl::CoalesceRasters(const gfx::Rect& canvas_rect, |
100 const gfx::Rect& content_rect, | 89 const gfx::Rect& content_rect, |
101 float contents_scale, | 90 float contents_scale, |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 if (!map_iter->second.GetPicture()) | 349 if (!map_iter->second.GetPicture()) |
361 return false; | 350 return false; |
362 } | 351 } |
363 return true; | 352 return true; |
364 } | 353 } |
365 | 354 |
366 void PicturePileImpl::SetShouldAttemptToUseDistanceFieldText() { | 355 void PicturePileImpl::SetShouldAttemptToUseDistanceFieldText() { |
367 should_attempt_to_use_distance_field_text_ = true; | 356 should_attempt_to_use_distance_field_text_ = true; |
368 } | 357 } |
369 | 358 |
370 void PicturePileImpl::SetBackgoundColor(SkColor background_color) { | |
371 background_color_ = background_color; | |
372 } | |
373 | |
374 void PicturePileImpl::SetRequiresClear(bool requires_clear) { | |
375 requires_clear_ = requires_clear; | |
376 } | |
377 | |
378 bool PicturePileImpl::ShouldAttemptToUseDistanceFieldText() const { | 359 bool PicturePileImpl::ShouldAttemptToUseDistanceFieldText() const { |
379 return should_attempt_to_use_distance_field_text_; | 360 return should_attempt_to_use_distance_field_text_; |
380 } | 361 } |
381 | 362 |
382 void PicturePileImpl::AsValueInto(base::debug::TracedValue* pictures) const { | 363 void PicturePileImpl::AsValueInto( |
| 364 base::trace_event::TracedValue* pictures) const { |
383 gfx::Rect tiling_rect(tiling_.tiling_size()); | 365 gfx::Rect tiling_rect(tiling_.tiling_size()); |
384 std::set<const void*> appended_pictures; | 366 std::set<const void*> appended_pictures; |
385 bool include_borders = true; | 367 bool include_borders = true; |
386 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders); | 368 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders); |
387 tile_iter; ++tile_iter) { | 369 tile_iter; ++tile_iter) { |
388 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); | 370 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); |
389 if (map_iter == picture_map_.end()) | 371 if (map_iter == picture_map_.end()) |
390 continue; | 372 continue; |
391 | 373 |
392 const Picture* picture = map_iter->second.GetPicture(); | 374 const Picture* picture = map_iter->second.GetPicture(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 | 428 |
447 processed_pictures_.insert(picture); | 429 processed_pictures_.insert(picture); |
448 pixel_ref_iterator_ = Picture::PixelRefIterator(layer_rect_, picture); | 430 pixel_ref_iterator_ = Picture::PixelRefIterator(layer_rect_, picture); |
449 if (pixel_ref_iterator_) | 431 if (pixel_ref_iterator_) |
450 break; | 432 break; |
451 } | 433 } |
452 } | 434 } |
453 | 435 |
454 void PicturePileImpl::DidBeginTracing() { | 436 void PicturePileImpl::DidBeginTracing() { |
455 std::set<const void*> processed_pictures; | 437 std::set<const void*> processed_pictures; |
456 for (PictureMap::iterator it = picture_map_.begin(); | 438 for (const auto& map_pair : picture_map_) { |
457 it != picture_map_.end(); | 439 const Picture* picture = map_pair.second.GetPicture(); |
458 ++it) { | |
459 const Picture* picture = it->second.GetPicture(); | |
460 if (picture && (processed_pictures.count(picture) == 0)) { | 440 if (picture && (processed_pictures.count(picture) == 0)) { |
461 picture->EmitTraceSnapshot(); | 441 picture->EmitTraceSnapshot(); |
462 processed_pictures.insert(picture); | 442 processed_pictures.insert(picture); |
463 } | 443 } |
464 } | 444 } |
465 } | 445 } |
466 | 446 |
467 } // namespace cc | 447 } // namespace cc |
OLD | NEW |