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

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

Issue 9582003: Support browser side thumbnailing for GPU composited pages on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 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 | 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 "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 14 matching lines...) Expand all
25 #include "content/common/gpu/gpu_messages.h" 25 #include "content/common/gpu/gpu_messages.h"
26 #include "content/common/view_messages.h" 26 #include "content/common/view_messages.h"
27 #include "content/port/browser/render_widget_host_view_port.h" 27 #include "content/port/browser/render_widget_host_view_port.h"
28 #include "content/public/browser/browser_accessibility_state.h" 28 #include "content/public/browser/browser_accessibility_state.h"
29 #include "content/public/browser/native_web_keyboard_event.h" 29 #include "content/public/browser/native_web_keyboard_event.h"
30 #include "content/public/browser/notification_service.h" 30 #include "content/public/browser/notification_service.h"
31 #include "content/public/browser/notification_types.h" 31 #include "content/public/browser/notification_types.h"
32 #include "content/public/browser/user_metrics.h" 32 #include "content/public/browser/user_metrics.h"
33 #include "content/public/common/content_switches.h" 33 #include "content/public/common/content_switches.h"
34 #include "content/public/common/result_codes.h" 34 #include "content/public/common/result_codes.h"
35 #include "skia/ext/platform_canvas.h"
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h" 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h"
36 #include "ui/base/keycodes/keyboard_codes.h" 37 #include "ui/base/keycodes/keyboard_codes.h"
37 #include "webkit/glue/webcursor.h" 38 #include "webkit/glue/webcursor.h"
38 #include "webkit/glue/webpreferences.h" 39 #include "webkit/glue/webpreferences.h"
39 #include "webkit/plugins/npapi/webplugin.h" 40 #include "webkit/plugins/npapi/webplugin.h"
40 41
41 #if defined(TOOLKIT_GTK) 42 #if defined(TOOLKIT_GTK)
42 #include "content/browser/renderer_host/backing_store_gtk.h" 43 #include "content/browser/renderer_host/backing_store_gtk.h"
43 #elif defined(OS_MACOSX) 44 #elif defined(OS_MACOSX)
44 #include "content/browser/renderer_host/backing_store_mac.h" 45 #include "content/browser/renderer_host/backing_store_mac.h"
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 if (!view_) 486 if (!view_)
486 return; 487 return;
487 view_->SetIsLoading(is_loading); 488 view_->SetIsLoading(is_loading);
488 } 489 }
489 490
490 bool RenderWidgetHostImpl::CopyFromBackingStore(skia::PlatformCanvas* output) { 491 bool RenderWidgetHostImpl::CopyFromBackingStore(skia::PlatformCanvas* output) {
491 BackingStore* backing_store = GetBackingStore(false); 492 BackingStore* backing_store = GetBackingStore(false);
492 if (!backing_store) 493 if (!backing_store)
493 return false; 494 return false;
494 495
496 TRACE_EVENT0("browser", "RenderWidgetHostImpl::CopyFromBackingStore");
495 return backing_store->CopyFromBackingStore( 497 return backing_store->CopyFromBackingStore(
496 gfx::Rect(backing_store->size()), output); 498 gfx::Rect(backing_store->size()), output);
497 } 499 }
498 500
501 bool RenderWidgetHostImpl::CopyFromCompositingSurface(
502 const gfx::Size& size,
503 skia::PlatformCanvas* output) {
504 if (!is_accelerated_compositing_active_)
505 return false;
506
507 TRACE_EVENT0("browser", "RenderWidgetHostImpl::CopyFromCompositingSurface");
508 std::vector<unsigned char> pixels(4 * size.GetArea());
509 if(!GpuSurfaceTracker::Get()->CopySurface(surface_id_,
510 size,
511 &pixels))
apatrick_chromium 2012/03/07 20:39:37 Is it possible to copy the pixels directly into th
mazda 2012/03/08 13:14:28 Actually SkBitmap::setPixels does not copy the dat
apatrick_chromium 2012/03/08 20:15:47 I think you could call SkBitmap::allocPixels befor
mazda 2012/03/10 07:51:37 Thanks. I changed the AcceleratedSurface::CopyTo t
512 return false;
513
514 SkBitmap bitmap;
515 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
516 bitmap.allocPixels();
517 bitmap.setPixels(&pixels[0]);
apatrick_chromium 2012/03/07 20:39:37 This won't work if the area of the surface is zero
mazda 2012/03/08 13:14:28 I added a check for |size| and also made Accelerat
518
519 if (!output->initialize(size.width(), size.height(), true))
520 return false;
521 output->writePixels(bitmap, 0, 0);
522 return true;
523 }
524
499 #if defined(TOOLKIT_GTK) 525 #if defined(TOOLKIT_GTK)
500 bool RenderWidgetHostImpl::CopyFromBackingStoreToGtkWindow( 526 bool RenderWidgetHostImpl::CopyFromBackingStoreToGtkWindow(
501 const gfx::Rect& dest_rect, GdkWindow* target) { 527 const gfx::Rect& dest_rect, GdkWindow* target) {
502 BackingStore* backing_store = GetBackingStore(false); 528 BackingStore* backing_store = GetBackingStore(false);
503 if (!backing_store) 529 if (!backing_store)
504 return false; 530 return false;
505 (static_cast<BackingStoreGtk*>(backing_store))->PaintToRect( 531 (static_cast<BackingStoreGtk*>(backing_store))->PaintToRect(
506 dest_rect, target); 532 dest_rect, target);
507 return true; 533 return true;
508 } 534 }
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 ui_shim->Send(new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id)); 1688 ui_shim->Send(new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id));
1663 } 1689 }
1664 1690
1665 // static 1691 // static
1666 void RenderWidgetHostImpl::AcknowledgePostSubBuffer(int32 route_id, 1692 void RenderWidgetHostImpl::AcknowledgePostSubBuffer(int32 route_id,
1667 int gpu_host_id) { 1693 int gpu_host_id) {
1668 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id); 1694 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id);
1669 if (ui_shim) 1695 if (ui_shim)
1670 ui_shim->Send(new AcceleratedSurfaceMsg_PostSubBufferACK(route_id)); 1696 ui_shim->Send(new AcceleratedSurfaceMsg_PostSubBufferACK(route_id));
1671 } 1697 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698