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

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

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « cc/resources/picture_pile_impl.h ('k') | cc/resources/picture_pile_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "cc/base/region.h" 9 #include "cc/base/region.h"
10 #include "cc/debug/debug_colors.h" 10 #include "cc/debug/debug_colors.h"
11 #include "cc/resources/picture_pile_impl.h" 11 #include "cc/resources/picture_pile_impl.h"
12 #include "skia/ext/analysis_canvas.h" 12 #include "skia/ext/analysis_canvas.h"
13 #include "third_party/skia/include/core/SkCanvas.h" 13 #include "third_party/skia/include/core/SkCanvas.h"
14 #include "third_party/skia/include/core/SkPictureRecorder.h" 14 #include "third_party/skia/include/core/SkPictureRecorder.h"
15 #include "ui/gfx/geometry/rect_conversions.h" 15 #include "ui/gfx/geometry/rect_conversions.h"
16 16
17 namespace cc { 17 namespace cc {
18 18
19 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() { 19 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() {
20 return make_scoped_refptr(new PicturePileImpl); 20 return make_scoped_refptr(new PicturePileImpl);
21 } 21 }
22 22
23 scoped_refptr<PicturePileImpl> PicturePileImpl::CreateFromOther( 23 scoped_refptr<PicturePileImpl> PicturePileImpl::CreateFromPicturePile(
24 const PicturePileBase* other) { 24 const PicturePile* other) {
25 return make_scoped_refptr(new PicturePileImpl(other)); 25 return make_scoped_refptr(new PicturePileImpl(other));
26 } 26 }
27 27
28 PicturePileImpl::PicturePileImpl() 28 PicturePileImpl::PicturePileImpl()
29 : likely_to_be_used_for_transform_animation_(false) { 29 : background_color_(SK_ColorTRANSPARENT),
30 contents_opaque_(false),
31 contents_fill_bounds_completely_(false),
32 is_solid_color_(false),
33 solid_color_(SK_ColorTRANSPARENT),
34 has_any_recordings_(false),
35 is_mask_(false),
36 clear_canvas_with_debug_color_(false),
37 min_contents_scale_(0.f),
38 slow_down_raster_scale_factor_for_debug_(0),
39 should_attempt_to_use_distance_field_text_(false) {
30 } 40 }
31 41
32 PicturePileImpl::PicturePileImpl(const PicturePileBase* other) 42 PicturePileImpl::PicturePileImpl(const PicturePile* other)
33 : PicturePileBase(other), 43 : picture_map_(other->picture_map_),
34 likely_to_be_used_for_transform_animation_(false) { 44 tiling_(other->tiling_),
45 background_color_(other->background_color_),
46 contents_opaque_(other->contents_opaque_),
47 contents_fill_bounds_completely_(other->contents_fill_bounds_completely_),
48 is_solid_color_(other->is_solid_color_),
49 solid_color_(other->solid_color_),
50 recorded_viewport_(other->recorded_viewport_),
51 has_any_recordings_(other->has_any_recordings_),
52 is_mask_(other->is_mask_),
53 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_),
54 min_contents_scale_(other->min_contents_scale_),
55 slow_down_raster_scale_factor_for_debug_(
56 other->slow_down_raster_scale_factor_for_debug_),
57 should_attempt_to_use_distance_field_text_(false) {
35 } 58 }
36 59
37 PicturePileImpl::~PicturePileImpl() { 60 PicturePileImpl::~PicturePileImpl() {
38 } 61 }
39 62
40 void PicturePileImpl::RasterDirect(SkCanvas* canvas, 63 void PicturePileImpl::PlaybackToSharedCanvas(SkCanvas* canvas,
41 const gfx::Rect& canvas_rect, 64 const gfx::Rect& canvas_rect,
42 float contents_scale) const { 65 float contents_scale) const {
43 RasterCommon(canvas, 66 RasterCommon(canvas,
44 NULL, 67 NULL,
45 canvas_rect, 68 canvas_rect,
46 contents_scale, 69 contents_scale,
47 false); 70 false);
48 } 71 }
49 72
50 void PicturePileImpl::RasterForAnalysis(skia::AnalysisCanvas* canvas, 73 void PicturePileImpl::RasterForAnalysis(skia::AnalysisCanvas* canvas,
51 const gfx::Rect& canvas_rect, 74 const gfx::Rect& canvas_rect,
52 float contents_scale) const { 75 float contents_scale) const {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 std::vector<SkPixelRef*>* pixel_refs) const { 336 std::vector<SkPixelRef*>* pixel_refs) const {
314 DCHECK_EQ(0u, pixel_refs->size()); 337 DCHECK_EQ(0u, pixel_refs->size());
315 for (PixelRefIterator iter(content_rect, contents_scale, this); iter; 338 for (PixelRefIterator iter(content_rect, contents_scale, this); iter;
316 ++iter) { 339 ++iter) {
317 pixel_refs->push_back(*iter); 340 pixel_refs->push_back(*iter);
318 } 341 }
319 } 342 }
320 343
321 bool PicturePileImpl::CoversRect(const gfx::Rect& content_rect, 344 bool PicturePileImpl::CoversRect(const gfx::Rect& content_rect,
322 float contents_scale) const { 345 float contents_scale) const {
323 return CanRaster(contents_scale, content_rect); 346 if (tiling_.tiling_size().IsEmpty())
347 return false;
348 gfx::Rect layer_rect =
349 gfx::ScaleToEnclosingRect(content_rect, 1.f / contents_scale);
350 layer_rect.Intersect(gfx::Rect(tiling_.tiling_size()));
351
352 // Common case inside of viewport to avoid the slower map lookups.
353 if (recorded_viewport_.Contains(layer_rect)) {
354 // Sanity check that there are no false positives in recorded_viewport_.
355 DCHECK(CanRasterSlowTileCheck(layer_rect));
356 return true;
357 }
358
359 return CanRasterSlowTileCheck(layer_rect);
324 } 360 }
325 361
326 bool PicturePileImpl::SuitableForDistanceFieldText() const { 362 gfx::Size PicturePileImpl::GetSize() const {
327 return likely_to_be_used_for_transform_animation_; 363 return tiling_.tiling_size();
364 }
365
366 bool PicturePileImpl::IsSolidColor() const {
367 return is_solid_color_;
368 }
369
370 SkColor PicturePileImpl::GetSolidColor() const {
371 DCHECK(IsSolidColor());
372 return solid_color_;
373 }
374
375 bool PicturePileImpl::HasRecordings() const {
376 return has_any_recordings_;
377 }
378
379 gfx::Rect PicturePileImpl::PaddedRect(const PictureMapKey& key) const {
380 gfx::Rect padded_rect = tiling_.TileBounds(key.first, key.second);
381 padded_rect.Inset(-buffer_pixels(), -buffer_pixels(), -buffer_pixels(),
382 -buffer_pixels());
383 return padded_rect;
384 }
385
386 bool PicturePileImpl::CanRasterSlowTileCheck(
387 const gfx::Rect& layer_rect) const {
388 bool include_borders = false;
389 for (TilingData::Iterator tile_iter(&tiling_, layer_rect, include_borders);
390 tile_iter; ++tile_iter) {
391 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index());
392 if (map_iter == picture_map_.end())
393 return false;
394 if (!map_iter->second.GetPicture())
395 return false;
396 }
397 return true;
398 }
399
400 void PicturePileImpl::SetShouldAttemptToUseDistanceFieldText() {
401 should_attempt_to_use_distance_field_text_ = true;
402 }
403
404 bool PicturePileImpl::ShouldAttemptToUseDistanceFieldText() const {
405 return should_attempt_to_use_distance_field_text_;
406 }
407
408 void PicturePileImpl::AsValueInto(base::debug::TracedValue* pictures) const {
409 gfx::Rect tiling_rect(tiling_.tiling_size());
410 std::set<const void*> appended_pictures;
411 bool include_borders = true;
412 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders);
413 tile_iter; ++tile_iter) {
414 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index());
415 if (map_iter == picture_map_.end())
416 continue;
417
418 const Picture* picture = map_iter->second.GetPicture();
419 if (picture && (appended_pictures.count(picture) == 0)) {
420 appended_pictures.insert(picture);
421 TracedValue::AppendIDRef(picture, pictures);
422 }
423 }
424 }
425
426 bool PicturePileImpl::IsMask() const {
427 return is_mask_;
328 } 428 }
329 429
330 PicturePileImpl::PixelRefIterator::PixelRefIterator( 430 PicturePileImpl::PixelRefIterator::PixelRefIterator(
331 const gfx::Rect& content_rect, 431 const gfx::Rect& content_rect,
332 float contents_scale, 432 float contents_scale,
333 const PicturePileImpl* picture_pile) 433 const PicturePileImpl* picture_pile)
334 : picture_pile_(picture_pile), 434 : picture_pile_(picture_pile),
335 layer_rect_( 435 layer_rect_(
336 gfx::ScaleToEnclosingRect(content_rect, 1.f / contents_scale)), 436 gfx::ScaleToEnclosingRect(content_rect, 1.f / contents_scale)),
337 tile_iterator_(&picture_pile_->tiling_, 437 tile_iterator_(&picture_pile_->tiling_,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 ++it) { 484 ++it) {
385 const Picture* picture = it->second.GetPicture(); 485 const Picture* picture = it->second.GetPicture();
386 if (picture && (processed_pictures.count(picture) == 0)) { 486 if (picture && (processed_pictures.count(picture) == 0)) {
387 picture->EmitTraceSnapshot(); 487 picture->EmitTraceSnapshot();
388 processed_pictures.insert(picture); 488 processed_pictures.insert(picture);
389 } 489 }
390 } 490 }
391 } 491 }
392 492
393 } // namespace cc 493 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_pile_impl.h ('k') | cc/resources/picture_pile_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698