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

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
aelias_OOO_until_Jul13 2013/07/10 23:07:22 nit: accidental whitespace
powei 2013/07/11 23:54:44 Done.
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // this function, keep in mind that the function *runs* on the impl thread! Any 247 // this function, keep in mind that the function *runs* on the impl thread! Any
246 // code that is logically a main thread operation, e.g. deletion of a Layer, 248 // code that is logically a main thread operation, e.g. deletion of a Layer,
247 // should be delayed until the LayerTreeHost::CommitComplete, which will run 249 // should be delayed until the LayerTreeHost::CommitComplete, which will run
248 // after the commit, but on the main thread. 250 // after the commit, but on the main thread.
249 void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { 251 void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
250 DCHECK(proxy_->IsImplThread()); 252 DCHECK(proxy_->IsImplThread());
251 253
252 // If there are linked evicted backings, these backings' resources may be put 254 // If there are linked evicted backings, these backings' resources may be put
253 // into the impl tree, so we can't draw yet. Determine this before clearing 255 // into the impl tree, so we can't draw yet. Determine this before clearing
254 // all evicted backings. 256 // all evicted backings.
257
aelias_OOO_until_Jul13 2013/07/10 23:07:22 nit: accidental whitespace
powei 2013/07/11 23:54:44 Done.
255 bool new_impl_tree_has_no_evicted_resources = false; 258 bool new_impl_tree_has_no_evicted_resources = false;
256 if (contents_texture_manager_) { 259 if (contents_texture_manager_) {
257 new_impl_tree_has_no_evicted_resources = 260 new_impl_tree_has_no_evicted_resources =
258 !contents_texture_manager_->LinkedEvictedBackingsExist(); 261 !contents_texture_manager_->LinkedEvictedBackingsExist();
259 262
260 // If the memory limit has been increased since this now-finishing 263 // If the memory limit has been increased since this now-finishing
261 // commit began, and the extra now-available memory would have been used, 264 // commit began, and the extra now-available memory would have been used,
262 // then request another commit. 265 // then request another commit.
263 if (contents_texture_manager_->MaxMemoryLimitBytes() < 266 if (contents_texture_manager_->MaxMemoryLimitBytes() <
264 host_impl->memory_allocation_limit_bytes() && 267 host_impl->memory_allocation_limit_bytes() &&
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 if (pending_page_scale_animation_) { 345 if (pending_page_scale_animation_) {
343 host_impl->StartPageScaleAnimation( 346 host_impl->StartPageScaleAnimation(
344 pending_page_scale_animation_->target_offset, 347 pending_page_scale_animation_->target_offset,
345 pending_page_scale_animation_->use_anchor, 348 pending_page_scale_animation_->use_anchor,
346 pending_page_scale_animation_->scale, 349 pending_page_scale_animation_->scale,
347 base::TimeTicks::Now(), 350 base::TimeTicks::Now(),
348 pending_page_scale_animation_->duration); 351 pending_page_scale_animation_->duration);
349 pending_page_scale_animation_.reset(); 352 pending_page_scale_animation_.reset();
350 } 353 }
351 354
355 // ui resource processing
aelias_OOO_until_Jul13 2013/07/10 23:07:22 Delete this comment
powei 2013/07/11 23:54:44 Done.
356 while (ui_resource_request_queue_.size() > 0) {
357 UIResourceRequest req = ui_resource_request_queue_.front();
358 ui_resource_request_queue_.pop_front();
359 host_impl->CreateUIResource(req.id, req.bitmap, req.async);
360 }
361
362 while (ui_resource_remove_queue_.size() > 0) {
363 UIResourceId uid = ui_resource_remove_queue_.front();
364 ui_resource_remove_queue_.pop_front();
365 host_impl->DeleteUIResource(uid);
366 }
367
352 DCHECK(!sync_tree->ViewportSizeInvalid()); 368 DCHECK(!sync_tree->ViewportSizeInvalid());
353 369
354 if (new_impl_tree_has_no_evicted_resources) { 370 if (new_impl_tree_has_no_evicted_resources) {
355 if (sync_tree->ContentsTexturesPurged()) 371 if (sync_tree->ContentsTexturesPurged())
356 sync_tree->ResetContentsTexturesPurged(); 372 sync_tree->ResetContentsTexturesPurged();
357 } 373 }
358 374
359 if (!settings_.impl_side_painting) { 375 if (!settings_.impl_side_painting) {
360 // If we're not in impl-side painting, the tree is immediately 376 // If we're not in impl-side painting, the tree is immediately
361 // considered active. 377 // considered active.
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 (*iter).second->Animate(monotonic_time); 1064 (*iter).second->Animate(monotonic_time);
1049 bool start_ready_animations = true; 1065 bool start_ready_animations = true;
1050 (*iter).second->UpdateState(start_ready_animations, NULL); 1066 (*iter).second->UpdateState(start_ready_animations, NULL);
1051 } 1067 }
1052 } 1068 }
1053 1069
1054 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { 1070 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() {
1055 return proxy_->CapturePicture(); 1071 return proxy_->CapturePicture();
1056 } 1072 }
1057 1073
1074 UIResourceId
1075 LayerTreeHost::CreateUIResource(scoped_refptr<UIResourceBitmap> bitmap,
1076 UIResourceManagerClient* client) {
1077 UIResourceRequest request;
1078 request.id = ui_resource_counter_++;
1079 request.bitmap = bitmap;
1080 request.async = true;
1081
1082 ui_resource_request_queue_.push_back(request);
1083 ui_resource_client_map_[request.id] = client;
1084
1085 return request.id;
1086 }
1087
1088 // Deletes a UI resource. May safely be called more than once.
1089 void LayerTreeHost::DeleteUIResource(UIResourceId uid) {
1090 if (ui_resource_client_map_.find(uid) != ui_resource_client_map_.end()) {
1091 ui_resource_remove_queue_.push_back(uid);
1092 ui_resource_client_map_.erase(uid);
1093 }
1094 }
1095
1096 void LayerTreeHost::UIResourceReady(UIResourceId id) {
1097 if (ui_resource_client_map_.find(id) != ui_resource_client_map_.end()) {
1098 ui_resource_client_map_[id]->UIResourceReady(id);
1099 }
1100 }
1101
1102 void LayerTreeHost::UIResourceLost(UIResourceId id) {}
1103
1104
1058 } // namespace cc 1105 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698