Skip to content

Commit

Permalink
Remove the Webkit thread in the PPAPI plugin process and perform the …
Browse files Browse the repository at this point in the history
…text and font operations

on the PPAPI main thread. This thread is now registered as the Webkit thread.

Fixes performance issues seen in Flapper with text and font operations. It appears that the perf
issues occur due to context switching between the main thread and the webkit thread.

As per comments from Brett moving the font forwarding code inline to ppb_font_shared.cc. This file
has been moved to ppapi/shared_impl/private as it now brings in a dependency on WebKit. The font
creation has been wired up to the ResourceCreationAPI as suggested.

BUG=110190
R=brettw
Review URL: https://chromiumcodereview.appspot.com/9133015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118385 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ananta@chromium.org committed Jan 19, 2012
1 parent fbd5746 commit d914b2b
Show file tree
Hide file tree
Showing 37 changed files with 330 additions and 769 deletions.
2 changes: 1 addition & 1 deletion chrome/renderer/chrome_ppb_pdf_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ PP_Resource GetResourceImage(PP_Instance instance_id,
if (!mapper.is_valid())
return 0;

skia::PlatformCanvas* canvas = image_data->mapped_canvas();
skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas();
// Note: Do not skBitmap::copyTo the canvas bitmap directly because it will
// ignore the allocated pixels in shared memory and re-allocate a new buffer.
canvas->writePixels(*res_bitmap, 0, 0);
Expand Down
2 changes: 0 additions & 2 deletions content/content_ppapi_plugin.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
'ppapi_plugin/ppapi_plugin_main.cc',
'ppapi_plugin/ppapi_thread.cc',
'ppapi_plugin/ppapi_thread.h',
'ppapi_plugin/ppapi_webkit_thread.cc',
'ppapi_plugin/ppapi_webkit_thread.h',
'ppapi_plugin/ppapi_webkitplatformsupport_impl.cc',
'ppapi_plugin/ppapi_webkitplatformsupport_impl.h',
],
Expand Down
20 changes: 5 additions & 15 deletions content/ppapi_plugin/ppapi_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "content/common/child_process_messages.h"
#include "content/ppapi_plugin/broker_process_dispatcher.h"
#include "content/ppapi_plugin/plugin_process_dispatcher.h"
#include "content/ppapi_plugin/ppapi_webkit_thread.h"
#include "content/ppapi_plugin/ppapi_webkitplatformsupport_impl.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/sandbox_init.h"
#include "ipc/ipc_channel_handle.h"
Expand All @@ -25,7 +25,7 @@
#include "ppapi/proxy/plugin_globals.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/interface_list.h"
#include "webkit/plugins/ppapi/webkit_forwarding_impl.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"

#if defined(OS_WIN)
#include "sandbox/src/sandbox.h"
Expand All @@ -50,6 +50,8 @@ PpapiThread::PpapiThread(bool is_broker)
base::RandInt(0, std::numeric_limits<PP_Module>::max())),
next_plugin_dispatcher_id_(1) {
ppapi::proxy::PluginGlobals::Get()->set_plugin_proxy_delegate(this);
webkit_platform_support_.reset(new PpapiWebKitPlatformSupportImpl);
WebKit::initialize(webkit_platform_support_.get());
}

PpapiThread::~PpapiThread() {
Expand All @@ -67,6 +69,7 @@ PpapiThread::~PpapiThread() {
library_.GetFunctionPointer("PPP_ShutdownModule"));
if (shutdown_function)
shutdown_function();
WebKit::shutdown();
}

// The "regular" ChildThread implements this function and does some standard
Expand Down Expand Up @@ -111,19 +114,6 @@ std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() {
return &globally_seen_instance_ids_;
}

ppapi::WebKitForwarding* PpapiThread::GetWebKitForwarding() {
if (!webkit_forwarding_.get())
webkit_forwarding_.reset(new webkit::ppapi::WebKitForwardingImpl);
return webkit_forwarding_.get();
}

void PpapiThread::PostToWebKitThread(const tracked_objects::Location& from_here,
const base::Closure& task) {
if (!webkit_thread_.get())
webkit_thread_.reset(new PpapiWebKitThread);
webkit_thread_->PostTask(from_here, task);
}

bool PpapiThread::SendToBrowser(IPC::Message* msg) {
return Send(msg);
}
Expand Down
13 changes: 4 additions & 9 deletions content/ppapi_plugin/ppapi_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "ppapi/proxy/plugin_proxy_delegate.h"

class FilePath;
class PpapiWebKitThread;
class PpapiWebKitPlatformSupportImpl;

namespace IPC {
struct ChannelHandle;
Expand All @@ -48,9 +48,6 @@ class PpapiThread : public ChildThread,
virtual void Unregister(uint32 plugin_dispatcher_id) OVERRIDE;

// PluginProxyDelegate.
virtual ppapi::WebKitForwarding* GetWebKitForwarding() OVERRIDE;
virtual void PostToWebKitThread(const tracked_objects::Location& from_here,
const base::Closure& task) OVERRIDE;
virtual bool SendToBrowser(IPC::Message* msg) OVERRIDE;
virtual void PreCacheFont(const void* logfontw) OVERRIDE;

Expand Down Expand Up @@ -92,15 +89,13 @@ class PpapiThread : public ChildThread,
// See Dispatcher::Delegate::GetGloballySeenInstanceIDSet.
std::set<PP_Instance> globally_seen_instance_ids_;

// Lazily created by GetWebKitForwarding.
scoped_ptr<ppapi::WebKitForwarding> webkit_forwarding_;

scoped_ptr<PpapiWebKitThread> webkit_thread_;

// The PluginDispatcher instances contained in the map are not owned by it.
std::map<uint32, ppapi::proxy::PluginDispatcher*> plugin_dispatchers_;
uint32 next_plugin_dispatcher_id_;

// The WebKitPlatformSupport implementation.
scoped_ptr<PpapiWebKitPlatformSupportImpl> webkit_platform_support_;

DISALLOW_IMPLICIT_CONSTRUCTORS(PpapiThread);
};

Expand Down
44 changes: 0 additions & 44 deletions content/ppapi_plugin/ppapi_webkit_thread.cc

This file was deleted.

50 changes: 0 additions & 50 deletions content/ppapi_plugin/ppapi_webkit_thread.h

This file was deleted.

7 changes: 5 additions & 2 deletions ppapi/ppapi_shared.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
'../net/net.gyp:net',
'../skia/skia.gyp:skia',
'../third_party/icu/icu.gyp:icuuc',
# TODO(ananta) : The WebKit dependency needs to move to a new target for NACL.
'../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:webkit',
'../ui/gfx/surface/surface.gyp:surface',
],
'defines': [
Expand Down Expand Up @@ -58,8 +60,6 @@
'shared_impl/ppb_file_io_shared.h',
'shared_impl/ppb_file_ref_shared.cc',
'shared_impl/ppb_file_ref_shared.h',
'shared_impl/ppb_font_shared.cc',
'shared_impl/ppb_font_shared.h',
'shared_impl/ppb_graphics_3d_shared.cc',
'shared_impl/ppb_graphics_3d_shared.h',
'shared_impl/ppb_image_data_shared.cc',
Expand Down Expand Up @@ -107,6 +107,9 @@
'shared_impl/private/net_address_private_impl.cc',
'shared_impl/private/net_address_private_impl.h',

'shared_impl/private/ppb_font_shared.cc',
'shared_impl/private/ppb_font_shared.h',

'shared_impl/private/tcp_socket_private_impl.cc',
'shared_impl/private/tcp_socket_private_impl.h',
'shared_impl/private/udp_socket_private_impl.cc',
Expand Down
1 change: 0 additions & 1 deletion ppapi/proxy/plugin_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace ppapi {

struct Preferences;
class Resource;
class WebKitForwarding;

namespace proxy {

Expand Down
10 changes: 0 additions & 10 deletions ppapi/proxy/plugin_proxy_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ class PPAPI_PROXY_EXPORT PluginProxyDelegate {
public:
virtual ~PluginProxyDelegate() {}

// Returns the WebKit forwarding object used to make calls into WebKit.
// Necessary only on the plugin side.
virtual WebKitForwarding* GetWebKitForwarding() = 0;

// Posts the given task to the WebKit thread associated with this plugin
// process. The WebKit thread should be lazily created if it does not
// exist yet.
virtual void PostToWebKitThread(const tracked_objects::Location& from_here,
const base::Closure& task) = 0;

// Sends the given message to the browser. Identical semantics to
// IPC::Message::Sender interface.
virtual bool SendToBrowser(IPC::Message* msg) = 0;
Expand Down
11 changes: 0 additions & 11 deletions ppapi/proxy/ppapi_proxy_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,6 @@ void PluginProxyTestHarness::PluginDelegateMock::Unregister(
uint32 plugin_dispatcher_id) {
}

ppapi::WebKitForwarding*
PluginProxyTestHarness::PluginDelegateMock::GetWebKitForwarding() {
NOTREACHED();
return NULL;
}

void PluginProxyTestHarness::PluginDelegateMock::PostToWebKitThread(
const tracked_objects::Location& from_here, const base::Closure& task) {
NOTREACHED();
}

bool PluginProxyTestHarness::PluginDelegateMock::SendToBrowser(
IPC::Message* msg) {
NOTREACHED();
Expand Down
3 changes: 0 additions & 3 deletions ppapi/proxy/ppapi_proxy_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ class PluginProxyTestHarness : public ProxyTestHarnessBase {
virtual void Unregister(uint32 plugin_dispatcher_id) OVERRIDE;

// PluginPepperDelegate implementation.
virtual ppapi::WebKitForwarding* GetWebKitForwarding() OVERRIDE;
virtual void PostToWebKitThread(const tracked_objects::Location& from_here,
const base::Closure& task) OVERRIDE;
virtual bool SendToBrowser(IPC::Message* msg) OVERRIDE;
virtual void PreCacheFont(const void* logfontw) OVERRIDE;

Expand Down
Loading

0 comments on commit d914b2b

Please sign in to comment.