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

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

Issue 793573006: Refactoring for merging ManagedTileState into Tile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix a nit 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
« no previous file with comments | « cc/cc.gyp ('k') | cc/layers/picture_layer_impl_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 "cc/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <set> 10 #include <set>
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 for (PictureLayerTilingSet::CoverageIterator iter( 248 for (PictureLayerTilingSet::CoverageIterator iter(
249 tilings_.get(), 249 tilings_.get(),
250 max_contents_scale, 250 max_contents_scale,
251 scaled_visible_content_rect, 251 scaled_visible_content_rect,
252 ideal_contents_scale_); 252 ideal_contents_scale_);
253 iter; 253 iter;
254 ++iter) { 254 ++iter) {
255 SkColor color; 255 SkColor color;
256 float width; 256 float width;
257 if (*iter && iter->IsReadyToDraw()) { 257 if (*iter && iter->IsReadyToDraw()) {
258 ManagedTileState::DrawInfo::Mode mode = iter->draw_info().mode(); 258 TileDrawInfo::Mode mode = iter->draw_info().mode();
259 if (mode == ManagedTileState::DrawInfo::SOLID_COLOR_MODE) { 259 if (mode == TileDrawInfo::SOLID_COLOR_MODE) {
260 color = DebugColors::SolidColorTileBorderColor(); 260 color = DebugColors::SolidColorTileBorderColor();
261 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); 261 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl());
262 } else if (mode == ManagedTileState::DrawInfo::PICTURE_PILE_MODE) { 262 } else if (mode == TileDrawInfo::PICTURE_PILE_MODE) {
263 color = DebugColors::PictureTileBorderColor(); 263 color = DebugColors::PictureTileBorderColor();
264 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); 264 width = DebugColors::PictureTileBorderWidth(layer_tree_impl());
265 } else if (iter.resolution() == HIGH_RESOLUTION) { 265 } else if (iter.resolution() == HIGH_RESOLUTION) {
266 color = DebugColors::HighResTileBorderColor(); 266 color = DebugColors::HighResTileBorderColor();
267 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); 267 width = DebugColors::HighResTileBorderWidth(layer_tree_impl());
268 } else if (iter.resolution() == LOW_RESOLUTION) { 268 } else if (iter.resolution() == LOW_RESOLUTION) {
269 color = DebugColors::LowResTileBorderColor(); 269 color = DebugColors::LowResTileBorderColor();
270 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); 270 width = DebugColors::LowResTileBorderWidth(layer_tree_impl());
271 } else if (iter->contents_scale() > max_contents_scale) { 271 } else if (iter->contents_scale() > max_contents_scale) {
272 color = DebugColors::ExtraHighResTileBorderColor(); 272 color = DebugColors::ExtraHighResTileBorderColor();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 gfx::Rect visible_geometry_rect = 316 gfx::Rect visible_geometry_rect =
317 scaled_occlusion.GetUnoccludedContentRect(geometry_rect); 317 scaled_occlusion.GetUnoccludedContentRect(geometry_rect);
318 if (visible_geometry_rect.IsEmpty()) 318 if (visible_geometry_rect.IsEmpty())
319 continue; 319 continue;
320 320
321 append_quads_data->visible_content_area += 321 append_quads_data->visible_content_area +=
322 visible_geometry_rect.width() * visible_geometry_rect.height(); 322 visible_geometry_rect.width() * visible_geometry_rect.height();
323 323
324 bool has_draw_quad = false; 324 bool has_draw_quad = false;
325 if (*iter && iter->IsReadyToDraw()) { 325 if (*iter && iter->IsReadyToDraw()) {
326 const ManagedTileState::DrawInfo& draw_info = iter->draw_info(); 326 const TileDrawInfo& draw_info = iter->draw_info();
327 switch (draw_info.mode()) { 327 switch (draw_info.mode()) {
328 case ManagedTileState::DrawInfo::RESOURCE_MODE: { 328 case TileDrawInfo::RESOURCE_MODE: {
329 gfx::RectF texture_rect = iter.texture_rect(); 329 gfx::RectF texture_rect = iter.texture_rect();
330 330
331 // The raster_contents_scale_ is the best scale that the layer is 331 // The raster_contents_scale_ is the best scale that the layer is
332 // trying to produce, even though it may not be ideal. Since that's 332 // trying to produce, even though it may not be ideal. Since that's
333 // the best the layer can promise in the future, consider those as 333 // the best the layer can promise in the future, consider those as
334 // complete. But if a tile is ideal scale, we don't want to consider 334 // complete. But if a tile is ideal scale, we don't want to consider
335 // it incomplete and trying to replace it with a tile at a worse 335 // it incomplete and trying to replace it with a tile at a worse
336 // scale. 336 // scale.
337 if (iter->contents_scale() != raster_contents_scale_ && 337 if (iter->contents_scale() != raster_contents_scale_ &&
338 iter->contents_scale() != ideal_contents_scale_ && 338 iter->contents_scale() != ideal_contents_scale_ &&
339 geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { 339 geometry_rect.Intersects(scaled_viewport_for_tile_priority)) {
340 append_quads_data->num_incomplete_tiles++; 340 append_quads_data->num_incomplete_tiles++;
341 } 341 }
342 342
343 TileDrawQuad* quad = 343 TileDrawQuad* quad =
344 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); 344 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>();
345 quad->SetNew(shared_quad_state, 345 quad->SetNew(shared_quad_state,
346 geometry_rect, 346 geometry_rect,
347 opaque_rect, 347 opaque_rect,
348 visible_geometry_rect, 348 visible_geometry_rect,
349 draw_info.get_resource_id(), 349 draw_info.get_resource_id(),
350 texture_rect, 350 texture_rect,
351 iter.texture_size(), 351 iter.texture_size(),
352 draw_info.contents_swizzled(), 352 draw_info.contents_swizzled(),
353 nearest_neighbor_); 353 nearest_neighbor_);
354 has_draw_quad = true; 354 has_draw_quad = true;
355 break; 355 break;
356 } 356 }
357 case ManagedTileState::DrawInfo::PICTURE_PILE_MODE: { 357 case TileDrawInfo::PICTURE_PILE_MODE: {
358 if (!layer_tree_impl() 358 if (!layer_tree_impl()
359 ->GetRendererCapabilities() 359 ->GetRendererCapabilities()
360 .allow_rasterize_on_demand) { 360 .allow_rasterize_on_demand) {
361 ++on_demand_missing_tile_count; 361 ++on_demand_missing_tile_count;
362 break; 362 break;
363 } 363 }
364 364
365 gfx::RectF texture_rect = iter.texture_rect(); 365 gfx::RectF texture_rect = iter.texture_rect();
366 366
367 ResourceProvider* resource_provider = 367 ResourceProvider* resource_provider =
368 layer_tree_impl()->resource_provider(); 368 layer_tree_impl()->resource_provider();
369 ResourceFormat format = 369 ResourceFormat format =
370 resource_provider->memory_efficient_texture_format(); 370 resource_provider->memory_efficient_texture_format();
371 PictureDrawQuad* quad = 371 PictureDrawQuad* quad =
372 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); 372 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>();
373 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, 373 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect,
374 visible_geometry_rect, texture_rect, iter.texture_size(), 374 visible_geometry_rect, texture_rect, iter.texture_size(),
375 nearest_neighbor_, format, iter->content_rect(), 375 nearest_neighbor_, format, iter->content_rect(),
376 iter->contents_scale(), raster_source_); 376 iter->contents_scale(), raster_source_);
377 has_draw_quad = true; 377 has_draw_quad = true;
378 break; 378 break;
379 } 379 }
380 case ManagedTileState::DrawInfo::SOLID_COLOR_MODE: { 380 case TileDrawInfo::SOLID_COLOR_MODE: {
381 SolidColorDrawQuad* quad = 381 SolidColorDrawQuad* quad =
382 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 382 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
383 quad->SetNew(shared_quad_state, 383 quad->SetNew(shared_quad_state,
384 geometry_rect, 384 geometry_rect,
385 visible_geometry_rect, 385 visible_geometry_rect,
386 draw_info.get_solid_color(), 386 draw_info.get_solid_color(),
387 false); 387 false);
388 has_draw_quad = true; 388 has_draw_quad = true;
389 break; 389 break;
390 } 390 }
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 if (!iter || !*iter) { 783 if (!iter || !*iter) {
784 *resource_id = 0; 784 *resource_id = 0;
785 return; 785 return;
786 } 786 }
787 787
788 // Masks only supported if they fit on exactly one tile. 788 // Masks only supported if they fit on exactly one tile.
789 DCHECK(iter.geometry_rect() == content_rect) 789 DCHECK(iter.geometry_rect() == content_rect)
790 << "iter rect " << iter.geometry_rect().ToString() << " content rect " 790 << "iter rect " << iter.geometry_rect().ToString() << " content rect "
791 << content_rect.ToString(); 791 << content_rect.ToString();
792 792
793 const ManagedTileState::DrawInfo& draw_info = iter->draw_info(); 793 const TileDrawInfo& draw_info = iter->draw_info();
794 if (!draw_info.IsReadyToDraw() || 794 if (!draw_info.IsReadyToDraw() ||
795 draw_info.mode() != ManagedTileState::DrawInfo::RESOURCE_MODE) { 795 draw_info.mode() != TileDrawInfo::RESOURCE_MODE) {
796 *resource_id = 0; 796 *resource_id = 0;
797 return; 797 return;
798 } 798 }
799 799
800 *resource_id = draw_info.get_resource_id(); 800 *resource_id = draw_info.get_resource_id();
801 *resource_size = iter.texture_size(); 801 *resource_size = iter.texture_size();
802 } 802 }
803 803
804 void PictureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) { 804 void PictureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) {
805 if (nearest_neighbor_ == nearest_neighbor) 805 if (nearest_neighbor_ == nearest_neighbor)
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 1325
1326 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { 1326 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const {
1327 if (!layer_tree_impl()->IsActiveTree()) 1327 if (!layer_tree_impl()->IsActiveTree())
1328 return true; 1328 return true;
1329 1329
1330 return AllTilesRequiredAreReadyToDraw( 1330 return AllTilesRequiredAreReadyToDraw(
1331 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); 1331 &PictureLayerTiling::IsTileRequiredForDrawIfVisible);
1332 } 1332 }
1333 1333
1334 } // namespace cc 1334 } // namespace cc
OLDNEW
« no previous file with comments | « cc/cc.gyp ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698