Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 return; | 170 return; |
| 171 } | 171 } |
| 172 | 172 |
| 173 float max_contents_scale = MaximumTilingContentsScale(); | 173 float max_contents_scale = MaximumTilingContentsScale(); |
| 174 PopulateScaledSharedQuadState(shared_quad_state, max_contents_scale); | 174 PopulateScaledSharedQuadState(shared_quad_state, max_contents_scale); |
| 175 Occlusion scaled_occlusion = | 175 Occlusion scaled_occlusion = |
| 176 draw_properties() | 176 draw_properties() |
| 177 .occlusion_in_content_space.GetOcclusionWithGivenDrawTransform( | 177 .occlusion_in_content_space.GetOcclusionWithGivenDrawTransform( |
| 178 shared_quad_state->quad_to_target_transform); | 178 shared_quad_state->quad_to_target_transform); |
| 179 | 179 |
| 180 gfx::Rect scaled_visible_layer_rect = | |
| 181 ScaleToEnclosingRect(visible_layer_rect(), max_contents_scale); | |
| 182 gfx::Rect visible_geometry_rect = | |
|
enne (OOO)
2016/07/08 17:58:55
Maybe an early out here if visible geometry rect i
| |
| 183 scaled_occlusion.GetUnoccludedContentRect(scaled_visible_layer_rect); | |
| 184 | |
| 180 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 185 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
| 181 AppendDebugBorderQuad( | 186 AppendDebugBorderQuad( |
| 182 render_pass, shared_quad_state->quad_layer_bounds, shared_quad_state, | 187 render_pass, shared_quad_state->quad_layer_bounds, shared_quad_state, |
| 183 append_quads_data, DebugColors::DirectPictureBorderColor(), | 188 append_quads_data, DebugColors::DirectPictureBorderColor(), |
| 184 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); | 189 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); |
| 185 | 190 |
| 186 gfx::Rect geometry_rect = shared_quad_state->visible_quad_layer_rect; | 191 gfx::Rect geometry_rect = shared_quad_state->visible_quad_layer_rect; |
| 187 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); | 192 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); |
| 188 gfx::Rect visible_geometry_rect = | 193 gfx::Rect visible_tile_rect = visible_geometry_rect; |
| 189 scaled_occlusion.GetUnoccludedContentRect(geometry_rect); | 194 visible_tile_rect.Intersect(geometry_rect); |
| 190 | 195 |
| 191 // The raster source may not be valid over the entire visible rect, | 196 // The raster source may not be valid over the entire visible rect, |
| 192 // and rastering outside of that may cause incorrect pixels. | 197 // and rastering outside of that may cause incorrect pixels. |
| 193 gfx::Rect scaled_recorded_viewport = gfx::ScaleToEnclosingRect( | 198 gfx::Rect scaled_recorded_viewport = gfx::ScaleToEnclosingRect( |
| 194 raster_source_->RecordedViewport(), max_contents_scale); | 199 raster_source_->RecordedViewport(), max_contents_scale); |
| 195 geometry_rect.Intersect(scaled_recorded_viewport); | 200 geometry_rect.Intersect(scaled_recorded_viewport); |
| 196 opaque_rect.Intersect(scaled_recorded_viewport); | 201 opaque_rect.Intersect(scaled_recorded_viewport); |
| 197 visible_geometry_rect.Intersect(scaled_recorded_viewport); | 202 visible_tile_rect.Intersect(scaled_recorded_viewport); |
| 198 | 203 |
| 199 if (visible_geometry_rect.IsEmpty()) | 204 if (visible_tile_rect.IsEmpty()) |
| 200 return; | 205 return; |
| 201 | 206 |
| 202 DCHECK(raster_source_->HasRecordings()); | 207 DCHECK(raster_source_->HasRecordings()); |
| 203 gfx::Rect quad_content_rect = shared_quad_state->visible_quad_layer_rect; | 208 gfx::Rect quad_content_rect = shared_quad_state->visible_quad_layer_rect; |
| 204 gfx::Size texture_size = quad_content_rect.size(); | 209 gfx::Size texture_size = quad_content_rect.size(); |
| 205 gfx::RectF texture_rect = gfx::RectF(gfx::SizeF(texture_size)); | 210 gfx::RectF texture_rect = gfx::RectF(gfx::SizeF(texture_size)); |
| 206 | 211 |
| 207 PictureDrawQuad* quad = | 212 PictureDrawQuad* quad = |
| 208 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); | 213 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); |
| 209 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, | 214 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, |
| 210 visible_geometry_rect, texture_rect, texture_size, | 215 visible_tile_rect, texture_rect, texture_size, |
| 211 nearest_neighbor_, RGBA_8888, quad_content_rect, | 216 nearest_neighbor_, RGBA_8888, quad_content_rect, |
| 212 max_contents_scale, raster_source_); | 217 max_contents_scale, raster_source_); |
| 213 ValidateQuadResources(quad); | 218 ValidateQuadResources(quad); |
| 214 return; | 219 return; |
| 215 } | 220 } |
| 216 | 221 |
| 217 AppendDebugBorderQuad(render_pass, shared_quad_state->quad_layer_bounds, | 222 AppendDebugBorderQuad(render_pass, shared_quad_state->quad_layer_bounds, |
| 218 shared_quad_state, append_quads_data); | 223 shared_quad_state, append_quads_data); |
| 219 | 224 |
| 220 if (ShowDebugBorders()) { | 225 if (ShowDebugBorders()) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 size_t on_demand_missing_tile_count = 0u; | 284 size_t on_demand_missing_tile_count = 0u; |
| 280 only_used_low_res_last_append_quads_ = true; | 285 only_used_low_res_last_append_quads_ = true; |
| 281 gfx::Rect scaled_recorded_viewport = gfx::ScaleToEnclosingRect( | 286 gfx::Rect scaled_recorded_viewport = gfx::ScaleToEnclosingRect( |
| 282 raster_source_->RecordedViewport(), max_contents_scale); | 287 raster_source_->RecordedViewport(), max_contents_scale); |
| 283 for (PictureLayerTilingSet::CoverageIterator iter( | 288 for (PictureLayerTilingSet::CoverageIterator iter( |
| 284 tilings_.get(), max_contents_scale, | 289 tilings_.get(), max_contents_scale, |
| 285 shared_quad_state->visible_quad_layer_rect, ideal_contents_scale_); | 290 shared_quad_state->visible_quad_layer_rect, ideal_contents_scale_); |
| 286 iter; ++iter) { | 291 iter; ++iter) { |
| 287 gfx::Rect geometry_rect = iter.geometry_rect(); | 292 gfx::Rect geometry_rect = iter.geometry_rect(); |
| 288 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); | 293 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); |
| 289 gfx::Rect visible_geometry_rect = | 294 |
| 290 scaled_occlusion.GetUnoccludedContentRect(geometry_rect); | 295 gfx::Rect visible_tile_rect = visible_geometry_rect; |
| 291 if (visible_geometry_rect.IsEmpty()) | 296 visible_tile_rect.Intersect(geometry_rect); |
| 297 | |
| 298 if (visible_tile_rect.IsEmpty()) | |
| 292 continue; | 299 continue; |
| 293 | 300 |
| 294 append_quads_data->visible_layer_area += | 301 append_quads_data->visible_layer_area += |
| 295 visible_geometry_rect.width() * visible_geometry_rect.height(); | 302 visible_tile_rect.width() * visible_tile_rect.height(); |
| 296 | 303 |
| 297 bool has_draw_quad = false; | 304 bool has_draw_quad = false; |
| 298 if (*iter && iter->draw_info().IsReadyToDraw()) { | 305 if (*iter && iter->draw_info().IsReadyToDraw()) { |
| 299 const TileDrawInfo& draw_info = iter->draw_info(); | 306 const TileDrawInfo& draw_info = iter->draw_info(); |
| 300 switch (draw_info.mode()) { | 307 switch (draw_info.mode()) { |
| 301 case TileDrawInfo::RESOURCE_MODE: { | 308 case TileDrawInfo::RESOURCE_MODE: { |
| 302 gfx::RectF texture_rect = iter.texture_rect(); | 309 gfx::RectF texture_rect = iter.texture_rect(); |
| 303 | 310 |
| 304 // The raster_contents_scale_ is the best scale that the layer is | 311 // The raster_contents_scale_ is the best scale that the layer is |
| 305 // trying to produce, even though it may not be ideal. Since that's | 312 // trying to produce, even though it may not be ideal. Since that's |
| 306 // the best the layer can promise in the future, consider those as | 313 // the best the layer can promise in the future, consider those as |
| 307 // complete. But if a tile is ideal scale, we don't want to consider | 314 // complete. But if a tile is ideal scale, we don't want to consider |
| 308 // it incomplete and trying to replace it with a tile at a worse | 315 // it incomplete and trying to replace it with a tile at a worse |
| 309 // scale. | 316 // scale. |
| 310 if (iter->contents_scale() != raster_contents_scale_ && | 317 if (iter->contents_scale() != raster_contents_scale_ && |
| 311 iter->contents_scale() != ideal_contents_scale_ && | 318 iter->contents_scale() != ideal_contents_scale_ && |
| 312 geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { | 319 geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { |
| 313 append_quads_data->num_incomplete_tiles++; | 320 append_quads_data->num_incomplete_tiles++; |
| 314 } | 321 } |
| 315 | 322 |
| 316 TileDrawQuad* quad = | 323 TileDrawQuad* quad = |
| 317 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); | 324 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); |
| 318 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, | 325 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, |
| 319 visible_geometry_rect, draw_info.resource_id(), | 326 visible_tile_rect, draw_info.resource_id(), texture_rect, |
| 320 texture_rect, draw_info.resource_size(), | 327 draw_info.resource_size(), draw_info.contents_swizzled(), |
| 321 draw_info.contents_swizzled(), nearest_neighbor_); | 328 nearest_neighbor_); |
| 322 ValidateQuadResources(quad); | 329 ValidateQuadResources(quad); |
| 323 iter->draw_info().set_was_ever_used_to_draw(); | 330 iter->draw_info().set_was_ever_used_to_draw(); |
| 324 has_draw_quad = true; | 331 has_draw_quad = true; |
| 325 break; | 332 break; |
| 326 } | 333 } |
| 327 case TileDrawInfo::SOLID_COLOR_MODE: { | 334 case TileDrawInfo::SOLID_COLOR_MODE: { |
| 328 SolidColorDrawQuad* quad = | 335 SolidColorDrawQuad* quad = |
| 329 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 336 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 330 quad->SetNew(shared_quad_state, geometry_rect, visible_geometry_rect, | 337 quad->SetNew(shared_quad_state, geometry_rect, visible_tile_rect, |
| 331 draw_info.solid_color(), false); | 338 draw_info.solid_color(), false); |
| 332 ValidateQuadResources(quad); | 339 ValidateQuadResources(quad); |
| 333 iter->draw_info().set_was_ever_used_to_draw(); | 340 iter->draw_info().set_was_ever_used_to_draw(); |
| 334 has_draw_quad = true; | 341 has_draw_quad = true; |
| 335 break; | 342 break; |
| 336 } | 343 } |
| 337 case TileDrawInfo::OOM_MODE: | 344 case TileDrawInfo::OOM_MODE: |
| 338 break; // Checkerboard. | 345 break; // Checkerboard. |
| 339 } | 346 } |
| 340 } | 347 } |
| 341 | 348 |
| 342 if (!has_draw_quad) { | 349 if (!has_draw_quad) { |
| 343 // Checkerboard. | 350 // Checkerboard. |
| 344 SkColor color = SafeOpaqueBackgroundColor(); | 351 SkColor color = SafeOpaqueBackgroundColor(); |
| 345 if (ShowDebugBorders()) { | 352 if (ShowDebugBorders()) { |
| 346 // Fill the whole tile with the missing tile color. | 353 // Fill the whole tile with the missing tile color. |
| 347 color = DebugColors::OOMTileBorderColor(); | 354 color = DebugColors::OOMTileBorderColor(); |
| 348 } | 355 } |
| 349 SolidColorDrawQuad* quad = | 356 SolidColorDrawQuad* quad = |
| 350 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 357 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 351 quad->SetNew(shared_quad_state, geometry_rect, visible_geometry_rect, | 358 quad->SetNew(shared_quad_state, geometry_rect, visible_tile_rect, color, |
| 352 color, false); | 359 false); |
| 353 ValidateQuadResources(quad); | 360 ValidateQuadResources(quad); |
| 354 | 361 |
| 355 if (geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { | 362 if (geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { |
| 356 append_quads_data->num_missing_tiles++; | 363 append_quads_data->num_missing_tiles++; |
| 357 ++missing_tile_count; | 364 ++missing_tile_count; |
| 358 } | 365 } |
| 359 int64_t checkerboarded_area = | 366 int64_t checkerboarded_area = |
| 360 visible_geometry_rect.width() * visible_geometry_rect.height(); | 367 visible_tile_rect.width() * visible_tile_rect.height(); |
| 361 append_quads_data->checkerboarded_visible_content_area += | 368 append_quads_data->checkerboarded_visible_content_area += |
| 362 checkerboarded_area; | 369 checkerboarded_area; |
| 363 // Intersect checkerboard rect with interest rect to generate rect where | 370 // Intersect checkerboard rect with interest rect to generate rect where |
| 364 // we checkerboarded and has recording. The area where we don't have | 371 // we checkerboarded and has recording. The area where we don't have |
| 365 // recording is not necessarily a Rect, and its area is calculated using | 372 // recording is not necessarily a Rect, and its area is calculated using |
| 366 // subtraction. | 373 // subtraction. |
| 367 gfx::Rect visible_rect_has_recording = visible_geometry_rect; | 374 gfx::Rect visible_rect_has_recording = visible_tile_rect; |
| 368 visible_rect_has_recording.Intersect(scaled_recorded_viewport); | 375 visible_rect_has_recording.Intersect(scaled_recorded_viewport); |
| 369 int64_t checkerboarded_has_recording_area = | 376 int64_t checkerboarded_has_recording_area = |
| 370 visible_rect_has_recording.width() * | 377 visible_rect_has_recording.width() * |
| 371 visible_rect_has_recording.height(); | 378 visible_rect_has_recording.height(); |
| 372 append_quads_data->checkerboarded_needs_raster_content_area += | 379 append_quads_data->checkerboarded_needs_raster_content_area += |
| 373 checkerboarded_has_recording_area; | 380 checkerboarded_has_recording_area; |
| 374 append_quads_data->checkerboarded_no_recording_content_area += | 381 append_quads_data->checkerboarded_no_recording_content_area += |
| 375 checkerboarded_area - checkerboarded_has_recording_area; | 382 checkerboarded_area - checkerboarded_has_recording_area; |
| 376 continue; | 383 continue; |
| 377 } | 384 } |
| 378 | 385 |
| 379 if (iter.resolution() != HIGH_RESOLUTION) { | 386 if (iter.resolution() != HIGH_RESOLUTION) { |
| 380 append_quads_data->approximated_visible_content_area += | 387 append_quads_data->approximated_visible_content_area += |
| 381 visible_geometry_rect.width() * visible_geometry_rect.height(); | 388 visible_tile_rect.width() * visible_tile_rect.height(); |
| 382 } | 389 } |
| 383 | 390 |
| 384 // If we have a draw quad, but it's not low resolution, then | 391 // If we have a draw quad, but it's not low resolution, then |
| 385 // mark that we've used something other than low res to draw. | 392 // mark that we've used something other than low res to draw. |
| 386 if (iter.resolution() != LOW_RESOLUTION) | 393 if (iter.resolution() != LOW_RESOLUTION) |
| 387 only_used_low_res_last_append_quads_ = false; | 394 only_used_low_res_last_append_quads_ = false; |
| 388 | 395 |
| 389 if (last_append_quads_tilings_.empty() || | 396 if (last_append_quads_tilings_.empty() || |
| 390 last_append_quads_tilings_.back() != iter.CurrentTiling()) { | 397 last_append_quads_tilings_.back() != iter.CurrentTiling()) { |
| 391 last_append_quads_tilings_.push_back(iter.CurrentTiling()); | 398 last_append_quads_tilings_.push_back(iter.CurrentTiling()); |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1304 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1311 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
| 1305 return !layer_tree_impl()->IsRecycleTree(); | 1312 return !layer_tree_impl()->IsRecycleTree(); |
| 1306 } | 1313 } |
| 1307 | 1314 |
| 1308 bool PictureLayerImpl::HasValidTilePriorities() const { | 1315 bool PictureLayerImpl::HasValidTilePriorities() const { |
| 1309 return IsOnActiveOrPendingTree() && | 1316 return IsOnActiveOrPendingTree() && |
| 1310 is_drawn_render_surface_layer_list_member(); | 1317 is_drawn_render_surface_layer_list_member(); |
| 1311 } | 1318 } |
| 1312 | 1319 |
| 1313 } // namespace cc | 1320 } // namespace cc |
| OLD | NEW |