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

Side by Side Diff: cc/trees/layer_tree_host.cc

Issue 18191020: UI Resource Manager (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 5 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
OLDNEW
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.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <stack> 8 #include <stack>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { 66 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
67 scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(client, 67 scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(client,
68 settings)); 68 settings));
69 if (!layer_tree_host->Initialize(impl_task_runner)) 69 if (!layer_tree_host->Initialize(impl_task_runner))
70 return scoped_ptr<LayerTreeHost>(); 70 return scoped_ptr<LayerTreeHost>();
71 return layer_tree_host.Pass(); 71 return layer_tree_host.Pass();
72 } 72 }
73 73
74 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, 74 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client,
75 const LayerTreeSettings& settings) 75 const LayerTreeSettings& settings)
76 : animating_(false), 76 : ui_resource_counter_(1),
77 animating_(false),
77 needs_full_tree_sync_(true), 78 needs_full_tree_sync_(true),
78 needs_filter_context_(false), 79 needs_filter_context_(false),
79 client_(client), 80 client_(client),
80 commit_number_(0), 81 commit_number_(0),
81 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), 82 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()),
82 output_surface_can_be_initialized_(true), 83 output_surface_can_be_initialized_(true),
83 output_surface_lost_(true), 84 output_surface_lost_(true),
84 num_failed_recreate_attempts_(0), 85 num_failed_recreate_attempts_(0),
85 settings_(settings), 86 settings_(settings),
86 debug_state_(settings.initial_debug_state), 87 debug_state_(settings.initial_debug_state),
87 overdraw_bottom_height_(0.f), 88 overdraw_bottom_height_(0.f),
88 device_scale_factor_(1.f), 89 device_scale_factor_(1.f),
89 visible_(true), 90 visible_(true),
90 page_scale_factor_(1.f), 91 page_scale_factor_(1.f),
91 min_page_scale_factor_(1.f), 92 min_page_scale_factor_(1.f),
92 max_page_scale_factor_(1.f), 93 max_page_scale_factor_(1.f),
93 trigger_idle_updates_(true), 94 trigger_idle_updates_(true),
94 background_color_(SK_ColorWHITE), 95 background_color_(SK_ColorWHITE),
95 has_transparent_background_(false), 96 has_transparent_background_(false),
96 partial_texture_update_requests_(0), 97 partial_texture_update_requests_(0),
97 in_paint_layer_contents_(false), 98 in_paint_layer_contents_(false),
98 total_frames_used_for_lcd_text_metrics_(0) { 99 total_frames_used_for_lcd_text_metrics_(0) {
100
99 if (settings_.accelerated_animation_enabled) 101 if (settings_.accelerated_animation_enabled)
100 animation_registrar_ = AnimationRegistrar::Create(); 102 animation_registrar_ = AnimationRegistrar::Create();
101 s_num_layer_tree_instances++; 103 s_num_layer_tree_instances++;
102 104
103 rendering_stats_instrumentation_->set_record_rendering_stats( 105 rendering_stats_instrumentation_->set_record_rendering_stats(
104 debug_state_.RecordRenderingStats()); 106 debug_state_.RecordRenderingStats());
105 } 107 }
106 108
107 bool LayerTreeHost::Initialize( 109 bool LayerTreeHost::Initialize(
108 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { 110 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 (*iter).second->Animate(monotonic_time); 1050 (*iter).second->Animate(monotonic_time);
1049 bool start_ready_animations = true; 1051 bool start_ready_animations = true;
1050 (*iter).second->UpdateState(start_ready_animations, NULL); 1052 (*iter).second->UpdateState(start_ready_animations, NULL);
1051 } 1053 }
1052 } 1054 }
1053 1055
1054 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { 1056 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() {
1055 return proxy_->CapturePicture(); 1057 return proxy_->CapturePicture();
1056 } 1058 }
1057 1059
1060 UIResourceId
1061 LayerTreeHost::CreateUIResource(scoped_refptr<UIResourceBitmap> bitmap,
1062 UIResourceManagerClient* client) {
1063 ui_resource_client_map_[ui_resource_counter_] = client;
1064 proxy_->CreateUIResource(ui_resource_counter_,
1065 bitmap,
1066 true);
1067 return ui_resource_counter_++;
1068 }
1069
1070 // Deletes a UI resource. May safely be called more than once.
1071 void LayerTreeHost::DeleteUIResource(UIResourceId uid) {
1072 proxy_->DeleteUIResource(uid);
1073 }
1074
1075 void LayerTreeHost::UIResourceReady(UIResourceId id) {
1076 if (ui_resource_client_map_.find(id) != ui_resource_client_map_.end()) {
1077 ui_resource_client_map_[id]->UIResourceReady(id);
1078 }
1079 }
1080
1081 void LayerTreeHost::UIResourceLost(UIResourceId id) {
1082 if (ui_resource_client_map_.find(id) != ui_resource_client_map_.end())
1083 ui_resource_client_map_[id]->UIResourceLost(id);
1084 }
1085
1086
1058 } // namespace cc 1087 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698