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

Side by Side Diff: chrome/browser/renderer_host/render_widget_host_view_views.cc

Issue 8241012: Enable accelerated WebKit compositor for Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address reviewer comments. Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/renderer_host/render_widget_host_view_views.h" 5 #include "chrome/browser/renderer_host/render_widget_host_view_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 19 matching lines...) Expand all
30 #include "ui/base/clipboard/clipboard.h" 30 #include "ui/base/clipboard/clipboard.h"
31 #include "ui/base/text/text_elider.h" 31 #include "ui/base/text/text_elider.h"
32 #include "ui/gfx/canvas.h" 32 #include "ui/gfx/canvas.h"
33 #include "ui/gfx/canvas_skia.h" 33 #include "ui/gfx/canvas_skia.h"
34 #include "views/events/event.h" 34 #include "views/events/event.h"
35 #include "views/ime/input_method.h" 35 #include "views/ime/input_method.h"
36 #include "views/views_delegate.h" 36 #include "views/views_delegate.h"
37 #include "views/widget/tooltip_manager.h" 37 #include "views/widget/tooltip_manager.h"
38 #include "views/widget/widget.h" 38 #include "views/widget/widget.h"
39 39
40 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
41 #include "base/bind.h"
42 #include "chrome/browser/renderer_host/accelerated_surface_container_touch.h"
43 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
44 #include "content/common/gpu/gpu_messages.h"
45 #include "ui/gfx/gl/gl_bindings.h"
46 #endif
47
40 #if defined(TOOLKIT_USES_GTK) 48 #if defined(TOOLKIT_USES_GTK)
41 #include <gtk/gtk.h> 49 #include <gtk/gtk.h>
42 #include <gtk/gtkwindow.h> 50 #include <gtk/gtkwindow.h>
43 #include <gdk/gdkx.h> 51 #include <gdk/gdkx.h>
44 #include "content/browser/renderer_host/gtk_window_utils.h" 52 #include "content/browser/renderer_host/gtk_window_utils.h"
45 #include "views/widget/native_widget_gtk.h" 53 #include "views/widget/native_widget_gtk.h"
46 #endif 54 #endif
47 55
48 #if defined(TOUCH_UI)
49 #include "chrome/browser/renderer_host/accelerated_surface_container_touch.h"
50 #endif
51
52 #if defined(OS_POSIX) 56 #if defined(OS_POSIX)
53 #include "content/browser/renderer_host/gtk_window_utils.h" 57 #include "content/browser/renderer_host/gtk_window_utils.h"
54 #endif 58 #endif
55 59
56 static const int kMaxWindowWidth = 4000; 60 static const int kMaxWindowWidth = 4000;
57 static const int kMaxWindowHeight = 4000; 61 static const int kMaxWindowHeight = 4000;
58 static const int kTouchControllerUpdateDelay = 150; 62 static const int kTouchControllerUpdateDelay = 150;
59 63
60 // static 64 // static
61 const char RenderWidgetHostViewViews::kViewClassName[] = 65 const char RenderWidgetHostViewViews::kViewClassName[] =
(...skipping 25 matching lines...) Expand all
87 WebKit::WebMouseEvent* wmevent) { 91 WebKit::WebMouseEvent* wmevent) {
88 wmevent->timeStampSeconds = base::Time::Now().ToDoubleT(); 92 wmevent->timeStampSeconds = base::Time::Now().ToDoubleT();
89 wmevent->modifiers = WebInputEventFlagsFromViewsEvent(event); 93 wmevent->modifiers = WebInputEventFlagsFromViewsEvent(event);
90 94
91 wmevent->windowX = wmevent->x = event.x(); 95 wmevent->windowX = wmevent->x = event.x();
92 wmevent->windowY = wmevent->y = event.y(); 96 wmevent->windowY = wmevent->y = event.y();
93 wmevent->globalX = wmevent->x + origin.x(); 97 wmevent->globalX = wmevent->x + origin.x();
94 wmevent->globalY = wmevent->y + origin.y(); 98 wmevent->globalY = wmevent->y + origin.y();
95 } 99 }
96 100
101 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
102 void AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id) {
103 // It's possible that gpu_host_id is no longer valid at this point (like if
104 // gpu process was restarted after a crash). SendToGpuHost handles this.
105 GpuProcessHostUIShim::SendToGpuHost(gpu_host_id,
106 new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id));
107 }
108 #endif
109
97 } // namespace 110 } // namespace
98 111
99 RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host) 112 RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host)
100 : host_(host), 113 : host_(host),
101 about_to_validate_and_paint_(false), 114 about_to_validate_and_paint_(false),
102 is_hidden_(false), 115 is_hidden_(false),
103 is_loading_(false), 116 is_loading_(false),
104 native_cursor_(gfx::kNullCursor), 117 native_cursor_(gfx::kNullCursor),
105 is_showing_context_menu_(false), 118 is_showing_context_menu_(false),
106 visually_deemphasized_(false), 119 visually_deemphasized_(false),
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 RenderWidgetHostView::GetDefaultScreenInfo(results); 1073 RenderWidgetHostView::GetDefaultScreenInfo(results);
1061 #endif 1074 #endif
1062 } 1075 }
1063 1076
1064 gfx::Rect RenderWidgetHostViewViews::GetRootWindowBounds() { 1077 gfx::Rect RenderWidgetHostViewViews::GetRootWindowBounds() {
1065 views::Widget* widget = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL; 1078 views::Widget* widget = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL;
1066 return widget ? widget->GetWindowScreenBounds() : gfx::Rect(); 1079 return widget ? widget->GetWindowScreenBounds() : gfx::Rect();
1067 } 1080 }
1068 #endif 1081 #endif
1069 1082
1070 #if !defined(TOUCH_UI) && !defined(OS_WIN) 1083 #if !defined(OS_WIN) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
1071 gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() { 1084 gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() {
1072 // TODO(oshima): The original implementation was broken as 1085 // TODO(oshima): The original implementation was broken as
1073 // GtkNativeViewManager doesn't know about NativeWidgetGtk. Figure 1086 // GtkNativeViewManager doesn't know about NativeWidgetGtk. Figure
1074 // out if this makes sense without compositor. If it does, then find 1087 // out if this makes sense without compositor. If it does, then find
1075 // out the right way to handle. 1088 // out the right way to handle.
1076 NOTIMPLEMENTED(); 1089 NOTIMPLEMENTED();
1077 return gfx::kNullPluginWindow; 1090 return gfx::kNullPluginWindow;
1078 } 1091 }
1079 #endif 1092 #endif
1093
1094 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
1095 gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() {
1096 // On TOUCH_UI builds, the GPU process renders to an offscreen surface
1097 // (created by the GPU process), which is later displayed by the browser.
1098 // As the GPU process creates this surface, we can return any non-zero value.
1099 return 1;
1100 }
1101
1102 void RenderWidgetHostViewViews::AcceleratedSurfaceNew(
1103 int32 width,
1104 int32 height,
1105 uint64* surface_id,
1106 TransportDIB::Handle* surface_handle) {
1107 scoped_ptr<AcceleratedSurfaceContainerTouch> surface(
1108 AcceleratedSurfaceContainerTouch::CreateAcceleratedSurfaceContainer(
1109 gfx::Size(width, height)));
1110 if (!surface->Initialize(surface_id)) {
1111 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer";
1112 return;
1113 }
1114 *surface_handle = surface->Handle();
1115
1116 accelerated_surface_containers_[*surface_id] = surface.release();
1117 }
1118
1119 void RenderWidgetHostViewViews::AcceleratedSurfaceRelease(uint64 surface_id) {
1120 accelerated_surface_containers_.erase(surface_id);
1121 }
1122
1123 void RenderWidgetHostViewViews::AcceleratedSurfaceBuffersSwapped(
1124 uint64 surface_id,
1125 int32 route_id,
1126 int gpu_host_id) {
1127 SetExternalTexture(accelerated_surface_containers_[surface_id].get());
1128 glFlush();
1129
1130 if (!GetWidget() || !GetWidget()->GetCompositor()) {
1131 // We have no compositor, so we have no way to display the surface
1132 AcknowledgeSwapBuffers(route_id, gpu_host_id); // Must still send the ACK
1133 } else {
1134 // Add sending an ACK to the list of things to do OnCompositingEnded
1135 on_compositing_ended_callbacks_.push_back(
1136 base::Bind(AcknowledgeSwapBuffers, route_id, gpu_host_id));
1137 ui::Compositor *compositor = GetWidget()->GetCompositor();
1138 if (!compositor->HasObserver(this))
1139 compositor->AddObserver(this);
1140 }
1141 }
1142
1143 void RenderWidgetHostViewViews::OnCompositingEnded(ui::Compositor* compositor) {
1144 for (std::vector< base::Callback<void(void)> >::const_iterator
1145 it = on_compositing_ended_callbacks_.begin();
1146 it != on_compositing_ended_callbacks_.end(); ++it) {
1147 it->Run();
1148 }
1149 on_compositing_ended_callbacks_.clear();
1150 compositor->RemoveObserver(this);
1151 }
1152
1153 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698