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

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

Issue 789433003: [cc] Add nearest neighbor filtering for PictureLayer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only SetNeedsDisplay|PushProperties if nearest_neighbor changed. Created 6 years 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 "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 #include <set> 9 #include <set>
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 raster_page_scale_(0.f), 81 raster_page_scale_(0.f),
82 raster_device_scale_(0.f), 82 raster_device_scale_(0.f),
83 raster_source_scale_(0.f), 83 raster_source_scale_(0.f),
84 raster_contents_scale_(0.f), 84 raster_contents_scale_(0.f),
85 low_res_raster_contents_scale_(0.f), 85 low_res_raster_contents_scale_(0.f),
86 raster_source_scale_is_fixed_(false), 86 raster_source_scale_is_fixed_(false),
87 was_screen_space_transform_animating_(false), 87 was_screen_space_transform_animating_(false),
88 needs_post_commit_initialization_(true), 88 needs_post_commit_initialization_(true),
89 should_update_tile_priorities_(false), 89 should_update_tile_priorities_(false),
90 only_used_low_res_last_append_quads_(false), 90 only_used_low_res_last_append_quads_(false),
91 is_mask_(false) { 91 is_mask_(false),
92 nearest_neighbor_(false) {
92 layer_tree_impl()->RegisterPictureLayerImpl(this); 93 layer_tree_impl()->RegisterPictureLayerImpl(this);
93 } 94 }
94 95
95 PictureLayerImpl::~PictureLayerImpl() { 96 PictureLayerImpl::~PictureLayerImpl() {
96 if (twin_layer_) 97 if (twin_layer_)
97 twin_layer_->twin_layer_ = nullptr; 98 twin_layer_->twin_layer_ = nullptr;
98 layer_tree_impl()->UnregisterPictureLayerImpl(this); 99 layer_tree_impl()->UnregisterPictureLayerImpl(this);
99 } 100 }
100 101
101 scoped_ptr<TilingSetEvictionQueue> PictureLayerImpl::CreateEvictionQueue( 102 scoped_ptr<TilingSetEvictionQueue> PictureLayerImpl::CreateEvictionQueue(
(...skipping 25 matching lines...) Expand all
127 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl); 128 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl);
128 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); 129 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this);
129 // The twin relationship does not need to exist before the first 130 // The twin relationship does not need to exist before the first
130 // PushPropertiesTo from pending to active layer since before that the active 131 // PushPropertiesTo from pending to active layer since before that the active
131 // layer can not have a pile or tilings, it has only been created and inserted 132 // layer can not have a pile or tilings, it has only been created and inserted
132 // into the tree at that point. 133 // into the tree at that point.
133 twin_layer_ = layer_impl; 134 twin_layer_ = layer_impl;
134 layer_impl->twin_layer_ = this; 135 layer_impl->twin_layer_ = this;
135 136
136 layer_impl->set_is_mask(is_mask_); 137 layer_impl->set_is_mask(is_mask_);
138 layer_impl->SetNearestNeighbor(nearest_neighbor_);
137 layer_impl->UpdateRasterSource(raster_source_); 139 layer_impl->UpdateRasterSource(raster_source_);
138 140
139 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); 141 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0);
140 // Tilings would be expensive to push, so we swap. 142 // Tilings would be expensive to push, so we swap.
141 layer_impl->tilings_.swap(tilings_); 143 layer_impl->tilings_.swap(tilings_);
142 layer_impl->tilings_->SetClient(layer_impl); 144 layer_impl->tilings_->SetClient(layer_impl);
143 if (tilings_) 145 if (tilings_)
144 tilings_->SetClient(this); 146 tilings_->SetClient(this);
145 147
146 // Ensure that the recycle tree doesn't have any unshared tiles. 148 // Ensure that the recycle tree doesn't have any unshared tiles.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 if (visible_geometry_rect.IsEmpty()) 245 if (visible_geometry_rect.IsEmpty())
244 return; 246 return;
245 247
246 gfx::Size texture_size = scaled_visible_content_rect.size(); 248 gfx::Size texture_size = scaled_visible_content_rect.size();
247 gfx::RectF texture_rect = gfx::RectF(texture_size); 249 gfx::RectF texture_rect = gfx::RectF(texture_size);
248 gfx::Rect quad_content_rect = scaled_visible_content_rect; 250 gfx::Rect quad_content_rect = scaled_visible_content_rect;
249 251
250 PictureDrawQuad* quad = 252 PictureDrawQuad* quad =
251 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); 253 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>();
252 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, 254 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect,
253 visible_geometry_rect, texture_rect, texture_size, RGBA_8888, 255 visible_geometry_rect, texture_rect, texture_size,
254 quad_content_rect, max_contents_scale, raster_source_); 256 nearest_neighbor_, RGBA_8888, quad_content_rect,
257 max_contents_scale, raster_source_);
255 return; 258 return;
256 } 259 }
257 260
258 AppendDebugBorderQuad( 261 AppendDebugBorderQuad(
259 render_pass, scaled_content_bounds, shared_quad_state, append_quads_data); 262 render_pass, scaled_content_bounds, shared_quad_state, append_quads_data);
260 263
261 if (ShowDebugBorders()) { 264 if (ShowDebugBorders()) {
262 for (PictureLayerTilingSet::CoverageIterator iter( 265 for (PictureLayerTilingSet::CoverageIterator iter(
263 tilings_.get(), 266 tilings_.get(),
264 max_contents_scale, 267 max_contents_scale,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 359
357 TileDrawQuad* quad = 360 TileDrawQuad* quad =
358 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); 361 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>();
359 quad->SetNew(shared_quad_state, 362 quad->SetNew(shared_quad_state,
360 geometry_rect, 363 geometry_rect,
361 opaque_rect, 364 opaque_rect,
362 visible_geometry_rect, 365 visible_geometry_rect,
363 draw_info.get_resource_id(), 366 draw_info.get_resource_id(),
364 texture_rect, 367 texture_rect,
365 iter.texture_size(), 368 iter.texture_size(),
366 draw_info.contents_swizzled()); 369 draw_info.contents_swizzled(),
370 nearest_neighbor_);
367 has_draw_quad = true; 371 has_draw_quad = true;
368 break; 372 break;
369 } 373 }
370 case ManagedTileState::DrawInfo::PICTURE_PILE_MODE: { 374 case ManagedTileState::DrawInfo::PICTURE_PILE_MODE: {
371 if (!layer_tree_impl() 375 if (!layer_tree_impl()
372 ->GetRendererCapabilities() 376 ->GetRendererCapabilities()
373 .allow_rasterize_on_demand) { 377 .allow_rasterize_on_demand) {
374 ++on_demand_missing_tile_count; 378 ++on_demand_missing_tile_count;
375 break; 379 break;
376 } 380 }
377 381
378 gfx::RectF texture_rect = iter.texture_rect(); 382 gfx::RectF texture_rect = iter.texture_rect();
379 383
380 ResourceProvider* resource_provider = 384 ResourceProvider* resource_provider =
381 layer_tree_impl()->resource_provider(); 385 layer_tree_impl()->resource_provider();
382 ResourceFormat format = 386 ResourceFormat format =
383 resource_provider->memory_efficient_texture_format(); 387 resource_provider->memory_efficient_texture_format();
384 PictureDrawQuad* quad = 388 PictureDrawQuad* quad =
385 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); 389 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>();
386 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, 390 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect,
387 visible_geometry_rect, texture_rect, iter.texture_size(), 391 visible_geometry_rect, texture_rect, iter.texture_size(),
388 format, iter->content_rect(), iter->contents_scale(), 392 nearest_neighbor_, format, iter->content_rect(),
389 raster_source_); 393 iter->contents_scale(), raster_source_);
390 has_draw_quad = true; 394 has_draw_quad = true;
391 break; 395 break;
392 } 396 }
393 case ManagedTileState::DrawInfo::SOLID_COLOR_MODE: { 397 case ManagedTileState::DrawInfo::SOLID_COLOR_MODE: {
394 SolidColorDrawQuad* quad = 398 SolidColorDrawQuad* quad =
395 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 399 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
396 quad->SetNew(shared_quad_state, 400 quad->SetNew(shared_quad_state,
397 geometry_rect, 401 geometry_rect,
398 visible_geometry_rect, 402 visible_geometry_rect,
399 draw_info.get_solid_color(), 403 draw_info.get_solid_color(),
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 if (!draw_info.IsReadyToDraw() || 858 if (!draw_info.IsReadyToDraw() ||
855 draw_info.mode() != ManagedTileState::DrawInfo::RESOURCE_MODE) { 859 draw_info.mode() != ManagedTileState::DrawInfo::RESOURCE_MODE) {
856 *resource_id = 0; 860 *resource_id = 0;
857 return; 861 return;
858 } 862 }
859 863
860 *resource_id = draw_info.get_resource_id(); 864 *resource_id = draw_info.get_resource_id();
861 *resource_size = iter.texture_size(); 865 *resource_size = iter.texture_size();
862 } 866 }
863 867
868 void PictureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) {
869 if (nearest_neighbor_ != nearest_neighbor) {
danakj 2014/12/09 19:44:45 if == return
jackhou1 2014/12/10 01:04:15 Done.
870 nearest_neighbor_ = nearest_neighbor;
871 SetNeedsPushProperties();
danakj 2014/12/09 19:44:45 NoteLayerPropertyChanged instead
jackhou1 2014/12/10 01:04:15 Done.
872 }
873 }
874
864 void PictureLayerImpl::DoPostCommitInitialization() { 875 void PictureLayerImpl::DoPostCommitInitialization() {
865 DCHECK(needs_post_commit_initialization_); 876 DCHECK(needs_post_commit_initialization_);
866 DCHECK(layer_tree_impl()->IsPendingTree()); 877 DCHECK(layer_tree_impl()->IsPendingTree());
867 878
868 if (!tilings_) 879 if (!tilings_)
869 tilings_ = PictureLayerTilingSet::Create(this); 880 tilings_ = PictureLayerTilingSet::Create(this);
870 881
871 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); 882 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer();
872 if (twin_layer) { 883 if (twin_layer) {
873 // If the twin has never been pushed to, do not sync from it. 884 // If the twin has never been pushed to, do not sync from it.
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 IteratorType index = stages_[current_stage_].iterator_type; 1492 IteratorType index = stages_[current_stage_].iterator_type;
1482 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type; 1493 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type;
1483 1494
1484 if (iterators_[index] && iterators_[index].get_type() == tile_type) 1495 if (iterators_[index] && iterators_[index].get_type() == tile_type)
1485 break; 1496 break;
1486 ++current_stage_; 1497 ++current_stage_;
1487 } 1498 }
1488 } 1499 }
1489 1500
1490 } // namespace cc 1501 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698