summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-20 21:26:39 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-20 21:26:39 +0000
commit3ec40f2a1a918be8350022342a6c9e7824b1d03b (patch)
tree154ec7366bfe00bb86fdbb4e11c68a848832f673 /ppapi/proxy
parent2d2118e9ebf9c85974e6299680253598a7a5610d (diff)
downloadchromium_src-3ec40f2a1a918be8350022342a6c9e7824b1d03b.zip
chromium_src-3ec40f2a1a918be8350022342a6c9e7824b1d03b.tar.gz
chromium_src-3ec40f2a1a918be8350022342a6c9e7824b1d03b.tar.bz2
Relanding this with fixes to the mac dbg builder
Remove the Webkit thread in the PPAPI plugin process and perform the 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 TBR=brettw Review URL: https://chromiumcodereview.appspot.com/9192038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118503 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r--ppapi/proxy/plugin_dispatcher.h1
-rw-r--r--ppapi/proxy/plugin_proxy_delegate.h10
-rw-r--r--ppapi/proxy/ppapi_proxy_test.cc11
-rw-r--r--ppapi/proxy/ppapi_proxy_test.h3
-rw-r--r--ppapi/proxy/ppb_font_proxy.cc182
-rw-r--r--ppapi/proxy/ppb_font_proxy.h50
-rw-r--r--ppapi/proxy/ppb_image_data_proxy.cc4
-rw-r--r--ppapi/proxy/ppb_image_data_proxy.h3
-rw-r--r--ppapi/proxy/resource_creation_proxy.cc10
9 files changed, 13 insertions, 261 deletions
diff --git a/ppapi/proxy/plugin_dispatcher.h b/ppapi/proxy/plugin_dispatcher.h
index 47df95d..947ab0a 100644
--- a/ppapi/proxy/plugin_dispatcher.h
+++ b/ppapi/proxy/plugin_dispatcher.h
@@ -24,7 +24,6 @@ namespace ppapi {
struct Preferences;
class Resource;
-class WebKitForwarding;
namespace proxy {
diff --git a/ppapi/proxy/plugin_proxy_delegate.h b/ppapi/proxy/plugin_proxy_delegate.h
index 07287ed..5045ba7 100644
--- a/ppapi/proxy/plugin_proxy_delegate.h
+++ b/ppapi/proxy/plugin_proxy_delegate.h
@@ -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;
diff --git a/ppapi/proxy/ppapi_proxy_test.cc b/ppapi/proxy/ppapi_proxy_test.cc
index 15dc967..7bfacc5 100644
--- a/ppapi/proxy/ppapi_proxy_test.cc
+++ b/ppapi/proxy/ppapi_proxy_test.cc
@@ -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();
diff --git a/ppapi/proxy/ppapi_proxy_test.h b/ppapi/proxy/ppapi_proxy_test.h
index 5816188..6278f71 100644
--- a/ppapi/proxy/ppapi_proxy_test.h
+++ b/ppapi/proxy/ppapi_proxy_test.h
@@ -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;
diff --git a/ppapi/proxy/ppb_font_proxy.cc b/ppapi/proxy/ppb_font_proxy.cc
index 49d3892..b12c22e 100644
--- a/ppapi/proxy/ppb_font_proxy.cc
+++ b/ppapi/proxy/ppb_font_proxy.cc
@@ -4,46 +4,18 @@
#include "ppapi/proxy/ppb_font_proxy.h"
-#include "base/bind.h"
-#include "base/debug/trace_event.h"
#include "ppapi/c/dev/ppb_font_dev.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_globals.h"
#include "ppapi/proxy/plugin_proxy_delegate.h"
#include "ppapi/proxy/ppapi_messages.h"
-#include "ppapi/proxy/ppb_image_data_proxy.h"
-#include "ppapi/proxy/serialized_var.h"
-#include "ppapi/shared_impl/ppapi_preferences.h"
-#include "ppapi/shared_impl/resource.h"
#include "ppapi/shared_impl/var.h"
-#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/ppb_image_data_api.h"
-#include "ppapi/thunk/thunk.h"
-using ppapi::thunk::EnterResourceNoLock;
-using ppapi::thunk::PPB_Font_API;
using ppapi::thunk::PPB_Font_FunctionAPI;
-using ppapi::thunk::PPB_ImageData_API;
namespace ppapi {
namespace proxy {
-namespace {
-
-bool PPTextRunToTextRun(const PP_TextRun_Dev* run,
- WebKitForwarding::Font::TextRun* output) {
- StringVar* str = StringVar::FromPPVar(run->text);
- if (!str)
- return false;
-
- output->text = str->value();
- output->rtl = PP_ToBool(run->rtl);
- output->override_direction = PP_ToBool(run->override_direction);
- return true;
-}
-
-} // namespace
-
PPB_Font_Proxy::PPB_Font_Proxy(Dispatcher* dispatcher)
: InterfaceProxy(dispatcher) {
}
@@ -55,6 +27,8 @@ PPB_Font_FunctionAPI* PPB_Font_Proxy::AsPPB_Font_FunctionAPI() {
return this;
}
+// TODO(ananta)
+// This needs to be wired up to the PPAPI plugin code.
PP_Var PPB_Font_Proxy::GetFontFamilies(PP_Instance instance) {
PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
if (!dispatcher)
@@ -76,157 +50,5 @@ bool PPB_Font_Proxy::OnMessageReceived(const IPC::Message& msg) {
return false;
}
-Font::Font(const HostResource& resource,
- const PP_FontDescription_Dev& desc)
- : Resource(resource),
- webkit_event_(false, false),
- font_forwarding_(NULL) {
- TRACE_EVENT0("ppapi proxy", "Font::Font");
- StringVar* face = StringVar::FromPPVar(desc.face);
-
- PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this);
- if (!dispatcher)
- return;
- WebKitForwarding* forwarding =
- PluginGlobals::Get()->plugin_proxy_delegate()->GetWebKitForwarding();
-
- RunOnWebKitThread(true,
- base::Bind(&WebKitForwarding::CreateFontForwarding,
- base::Unretained(forwarding),
- &webkit_event_, desc,
- face ? face->value() : std::string(),
- dispatcher->preferences(),
- &font_forwarding_));
-}
-
-Font::~Font() {
- if (font_forwarding_) {
- RunOnWebKitThread(false,
- base::Bind(&DeleteFontForwarding, font_forwarding_));
- }
-}
-
-PPB_Font_API* Font::AsPPB_Font_API() {
- return this;
-}
-
-PP_Bool Font::Describe(PP_FontDescription_Dev* description,
- PP_FontMetrics_Dev* metrics) {
- TRACE_EVENT0("ppapi proxy", "Font::Describe");
- std::string face;
- PP_Bool result = PP_FALSE;
- if (font_forwarding_) {
- RunOnWebKitThread(true,
- base::Bind(&WebKitForwarding::Font::Describe,
- base::Unretained(font_forwarding_),
- &webkit_event_, description, &face, metrics,
- &result));
- }
-
- if (PP_ToBool(result))
- description->face = StringVar::StringToPPVar(face);
- else
- description->face = PP_MakeUndefined();
- return result;
-}
-
-PP_Bool Font::DrawTextAt(PP_Resource pp_image_data,
- const PP_TextRun_Dev* text,
- const PP_Point* position,
- uint32_t color,
- const PP_Rect* clip,
- PP_Bool image_data_is_opaque) {
- TRACE_EVENT0("ppapi proxy", "Font::DrawTextAt");
- if (!font_forwarding_)
- return PP_FALSE;
-
- // Convert to an ImageData object.
- EnterResourceNoLock<PPB_ImageData_API> enter(pp_image_data, true);
- if (enter.failed())
- return PP_FALSE;
- ImageData* image_data = static_cast<ImageData*>(enter.object());
-
- skia::PlatformCanvas* canvas = image_data->mapped_canvas();
- bool needs_unmapping = false;
- if (!canvas) {
- needs_unmapping = true;
- image_data->Map();
- canvas = image_data->mapped_canvas();
- if (!canvas)
- return PP_FALSE; // Failure mapping.
- }
-
- WebKitForwarding::Font::TextRun run;
- if (!PPTextRunToTextRun(text, &run)) {
- if (needs_unmapping)
- image_data->Unmap();
- return PP_FALSE;
- }
- RunOnWebKitThread(
- true,
- base::Bind(&WebKitForwarding::Font::DrawTextAt,
- base::Unretained(font_forwarding_), &webkit_event_,
- WebKitForwarding::Font::DrawTextParams(canvas, run, position,
- color, clip,
- image_data_is_opaque)));
-
- if (needs_unmapping)
- image_data->Unmap();
- return PP_TRUE;
-}
-
-int32_t Font::MeasureText(const PP_TextRun_Dev* text) {
- TRACE_EVENT0("ppapi proxy", "Font::MeasureText");
- WebKitForwarding::Font::TextRun run;
- if (!font_forwarding_ || !PPTextRunToTextRun(text, &run))
- return -1;
- int32_t result = -1;
- RunOnWebKitThread(true,
- base::Bind(&WebKitForwarding::Font::MeasureText,
- base::Unretained(font_forwarding_),
- &webkit_event_, run, &result));
- return result;
-}
-
-uint32_t Font::CharacterOffsetForPixel(const PP_TextRun_Dev* text,
- int32_t pixel_position) {
- TRACE_EVENT0("ppapi proxy", "Font::CharacterOffsetForPixel");
- WebKitForwarding::Font::TextRun run;
- if (!font_forwarding_ || !PPTextRunToTextRun(text, &run))
- return -1;
- uint32_t result = -1;
- RunOnWebKitThread(true,
- base::Bind(&WebKitForwarding::Font::CharacterOffsetForPixel,
- base::Unretained(font_forwarding_),
- &webkit_event_, run, pixel_position, &result));
- return result;
-}
-
-int32_t Font::PixelOffsetForCharacter(const PP_TextRun_Dev* text,
- uint32_t char_offset) {
- TRACE_EVENT0("ppapi proxy", "Font::PixelOffsetForCharacter");
- WebKitForwarding::Font::TextRun run;
- if (!font_forwarding_ || !PPTextRunToTextRun(text, &run))
- return -1;
- int32_t result = -1;
- RunOnWebKitThread(true,
- base::Bind(&WebKitForwarding::Font::PixelOffsetForCharacter,
- base::Unretained(font_forwarding_),
- &webkit_event_, run, char_offset, &result));
- return result;
-}
-
-void Font::RunOnWebKitThread(bool blocking, const base::Closure& task) {
- PluginGlobals::Get()->plugin_proxy_delegate()->PostToWebKitThread(
- FROM_HERE, task);
- if (blocking)
- webkit_event_.Wait();
-}
-
-// static
-void Font::DeleteFontForwarding(WebKitForwarding::Font* font_forwarding) {
- delete font_forwarding;
-}
-
} // namespace proxy
} // namespace ppapi
diff --git a/ppapi/proxy/ppb_font_proxy.h b/ppapi/proxy/ppb_font_proxy.h
index 58fdc22..2849f3d 100644
--- a/ppapi/proxy/ppb_font_proxy.h
+++ b/ppapi/proxy/ppb_font_proxy.h
@@ -6,12 +6,10 @@
#define PPAPI_PROXY_PPB_FONT_PROXY_H_
#include "base/callback_forward.h"
-#include "base/synchronization/waitable_event.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/shared_impl/function_group_base.h"
#include "ppapi/shared_impl/host_resource.h"
#include "ppapi/shared_impl/resource.h"
-#include "ppapi/shared_impl/webkit_forwarding.h"
#include "ppapi/thunk/ppb_font_api.h"
namespace ppapi {
@@ -38,54 +36,6 @@ class PPB_Font_Proxy : public InterfaceProxy,
DISALLOW_COPY_AND_ASSIGN(PPB_Font_Proxy);
};
-class Font : public ppapi::Resource,
- public ppapi::thunk::PPB_Font_API {
- public:
- // Note that there isn't a "real" resource in the renderer backing a font,
- // it lives entirely in the plugin process. So the resource ID in the host
- // resource should be 0. However, various code assumes the instance in the
- // host resource is valid (this is how resources are associated with
- // instances), so that should be set.
- Font(const ppapi::HostResource& resource, const PP_FontDescription_Dev& desc);
- virtual ~Font();
-
- // Resource.
- virtual ppapi::thunk::PPB_Font_API* AsPPB_Font_API() OVERRIDE;
-
- // PPB_Font_API implementation.
- virtual PP_Bool Describe(PP_FontDescription_Dev* description,
- PP_FontMetrics_Dev* metrics) OVERRIDE;
- virtual PP_Bool DrawTextAt(PP_Resource image_data,
- const PP_TextRun_Dev* text,
- const PP_Point* position,
- uint32_t color,
- const PP_Rect* clip,
- PP_Bool image_data_is_opaque) OVERRIDE;
- virtual int32_t MeasureText(const PP_TextRun_Dev* text) OVERRIDE;
- virtual uint32_t CharacterOffsetForPixel(const PP_TextRun_Dev* text,
- int32_t pixel_position) OVERRIDE;
- virtual int32_t PixelOffsetForCharacter(const PP_TextRun_Dev* text,
- uint32_t char_offset) OVERRIDE;
-
- private:
- // Posts the given closure to the WebKit thread.
- // If |blocking| is true, the method waits on |webkit_event_| for the task to
- // continue.
- void RunOnWebKitThread(bool blocking, const base::Closure& task);
-
- static void DeleteFontForwarding(
- ppapi::WebKitForwarding::Font* font_forwarding);
-
- base::WaitableEvent webkit_event_;
-
- // This class owns |font_forwarding_|.
- // |font_forwarding_| should always be used on the WebKit thread (including
- // destruction).
- ppapi::WebKitForwarding::Font* font_forwarding_;
-
- DISALLOW_COPY_AND_ASSIGN(Font);
-};
-
} // namespace proxy
} // namespace ppapi
diff --git a/ppapi/proxy/ppb_image_data_proxy.cc b/ppapi/proxy/ppb_image_data_proxy.cc
index 20f8f62..c02e136 100644
--- a/ppapi/proxy/ppb_image_data_proxy.cc
+++ b/ppapi/proxy/ppb_image_data_proxy.cc
@@ -77,6 +77,10 @@ int32_t ImageData::GetSharedMemory(int* /* handle */,
return PP_ERROR_NOACCESS;
}
+skia::PlatformCanvas* ImageData::GetPlatformCanvas() {
+ return mapped_canvas_.get();
+}
+
#if defined(OS_WIN)
const ImageHandle ImageData::NullHandle = NULL;
#elif defined(OS_MACOSX)
diff --git a/ppapi/proxy/ppb_image_data_proxy.h b/ppapi/proxy/ppb_image_data_proxy.h
index 7890641..00fec80 100644
--- a/ppapi/proxy/ppb_image_data_proxy.h
+++ b/ppapi/proxy/ppb_image_data_proxy.h
@@ -51,8 +51,7 @@ class ImageData : public ppapi::Resource,
virtual void* Map() OVERRIDE;
virtual void Unmap() OVERRIDE;
virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE;
-
- skia::PlatformCanvas* mapped_canvas() const { return mapped_canvas_.get(); }
+ virtual skia::PlatformCanvas* GetPlatformCanvas() OVERRIDE;
const PP_ImageDataDesc& desc() const { return desc_; }
diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc
index 02f2723..6c99ac1 100644
--- a/ppapi/proxy/resource_creation_proxy.cc
+++ b/ppapi/proxy/resource_creation_proxy.cc
@@ -33,10 +33,10 @@
#include "ppapi/shared_impl/function_group_base.h"
#include "ppapi/shared_impl/host_resource.h"
#include "ppapi/shared_impl/ppb_audio_config_shared.h"
-#include "ppapi/shared_impl/ppb_font_shared.h"
#include "ppapi/shared_impl/ppb_input_event_shared.h"
#include "ppapi/shared_impl/ppb_resource_array_shared.h"
#include "ppapi/shared_impl/ppb_url_request_info_shared.h"
+#include "ppapi/shared_impl/private/ppb_font_shared.h"
#include "ppapi/shared_impl/var.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_image_data_api.h"
@@ -152,10 +152,12 @@ PP_Resource ResourceCreationProxy::CreateFlashNetConnector(
PP_Resource ResourceCreationProxy::CreateFontObject(
PP_Instance instance,
const PP_FontDescription_Dev* description) {
- if (!PPB_Font_Shared::IsPPFontDescriptionValid(*description))
+ PluginDispatcher* dispatcher =
+ PluginDispatcher::GetForInstance(instance);
+ if (!dispatcher)
return 0;
- return (new Font(HostResource::MakeInstanceOnly(instance), *description))->
- GetReference();
+ return PPB_Font_Shared::CreateAsProxy(instance, *description,
+ dispatcher->preferences());
}
PP_Resource ResourceCreationProxy::CreateGraphics2D(PP_Instance instance,