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

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

Issue 93773002: Refactor SingleThreadProxy to reduce the call invocation for LayerTreeHost::contents_texture_manage… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch after formatting. Created 7 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/single_thread_proxy.h" 5 #include "cc/trees/single_thread_proxy.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "cc/debug/benchmark_instrumentation.h" 9 #include "cc/debug/benchmark_instrumentation.h"
10 #include "cc/output/context_provider.h" 10 #include "cc/output/context_provider.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 193 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
194 DebugScopedSetImplThread impl(this); 194 DebugScopedSetImplThread impl(this);
195 195
196 // This CapturePostTasks should be destroyed before CommitComplete() is 196 // This CapturePostTasks should be destroyed before CommitComplete() is
197 // called since that goes out to the embedder, and we want the embedder 197 // called since that goes out to the embedder, and we want the embedder
198 // to receive its callbacks before that. 198 // to receive its callbacks before that.
199 BlockingTaskRunner::CapturePostTasks blocked; 199 BlockingTaskRunner::CapturePostTasks blocked;
200 200
201 layer_tree_host_impl_->BeginCommit(); 201 layer_tree_host_impl_->BeginCommit();
202 202
203 if (layer_tree_host_->contents_texture_manager()) { 203 if (PrioritizedResourceManager* contents_texture_manager =
204 layer_tree_host_->contents_texture_manager()-> 204 layer_tree_host_->contents_texture_manager()) {
205 PushTexturePrioritiesToBackings(); 205 contents_texture_manager->PushTexturePrioritiesToBackings();
206 } 206 }
207 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); 207 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get());
208 208
209 scoped_ptr<ResourceUpdateController> update_controller = 209 scoped_ptr<ResourceUpdateController> update_controller =
210 ResourceUpdateController::Create( 210 ResourceUpdateController::Create(
211 NULL, 211 NULL,
212 Proxy::MainThreadTaskRunner(), 212 Proxy::MainThreadTaskRunner(),
213 queue.Pass(), 213 queue.Pass(),
214 layer_tree_host_impl_->resource_provider()); 214 layer_tree_host_impl_->resource_provider());
215 update_controller->Finalize(); 215 update_controller->Finalize();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 base::Time wall_clock_time) { 322 base::Time wall_clock_time) {
323 DCHECK(Proxy::IsImplThread()); 323 DCHECK(Proxy::IsImplThread());
324 DebugScopedSetMainThread main(this); 324 DebugScopedSetMainThread main(this);
325 layer_tree_host_->SetAnimationEvents(events.Pass(), wall_clock_time); 325 layer_tree_host_->SetAnimationEvents(events.Pass(), wall_clock_time);
326 } 326 }
327 327
328 bool SingleThreadProxy::ReduceContentsTextureMemoryOnImplThread( 328 bool SingleThreadProxy::ReduceContentsTextureMemoryOnImplThread(
329 size_t limit_bytes, 329 size_t limit_bytes,
330 int priority_cutoff) { 330 int priority_cutoff) {
331 DCHECK(IsImplThread()); 331 DCHECK(IsImplThread());
332 if (!layer_tree_host_->contents_texture_manager()) 332 PrioritizedResourceManager* contents_texture_manager =
333 return false; 333 layer_tree_host_->contents_texture_manager();
334 if (!layer_tree_host_impl_->resource_provider()) 334
335 ResourceProvider* resource_provider =
336 layer_tree_host_impl_->resource_provider();
337
338 if (!contents_texture_manager || !resource_provider)
335 return false; 339 return false;
336 340
337 return layer_tree_host_->contents_texture_manager()->ReduceMemoryOnImplThread( 341 return contents_texture_manager->ReduceMemoryOnImplThread(
338 limit_bytes, priority_cutoff, layer_tree_host_impl_->resource_provider()); 342 limit_bytes, priority_cutoff, resource_provider);
339 } 343 }
340 344
341 void SingleThreadProxy::SendManagedMemoryStats() { 345 void SingleThreadProxy::SendManagedMemoryStats() {
342 DCHECK(Proxy::IsImplThread()); 346 DCHECK(Proxy::IsImplThread());
343 if (!layer_tree_host_impl_) 347 if (!layer_tree_host_impl_)
344 return; 348 return;
345 if (!layer_tree_host_->contents_texture_manager()) 349 PrioritizedResourceManager* contents_texture_manager =
350 layer_tree_host_->contents_texture_manager();
351 if (!contents_texture_manager)
346 return; 352 return;
347 353
348 PrioritizedResourceManager* contents_texture_manager =
349 layer_tree_host_->contents_texture_manager();
350 layer_tree_host_impl_->SendManagedMemoryStats( 354 layer_tree_host_impl_->SendManagedMemoryStats(
351 contents_texture_manager->MemoryVisibleBytes(), 355 contents_texture_manager->MemoryVisibleBytes(),
352 contents_texture_manager->MemoryVisibleAndNearbyBytes(), 356 contents_texture_manager->MemoryVisibleAndNearbyBytes(),
353 contents_texture_manager->MemoryUseBytes()); 357 contents_texture_manager->MemoryUseBytes());
354 } 358 }
355 359
356 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } 360 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; }
357 361
358 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { 362 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() {
359 // Cause a commit so we can notice the lost context. 363 // Cause a commit so we can notice the lost context.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 gfx::Rect device_viewport_damage_rect, 431 gfx::Rect device_viewport_damage_rect,
428 bool for_readback, 432 bool for_readback,
429 LayerTreeHostImpl::FrameData* frame) { 433 LayerTreeHostImpl::FrameData* frame) {
430 DCHECK(Proxy::IsMainThread()); 434 DCHECK(Proxy::IsMainThread());
431 435
432 if (!layer_tree_host_->InitializeOutputSurfaceIfNeeded()) 436 if (!layer_tree_host_->InitializeOutputSurfaceIfNeeded())
433 return false; 437 return false;
434 438
435 layer_tree_host_->AnimateLayers(frame_begin_time); 439 layer_tree_host_->AnimateLayers(frame_begin_time);
436 440
437 if (layer_tree_host_->contents_texture_manager()) { 441 if (PrioritizedResourceManager* contents_texture_manager =
438 layer_tree_host_->contents_texture_manager() 442 layer_tree_host_->contents_texture_manager()) {
439 ->UnlinkAndClearEvictedBackings(); 443 contents_texture_manager->UnlinkAndClearEvictedBackings();
440 layer_tree_host_->contents_texture_manager()->SetMaxMemoryLimitBytes( 444 contents_texture_manager->SetMaxMemoryLimitBytes(
441 layer_tree_host_impl_->memory_allocation_limit_bytes()); 445 layer_tree_host_impl_->memory_allocation_limit_bytes());
442 layer_tree_host_->contents_texture_manager()->SetExternalPriorityCutoff( 446 contents_texture_manager->SetExternalPriorityCutoff(
443 layer_tree_host_impl_->memory_allocation_priority_cutoff()); 447 layer_tree_host_impl_->memory_allocation_priority_cutoff());
444 } 448 }
445 449
446 scoped_ptr<ResourceUpdateQueue> queue = 450 scoped_ptr<ResourceUpdateQueue> queue =
447 make_scoped_ptr(new ResourceUpdateQueue); 451 make_scoped_ptr(new ResourceUpdateQueue);
448 layer_tree_host_->UpdateLayers(queue.get()); 452 layer_tree_host_->UpdateLayers(queue.get());
449 453
450 layer_tree_host_->WillCommit(); 454 layer_tree_host_->WillCommit();
451 455
452 scoped_refptr<cc::ContextProvider> offscreen_context_provider; 456 scoped_refptr<cc::ContextProvider> offscreen_context_provider;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 void SingleThreadProxy::DidSwapFrame() { 546 void SingleThreadProxy::DidSwapFrame() {
543 if (next_frame_is_newly_committed_frame_) { 547 if (next_frame_is_newly_committed_frame_) {
544 next_frame_is_newly_committed_frame_ = false; 548 next_frame_is_newly_committed_frame_ = false;
545 layer_tree_host_->DidCommitAndDrawFrame(); 549 layer_tree_host_->DidCommitAndDrawFrame();
546 } 550 }
547 } 551 }
548 552
549 bool SingleThreadProxy::CommitPendingForTesting() { return false; } 553 bool SingleThreadProxy::CommitPendingForTesting() { return false; }
550 554
551 } // namespace cc 555 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698