diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-03 02:11:48 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-03 02:11:48 +0000 |
commit | 661eb9d1aa5468b984a92e66937432d881f70427 (patch) | |
tree | 81bf2b132ac6c7b05b04598e875552819222bb73 /chrome/browser/renderer_host | |
parent | 99aa2dbf4962fb1a4a52a3eae9bb51ad3113b7be (diff) | |
download | chromium_src-661eb9d1aa5468b984a92e66937432d881f70427.zip chromium_src-661eb9d1aa5468b984a92e66937432d881f70427.tar.gz chromium_src-661eb9d1aa5468b984a92e66937432d881f70427.tar.bz2 |
From agl. Cleaned up version of issue 19046.
POSIX: bitmap data on the wire
On Windows, when drawing a given rect in the renderer, we allocate memory for the bitmap, render and send a shared memory handle across IPC. In the browser, we bitblit the shared memory to the backing store and draw it to the screen.
In the long term, on Linux, we want the backingstore to be shared with both X and the renderer. The renderer then draws directly to that store, sends an IPC to the browser and the browser sends a message to X to bitblit to the display. Since only cache a few backing stores we'll need messages from the browser to tell the renderer to attach and detatch from shared memory regions as they get created and evicted.
In the short term, however, to get something that works, we make a BitmapWireData typedef. This will be a shared memory region on Windows, as before, and on POSIX we'll be sending the bitmap data over the wire. Obviously this'll be pretty slow but it'll work sooner.
Review URL: http://codereview.chromium.org/19491
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9065 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r-- | chrome/browser/renderer_host/backing_store.cc | 2 | ||||
-rw-r--r-- | chrome/browser/renderer_host/backing_store.h | 16 | ||||
-rw-r--r-- | chrome/browser/renderer_host/backing_store_posix.cc | 37 | ||||
-rw-r--r-- | chrome/browser/renderer_host/backing_store_win.cc | 5 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host.cc | 33 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host.h | 9 |
6 files changed, 75 insertions, 27 deletions
diff --git a/chrome/browser/renderer_host/backing_store.cc b/chrome/browser/renderer_host/backing_store.cc index 9cff6aa7..da988768 100644 --- a/chrome/browser/renderer_host/backing_store.cc +++ b/chrome/browser/renderer_host/backing_store.cc @@ -60,7 +60,7 @@ BackingStore* BackingStoreManager::PrepareBackingStore( RenderWidgetHost* host, const gfx::Rect& backing_store_rect, base::ProcessHandle process_handle, - HANDLE bitmap_section, + BitmapWireData bitmap_section, const gfx::Rect& bitmap_rect, bool* needs_full_paint) { BackingStore* backing_store = GetBackingStore(host, diff --git a/chrome/browser/renderer_host/backing_store.h b/chrome/browser/renderer_host/backing_store.h index eddb4c4..ce15c88 100644 --- a/chrome/browser/renderer_host/backing_store.h +++ b/chrome/browser/renderer_host/backing_store.h @@ -10,10 +10,13 @@ #include "base/gfx/size.h" #include "base/process.h" #include "build/build_config.h" +#include "chrome/common/bitmap_wire_data.h" #include "chrome/common/mru_cache.h" #if defined(OS_WIN) #include <windows.h> +#elif defined(OS_POSIX) +#include "skia/ext/platform_canvas.h" #endif class RenderWidgetHost; @@ -33,17 +36,15 @@ class BackingStore { #endif // Paints the bitmap from the renderer onto the backing store. - // TODO(port): The HANDLE is a shared section on Windows. Abstract this. bool PaintRect(base::ProcessHandle process, - HANDLE bitmap_section, + BitmapWireData bitmap_section, const gfx::Rect& bitmap_rect); // Scrolls the given rect in the backing store, replacing the given region // identified by |bitmap_rect| by the bitmap in the file identified by the // given file handle. - // TODO(port): The HANDLE is a shared section on Windows. Abstract this. void ScrollRect(base::ProcessHandle process, - HANDLE bitmap, const gfx::Rect& bitmap_rect, + BitmapWireData bitmap, const gfx::Rect& bitmap_rect, int dx, int dy, const gfx::Rect& clip_rect, const gfx::Size& view_size); @@ -69,7 +70,9 @@ class BackingStore { // Handle to the original bitmap in the dc. HANDLE original_bitmap_; -#endif +#elif defined(OS_POSIX) + skia::PlatformCanvas canvas_; +#endif // defined(OS_WIN) DISALLOW_COPY_AND_ASSIGN(BackingStore); }; @@ -105,11 +108,10 @@ class BackingStoreManager { // needs_full_paint // Set if we need to send out a request to paint the view // to the renderer. - // TODO(port): The HANDLE is a shared section on Windows. Abstract this. static BackingStore* PrepareBackingStore(RenderWidgetHost* host, const gfx::Rect& backing_store_rect, base::ProcessHandle process_handle, - HANDLE bitmap_section, + BitmapWireData bitmap_section, const gfx::Rect& bitmap_rect, bool* needs_full_paint); diff --git a/chrome/browser/renderer_host/backing_store_posix.cc b/chrome/browser/renderer_host/backing_store_posix.cc new file mode 100644 index 0000000..a21b235 --- /dev/null +++ b/chrome/browser/renderer_host/backing_store_posix.cc @@ -0,0 +1,37 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/renderer_host/backing_store.h" + +BackingStore::BackingStore(const gfx::Size& size) + : size_(size) { + if (!canvas_.initialize(size.width(), size.height(), true)) + SK_CRASH(); +} + +BackingStore::~BackingStore() { +} + +bool BackingStore::PaintRect(base::ProcessHandle process, + BitmapWireData bitmap, + const gfx::Rect& bitmap_rect) { + if (bitmap.width() != bitmap_rect.width() || + bitmap.height() != bitmap_rect.height() || + bitmap.config() != SkBitmap::kARGB_8888_Config) { + return false; + } + + canvas_.drawBitmap(bitmap, bitmap_rect.x(), bitmap_rect.y()); + return true; +} + +void BackingStore::ScrollRect(base::ProcessHandle process, + BitmapWireData bitmap, + const gfx::Rect& bitmap_rect, + int dx, int dy, + const gfx::Rect& clip_rect, + const gfx::Size& view_size) { + // TODO(port): implement scrolling + NOTIMPLEMENTED(); +} diff --git a/chrome/browser/renderer_host/backing_store_win.cc b/chrome/browser/renderer_host/backing_store_win.cc index 0a09d2e..2ca9396 100644 --- a/chrome/browser/renderer_host/backing_store_win.cc +++ b/chrome/browser/renderer_host/backing_store_win.cc @@ -31,7 +31,7 @@ BackingStore::~BackingStore() { } bool BackingStore::PaintRect(base::ProcessHandle process, - HANDLE bitmap_section, + BitmapWireData bitmap_section, const gfx::Rect& bitmap_rect) { // The bitmap received is valid only in the renderer process. HANDLE valid_bitmap = @@ -76,7 +76,8 @@ bool BackingStore::PaintRect(base::ProcessHandle process, } void BackingStore::ScrollRect(base::ProcessHandle process, - HANDLE bitmap, const gfx::Rect& bitmap_rect, + BitmapWireData bitmap, + const gfx::Rect& bitmap_rect, int dx, int dy, const gfx::Rect& clip_rect, const gfx::Size& view_size) { diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index a163705..50a6ef3 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -4,19 +4,23 @@ #include "chrome/browser/renderer_host/render_widget_host.h" -#include "base/gfx/gdi_util.h" +#include "base/gfx/native_widget_types.h" #include "base/message_loop.h" -#include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/renderer_host/backing_store.h" #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/renderer_host/render_widget_helper.h" #include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/common/notification_service.h" -#include "chrome/common/win_util.h" #include "chrome/views/view.h" #include "webkit/glue/webcursor.h" #include "webkit/glue/webinputevent.h" +#if defined(OS_WIN) +#include "base/gfx/gdi_util.h" +#include "chrome/app/chrome_dll_resource.h" +#include "chrome/common/win_util.h" +#endif // defined(OS_WIN) + using base::Time; using base::TimeDelta; using base::TimeTicks; @@ -35,18 +39,18 @@ static const int kHungRendererDelayMs = 20000; RenderWidgetHost::RenderWidgetHost(RenderProcessHost* process, int routing_id) - : process_(process), + : view_(NULL), + process_(process), routing_id_(routing_id), - resize_ack_pending_(false), - mouse_move_pending_(false), - view_(NULL), is_loading_(false), is_hidden_(false), + repaint_ack_pending_(false), + resize_ack_pending_(false), suppress_view_updating_(false), + mouse_move_pending_(false), needs_repainting_on_restore_(false), is_unresponsive_(false), - view_being_painted_(false), - repaint_ack_pending_(false) { + view_being_painted_(false) { if (routing_id_ == MSG_ROUTING_NONE) routing_id_ = process_->GetNextRoutingID(); @@ -277,9 +281,15 @@ void RenderWidgetHost::ForwardWheelEvent( } void RenderWidgetHost::ForwardKeyboardEvent(const WebKeyboardEvent& key_event) { +#if defined(OS_WIN) if (key_event.type == WebKeyboardEvent::CHAR && (key_event.key_code == VK_RETURN || key_event.key_code == VK_SPACE)) OnEnterOrSpace(); +#else + // TODO(port): we don't have portable keyboard codes yet + // Maybe use keyboard_codes.h if we stick with it + NOTIMPLEMENTED(); +#endif ForwardInputEvent(key_event, sizeof(WebKeyboardEvent)); } @@ -408,7 +418,6 @@ void RenderWidgetHost::OnMsgPaintRect( UMA_HISTOGRAM_TIMES(L"MPArch.RWH_RepaintDelta", delta); } - DCHECK(params.bitmap); DCHECK(!params.bitmap_rect.IsEmpty()); DCHECK(!params.view_size.IsEmpty()); @@ -547,7 +556,7 @@ void RenderWidgetHost::OnMsgImeUpdateStatus(ViewHostMsg_ImeControl control, } } -void RenderWidgetHost::PaintBackingStoreRect(HANDLE bitmap, +void RenderWidgetHost::PaintBackingStoreRect(BitmapWireData bitmap, const gfx::Rect& bitmap_rect, const gfx::Size& view_size) { if (is_hidden_) { @@ -576,7 +585,7 @@ void RenderWidgetHost::PaintBackingStoreRect(HANDLE bitmap, } } -void RenderWidgetHost::ScrollBackingStoreRect(HANDLE bitmap, +void RenderWidgetHost::ScrollBackingStoreRect(BitmapWireData bitmap, const gfx::Rect& bitmap_rect, int dx, int dy, const gfx::Rect& clip_rect, diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h index d61320b..08f20f0 100644 --- a/chrome/browser/renderer_host/render_widget_host.h +++ b/chrome/browser/renderer_host/render_widget_host.h @@ -5,13 +5,13 @@ #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ -#include <windows.h> - #include <vector> #include "base/gfx/size.h" #include "base/timer.h" +#include "chrome/common/bitmap_wire_data.h" #include "chrome/common/ipc_channel.h" +#include "chrome/common/render_messages.h" #include "testing/gtest/include/gtest/gtest_prod.h" namespace gfx { @@ -27,7 +27,6 @@ class WebKeyboardEvent; class WebMouseEvent; class WebMouseWheelEvent; class WebCursor; -enum ViewHostMsg_ImeControl; struct ViewHostMsg_PaintRect_Params; struct ViewHostMsg_ScrollRect_Params; struct WebPluginGeometry; @@ -260,14 +259,14 @@ class RenderWidgetHost : public IPC::Channel::Listener { const gfx::Rect& caret_rect); // Paints the given bitmap to the current backing store at the given location. - void PaintBackingStoreRect(HANDLE bitmap, + void PaintBackingStoreRect(BitmapWireData bitmap, const gfx::Rect& bitmap_rect, const gfx::Size& view_size); // Scrolls the given |clip_rect| in the backing by the given dx/dy amount. The // |bitmap| and its corresponding location |bitmap_rect| in the backing store // is the newly painted pixels by the renderer. - void ScrollBackingStoreRect(HANDLE bitmap, + void ScrollBackingStoreRect(BitmapWireData bitmap, const gfx::Rect& bitmap_rect, int dx, int dy, const gfx::Rect& clip_rect, |