| OLD | NEW | 
|---|
| 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  Loading... | 
| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 563   is_loading_ = is_loading; | 564   is_loading_ = is_loading; | 
| 564   if (!view_) | 565   if (!view_) | 
| 565     return; | 566     return; | 
| 566   view_->SetIsLoading(is_loading); | 567   view_->SetIsLoading(is_loading); | 
| 567 } | 568 } | 
| 568 | 569 | 
| 569 void RenderWidgetHostImpl::CopyFromBackingStore( | 570 void RenderWidgetHostImpl::CopyFromBackingStore( | 
| 570     const gfx::Rect& src_subrect, | 571     const gfx::Rect& src_subrect, | 
| 571     const gfx::Size& accelerated_dst_size, | 572     const gfx::Size& accelerated_dst_size, | 
| 572     const base::Callback<void(bool, const SkBitmap&)>& callback) { | 573     const base::Callback<void(bool, const SkBitmap&)>& callback) { | 
|  | 574 | 
| 573   if (view_ && is_accelerated_compositing_active_) { | 575   if (view_ && is_accelerated_compositing_active_) { | 
| 574     TRACE_EVENT0("browser", | 576     TRACE_EVENT0("browser", | 
| 575         "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface"); | 577         "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface"); | 
| 576     gfx::Rect copy_rect = src_subrect.IsEmpty() ? | 578     gfx::Rect accelerated_copy_rect = src_subrect.IsEmpty() ? | 
| 577         gfx::Rect(view_->GetViewBounds().size()) : src_subrect; | 579         gfx::Rect(view_->GetViewBounds().size()) : src_subrect; | 
| 578     view_->CopyFromCompositingSurface(copy_rect, | 580     view_->CopyFromCompositingSurface(accelerated_copy_rect, | 
| 579                                       accelerated_dst_size, | 581                                       accelerated_dst_size, | 
| 580                                       callback); | 582                                       callback); | 
| 581     return; | 583     return; | 
| 582   } | 584   } | 
| 583 | 585 | 
| 584   BackingStore* backing_store = GetBackingStore(false); | 586   BackingStore* backing_store = GetBackingStore(false); | 
| 585   if (!backing_store) { | 587   if (!backing_store) { | 
| 586     callback.Run(false, SkBitmap()); | 588     callback.Run(false, SkBitmap()); | 
| 587     return; | 589     return; | 
| 588   } | 590   } | 
| 589 | 591 | 
| 590   TRACE_EVENT0("browser", | 592   TRACE_EVENT0("browser", | 
| 591       "RenderWidgetHostImpl::CopyFromBackingStore::FromBackingStore"); | 593       "RenderWidgetHostImpl::CopyFromBackingStore::FromBackingStore"); | 
| 592   gfx::Rect copy_rect = src_subrect.IsEmpty() ? | 594   gfx::Rect copy_rect = src_subrect.IsEmpty() ? | 
| 593       gfx::Rect(backing_store->size()) : src_subrect; | 595       gfx::Rect(backing_store->size()) : src_subrect; | 
| 594   // When the result size is equal to the backing store size, copy from the | 596   // When the result size is equal to the backing store size, copy from the | 
| 595   // backing store directly to the output canvas. | 597   // backing store directly to the output canvas. | 
| 596   skia::PlatformBitmap output; | 598   skia::PlatformBitmap output; | 
| 597   bool result = backing_store->CopyFromBackingStore(copy_rect, &output); | 599   bool result = backing_store->CopyFromBackingStore(copy_rect, &output); | 
| 598   callback.Run(result, output.GetBitmap()); | 600   callback.Run(result, output.GetBitmap()); | 
| 599 } | 601 } | 
| 600 | 602 | 
|  | 603 void RenderWidgetHostImpl::GetSnapshotFromRenderer( | 
|  | 604     const gfx::Rect& src_subrect, | 
|  | 605     const gfx::Size& dst_size, | 
|  | 606     const base::Callback<void(bool, const SkBitmap&)>& callback) { | 
|  | 607   TRACE_EVENT0("browser", "RenderWidgetHostImpl::GetSnapshotFromRenderer"); | 
|  | 608   pending_snapshots_.push(std::make_pair(dst_size, callback)); | 
|  | 609 | 
|  | 610   gfx::Rect copy_rect = src_subrect.IsEmpty() ? | 
|  | 611       gfx::Rect(view_->GetViewBounds().size()) : src_subrect; | 
|  | 612   Send(new ViewMsg_Snapshot(routing_id_, copy_rect)); | 
|  | 613 } | 
|  | 614 | 
|  | 615 void RenderWidgetHostImpl::OnSnapshot(bool success, | 
|  | 616                                       const SkBitmap& bitmap) { | 
|  | 617   if (pending_snapshots_.size() == 0) { | 
|  | 618     LOG(ERROR) << "RenderWidgetHostImpl::OnSnapshot: " | 
|  | 619                   "Received a snapshot that was not requested."; | 
|  | 620     return; | 
|  | 621   } | 
|  | 622 | 
|  | 623   PendingSnapshotInfo snapshot_info = pending_snapshots_.front(); | 
|  | 624   pending_snapshots_.pop(); | 
|  | 625 | 
|  | 626   const gfx::Size& dst_size = snapshot_info.first; | 
|  | 627   const base::Callback<void(bool, const SkBitmap&)>& callback = | 
|  | 628       snapshot_info.second; | 
|  | 629 | 
|  | 630   if (!success) { | 
|  | 631     callback.Run(success, SkBitmap()); | 
|  | 632     return; | 
|  | 633   } | 
|  | 634 | 
|  | 635   SkBitmap resized = skia::ImageOperations::Resize( | 
|  | 636       bitmap, skia::ImageOperations::RESIZE_GOOD, dst_size.width(), | 
|  | 637       dst_size.height()); | 
|  | 638 | 
|  | 639   callback.Run(success, resized); | 
|  | 640 } | 
|  | 641 | 
| 601 #if defined(TOOLKIT_GTK) | 642 #if defined(TOOLKIT_GTK) | 
| 602 bool RenderWidgetHostImpl::CopyFromBackingStoreToGtkWindow( | 643 bool RenderWidgetHostImpl::CopyFromBackingStoreToGtkWindow( | 
| 603     const gfx::Rect& dest_rect, GdkWindow* target) { | 644     const gfx::Rect& dest_rect, GdkWindow* target) { | 
| 604   BackingStore* backing_store = GetBackingStore(false); | 645   BackingStore* backing_store = GetBackingStore(false); | 
| 605   if (!backing_store) | 646   if (!backing_store) | 
| 606     return false; | 647     return false; | 
| 607   (static_cast<BackingStoreGtk*>(backing_store))->PaintToRect( | 648   (static_cast<BackingStoreGtk*>(backing_store))->PaintToRect( | 
| 608       dest_rect, target); | 649       dest_rect, target); | 
| 609   return true; | 650   return true; | 
| 610 } | 651 } | 
| (...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2410     return; | 2451     return; | 
| 2411 | 2452 | 
| 2412   OnRenderAutoResized(new_size); | 2453   OnRenderAutoResized(new_size); | 
| 2413 } | 2454 } | 
| 2414 | 2455 | 
| 2415 void RenderWidgetHostImpl::DetachDelegate() { | 2456 void RenderWidgetHostImpl::DetachDelegate() { | 
| 2416   delegate_ = NULL; | 2457   delegate_ = NULL; | 
| 2417 } | 2458 } | 
| 2418 | 2459 | 
| 2419 }  // namespace content | 2460 }  // namespace content | 
| OLD | NEW | 
|---|