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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 10352016: Consolidate RenderWidgetHost::CopyFromBackingStore and RenderWidgetHost::AsyncCopyFromBackingStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 SetView(NULL); 475 SetView(NULL);
476 } 476 }
477 477
478 void RenderWidgetHostImpl::SetIsLoading(bool is_loading) { 478 void RenderWidgetHostImpl::SetIsLoading(bool is_loading) {
479 is_loading_ = is_loading; 479 is_loading_ = is_loading;
480 if (!view_) 480 if (!view_)
481 return; 481 return;
482 view_->SetIsLoading(is_loading); 482 view_->SetIsLoading(is_loading);
483 } 483 }
484 484
485 bool RenderWidgetHostImpl::CopyFromBackingStore( 485 void RenderWidgetHostImpl::CopyFromBackingStore(
486 const gfx::Rect& src_rect,
487 const gfx::Size& accelerated_dest_size,
488 skia::PlatformCanvas* output) {
489 if (view_ && is_accelerated_compositing_active_) {
490 TRACE_EVENT0("browser",
491 "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface");
492 // TODO(mazda): Support partial copy with |src_rect|
493 // (http://crbug.com/118571).
494 return view_->CopyFromCompositingSurface(accelerated_dest_size, output);
495 }
496
497 BackingStore* backing_store = GetBackingStore(false);
498 if (!backing_store)
499 return false;
500
501 TRACE_EVENT0("browser",
502 "RenderWidgetHostImpl::CopyFromBackingStore::FromBackingStore");
503 const gfx::Size backing_store_size = backing_store->size();
504 gfx::Rect copy_rect = src_rect.IsEmpty() ?
505 gfx::Rect(0, 0, backing_store_size.width(), backing_store_size.height()) :
506 src_rect;
507 // When the result size is equal to the backing store size, copy from the
508 // backing store directly to the output canvas.
509 return backing_store->CopyFromBackingStore(copy_rect, output);
510 }
511
512 void RenderWidgetHostImpl::AsyncCopyFromBackingStore(
513 const gfx::Rect& src_rect, 486 const gfx::Rect& src_rect,
514 const gfx::Size& accelerated_dest_size, 487 const gfx::Size& accelerated_dest_size,
515 skia::PlatformCanvas* output, 488 skia::PlatformCanvas* output,
516 base::Callback<void(bool)> callback) { 489 base::Callback<void(bool)> callback) {
517 if (view_ && is_accelerated_compositing_active_) { 490 if (view_ && is_accelerated_compositing_active_) {
518 TRACE_EVENT0("browser", 491 TRACE_EVENT0("browser",
519 "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface"); 492 "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface");
520 // TODO(mazda): Support partial copy with |src_rect| 493 // TODO(mazda): Support partial copy with |src_rect|
521 // (http://crbug.com/118571). 494 // (http://crbug.com/118571).
522 view_->AsyncCopyFromCompositingSurface(accelerated_dest_size, 495 view_->CopyFromCompositingSurface(accelerated_dest_size,
523 output, 496 output,
524 callback); 497 callback);
525 return; 498 return;
526 } 499 }
527 500
528 BackingStore* backing_store = GetBackingStore(false); 501 BackingStore* backing_store = GetBackingStore(false);
529 if (!backing_store) { 502 if (!backing_store) {
530 callback.Run(false); 503 callback.Run(false);
531 return; 504 return;
532 } 505 }
533 506
534 TRACE_EVENT0("browser", 507 TRACE_EVENT0("browser",
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 // indicate that no callback is in progress (i.e. without this line 1784 // indicate that no callback is in progress (i.e. without this line
1812 // DelayedAutoResized will not get called again). 1785 // DelayedAutoResized will not get called again).
1813 new_auto_size_.SetSize(0, 0); 1786 new_auto_size_.SetSize(0, 0);
1814 if (!should_auto_resize_) 1787 if (!should_auto_resize_)
1815 return; 1788 return;
1816 1789
1817 OnRenderAutoResized(new_size); 1790 OnRenderAutoResized(new_size);
1818 } 1791 }
1819 1792
1820 } // namespace content 1793 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_view_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698