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

Side by Side Diff: cc/layers/picture_layer_impl.cc

Issue 222903005: cc: Let skia veto gpu rasterization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: replaced && with &= Created 6 years, 8 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 | Annotate | Revision Log
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 "cc/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 ideal_contents_scale_(0.f), 47 ideal_contents_scale_(0.f),
48 raster_page_scale_(0.f), 48 raster_page_scale_(0.f),
49 raster_device_scale_(0.f), 49 raster_device_scale_(0.f),
50 raster_source_scale_(0.f), 50 raster_source_scale_(0.f),
51 raster_contents_scale_(0.f), 51 raster_contents_scale_(0.f),
52 low_res_raster_contents_scale_(0.f), 52 low_res_raster_contents_scale_(0.f),
53 raster_source_scale_was_animating_(false), 53 raster_source_scale_was_animating_(false),
54 is_using_lcd_text_(tree_impl->settings().can_use_lcd_text), 54 is_using_lcd_text_(tree_impl->settings().can_use_lcd_text),
55 needs_post_commit_initialization_(true), 55 needs_post_commit_initialization_(true),
56 should_update_tile_priorities_(false), 56 should_update_tile_priorities_(false),
57 has_gpu_rasterization_hint_(false),
58 should_use_low_res_tiling_(tree_impl->settings().create_low_res_tiling), 57 should_use_low_res_tiling_(tree_impl->settings().create_low_res_tiling),
58 use_gpu_rasterization_(false),
59 layer_needs_to_register_itself_(true) {} 59 layer_needs_to_register_itself_(true) {}
60 60
61 PictureLayerImpl::~PictureLayerImpl() { 61 PictureLayerImpl::~PictureLayerImpl() {
62 if (!layer_needs_to_register_itself_) 62 if (!layer_needs_to_register_itself_)
63 layer_tree_impl()->tile_manager()->UnregisterPictureLayerImpl(this); 63 layer_tree_impl()->tile_manager()->UnregisterPictureLayerImpl(this);
64 } 64 }
65 65
66 const char* PictureLayerImpl::LayerTypeAsString() const { 66 const char* PictureLayerImpl::LayerTypeAsString() const {
67 return "cc::PictureLayerImpl"; 67 return "cc::PictureLayerImpl";
68 } 68 }
(...skipping 20 matching lines...) Expand all
89 89
90 LayerImpl::PushPropertiesTo(base_layer); 90 LayerImpl::PushPropertiesTo(base_layer);
91 91
92 // When the pending tree pushes to the active tree, the pending twin 92 // When the pending tree pushes to the active tree, the pending twin
93 // disappears. 93 // disappears.
94 layer_impl->twin_layer_ = NULL; 94 layer_impl->twin_layer_ = NULL;
95 twin_layer_ = NULL; 95 twin_layer_ = NULL;
96 96
97 layer_impl->SetIsMask(is_mask_); 97 layer_impl->SetIsMask(is_mask_);
98 layer_impl->pile_ = pile_; 98 layer_impl->pile_ = pile_;
99 layer_impl->SetHasGpuRasterizationHint(has_gpu_rasterization_hint_); 99 layer_impl->use_gpu_rasterization_ = use_gpu_rasterization_;
100 100
101 // Tilings would be expensive to push, so we swap. This optimization requires 101 // Tilings would be expensive to push, so we swap. This optimization requires
102 // an extra invalidation in SyncFromActiveLayer. 102 // an extra invalidation in SyncFromActiveLayer.
103 layer_impl->tilings_.swap(tilings_); 103 layer_impl->tilings_.swap(tilings_);
104 layer_impl->tilings_->SetClient(layer_impl); 104 layer_impl->tilings_->SetClient(layer_impl);
105 if (tilings_) 105 if (tilings_)
106 tilings_->SetClient(this); 106 tilings_->SetClient(this);
107 107
108 layer_impl->raster_page_scale_ = raster_page_scale_; 108 layer_impl->raster_page_scale_ = raster_page_scale_;
109 layer_impl->raster_device_scale_ = raster_device_scale_; 109 layer_impl->raster_device_scale_ = raster_device_scale_;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 *contents_scale_x = max_contents_scale; 472 *contents_scale_x = max_contents_scale;
473 *contents_scale_y = max_contents_scale; 473 *contents_scale_y = max_contents_scale;
474 *content_bounds = gfx::ToCeiledSize( 474 *content_bounds = gfx::ToCeiledSize(
475 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale)); 475 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale));
476 } 476 }
477 477
478 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { 478 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() {
479 return pile_->GetFlattenedPicture(); 479 return pile_->GetFlattenedPicture();
480 } 480 }
481 481
482 void PictureLayerImpl::SetHasGpuRasterizationHint(bool has_hint) { 482 void PictureLayerImpl::SetUseGpuRasterization(bool use_gpu) {
483 bool old_should_use_gpu_rasterization = ShouldUseGpuRasterization(); 483 if (use_gpu_rasterization_ == use_gpu)
484 has_gpu_rasterization_hint_ = has_hint; 484 return;
485 if (ShouldUseGpuRasterization() != old_should_use_gpu_rasterization)
486 RemoveAllTilings();
487 }
488 485
489 bool PictureLayerImpl::ShouldUseGpuRasterization() const { 486 use_gpu_rasterization_ = use_gpu;
490 switch (layer_tree_impl()->settings().rasterization_site) { 487 RemoveAllTilings();
491 case LayerTreeSettings::CpuRasterization:
492 return false;
493 case LayerTreeSettings::HybridRasterization:
494 return has_gpu_rasterization_hint_;
495 case LayerTreeSettings::GpuRasterization:
496 return true;
497 }
498 NOTREACHED();
499 return false;
500 } 488 }
501 489
502 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, 490 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling,
503 const gfx::Rect& content_rect) { 491 const gfx::Rect& content_rect) {
504 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) 492 if (!pile_->CanRaster(tiling->contents_scale(), content_rect))
505 return scoped_refptr<Tile>(); 493 return scoped_refptr<Tile>();
506 494
507 int flags = 0; 495 int flags = 0;
508 if (is_using_lcd_text_) 496 if (is_using_lcd_text_)
509 flags |= Tile::USE_LCD_TEXT; 497 flags |= Tile::USE_LCD_TEXT;
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 DCHECK(*this); 1357 DCHECK(*this);
1370 1358
1371 IteratorType index = stages_[current_stage_].iterator_type; 1359 IteratorType index = stages_[current_stage_].iterator_type;
1372 DCHECK(iterators_[index]); 1360 DCHECK(iterators_[index]);
1373 DCHECK(iterators_[index].get_type() == stages_[current_stage_].tile_type); 1361 DCHECK(iterators_[index].get_type() == stages_[current_stage_].tile_type);
1374 1362
1375 return *iterators_[index]; 1363 return *iterators_[index];
1376 } 1364 }
1377 1365
1378 } // namespace cc 1366 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698