| 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 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "cc/resources/prioritized_resource_manager.h" | 42 #include "cc/resources/prioritized_resource_manager.h" |
| 43 #include "cc/scheduler/delay_based_time_source.h" | 43 #include "cc/scheduler/delay_based_time_source.h" |
| 44 #include "cc/scheduler/texture_uploader.h" | 44 #include "cc/scheduler/texture_uploader.h" |
| 45 #include "cc/trees/damage_tracker.h" | 45 #include "cc/trees/damage_tracker.h" |
| 46 #include "cc/trees/layer_tree_host.h" | 46 #include "cc/trees/layer_tree_host.h" |
| 47 #include "cc/trees/layer_tree_host_common.h" | 47 #include "cc/trees/layer_tree_host_common.h" |
| 48 #include "cc/trees/layer_tree_impl.h" | 48 #include "cc/trees/layer_tree_impl.h" |
| 49 #include "cc/trees/quad_culler.h" | 49 #include "cc/trees/quad_culler.h" |
| 50 #include "cc/trees/single_thread_proxy.h" | 50 #include "cc/trees/single_thread_proxy.h" |
| 51 #include "cc/trees/tree_synchronizer.h" | 51 #include "cc/trees/tree_synchronizer.h" |
| 52 #include "gpu/GLES2/gl2extchromium.h" |
| 52 #include "ui/gfx/size_conversions.h" | 53 #include "ui/gfx/size_conversions.h" |
| 53 #include "ui/gfx/vector2d_conversions.h" | 54 #include "ui/gfx/vector2d_conversions.h" |
| 54 | 55 |
| 55 namespace { | 56 namespace { |
| 56 | 57 |
| 57 void DidVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) { | 58 void DidVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) { |
| 58 if (visible) { | 59 if (visible) { |
| 59 TRACE_EVENT_ASYNC_BEGIN1("webkit", | 60 TRACE_EVENT_ASYNC_BEGIN1("webkit", |
| 60 "LayerTreeHostImpl::SetVisible", | 61 "LayerTreeHostImpl::SetVisible", |
| 61 id, | 62 id, |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 bool root_surface_has_no_visible_damage = | 558 bool root_surface_has_no_visible_damage = |
| 558 !root_surface->damage_tracker()->current_damage_rect().Intersects( | 559 !root_surface->damage_tracker()->current_damage_rect().Intersects( |
| 559 root_surface->content_rect()); | 560 root_surface->content_rect()); |
| 560 bool root_surface_has_contributing_layers = | 561 bool root_surface_has_contributing_layers = |
| 561 !root_surface->layer_list().empty(); | 562 !root_surface->layer_list().empty(); |
| 562 if (root_surface_has_contributing_layers && | 563 if (root_surface_has_contributing_layers && |
| 563 root_surface_has_no_visible_damage) { | 564 root_surface_has_no_visible_damage) { |
| 564 TRACE_EVENT0("cc", | 565 TRACE_EVENT0("cc", |
| 565 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect"); | 566 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect"); |
| 566 frame->has_no_damage = true; | 567 frame->has_no_damage = true; |
| 568 |
| 567 // A copy request should cause damage, so we should not have any copy | 569 // A copy request should cause damage, so we should not have any copy |
| 568 // requests in this case. | 570 // requests in this case. |
| 569 DCHECK_EQ(0u, active_tree_->LayersWithCopyOutputRequest().size()); | 571 DCHECK_EQ(0u, active_tree_->LayersWithCopyOutputRequest().size()); |
| 570 return true; | 572 return true; |
| 571 } | 573 } |
| 572 | 574 |
| 573 TRACE_EVENT1("cc", | 575 TRACE_EVENT1("cc", |
| 574 "LayerTreeHostImpl::CalculateRenderPasses", | 576 "LayerTreeHostImpl::CalculateRenderPasses", |
| 575 "render_surface_layer_list.size()", | 577 "render_surface_layer_list.size()", |
| 576 static_cast<uint64>(frame->render_surface_layer_list->size())); | 578 static_cast<uint64>(frame->render_surface_layer_list->size())); |
| (...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2355 return layer ? layer->GetPicture() : skia::RefPtr<SkPicture>(); | 2357 return layer ? layer->GetPicture() : skia::RefPtr<SkPicture>(); |
| 2356 } | 2358 } |
| 2357 | 2359 |
| 2358 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { | 2360 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { |
| 2359 if (debug_state_.continuous_painting != debug_state.continuous_painting) | 2361 if (debug_state_.continuous_painting != debug_state.continuous_painting) |
| 2360 paint_time_counter_->ClearHistory(); | 2362 paint_time_counter_->ClearHistory(); |
| 2361 | 2363 |
| 2362 debug_state_ = debug_state; | 2364 debug_state_ = debug_state; |
| 2363 } | 2365 } |
| 2364 | 2366 |
| 2367 void LayerTreeHostImpl::CreateUIResource(UIResourceId uid, |
| 2368 scoped_refptr<UIResourceBitmap> bitmap, |
| 2369 bool async) { |
| 2370 ResourceProvider::ResourceId id = |
| 2371 resource_provider_->CreateGLTexture(bitmap->GetSize(), |
| 2372 GL_RGBA, |
| 2373 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, |
| 2374 ResourceProvider::TextureUsageAny); |
| 2375 |
| 2376 ui_resource_map_[uid] = id; |
| 2377 gfx::Size bitmap_size = bitmap->GetSize(); |
| 2378 resource_provider_->SetPixels(id, |
| 2379 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), |
| 2380 gfx::Rect(1, 1, bitmap_size.width(), |
| 2381 bitmap_size.height()), |
| 2382 gfx::Rect(1, 1, bitmap_size.width(), |
| 2383 bitmap_size.height()), |
| 2384 gfx::Vector2d(0, 0)); |
| 2385 |
| 2386 client_->UIResourceCreatedOnImplThread(uid); |
| 2387 } |
| 2388 |
| 2389 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
| 2390 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
| 2391 if (id) { |
| 2392 resource_provider_->DeleteResource(id); |
| 2393 ui_resource_map_.erase(uid); |
| 2394 } |
| 2395 } |
| 2396 |
| 2397 ResourceProvider::ResourceId |
| 2398 LayerTreeHostImpl::ResourceIdForUIResource(UIResourceId uid) const { |
| 2399 if (ui_resource_map_.find(uid) != ui_resource_map_.end()) { |
| 2400 return ui_resource_map_.find(uid)->second; |
| 2401 } |
| 2402 return 0; |
| 2403 } |
| 2404 |
| 2405 |
| 2365 } // namespace cc | 2406 } // namespace cc |
| OLD | NEW |