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

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: "" 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(VIEWS_GPU_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 void AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id) {
102 // It's possible that gpu_host_id is no longer valid at this point (like if
103 // gpu process was restarted after a crash). SendToGpuHost handles this.
104 GpuProcessHostUIShim::SendToGpuHost(gpu_host_id,
105 new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id));
106 }
107
97 } // namespace 108 } // namespace
98 109
99 RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host) 110 RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host)
100 : host_(host), 111 : host_(host),
101 about_to_validate_and_paint_(false), 112 about_to_validate_and_paint_(false),
102 is_hidden_(false), 113 is_hidden_(false),
103 is_loading_(false), 114 is_loading_(false),
104 native_cursor_(gfx::kNullCursor), 115 native_cursor_(gfx::kNullCursor),
105 is_showing_context_menu_(false), 116 is_showing_context_menu_(false),
106 visually_deemphasized_(false), 117 visually_deemphasized_(false),
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 RenderWidgetHostView::GetDefaultScreenInfo(results); 1071 RenderWidgetHostView::GetDefaultScreenInfo(results);
1061 #endif 1072 #endif
1062 } 1073 }
1063 1074
1064 gfx::Rect RenderWidgetHostViewViews::GetRootWindowBounds() { 1075 gfx::Rect RenderWidgetHostViewViews::GetRootWindowBounds() {
1065 views::Widget* widget = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL; 1076 views::Widget* widget = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL;
1066 return widget ? widget->GetWindowScreenBounds() : gfx::Rect(); 1077 return widget ? widget->GetWindowScreenBounds() : gfx::Rect();
1067 } 1078 }
1068 #endif 1079 #endif
1069 1080
1070 #if !defined(TOUCH_UI) && !defined(OS_WIN) 1081 #if !defined(OS_WIN) && !defined(VIEWS_GPU_IMAGE_TRANSPORT)
1071 gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() { 1082 gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() {
1072 // TODO(oshima): The original implementation was broken as 1083 // TODO(oshima): The original implementation was broken as
1073 // GtkNativeViewManager doesn't know about NativeWidgetGtk. Figure 1084 // GtkNativeViewManager doesn't know about NativeWidgetGtk. Figure
1074 // out if this makes sense without compositor. If it does, then find 1085 // out if this makes sense without compositor. If it does, then find
1075 // out the right way to handle. 1086 // out the right way to handle.
1076 NOTIMPLEMENTED(); 1087 NOTIMPLEMENTED();
1077 return gfx::kNullPluginWindow; 1088 return gfx::kNullPluginWindow;
1078 } 1089 }
1079 #endif 1090 #endif
1091
1092 #if defined(VIEWS_GPU_IMAGE_TRANSPORT)
1093 gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() {
1094 // On TOUCH_UI builds, the GPU process renders to an offscreen surface
1095 // (created by the GPU process), which is later displayed by the browser.
1096 // As the GPU process creates this surface, we can return any non-zero value.
1097 return 1;
1098 }
1099
1100 void RenderWidgetHostViewViews::AcceleratedSurfaceNew(
1101 int32 width,
1102 int32 height,
1103 uint64* surface_id,
1104 TransportDIB::Handle* surface_handle) {
1105 scoped_ptr<AcceleratedSurfaceContainerTouch> surface(
1106 AcceleratedSurfaceContainerTouch::CreateAcceleratedSurfaceContainer(
1107 gfx::Size(width, height)));
1108 if (!surface->Initialize(surface_id)) {
1109 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer";
1110 return;
1111 }
1112 *surface_handle = surface->Handle();
1113
1114 accelerated_surface_containers_[*surface_id] = surface.release();
1115 }
1116
1117 void RenderWidgetHostViewViews::AcceleratedSurfaceRelease(uint64 surface_id) {
1118 accelerated_surface_containers_.erase(surface_id);
1119 }
1120
1121 void RenderWidgetHostViewViews::AcceleratedSurfaceBuffersSwapped(
1122 uint64 surface_id,
1123 int32 route_id,
1124 int gpu_host_id) {
1125 SetExternalTexture(accelerated_surface_containers_[surface_id].get());
1126 glFlush();
1127
1128 if (!GetWidget() || !GetWidget()->GetCompositor()) {
1129 // We have no compositor, so we have no way to display the surface
1130 AcknowledgeSwapBuffers(route_id, gpu_host_id); // Must still send the ACK
1131 } else {
1132 // Add sending an ACK to the list of things to do OnCompositingEnded
1133 on_compositing_ended_callbacks_.push_back(
1134 base::Bind(AcknowledgeSwapBuffers, route_id, gpu_host_id));
1135 ui::Compositor *compositor = GetWidget()->GetCompositor();
1136 if (!compositor->HasObserver(this))
1137 compositor->AddObserver(this);
1138 }
1139 }
1140
1141 void RenderWidgetHostViewViews::OnCompositingEnded(ui::Compositor* compositor) {
1142 for (std::vector< base::Callback<void(void)> >::const_iterator
1143 it = on_compositing_ended_callbacks_.begin();
1144 it != on_compositing_ended_callbacks_.end(); ++it) {
1145 it->Run();
1146 }
1147 on_compositing_ended_callbacks_.clear();
1148 compositor->RemoveObserver(this);
1149 }
1150
1151 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698