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

Unified Diff: chrome/browser/renderer_host/render_widget_host_view_views.cc

Issue 6246129: BackingStoreSkia: Use skia for painting in RenderWidgetHostViewViews. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/renderer_host/render_widget_host_view_views.cc
diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.cc b/chrome/browser/renderer_host/render_widget_host_view_views.cc
index 9e4a2c95f3e477adafbf7c22ae98f25179d376f9..bca53a588048080d31bf613d78c0e2ff50729bec 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_views.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_views.cc
@@ -14,12 +14,14 @@
#include "base/string_number_conversions.h"
#include "base/task.h"
#include "base/time.h"
+#include "chrome/browser/renderer_host/backing_store_skia.h"
#include "chrome/browser/renderer_host/backing_store_x.h"
#include "chrome/browser/renderer_host/render_widget_host.h"
#include "chrome/common/native_web_keyboard_event.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/result_codes.h"
#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFactory.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
@@ -32,6 +34,7 @@
static const int kMaxWindowWidth = 4000;
static const int kMaxWindowHeight = 4000;
static const char* kRenderWidgetHostViewKey = "__RENDER_WIDGET_HOST_VIEW__";
+static const char* kBackingStoreSkiaSwitch = "use-backing-store-skia";
agl 2011/02/07 17:26:47 use |char kBackingStoreSkiaSwitch[]| to save a rel
sadrul 2011/02/07 18:22:38 Done.
using WebKit::WebInputEventFactory;
using WebKit::WebMouseWheelEvent;
@@ -39,6 +42,18 @@ using WebKit::WebTouchEvent;
namespace {
+bool UsingBackingStoreSkia() {
+ static bool decided = false;
+ static bool use_skia = false;
+ if (!decided) {
+ CommandLine* cmdline = CommandLine::ForCurrentProcess();
+ use_skia = (cmdline && cmdline->HasSwitch(kBackingStoreSkiaSwitch));
+ decided = true;
+ }
+
+ return use_skia;
+}
+
int WebInputEventFlagsFromViewsEvent(const views::Event& event) {
int modifiers = 0;
@@ -328,9 +343,13 @@ BackingStore* RenderWidgetHostViewViews::AllocBackingStore(
gfx::NativeView nview = GetInnerNativeView();
if (!nview)
return NULL;
- return new BackingStoreX(host_, size,
- ui::GetVisualFromGtkWidget(nview),
- gtk_widget_get_visual(nview)->depth);
+
+ if (UsingBackingStoreSkia())
agl 2011/02/07 17:26:47 the style guide lets you do this, although I would
sadrul 2011/02/07 18:22:38 Done.
+ return new BackingStoreSkia(host_, size);
+ else
+ return new BackingStoreX(host_, size,
+ ui::GetVisualFromGtkWidget(nview),
+ gtk_widget_get_visual(nview)->depth);
}
gfx::NativeView RenderWidgetHostViewViews::GetInnerNativeView() const {
@@ -380,8 +399,7 @@ void RenderWidgetHostViewViews::Paint(gfx::Canvas* canvas) {
ConvertPointToWidget(this, &origin);
about_to_validate_and_paint_ = true;
- BackingStoreX* backing_store = static_cast<BackingStoreX*>(
- host_->GetBackingStore(true));
+ BackingStore* backing_store = host_->GetBackingStore(true);
// Calling GetBackingStore maybe have changed |invalid_rect_|...
about_to_validate_and_paint_ = false;
@@ -396,9 +414,15 @@ void RenderWidgetHostViewViews::Paint(gfx::Canvas* canvas) {
if (!visually_deemphasized_) {
// In the common case, use XCopyArea. We don't draw more than once, so
// we don't need to double buffer.
- backing_store->XShowRect(origin,
- paint_rect, ui::GetX11WindowFromGdkWindow(window));
- } else {
+
+ if (UsingBackingStoreSkia()) {
+ static_cast<BackingStoreSkia*>(backing_store)->SkiaShowRect(
+ gfx::Point(paint_rect.x(), paint_rect.y()), canvas);
+ } else {
+ static_cast<BackingStoreX*>(backing_store)->XShowRect(origin,
+ paint_rect, ui::GetX11WindowFromGdkWindow(window));
+ }
+ } else if (!UsingBackingStoreSkia()) {
// If the grey blend is showing, we make two drawing calls. Use double
// buffering to prevent flicker. Use CairoShowRect because XShowRect
// shortcuts GDK's double buffering.
@@ -406,7 +430,8 @@ void RenderWidgetHostViewViews::Paint(gfx::Canvas* canvas) {
paint_rect.width(), paint_rect.height() };
gdk_window_begin_paint_rect(window, &rect);
- backing_store->CairoShowRect(paint_rect, GDK_DRAWABLE(window));
+ static_cast<BackingStoreX*>(backing_store)->CairoShowRect(
+ paint_rect, GDK_DRAWABLE(window));
cairo_t* cr = gdk_cairo_create(window);
gdk_cairo_rectangle(cr, &rect);
@@ -415,6 +440,9 @@ void RenderWidgetHostViewViews::Paint(gfx::Canvas* canvas) {
cairo_destroy(cr);
gdk_window_end_paint(window);
+ } else {
+ // TODO(sad)
+ NOTIMPLEMENTED();
agl 2011/02/07 17:26:47 NOTREACHED()?
sadrul 2011/02/07 18:22:38 It's not clear to me when |visually_deemphasized_|
}
}
if (!whiteout_start_time_.is_null()) {
@@ -590,7 +618,7 @@ void RenderWidgetHostViewViews::DidGainFocus() {
void RenderWidgetHostViewViews::WillLoseFocus() {
// If we are showing a context menu, maintain the illusion that webkit has
// focus.
- if (!is_showing_context_menu_ && !is_hidden_)
+ if (!is_showing_context_menu_ && !is_hidden_ && GetRenderWidgetHost())
agl 2011/02/07 17:26:47 This seems like it doesn't belong. If it's fixing
sadrul 2011/02/07 18:22:38 Indeed. This is a fix for a bug, and sneaked into
GetRenderWidgetHost()->Blur();
}

Powered by Google App Engine
This is Rietveld 408576698