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

Side by Side Diff: cc/trees/layer_tree_host_impl.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_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 22 matching lines...) Expand all
33 #include "cc/output/copy_output_request.h" 33 #include "cc/output/copy_output_request.h"
34 #include "cc/output/delegating_renderer.h" 34 #include "cc/output/delegating_renderer.h"
35 #include "cc/output/gl_renderer.h" 35 #include "cc/output/gl_renderer.h"
36 #include "cc/output/software_renderer.h" 36 #include "cc/output/software_renderer.h"
37 #include "cc/quads/render_pass_draw_quad.h" 37 #include "cc/quads/render_pass_draw_quad.h"
38 #include "cc/quads/shared_quad_state.h" 38 #include "cc/quads/shared_quad_state.h"
39 #include "cc/quads/solid_color_draw_quad.h" 39 #include "cc/quads/solid_color_draw_quad.h"
40 #include "cc/resources/memory_history.h" 40 #include "cc/resources/memory_history.h"
41 #include "cc/resources/picture_layer_tiling.h" 41 #include "cc/resources/picture_layer_tiling.h"
42 #include "cc/resources/prioritized_resource_manager.h" 42 #include "cc/resources/prioritized_resource_manager.h"
43 #include "cc/resources/ui_resource_bitmap.h"
43 #include "cc/scheduler/delay_based_time_source.h" 44 #include "cc/scheduler/delay_based_time_source.h"
44 #include "cc/scheduler/texture_uploader.h" 45 #include "cc/scheduler/texture_uploader.h"
45 #include "cc/trees/damage_tracker.h" 46 #include "cc/trees/damage_tracker.h"
46 #include "cc/trees/layer_tree_host.h" 47 #include "cc/trees/layer_tree_host.h"
47 #include "cc/trees/layer_tree_host_common.h" 48 #include "cc/trees/layer_tree_host_common.h"
48 #include "cc/trees/layer_tree_impl.h" 49 #include "cc/trees/layer_tree_impl.h"
49 #include "cc/trees/quad_culler.h" 50 #include "cc/trees/quad_culler.h"
50 #include "cc/trees/single_thread_proxy.h" 51 #include "cc/trees/single_thread_proxy.h"
51 #include "cc/trees/tree_synchronizer.h" 52 #include "cc/trees/tree_synchronizer.h"
53 #include "gpu/GLES2/gl2extchromium.h"
52 #include "ui/gfx/size_conversions.h" 54 #include "ui/gfx/size_conversions.h"
53 #include "ui/gfx/vector2d_conversions.h" 55 #include "ui/gfx/vector2d_conversions.h"
54 56
55 namespace { 57 namespace {
56 58
57 void DidVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) { 59 void DidVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) {
58 if (visible) { 60 if (visible) {
59 TRACE_EVENT_ASYNC_BEGIN1("webkit", 61 TRACE_EVENT_ASYNC_BEGIN1("webkit",
60 "LayerTreeHostImpl::SetVisible", 62 "LayerTreeHostImpl::SetVisible",
61 id, 63 id,
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 top_controls_manager_ ? top_controls_manager_->content_top_offset() : 0.f; 1293 top_controls_manager_ ? top_controls_manager_->content_top_offset() : 0.f;
1292 return gfx::SizeF(dip_size.width(), 1294 return gfx::SizeF(dip_size.width(),
1293 dip_size.height() - top_offset - overdraw_bottom_height_); 1295 dip_size.height() - top_offset - overdraw_bottom_height_);
1294 } 1296 }
1295 1297
1296 const LayerTreeSettings& LayerTreeHostImpl::Settings() const { 1298 const LayerTreeSettings& LayerTreeHostImpl::Settings() const {
1297 return settings(); 1299 return settings();
1298 } 1300 }
1299 1301
1300 void LayerTreeHostImpl::DidLoseOutputSurface() { 1302 void LayerTreeHostImpl::DidLoseOutputSurface() {
1303 // When output surface is lost, notify the client of the lost and remove
1304 // exisiting entries.
enne (OOO) 2013/07/22 23:09:15 typo: exisiting => existing
powei 2013/07/24 02:28:29 Done.
1305 for (UIResourceMap::iterator iter = ui_resource_map_.begin();
1306 iter != ui_resource_map_.end();
1307 iter++) {
1308 client_->UIResourceLostOnImplThread(iter->first);
enne (OOO) 2013/07/22 23:09:15 I am still a little confused about this path. It
aelias_OOO_until_Jul13 2013/07/23 00:06:48 I agree with Enne, the loop should be in LayerTree
powei 2013/07/24 02:28:29 Done.
powei 2013/07/24 02:28:29 Done.
1309 }
1310 // Remove all map from existing UIResourceId to ResourceId.
1311 ui_resource_map_.clear();
1312 // Remove all pending UI resource requests because there might be
1313 // deletion requests, which can no longer be honored (or already
1314 // gone anyways).
1315 ui_resource_request_queue_.clear();
1316
1301 // TODO(jamesr): The renderer_ check is needed to make some of the 1317 // TODO(jamesr): The renderer_ check is needed to make some of the
1302 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or 1318 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or
1303 // important) in production. We should adjust the test to not need this. 1319 // important) in production. We should adjust the test to not need this.
1304 if (renderer_) 1320 if (renderer_)
1305 client_->DidLoseOutputSurfaceOnImplThread(); 1321 client_->DidLoseOutputSurfaceOnImplThread();
1306 } 1322 }
1307 1323
1308 void LayerTreeHostImpl::Readback(void* pixels, 1324 void LayerTreeHostImpl::Readback(void* pixels,
1309 gfx::Rect rect_in_device_viewport) { 1325 gfx::Rect rect_in_device_viewport) {
1310 DCHECK(renderer_); 1326 DCHECK(renderer_);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 client_->RenewTreePriority(); 1439 client_->RenewTreePriority();
1424 1440
1425 if (debug_state_.continuous_painting) { 1441 if (debug_state_.continuous_painting) {
1426 const RenderingStats& stats = 1442 const RenderingStats& stats =
1427 rendering_stats_instrumentation_->GetRenderingStats(); 1443 rendering_stats_instrumentation_->GetRenderingStats();
1428 paint_time_counter_->SavePaintTime( 1444 paint_time_counter_->SavePaintTime(
1429 stats.total_paint_time + stats.total_record_time + 1445 stats.total_paint_time + stats.total_record_time +
1430 stats.total_rasterize_time_for_now_bins_on_pending_tree); 1446 stats.total_rasterize_time_for_now_bins_on_pending_tree);
1431 } 1447 }
1432 1448
1449 while (ui_resource_request_queue_.size() > 0) {
1450 UIResourceRequest req = ui_resource_request_queue_.front();
1451 ui_resource_request_queue_.pop_front();
1452 switch (req.type) {
1453 case UIResourceCreate:
1454 CreateUIResource(req.id, req.bitmap);
enne (OOO) 2013/07/22 23:09:15 In general activation is gated on having all of yo
aelias_OOO_until_Jul13 2013/07/23 00:06:48 Yes, the assumption is that for v1 of this patch,
powei 2013/07/24 02:28:29 Done.
powei 2013/07/24 02:28:29 Done.
1455 break;
1456 case UIResourceDelete:
1457 DeleteUIResource(req.id);
1458 break;
1459 }
1460 }
1461
1433 client_->DidActivatePendingTree(); 1462 client_->DidActivatePendingTree();
1434 } 1463 }
1435 1464
1436 void LayerTreeHostImpl::SetVisible(bool visible) { 1465 void LayerTreeHostImpl::SetVisible(bool visible) {
1437 DCHECK(proxy_->IsImplThread()); 1466 DCHECK(proxy_->IsImplThread());
1438 1467
1439 if (visible_ == visible) 1468 if (visible_ == visible)
1440 return; 1469 return;
1441 visible_ = visible; 1470 visible_ = visible;
1442 DidVisibilityChange(this, visible_); 1471 DidVisibilityChange(this, visible_);
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
2355 return layer ? layer->GetPicture() : skia::RefPtr<SkPicture>(); 2384 return layer ? layer->GetPicture() : skia::RefPtr<SkPicture>();
2356 } 2385 }
2357 2386
2358 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { 2387 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) {
2359 if (debug_state_.continuous_painting != debug_state.continuous_painting) 2388 if (debug_state_.continuous_painting != debug_state.continuous_painting)
2360 paint_time_counter_->ClearHistory(); 2389 paint_time_counter_->ClearHistory();
2361 2390
2362 debug_state_ = debug_state; 2391 debug_state_ = debug_state;
2363 } 2392 }
2364 2393
2394 void LayerTreeHostImpl::CreateUIResource(
2395 UIResourceId uid,
2396 scoped_refptr<UIResourceBitmap> bitmap) {
2397 ResourceProvider::ResourceId id =
2398 resource_provider_->CreateGLTexture(bitmap->GetSize(),
enne (OOO) 2013/07/22 23:09:15 CreateGLTexture in LayerTreeHostImpl? What if ther
powei 2013/07/24 02:28:29 Done.
2399 GL_RGBA,
enne (OOO) 2013/07/22 23:09:15 Should you DCHECK that bitmap's format is RGBA8 an
powei 2013/07/24 02:28:29 Done.
2400 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM,
2401 ResourceProvider::TextureUsageAny);
2402
2403 ui_resource_map_[uid] = id;
enne (OOO) 2013/07/22 23:09:15 Can you DCHECK that it doesn't previously exist?
powei 2013/07/24 02:28:29 Done.
2404 gfx::Size bitmap_size = bitmap->GetSize();
2405 resource_provider_->SetPixels(id,
2406 reinterpret_cast<uint8_t*>(bitmap->GetPixels()),
2407 gfx::Rect(bitmap_size),
2408 gfx::Rect(bitmap_size),
2409 gfx::Vector2d(0, 0));
2410 }
2411
2412 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
2413 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2414 if (id) {
2415 resource_provider_->DeleteResource(id);
2416 ui_resource_map_.erase(uid);
2417 }
2418 }
2419
2420 ResourceProvider::ResourceId
2421 LayerTreeHostImpl::ResourceIdForUIResource(UIResourceId uid) const {
2422 if (ui_resource_map_.find(uid) != ui_resource_map_.end()) {
enne (OOO) 2013/07/22 23:09:15 If you're going to find and then do something with
powei 2013/07/24 02:28:29 Done.
2423 return ui_resource_map_.find(uid)->second;
2424 }
2425 return 0;
2426 }
2427
2428
2365 } // namespace cc 2429 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698