Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1095 } | 1095 } |
| 1096 } | 1096 } |
| 1097 } | 1097 } |
| 1098 | 1098 |
| 1099 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { | 1099 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { |
| 1100 TRACE_EVENT1("cc", | 1100 TRACE_EVENT1("cc", |
| 1101 "LayerTreeHostImpl::PrepareToDraw", | 1101 "LayerTreeHostImpl::PrepareToDraw", |
| 1102 "SourceFrameNumber", | 1102 "SourceFrameNumber", |
| 1103 active_tree_->source_frame_number()); | 1103 active_tree_->source_frame_number()); |
| 1104 | 1104 |
| 1105 if (!have_valid_output_surface_) | |
|
danakj
2014/08/15 17:45:15
For this to happen, we'd have to get the callback
dneto
2014/08/15 17:58:20
In a first attempt, I made LTHI::CanDraw return fa
danakj
2014/08/15 18:00:12
Ya, make DoComposite return void. I'm suggesting t
| |
| 1106 return DRAW_ABORTED_CONTEXT_LOST; | |
| 1107 | |
| 1105 if (need_to_update_visible_tiles_before_draw_ && | 1108 if (need_to_update_visible_tiles_before_draw_ && |
| 1106 tile_manager_ && tile_manager_->UpdateVisibleTiles()) { | 1109 tile_manager_ && tile_manager_->UpdateVisibleTiles()) { |
| 1107 DidInitializeVisibleTile(); | 1110 DidInitializeVisibleTile(); |
| 1108 } | 1111 } |
| 1109 need_to_update_visible_tiles_before_draw_ = true; | 1112 need_to_update_visible_tiles_before_draw_ = true; |
| 1110 | 1113 |
| 1111 UMA_HISTOGRAM_CUSTOM_COUNTS( | 1114 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 1112 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20); | 1115 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20); |
| 1113 | 1116 |
| 1114 bool ok = active_tree_->UpdateDrawProperties(); | 1117 bool ok = active_tree_->UpdateDrawProperties(); |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1609 // Once all layers have been drawn, pending texture uploads should no | 1612 // Once all layers have been drawn, pending texture uploads should no |
| 1610 // longer block future uploads. | 1613 // longer block future uploads. |
| 1611 resource_provider_->MarkPendingUploadsAsNonBlocking(); | 1614 resource_provider_->MarkPendingUploadsAsNonBlocking(); |
| 1612 } | 1615 } |
| 1613 | 1616 |
| 1614 void LayerTreeHostImpl::FinishAllRendering() { | 1617 void LayerTreeHostImpl::FinishAllRendering() { |
| 1615 if (renderer_) | 1618 if (renderer_) |
| 1616 renderer_->Finish(); | 1619 renderer_->Finish(); |
| 1617 } | 1620 } |
| 1618 | 1621 |
| 1619 bool LayerTreeHostImpl::IsContextLost() { | |
| 1620 DCHECK(proxy_->IsImplThread()); | |
| 1621 // To avoid races, rely only on the lost-surface callback. | |
| 1622 // See crbug.com/392891. | |
| 1623 return !have_valid_output_surface_; | |
| 1624 } | |
| 1625 | |
| 1626 void LayerTreeHostImpl::SetUseGpuRasterization(bool use_gpu) { | 1622 void LayerTreeHostImpl::SetUseGpuRasterization(bool use_gpu) { |
| 1627 if (use_gpu == use_gpu_rasterization_) | 1623 if (use_gpu == use_gpu_rasterization_) |
| 1628 return; | 1624 return; |
| 1629 | 1625 |
| 1630 use_gpu_rasterization_ = use_gpu; | 1626 use_gpu_rasterization_ = use_gpu; |
| 1631 ReleaseTreeResources(); | 1627 ReleaseTreeResources(); |
| 1632 | 1628 |
| 1633 // Replace existing tile manager with another one that uses appropriate | 1629 // Replace existing tile manager with another one that uses appropriate |
| 1634 // rasterizer. | 1630 // rasterizer. |
| 1635 if (tile_manager_) { | 1631 if (tile_manager_) { |
| (...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3290 ResourceFormat format = resource_provider_->best_texture_format(); | 3286 ResourceFormat format = resource_provider_->best_texture_format(); |
| 3291 switch (bitmap.GetFormat()) { | 3287 switch (bitmap.GetFormat()) { |
| 3292 case UIResourceBitmap::RGBA8: | 3288 case UIResourceBitmap::RGBA8: |
| 3293 break; | 3289 break; |
| 3294 case UIResourceBitmap::ALPHA_8: | 3290 case UIResourceBitmap::ALPHA_8: |
| 3295 format = ALPHA_8; | 3291 format = ALPHA_8; |
| 3296 break; | 3292 break; |
| 3297 case UIResourceBitmap::ETC1: | 3293 case UIResourceBitmap::ETC1: |
| 3298 format = ETC1; | 3294 format = ETC1; |
| 3299 break; | 3295 break; |
| 3300 }; | 3296 } |
|
dneto
2014/08/15 17:44:31
This fixes a readability issue reported when I fir
| |
| 3301 id = resource_provider_->CreateResource( | 3297 id = resource_provider_->CreateResource( |
| 3302 bitmap.GetSize(), | 3298 bitmap.GetSize(), |
| 3303 wrap_mode, | 3299 wrap_mode, |
| 3304 ResourceProvider::TextureUsageAny, | 3300 ResourceProvider::TextureUsageAny, |
| 3305 format); | 3301 format); |
| 3306 | 3302 |
| 3307 UIResourceData data; | 3303 UIResourceData data; |
| 3308 data.resource_id = id; | 3304 data.resource_id = id; |
| 3309 data.size = bitmap.GetSize(); | 3305 data.size = bitmap.GetSize(); |
| 3310 data.opaque = bitmap.GetOpaque(); | 3306 data.opaque = bitmap.GetOpaque(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3406 } | 3402 } |
| 3407 | 3403 |
| 3408 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3404 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3409 std::vector<PictureLayerImpl*>::iterator it = | 3405 std::vector<PictureLayerImpl*>::iterator it = |
| 3410 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3406 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3411 DCHECK(it != picture_layers_.end()); | 3407 DCHECK(it != picture_layers_.end()); |
| 3412 picture_layers_.erase(it); | 3408 picture_layers_.erase(it); |
| 3413 } | 3409 } |
| 3414 | 3410 |
| 3415 } // namespace cc | 3411 } // namespace cc |
| OLD | NEW |