Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Side by Side Diff: cc/resources/picture_pile_impl.cc

Issue 930503002: cc: Make raster source members const (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Display lists too Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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),
danakj 2015/02/14 01:34:16 I think you could have left this one alone, there'
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
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
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( 363 void PicturePileImpl::AsValueInto(
383 base::trace_event::TracedValue* pictures) const { 364 base::trace_event::TracedValue* pictures) const {
384 gfx::Rect tiling_rect(tiling_.tiling_size()); 365 gfx::Rect tiling_rect(tiling_.tiling_size());
385 std::set<const void*> appended_pictures; 366 std::set<const void*> appended_pictures;
386 bool include_borders = true; 367 bool include_borders = true;
387 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders); 368 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 428
448 processed_pictures_.insert(picture); 429 processed_pictures_.insert(picture);
449 pixel_ref_iterator_ = Picture::PixelRefIterator(layer_rect_, picture); 430 pixel_ref_iterator_ = Picture::PixelRefIterator(layer_rect_, picture);
450 if (pixel_ref_iterator_) 431 if (pixel_ref_iterator_)
451 break; 432 break;
452 } 433 }
453 } 434 }
454 435
455 void PicturePileImpl::DidBeginTracing() { 436 void PicturePileImpl::DidBeginTracing() {
456 std::set<const void*> processed_pictures; 437 std::set<const void*> processed_pictures;
457 for (PictureMap::iterator it = picture_map_.begin(); 438 for (const auto& map_pair : picture_map_) {
458 it != picture_map_.end(); 439 const Picture* picture = map_pair.second.GetPicture();
459 ++it) {
460 const Picture* picture = it->second.GetPicture();
461 if (picture && (processed_pictures.count(picture) == 0)) { 440 if (picture && (processed_pictures.count(picture) == 0)) {
462 picture->EmitTraceSnapshot(); 441 picture->EmitTraceSnapshot();
463 processed_pictures.insert(picture); 442 processed_pictures.insert(picture);
464 } 443 }
465 } 444 }
466 } 445 }
467 446
468 } // namespace cc 447 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698