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

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

Issue 12746009: Revert 189969 "Add RenderWidgetHost::GetSnapshotFromRenderer met..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1450/src/
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 | 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_view_gtk.h" 5 #include "content/browser/renderer_host/render_widget_host_view_gtk.h"
6 6
7 // If this gets included after the gtk headers, then a bunch of compiler 7 // If this gets included after the gtk headers, then a bunch of compiler
8 // errors happen because of a "#define Status int" in Xlib.h, which interacts 8 // errors happen because of a "#define Status int" in Xlib.h, which interacts
9 // badly with net::URLRequestStatus::Status. 9 // badly with net::URLRequestStatus::Status.
10 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 ui::GetVisualFromGtkWidget(view_.get()), 1044 ui::GetVisualFromGtkWidget(view_.get()),
1045 depth); 1045 depth);
1046 } 1046 }
1047 1047
1048 // NOTE: |output| is initialized with the size of |src_subrect|, and |dst_size| 1048 // NOTE: |output| is initialized with the size of |src_subrect|, and |dst_size|
1049 // is ignored on GTK. 1049 // is ignored on GTK.
1050 void RenderWidgetHostViewGtk::CopyFromCompositingSurface( 1050 void RenderWidgetHostViewGtk::CopyFromCompositingSurface(
1051 const gfx::Rect& src_subrect, 1051 const gfx::Rect& src_subrect,
1052 const gfx::Size& /* dst_size */, 1052 const gfx::Size& /* dst_size */,
1053 const base::Callback<void(bool, const SkBitmap&)>& callback) { 1053 const base::Callback<void(bool, const SkBitmap&)>& callback) {
1054 // Grab the snapshot from the renderer as that's the only reliable way to 1054 base::ScopedClosureRunner scoped_callback_runner(
1055 // readback from the GPU for this platform right now. 1055 base::Bind(callback, false, SkBitmap()));
1056 GetRenderWidgetHost()->GetSnapshotFromRenderer(src_subrect, callback); 1056
1057 XID parent_window = ui::GetParentWindow(compositing_surface_);
1058 if (parent_window == None)
1059 return;
1060
1061 // Get the window offset with respect to its parent.
1062 XWindowAttributes attr;
1063 if (!XGetWindowAttributes(ui::GetXDisplay(), compositing_surface_, &attr))
1064 return;
1065
1066 gfx::Rect src_subrect_in_parent(src_subrect);
1067 src_subrect_in_parent.Offset(attr.x, attr.y);
1068
1069 ui::XScopedImage image(XGetImage(ui::GetXDisplay(), parent_window,
1070 src_subrect_in_parent.x(),
1071 src_subrect_in_parent.y(),
1072 src_subrect_in_parent.width(),
1073 src_subrect_in_parent.height(),
1074 AllPlanes, ZPixmap));
1075 if (!image.get())
1076 return;
1077
1078 SkBitmap bitmap;
1079 bitmap.setConfig(SkBitmap::kARGB_8888_Config,
1080 image->width,
1081 image->height,
1082 image->bytes_per_line);
1083 if (!bitmap.allocPixels())
1084 return;
1085 bitmap.setIsOpaque(true);
1086
1087 const size_t bitmap_size = bitmap.getSize();
1088 DCHECK_EQ(bitmap_size,
1089 static_cast<size_t>(image->height * image->bytes_per_line));
1090 unsigned char* pixels = static_cast<unsigned char*>(bitmap.getPixels());
1091 memcpy(pixels, image->data, bitmap_size);
1092
1093 scoped_callback_runner.Release();
1094 callback.Run(true, bitmap);
1057 } 1095 }
1058 1096
1059 void RenderWidgetHostViewGtk::CopyFromCompositingSurfaceToVideoFrame( 1097 void RenderWidgetHostViewGtk::CopyFromCompositingSurfaceToVideoFrame(
1060 const gfx::Rect& src_subrect, 1098 const gfx::Rect& src_subrect,
1061 const scoped_refptr<media::VideoFrame>& target, 1099 const scoped_refptr<media::VideoFrame>& target,
1062 const base::Callback<void(bool)>& callback) { 1100 const base::Callback<void(bool)>& callback) {
1063 NOTIMPLEMENTED(); 1101 NOTIMPLEMENTED();
1064 callback.Run(false); 1102 callback.Run(false);
1065 } 1103 }
1066 1104
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 gfx::PluginWindowHandle id) { 1614 gfx::PluginWindowHandle id) {
1577 plugin_container_manager_.CreatePluginContainer(id); 1615 plugin_container_manager_.CreatePluginContainer(id);
1578 } 1616 }
1579 1617
1580 void RenderWidgetHostViewGtk::OnDestroyPluginContainer( 1618 void RenderWidgetHostViewGtk::OnDestroyPluginContainer(
1581 gfx::PluginWindowHandle id) { 1619 gfx::PluginWindowHandle id) {
1582 plugin_container_manager_.DestroyPluginContainer(id); 1620 plugin_container_manager_.DestroyPluginContainer(id);
1583 } 1621 }
1584 1622
1585 } // namespace content 1623 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698