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

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

Issue 4399003: Deleted code associated with --enable-gpu-rendering and... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/keyboard_code_conversion_gtk.h" 10 #include "app/keyboard_code_conversion_gtk.h"
11 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
12 #include "app/x11_util.h" 12 #include "app/x11_util.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/string_number_conversions.h" 17 #include "base/string_number_conversions.h"
18 #include "base/task.h" 18 #include "base/task.h"
19 #include "base/time.h" 19 #include "base/time.h"
20 #include "chrome/browser/renderer_host/backing_store_x.h" 20 #include "chrome/browser/renderer_host/backing_store_x.h"
21 #include "chrome/browser/renderer_host/gpu_view_host.h"
22 #include "chrome/browser/renderer_host/render_widget_host.h" 21 #include "chrome/browser/renderer_host/render_widget_host.h"
23 #include "chrome/browser/renderer_host/video_layer_x.h"
24 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/native_web_keyboard_event.h" 23 #include "chrome/common/native_web_keyboard_event.h"
26 #include "chrome/common/render_messages.h" 24 #include "chrome/common/render_messages.h"
27 #include "third_party/WebKit/WebKit/chromium/public/gtk/WebInputEventFactory.h" 25 #include "third_party/WebKit/WebKit/chromium/public/gtk/WebInputEventFactory.h"
28 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" 26 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
29 #include "views/event.h" 27 #include "views/event.h"
30 #include "views/widget/widget.h" 28 #include "views/widget/widget.h"
31 29
32 static const int kMaxWindowWidth = 4000; 30 static const int kMaxWindowWidth = 4000;
33 static const int kMaxWindowHeight = 4000; 31 static const int kMaxWindowHeight = 4000;
(...skipping 20 matching lines...) Expand all
54 } // namespace 52 } // namespace
55 53
56 // static 54 // static
57 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( 55 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
58 RenderWidgetHost* widget) { 56 RenderWidgetHost* widget) {
59 return new RenderWidgetHostViewViews(widget); 57 return new RenderWidgetHostViewViews(widget);
60 } 58 }
61 59
62 RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host) 60 RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host)
63 : host_(host), 61 : host_(host),
64 enable_gpu_rendering_(false),
65 about_to_validate_and_paint_(false), 62 about_to_validate_and_paint_(false),
66 is_hidden_(false), 63 is_hidden_(false),
67 is_loading_(false), 64 is_loading_(false),
68 is_showing_context_menu_(false), 65 is_showing_context_menu_(false),
69 visually_deemphasized_(false) { 66 visually_deemphasized_(false) {
70 SetFocusable(true); 67 SetFocusable(true);
71 host_->set_view(this); 68 host_->set_view(this);
72
73 // Enable experimental out-of-process GPU rendering.
74 CommandLine* command_line = CommandLine::ForCurrentProcess();
75 enable_gpu_rendering_ =
76 command_line->HasSwitch(switches::kEnableGPURendering);
77 } 69 }
78 70
79 RenderWidgetHostViewViews::~RenderWidgetHostViewViews() { 71 RenderWidgetHostViewViews::~RenderWidgetHostViewViews() {
80 RenderViewGone(); 72 RenderViewGone();
81 } 73 }
82 74
83 void RenderWidgetHostViewViews::InitAsChild() { 75 void RenderWidgetHostViewViews::InitAsChild() {
84 Show(); 76 Show();
85 } 77 }
86 78
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 bool RenderWidgetHostViewViews::NeedsInputGrab() { 252 bool RenderWidgetHostViewViews::NeedsInputGrab() {
261 return popup_type_ == WebKit::WebPopupTypeSelect; 253 return popup_type_ == WebKit::WebPopupTypeSelect;
262 } 254 }
263 255
264 bool RenderWidgetHostViewViews::IsPopup() { 256 bool RenderWidgetHostViewViews::IsPopup() {
265 return popup_type_ != WebKit::WebPopupTypeNone; 257 return popup_type_ != WebKit::WebPopupTypeNone;
266 } 258 }
267 259
268 BackingStore* RenderWidgetHostViewViews::AllocBackingStore( 260 BackingStore* RenderWidgetHostViewViews::AllocBackingStore(
269 const gfx::Size& size) { 261 const gfx::Size& size) {
270 if (enable_gpu_rendering_) {
271 // Use a special GPU accelerated backing store.
272 if (!gpu_view_host_.get()) {
273 // Here we lazily make the GpuViewHost. This must be allocated when we
274 // have a native view realized, which happens sometime after creation
275 // when our owner puts us in the parent window.
276 DCHECK(GetNativeView());
277 XID window_xid = x11_util::GetX11WindowFromGtkWidget(GetNativeView());
278 gpu_view_host_.reset(new GpuViewHost(host_, window_xid));
279 }
280 return gpu_view_host_->CreateBackingStore(size);
281 }
282
283 return new BackingStoreX(host_, size, 262 return new BackingStoreX(host_, size,
284 x11_util::GetVisualFromGtkWidget(native_view()), 263 x11_util::GetVisualFromGtkWidget(native_view()),
285 gtk_widget_get_visual(native_view())->depth); 264 gtk_widget_get_visual(native_view())->depth);
286 } 265 }
287 266
288 gfx::NativeView RenderWidgetHostViewViews::native_view() const { 267 gfx::NativeView RenderWidgetHostViewViews::native_view() const {
289 return GetWidget()->GetNativeView(); 268 return GetWidget()->GetNativeView();
290 } 269 }
291 270
292 VideoLayer* RenderWidgetHostViewViews::AllocVideoLayer(const gfx::Size& size) {
293 if (enable_gpu_rendering_) {
294 // TODO(scherkus): is it possible for a video layer to be allocated before a
295 // backing store?
296 DCHECK(gpu_view_host_.get())
297 << "AllocVideoLayer() called before AllocBackingStore()";
298 return gpu_view_host_->CreateVideoLayer(size);
299 }
300
301 return new VideoLayerX(host_, size,
302 x11_util::GetVisualFromGtkWidget(native_view()),
303 gtk_widget_get_visual(native_view())->depth);
304 }
305
306 void RenderWidgetHostViewViews::SetBackground(const SkBitmap& background) { 271 void RenderWidgetHostViewViews::SetBackground(const SkBitmap& background) {
307 RenderWidgetHostView::SetBackground(background); 272 RenderWidgetHostView::SetBackground(background);
308 host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background)); 273 host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background));
309 } 274 }
310 275
311 void RenderWidgetHostViewViews::Paint(gfx::Canvas* canvas) { 276 void RenderWidgetHostViewViews::Paint(gfx::Canvas* canvas) {
312 if (enable_gpu_rendering_) {
313 // When we're proxying painting, we don't actually display the web page
314 // ourselves.
315 if (gpu_view_host_.get())
316 gpu_view_host_->OnWindowPainted();
317
318 // Erase the background. This will prevent a flash of black when resizing
319 // or exposing the window. White is usually better than black.
320 return;
321 }
322
323 // Don't do any painting if the GPU process is rendering directly 277 // Don't do any painting if the GPU process is rendering directly
324 // into the View. 278 // into the View.
325 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(); 279 RenderWidgetHost* render_widget_host = GetRenderWidgetHost();
326 if (render_widget_host->is_gpu_rendering_active()) { 280 if (render_widget_host->is_gpu_rendering_active()) {
327 return; 281 return;
328 } 282 }
329 283
330 GdkWindow* window = native_view()->window; 284 GdkWindow* window = native_view()->window;
331 DCHECK(!about_to_validate_and_paint_); 285 DCHECK(!about_to_validate_and_paint_);
332 286
(...skipping 12 matching lines...) Expand all
345 if (backing_store) { 299 if (backing_store) {
346 // Only render the widget if it is attached to a window; there's a short 300 // Only render the widget if it is attached to a window; there's a short
347 // period where this object isn't attached to a window but hasn't been 301 // period where this object isn't attached to a window but hasn't been
348 // Destroy()ed yet and it receives paint messages... 302 // Destroy()ed yet and it receives paint messages...
349 if (window) { 303 if (window) {
350 if (!visually_deemphasized_) { 304 if (!visually_deemphasized_) {
351 // In the common case, use XCopyArea. We don't draw more than once, so 305 // In the common case, use XCopyArea. We don't draw more than once, so
352 // we don't need to double buffer. 306 // we don't need to double buffer.
353 backing_store->XShowRect( 307 backing_store->XShowRect(
354 paint_rect, x11_util::GetX11WindowFromGtkWidget(native_view())); 308 paint_rect, x11_util::GetX11WindowFromGtkWidget(native_view()));
355
356 // Paint the video layer using XCopyArea.
357 // TODO(scherkus): implement VideoLayerX::CairoShow() for grey
358 // blending.
359 VideoLayerX* video_layer = static_cast<VideoLayerX*>(
360 host_->video_layer());
361 if (video_layer)
362 video_layer->XShow(
363 x11_util::GetX11WindowFromGtkWidget(native_view()));
364 } else { 309 } else {
365 // If the grey blend is showing, we make two drawing calls. Use double 310 // If the grey blend is showing, we make two drawing calls. Use double
366 // buffering to prevent flicker. Use CairoShowRect because XShowRect 311 // buffering to prevent flicker. Use CairoShowRect because XShowRect
367 // shortcuts GDK's double buffering. 312 // shortcuts GDK's double buffering.
368 GdkRectangle rect = { paint_rect.x(), paint_rect.y(), 313 GdkRectangle rect = { paint_rect.x(), paint_rect.y(),
369 paint_rect.width(), paint_rect.height() }; 314 paint_rect.width(), paint_rect.height() };
370 gdk_window_begin_paint_rect(window, &rect); 315 gdk_window_begin_paint_rect(window, &rect);
371 316
372 backing_store->CairoShowRect(paint_rect, GDK_DRAWABLE(window)); 317 backing_store->CairoShowRect(paint_rect, GDK_DRAWABLE(window));
373 318
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 } 559 }
615 560
616 // static 561 // static
617 RenderWidgetHostView* 562 RenderWidgetHostView*
618 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( 563 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView(
619 gfx::NativeView widget) { 564 gfx::NativeView widget) {
620 gpointer user_data = g_object_get_data(G_OBJECT(widget), 565 gpointer user_data = g_object_get_data(G_OBJECT(widget),
621 kRenderWidgetHostViewKey); 566 kRenderWidgetHostViewKey);
622 return reinterpret_cast<RenderWidgetHostView*>(user_data); 567 return reinterpret_cast<RenderWidgetHostView*>(user_data);
623 } 568 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698