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

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

Issue 14960006: cc: Don't do CompositeAndReadback when using DelegatingRenderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
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/base/thread.h" 9 #include "cc/base/thread.h"
10 #include "cc/output/context_provider.h" 10 #include "cc/output/context_provider.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 bool SingleThreadProxy::CompositeAndReadback(void* pixels, gfx::Rect rect) { 54 bool SingleThreadProxy::CompositeAndReadback(void* pixels, gfx::Rect rect) {
55 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeAndReadback"); 55 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeAndReadback");
56 DCHECK(Proxy::IsMainThread()); 56 DCHECK(Proxy::IsMainThread());
57 57
58 gfx::Rect device_viewport_damage_rect = rect; 58 gfx::Rect device_viewport_damage_rect = rect;
59 59
60 LayerTreeHostImpl::FrameData frame; 60 LayerTreeHostImpl::FrameData frame;
61 if (!CommitAndComposite(base::TimeTicks::Now(), 61 if (!CommitAndComposite(base::TimeTicks::Now(),
62 device_viewport_damage_rect, 62 device_viewport_damage_rect,
63 true, // for_readback
63 &frame)) 64 &frame))
64 return false; 65 return false;
65 66
66 { 67 {
67 DebugScopedSetImplThread impl(this); 68 DebugScopedSetImplThread impl(this);
68 layer_tree_host_impl_->Readback(pixels, rect); 69 layer_tree_host_impl_->Readback(pixels, rect);
69 70
70 if (layer_tree_host_impl_->IsContextLost()) 71 if (layer_tree_host_impl_->IsContextLost())
71 return false; 72 return false;
72 73
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 331 }
331 332
332 // Called by the legacy scheduling path (e.g. where render_widget does the 333 // Called by the legacy scheduling path (e.g. where render_widget does the
333 // scheduling) 334 // scheduling)
334 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { 335 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) {
335 gfx::Rect device_viewport_damage_rect; 336 gfx::Rect device_viewport_damage_rect;
336 337
337 LayerTreeHostImpl::FrameData frame; 338 LayerTreeHostImpl::FrameData frame;
338 if (CommitAndComposite(frame_begin_time, 339 if (CommitAndComposite(frame_begin_time,
339 device_viewport_damage_rect, 340 device_viewport_damage_rect,
341 false, // for_readback
340 &frame)) { 342 &frame)) {
341 layer_tree_host_impl_->SwapBuffers(frame); 343 layer_tree_host_impl_->SwapBuffers(frame);
342 DidSwapFrame(); 344 DidSwapFrame();
343 } 345 }
344 } 346 }
345 347
346 scoped_ptr<base::Value> SingleThreadProxy::AsValue() const { 348 scoped_ptr<base::Value> SingleThreadProxy::AsValue() const {
347 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 349 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
348 { 350 {
349 // The following line casts away const modifiers because it is just 351 // The following line casts away const modifiers because it is just
(...skipping 13 matching lines...) Expand all
363 if (layer_tree_host_impl_->renderer()) { 365 if (layer_tree_host_impl_->renderer()) {
364 DCHECK(!layer_tree_host_->output_surface_lost()); 366 DCHECK(!layer_tree_host_->output_surface_lost());
365 layer_tree_host_impl_->renderer()->DoNoOp(); 367 layer_tree_host_impl_->renderer()->DoNoOp();
366 } 368 }
367 } 369 }
368 } 370 }
369 371
370 bool SingleThreadProxy::CommitAndComposite( 372 bool SingleThreadProxy::CommitAndComposite(
371 base::TimeTicks frame_begin_time, 373 base::TimeTicks frame_begin_time,
372 gfx::Rect device_viewport_damage_rect, 374 gfx::Rect device_viewport_damage_rect,
375 bool for_readback,
373 LayerTreeHostImpl::FrameData* frame) { 376 LayerTreeHostImpl::FrameData* frame) {
374 DCHECK(Proxy::IsMainThread()); 377 DCHECK(Proxy::IsMainThread());
375 378
376 if (!layer_tree_host_->InitializeOutputSurfaceIfNeeded()) 379 if (!layer_tree_host_->InitializeOutputSurfaceIfNeeded())
377 return false; 380 return false;
378 381
379 scoped_refptr<cc::ContextProvider> offscreen_context_provider; 382 scoped_refptr<cc::ContextProvider> offscreen_context_provider;
380 if (renderer_capabilities_for_main_thread_.using_offscreen_context3d && 383 if (renderer_capabilities_for_main_thread_.using_offscreen_context3d &&
381 layer_tree_host_->needs_offscreen_context()) { 384 layer_tree_host_->needs_offscreen_context()) {
382 offscreen_context_provider = 385 offscreen_context_provider =
383 layer_tree_host_->client()->OffscreenContextProviderForMainThread(); 386 layer_tree_host_->client()->OffscreenContextProviderForMainThread();
384 if (offscreen_context_provider) 387 if (offscreen_context_provider)
385 created_offscreen_context_provider_ = true; 388 created_offscreen_context_provider_ = true;
386 } 389 }
387 390
388 layer_tree_host_->contents_texture_manager()->UnlinkAndClearEvictedBackings(); 391 layer_tree_host_->contents_texture_manager()->UnlinkAndClearEvictedBackings();
389 392
390 scoped_ptr<ResourceUpdateQueue> queue = 393 scoped_ptr<ResourceUpdateQueue> queue =
391 make_scoped_ptr(new ResourceUpdateQueue); 394 make_scoped_ptr(new ResourceUpdateQueue);
392 layer_tree_host_->UpdateLayers( 395 layer_tree_host_->UpdateLayers(
393 queue.get(), layer_tree_host_impl_->memory_allocation_limit_bytes()); 396 queue.get(), layer_tree_host_impl_->memory_allocation_limit_bytes());
394 397
395 layer_tree_host_->WillCommit(); 398 layer_tree_host_->WillCommit();
396 DoCommit(queue.Pass()); 399 DoCommit(queue.Pass());
397 bool result = DoComposite(offscreen_context_provider, 400 bool result = DoComposite(offscreen_context_provider,
398 frame_begin_time, 401 frame_begin_time,
399 device_viewport_damage_rect, 402 device_viewport_damage_rect,
403 for_readback,
400 frame); 404 frame);
401 layer_tree_host_->DidBeginFrame(); 405 layer_tree_host_->DidBeginFrame();
402 return result; 406 return result;
403 } 407 }
404 408
405 bool SingleThreadProxy::ShouldComposite() const { 409 bool SingleThreadProxy::ShouldComposite() const {
406 DCHECK(Proxy::IsImplThread()); 410 DCHECK(Proxy::IsImplThread());
407 return layer_tree_host_impl_->visible() && 411 return layer_tree_host_impl_->visible() &&
408 layer_tree_host_impl_->CanDraw(); 412 layer_tree_host_impl_->CanDraw();
409 } 413 }
410 414
411 bool SingleThreadProxy::DoComposite( 415 bool SingleThreadProxy::DoComposite(
412 scoped_refptr<cc::ContextProvider> offscreen_context_provider, 416 scoped_refptr<cc::ContextProvider> offscreen_context_provider,
413 base::TimeTicks frame_begin_time, 417 base::TimeTicks frame_begin_time,
414 gfx::Rect device_viewport_damage_rect, 418 gfx::Rect device_viewport_damage_rect,
419 bool for_readback,
415 LayerTreeHostImpl::FrameData* frame) { 420 LayerTreeHostImpl::FrameData* frame) {
416 DCHECK(!layer_tree_host_->output_surface_lost()); 421 DCHECK(!layer_tree_host_->output_surface_lost());
417 422
418 bool lost_output_surface = false; 423 bool lost_output_surface = false;
419 { 424 {
420 DebugScopedSetImplThread impl(this); 425 DebugScopedSetImplThread impl(this);
421 base::AutoReset<bool> mark_inside(&inside_draw_, true); 426 base::AutoReset<bool> mark_inside(&inside_draw_, true);
422 427
423 layer_tree_host_impl_->resource_provider()-> 428 layer_tree_host_impl_->resource_provider()->
424 set_offscreen_context_provider(offscreen_context_provider); 429 set_offscreen_context_provider(offscreen_context_provider);
425 430
431 bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels();
432
426 // We guard PrepareToDraw() with CanDraw() because it always returns a valid 433 // We guard PrepareToDraw() with CanDraw() because it always returns a valid
427 // frame, so can only be used when such a frame is possible. Since 434 // frame, so can only be used when such a frame is possible. Since
428 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on 435 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
429 // CanDraw() as well. 436 // CanDraw() as well.
430 if (!ShouldComposite()) { 437 if (!ShouldComposite() || (for_readback && !can_do_readback)) {
431 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true); 438 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true);
432 return false; 439 return false;
433 } 440 }
434 441
435 layer_tree_host_impl_->Animate( 442 layer_tree_host_impl_->Animate(
436 layer_tree_host_impl_->CurrentFrameTimeTicks(), 443 layer_tree_host_impl_->CurrentFrameTimeTicks(),
437 layer_tree_host_impl_->CurrentFrameTime()); 444 layer_tree_host_impl_->CurrentFrameTime());
438 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false); 445 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false);
439 446
440 layer_tree_host_impl_->PrepareToDraw(frame, device_viewport_damage_rect); 447 layer_tree_host_impl_->PrepareToDraw(frame, device_viewport_damage_rect);
(...skipping 28 matching lines...) Expand all
469 476
470 bool SingleThreadProxy::CommitPendingForTesting() { return false; } 477 bool SingleThreadProxy::CommitPendingForTesting() { return false; }
471 478
472 skia::RefPtr<SkPicture> SingleThreadProxy::CapturePicture() { 479 skia::RefPtr<SkPicture> SingleThreadProxy::CapturePicture() {
473 // Impl-side painting only. 480 // Impl-side painting only.
474 NOTREACHED(); 481 NOTREACHED();
475 return skia::RefPtr<SkPicture>(); 482 return skia::RefPtr<SkPicture>();
476 } 483 }
477 484
478 } // namespace cc 485 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698