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

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

Issue 12881005: Allow CopyFromBackingStore to fallback to copying from the renderer side if the accelerated surface… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 9 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 (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 <math.h> 7 #include <math.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) 384 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse)
385 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) 385 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse)
386 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup, 386 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup,
387 OnShowDisambiguationPopup) 387 OnShowDisambiguationPopup)
388 #if defined(OS_WIN) 388 #if defined(OS_WIN)
389 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowCreated, 389 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowCreated,
390 OnWindowlessPluginDummyWindowCreated) 390 OnWindowlessPluginDummyWindowCreated)
391 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowDestroyed, 391 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowDestroyed,
392 OnWindowlessPluginDummyWindowDestroyed) 392 OnWindowlessPluginDummyWindowDestroyed)
393 #endif 393 #endif
394 IPC_MESSAGE_HANDLER(ViewHostMsg_Snapshot, OnSnapshot)
394 IPC_MESSAGE_UNHANDLED(handled = false) 395 IPC_MESSAGE_UNHANDLED(handled = false)
395 IPC_END_MESSAGE_MAP_EX() 396 IPC_END_MESSAGE_MAP_EX()
396 397
397 if (!handled && view_ && view_->OnMessageReceived(msg)) 398 if (!handled && view_ && view_->OnMessageReceived(msg))
398 return true; 399 return true;
399 400
400 if (!msg_is_ok) { 401 if (!msg_is_ok) {
401 // The message de-serialization failed. Kill the renderer process. 402 // The message de-serialization failed. Kill the renderer process.
402 RecordAction(UserMetricsAction("BadMessageTerminate_RWH")); 403 RecordAction(UserMetricsAction("BadMessageTerminate_RWH"));
403 GetProcess()->ReceivedBadMessage(); 404 GetProcess()->ReceivedBadMessage();
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 "RenderWidgetHostImpl::CopyFromBackingStore::FromBackingStore"); 592 "RenderWidgetHostImpl::CopyFromBackingStore::FromBackingStore");
592 gfx::Rect copy_rect = src_subrect.IsEmpty() ? 593 gfx::Rect copy_rect = src_subrect.IsEmpty() ?
593 gfx::Rect(backing_store->size()) : src_subrect; 594 gfx::Rect(backing_store->size()) : src_subrect;
594 // When the result size is equal to the backing store size, copy from the 595 // When the result size is equal to the backing store size, copy from the
595 // backing store directly to the output canvas. 596 // backing store directly to the output canvas.
596 skia::PlatformBitmap output; 597 skia::PlatformBitmap output;
597 bool result = backing_store->CopyFromBackingStore(copy_rect, &output); 598 bool result = backing_store->CopyFromBackingStore(copy_rect, &output);
598 callback.Run(result, output.GetBitmap()); 599 callback.Run(result, output.GetBitmap());
599 } 600 }
600 601
602 void RenderWidgetHostImpl::GetSnapshotFromRenderer(
603 const gfx::Rect& src_subrect,
604 const gfx::Size& dst_size,
605 const base::Callback<void(bool, const SkBitmap&)>& callback) {
606 TRACE_EVENT0("browser", "RenderWidgetHostImpl::GetSnapshotFromRenderer");
607 pending_snapshots_.push(std::make_pair(dst_size, callback));
608 Send(new ViewMsg_Snapshot(routing_id_, src_subrect));
609 }
610
611 void RenderWidgetHostImpl::OnSnapshot(bool success,
612 const SkBitmap& bitmap) {
613 if (pending_snapshots_.size() == 0) {
614 LOG(ERROR) << "RenderWidgetHostImpl::OnSnapshot: "
615 "Received a snapshot that was not requested.";
616 return;
617 }
618
619 PendingSnapshotInfo snapshot_info = pending_snapshots_.front();
620 pending_snapshots_.pop();
621
622 const gfx::Size& dst_size = snapshot_info.first;
623 const base::Callback<void(bool, const SkBitmap&)>& callback =
624 snapshot_info.second;
625
626 if (!success) {
627 callback.Run(success, SkBitmap());
628 return;
629 }
630
631 SkBitmap resized = skia::ImageOperations::Resize(
632 bitmap, skia::ImageOperations::RESIZE_GOOD, dst_size.width(),
633 dst_size.height());
634
635 callback.Run(success, resized);
636 }
637
601 #if defined(TOOLKIT_GTK) 638 #if defined(TOOLKIT_GTK)
602 bool RenderWidgetHostImpl::CopyFromBackingStoreToGtkWindow( 639 bool RenderWidgetHostImpl::CopyFromBackingStoreToGtkWindow(
603 const gfx::Rect& dest_rect, GdkWindow* target) { 640 const gfx::Rect& dest_rect, GdkWindow* target) {
604 BackingStore* backing_store = GetBackingStore(false); 641 BackingStore* backing_store = GetBackingStore(false);
605 if (!backing_store) 642 if (!backing_store)
606 return false; 643 return false;
607 (static_cast<BackingStoreGtk*>(backing_store))->PaintToRect( 644 (static_cast<BackingStoreGtk*>(backing_store))->PaintToRect(
608 dest_rect, target); 645 dest_rect, target);
609 return true; 646 return true;
610 } 647 }
(...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 return; 2447 return;
2411 2448
2412 OnRenderAutoResized(new_size); 2449 OnRenderAutoResized(new_size);
2413 } 2450 }
2414 2451
2415 void RenderWidgetHostImpl::DetachDelegate() { 2452 void RenderWidgetHostImpl::DetachDelegate() {
2416 delegate_ = NULL; 2453 delegate_ = NULL;
2417 } 2454 }
2418 2455
2419 } // namespace content 2456 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698