summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/renderer/chrome_ppb_pdf_impl.cc2
-rw-r--r--content/content_ppapi_plugin.gypi2
-rw-r--r--content/ppapi_plugin/ppapi_thread.cc20
-rw-r--r--content/ppapi_plugin/ppapi_thread.h13
-rw-r--r--content/ppapi_plugin/ppapi_webkit_thread.cc44
-rw-r--r--content/ppapi_plugin/ppapi_webkit_thread.h50
-rw-r--r--ppapi/ppapi_shared.gypi7
-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
-rw-r--r--ppapi/shared_impl/ppb_font_shared.cc35
-rw-r--r--ppapi/shared_impl/ppb_font_shared.h32
-rw-r--r--ppapi/shared_impl/private/ppb_font_shared.cc (renamed from webkit/plugins/ppapi/webkit_forwarding_impl.cc)241
-rw-r--r--ppapi/shared_impl/private/ppb_font_shared.h72
-rw-r--r--ppapi/shared_impl/webkit_forwarding.h29
-rw-r--r--ppapi/thunk/ppb_font_api.h3
-rw-r--r--ppapi/thunk/ppb_image_data_api.h7
-rw-r--r--webkit/glue/webkit_glue.gypi2
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc7
-rw-r--r--webkit/plugins/ppapi/plugin_module.h6
-rw-r--r--webkit/plugins/ppapi/ppb_flash_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_font_impl.cc142
-rw-r--r--webkit/plugins/ppapi/ppb_font_impl.h43
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc6
-rw-r--r--webkit/plugins/ppapi/ppb_image_data_impl.cc4
-rw-r--r--webkit/plugins/ppapi/ppb_image_data_impl.h3
-rw-r--r--webkit/plugins/ppapi/ppb_scrollbar_impl.cc2
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.cc10
-rw-r--r--webkit/plugins/ppapi/resource_helper.cc7
-rw-r--r--webkit/plugins/ppapi/resource_helper.h4
-rw-r--r--webkit/plugins/ppapi/webkit_forwarding_impl.h30
37 files changed, 330 insertions, 769 deletions
diff --git a/chrome/renderer/chrome_ppb_pdf_impl.cc b/chrome/renderer/chrome_ppb_pdf_impl.cc
index 5a4592c..3f0c688 100644
--- a/chrome/renderer/chrome_ppb_pdf_impl.cc
+++ b/chrome/renderer/chrome_ppb_pdf_impl.cc
@@ -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);
diff --git a/content/content_ppapi_plugin.gypi b/content/content_ppapi_plugin.gypi
index b428614..c5a2543 100644
--- a/content/content_ppapi_plugin.gypi
+++ b/content/content_ppapi_plugin.gypi
@@ -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',
],
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc
index e989785..3277f1b 100644
--- a/content/ppapi_plugin/ppapi_thread.cc
+++ b/content/ppapi_plugin/ppapi_thread.cc
@@ -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"
@@ -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"
@@ -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() {
@@ -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
@@ -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);
}
diff --git a/content/ppapi_plugin/ppapi_thread.h b/content/ppapi_plugin/ppapi_thread.h
index 56e12c5..bff66db 100644
--- a/content/ppapi_plugin/ppapi_thread.h
+++ b/content/ppapi_plugin/ppapi_thread.h
@@ -22,7 +22,7 @@
#include "ppapi/proxy/plugin_proxy_delegate.h"
class FilePath;
-class PpapiWebKitThread;
+class PpapiWebKitPlatformSupportImpl;
namespace IPC {
struct ChannelHandle;
@@ -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;
@@ -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);
};
diff --git a/content/ppapi_plugin/ppapi_webkit_thread.cc b/content/ppapi_plugin/ppapi_webkit_thread.cc
deleted file mode 100644
index cb3d482..0000000
--- a/content/ppapi_plugin/ppapi_webkit_thread.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) 2011 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 "content/ppapi_plugin/ppapi_webkit_thread.h"
-
-#include "base/logging.h"
-#include "content/ppapi_plugin/ppapi_webkitplatformsupport_impl.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
-
-PpapiWebKitThread::PpapiWebKitThread() {
- DCHECK(!webkit_thread_.get());
-
- webkit_thread_.reset(new InternalWebKitThread);
- bool started = webkit_thread_->Start();
- DCHECK(started);
-}
-
-PpapiWebKitThread::~PpapiWebKitThread() {
-}
-
-void PpapiWebKitThread::PostTask(const tracked_objects::Location& from_here,
- const base::Closure& task) {
- webkit_thread_->message_loop()->PostTask(from_here, task);
-}
-
-PpapiWebKitThread::InternalWebKitThread::InternalWebKitThread()
- : base::Thread("PPAPIWebKit") {
-}
-
-PpapiWebKitThread::InternalWebKitThread::~InternalWebKitThread() {
- Stop();
-}
-
-void PpapiWebKitThread::InternalWebKitThread::Init() {
- DCHECK(!webkit_platform_support_.get());
- webkit_platform_support_.reset(new PpapiWebKitPlatformSupportImpl);
- WebKit::initialize(webkit_platform_support_.get());
-}
-
-void PpapiWebKitThread::InternalWebKitThread::CleanUp() {
- DCHECK(webkit_platform_support_.get());
- WebKit::shutdown();
-}
diff --git a/content/ppapi_plugin/ppapi_webkit_thread.h b/content/ppapi_plugin/ppapi_webkit_thread.h
deleted file mode 100644
index a7606f6..0000000
--- a/content/ppapi_plugin/ppapi_webkit_thread.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2011 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.
-
-#ifndef CONTENT_PPAPI_PLUGIN_PPAPI_WEBKIT_THREAD_H_
-#define CONTENT_PPAPI_PLUGIN_PPAPI_WEBKIT_THREAD_H_
-#pragma once
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/threading/thread.h"
-
-class PpapiWebKitPlatformSupportImpl;
-
-// This creates a WebKit main thread on instantiation on construction and kills
-// it on deletion. See also content/browser/in_process_webkit for the
-// corresponding concept in the browser process.
-class PpapiWebKitThread {
- public:
- PpapiWebKitThread();
- ~PpapiWebKitThread();
-
- // Posts the given task to the thread, see MessageLoop::PostTask.
- void PostTask(
- const tracked_objects::Location& from_here,
- const base::Closure& task);
-
- private:
- // Must be private so that we can carefully control its lifetime.
- class InternalWebKitThread : public base::Thread {
- public:
- InternalWebKitThread();
- virtual ~InternalWebKitThread();
- // Does the actual initialization and shutdown of WebKit. Called at the
- // beginning and end of the thread's lifetime.
- virtual void Init() OVERRIDE;
- virtual void CleanUp() OVERRIDE;
-
- private:
- // The WebKitPlatformSupport implementation. Only access on WebKit thread.
- scoped_ptr<PpapiWebKitPlatformSupportImpl> webkit_platform_support_;
- };
-
- // Pointer to the actual WebKitThread.
- scoped_ptr<InternalWebKitThread> webkit_thread_;
-
- DISALLOW_COPY_AND_ASSIGN(PpapiWebKitThread);
-};
-
-#endif // CONTENT_PPAPI_PLUGIN_PPAPI_WEBKIT_THREAD_H_
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index 2802b5d..7016fb6 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -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': [
@@ -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',
@@ -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',
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,
diff --git a/ppapi/shared_impl/ppb_font_shared.cc b/ppapi/shared_impl/ppb_font_shared.cc
deleted file mode 100644
index a714643..0000000
--- a/ppapi/shared_impl/ppb_font_shared.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2011 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 "ppapi/shared_impl/ppb_font_shared.h"
-
-#include "ppapi/c/dev/ppb_font_dev.h"
-
-namespace ppapi {
-
-// static
-bool PPB_Font_Shared::IsPPFontDescriptionValid(
- const PP_FontDescription_Dev& desc) {
- // Check validity of string. We can't check the actual text since we could
- // be on the wrong thread and don't know if we're in the plugin or the host.
- if (desc.face.type != PP_VARTYPE_STRING &&
- desc.face.type != PP_VARTYPE_UNDEFINED)
- return false;
-
- // Check enum ranges.
- if (static_cast<int>(desc.family) < PP_FONTFAMILY_DEFAULT ||
- static_cast<int>(desc.family) > PP_FONTFAMILY_MONOSPACE)
- return false;
- if (static_cast<int>(desc.weight) < PP_FONTWEIGHT_100 ||
- static_cast<int>(desc.weight) > PP_FONTWEIGHT_900)
- return false;
-
- // Check for excessive sizes which may cause layout to get confused.
- if (desc.size > 200)
- return false;
-
- return true;
-}
-
-} // namespace ppapi
diff --git a/ppapi/shared_impl/ppb_font_shared.h b/ppapi/shared_impl/ppb_font_shared.h
deleted file mode 100644
index af0f681..0000000
--- a/ppapi/shared_impl/ppb_font_shared.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2011 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.
-
-#ifndef PPAPI_SHARED_IMPL_PPB_FONT_SHARED_H_
-#define PPAPI_SHARED_IMPL_PPB_FONT_SHARED_H_
-#pragma once
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "ppapi/c/pp_bool.h"
-#include "ppapi/c/pp_stdint.h"
-#include "ppapi/shared_impl/ppapi_shared_export.h"
-
-struct PP_FontDescription_Dev;
-
-namespace ppapi {
-
-class PPAPI_SHARED_EXPORT PPB_Font_Shared {
- public:
- // Validates the parameters in thee description. Can be called on any thread.
- static bool IsPPFontDescriptionValid(const PP_FontDescription_Dev& desc);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(PPB_Font_Shared);
-};
-
-} // namespace ppapi
-
-#endif // PPAPI_SHARED_IMPL_PPB_FONT_SHARED_H_
diff --git a/webkit/plugins/ppapi/webkit_forwarding_impl.cc b/ppapi/shared_impl/private/ppb_font_shared.cc
index 967919b..3af5288 100644
--- a/webkit/plugins/ppapi/webkit_forwarding_impl.cc
+++ b/ppapi/shared_impl/private/ppb_font_shared.cc
@@ -2,44 +2,59 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "webkit/plugins/ppapi/webkit_forwarding_impl.h"
-
-#include <string>
+#include "ppapi/shared_impl/private/ppb_font_shared.h"
#include "base/debug/trace_event.h"
-#include "base/memory/scoped_ptr.h"
#include "base/string_util.h"
-#include "base/synchronization/waitable_event.h"
#include "base/utf_string_conversions.h"
#include "ppapi/c/dev/ppb_font_dev.h"
-#include "ppapi/c/pp_point.h"
-#include "ppapi/c/pp_rect.h"
#include "ppapi/shared_impl/ppapi_preferences.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"
#include "skia/ext/platform_canvas.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebFont.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebFontDescription.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatPoint.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatRect.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFont.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFontDescription.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextRun.h"
-#include "webkit/glue/webkit_glue.h"
-using ::ppapi::WebKitForwarding;
-using WebKit::WebCanvas;
+using ppapi::StringVar;
+using ppapi::thunk::EnterResource;
+using ppapi::thunk::EnterResourceNoLock;
+using ppapi::thunk::PPB_ImageData_API;
+using ppapi::WebKitForwarding;
using WebKit::WebFloatPoint;
using WebKit::WebFloatRect;
using WebKit::WebFont;
using WebKit::WebFontDescription;
using WebKit::WebRect;
using WebKit::WebTextRun;
+using WebKit::WebCanvas;
-namespace webkit {
namespace ppapi {
namespace {
+// Converts the given PP_TextRun to a TextRun, returning true on success.
+// False means the input was invalid.
+bool PPTextRunToTextRun(const PP_TextRun_Dev* run,
+ WebKitForwarding::Font::TextRun* output) {
+ StringVar* text_string = StringVar::FromPPVar(run->text);
+ if (!text_string)
+ return false;
+
+ output->text = text_string->value();
+ output->rtl = run->rtl == PP_TRUE ? true : false;
+ output->override_direction =
+ run->override_direction == PP_TRUE ? true : false;
+ return true;
+}
+
// The PP_* version lacks "None", so is just one value shifted from the
// WebFontDescription version. These values are checked in
// PPFontDescToWebFontDesc to make sure the conversion is correct. This is a
@@ -136,22 +151,17 @@ class FontImpl : public WebKitForwarding::Font {
const ::ppapi::Preferences& prefs);
virtual ~FontImpl();
- virtual void Describe(base::WaitableEvent* event,
- PP_FontDescription_Dev* description,
+ virtual void Describe(PP_FontDescription_Dev* description,
std::string* face,
PP_FontMetrics_Dev* metrics,
PP_Bool* result) OVERRIDE;
- virtual void DrawTextAt(base::WaitableEvent* event,
- const DrawTextParams& params) OVERRIDE;
- virtual void MeasureText(base::WaitableEvent* event,
- const TextRun& text,
+ virtual void DrawTextAt(const DrawTextParams& params) OVERRIDE;
+ virtual void MeasureText(const TextRun& text,
int32_t* result) OVERRIDE;
- virtual void CharacterOffsetForPixel(base::WaitableEvent* event,
- const TextRun& text,
+ virtual void CharacterOffsetForPixel(const TextRun& text,
int32_t pixel_position,
uint32_t* result) OVERRIDE;
- virtual void PixelOffsetForCharacter(base::WaitableEvent* event,
- const TextRun& text,
+ virtual void PixelOffsetForCharacter(const TextRun& text,
uint32_t char_offset,
int32_t* result) OVERRIDE;
@@ -172,8 +182,7 @@ FontImpl::FontImpl(const PP_FontDescription_Dev& desc,
FontImpl::~FontImpl() {
}
-void FontImpl::Describe(base::WaitableEvent* event,
- PP_FontDescription_Dev* description,
+void FontImpl::Describe(PP_FontDescription_Dev* description,
std::string* face,
PP_FontMetrics_Dev* metrics,
PP_Bool* result) {
@@ -205,12 +214,9 @@ void FontImpl::Describe(base::WaitableEvent* event,
*result = PP_TRUE;
}
- if (event)
- event->Signal();
}
-void FontImpl::DrawTextAt(base::WaitableEvent* event,
- const DrawTextParams& params) {
+void FontImpl::DrawTextAt(const DrawTextParams& params) {
TRACE_EVENT0("ppapi WebKit thread", "FontImpl::DrawTextAt");
WebTextRun run = TextRunToWebTextRun(params.text);
@@ -230,34 +236,32 @@ void FontImpl::DrawTextAt(base::WaitableEvent* event,
params.clip->size.width, params.clip->size.height);
}
- font_->drawText(webkit_glue::ToWebCanvas(params.destination), run,
- web_position, params.color, web_clip,
+#if WEBKIT_USING_SKIA
+ WebCanvas* canvas = params.destination;
+#elif WEBKIT_USING_CG
+ WebCanvas* canvas = skia::GetBitmapContext(skia::GetTopDevice(*destination));
+#else
+ NOTIMPLEMENTED();
+ return;
+#endif
+ font_->drawText(canvas, run, web_position, params.color, web_clip,
params.image_data_is_opaque == PP_TRUE);
- if (event)
- event->Signal();
}
-void FontImpl::MeasureText(base::WaitableEvent* event,
- const TextRun& text, int32_t* result) {
+void FontImpl::MeasureText(const TextRun& text, int32_t* result) {
TRACE_EVENT0("ppapi WebKit thread", "FontImpl::MeasureText");
*result = font_->calculateWidth(TextRunToWebTextRun(text));
- if (event)
- event->Signal();
}
-void FontImpl::CharacterOffsetForPixel(base::WaitableEvent* event,
- const TextRun& text,
+void FontImpl::CharacterOffsetForPixel(const TextRun& text,
int32_t pixel_position,
uint32_t* result) {
TRACE_EVENT0("ppapi WebKit thread", "FontImpl::CharacterOffsetForPixel");
*result = static_cast<uint32_t>(font_->offsetForPosition(
TextRunToWebTextRun(text), static_cast<float>(pixel_position)));
- if (event)
- event->Signal();
}
-void FontImpl::PixelOffsetForCharacter(base::WaitableEvent* event,
- const TextRun& text,
+void FontImpl::PixelOffsetForCharacter(const TextRun& text,
uint32_t char_offset,
int32_t* result) {
TRACE_EVENT0("ppapi WebKit thread", "FontImpl::PixelOffsetForCharacter");
@@ -269,32 +273,147 @@ void FontImpl::PixelOffsetForCharacter(base::WaitableEvent* event,
run, WebFloatPoint(0.0f, 0.0f), font_->height(), 0, char_offset);
*result = static_cast<int>(rect.width);
}
- if (event)
- event->Signal();
}
} // namespace
-// WebKitForwardingImpl --------------------------------------------------------
+// static
+bool PPB_Font_Shared::IsPPFontDescriptionValid(
+ const PP_FontDescription_Dev& desc) {
+ // Check validity of string. We can't check the actual text since we could
+ // be on the wrong thread and don't know if we're in the plugin or the host.
+ if (desc.face.type != PP_VARTYPE_STRING &&
+ desc.face.type != PP_VARTYPE_UNDEFINED)
+ return false;
+
+ // Check enum ranges.
+ if (static_cast<int>(desc.family) < PP_FONTFAMILY_DEFAULT ||
+ static_cast<int>(desc.family) > PP_FONTFAMILY_MONOSPACE)
+ return false;
+ if (static_cast<int>(desc.weight) < PP_FONTWEIGHT_100 ||
+ static_cast<int>(desc.weight) > PP_FONTWEIGHT_900)
+ return false;
+
+ // Check for excessive sizes which may cause layout to get confused.
+ if (desc.size > 200)
+ return false;
+
+ return true;
+}
+
+// static
+PP_Resource PPB_Font_Shared::CreateAsImpl(
+ PP_Instance instance,
+ const PP_FontDescription_Dev& description,
+ const ::ppapi::Preferences& prefs) {
+ if (!::ppapi::PPB_Font_Shared::IsPPFontDescriptionValid(description))
+ return 0;
+ return (new PPB_Font_Shared(instance, description, prefs))->GetReference();
+}
+
+// static
+PP_Resource PPB_Font_Shared::CreateAsProxy(
+ PP_Instance instance,
+ const PP_FontDescription_Dev& description,
+ const ::ppapi::Preferences& prefs) {
+ return CreateAsImpl(instance, description, prefs);
+}
+
+PPB_Font_Shared::PPB_Font_Shared(PP_Instance pp_instance,
+ const PP_FontDescription_Dev& desc,
+ const ::ppapi::Preferences& prefs)
+ : Resource(pp_instance) {
+ StringVar* face_name = StringVar::FromPPVar(desc.face);
+
+ font_impl_.reset(new FontImpl(
+ desc, face_name ? face_name->value() : std::string(), prefs));
+}
+
+PPB_Font_Shared::~PPB_Font_Shared() {
+}
-WebKitForwardingImpl::WebKitForwardingImpl() {
+::ppapi::thunk::PPB_Font_API* PPB_Font_Shared::AsPPB_Font_API() {
+ return this;
}
-WebKitForwardingImpl::~WebKitForwardingImpl() {
+PP_Bool PPB_Font_Shared::Describe(PP_FontDescription_Dev* description,
+ PP_FontMetrics_Dev* metrics) {
+ std::string face;
+ PP_Bool result = PP_FALSE;
+ font_impl_->Describe(description, &face, metrics, &result);
+ if (!result)
+ return PP_FALSE;
+
+ // Convert the string.
+ description->face = StringVar::StringToPPVar(face);
+ return PP_TRUE;
+}
+
+PP_Bool PPB_Font_Shared::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) {
+ PP_Bool result = PP_FALSE;
+ // Get and map the image data we're painting to.
+ EnterResource<PPB_ImageData_API> enter(image_data, true);
+ if (enter.failed())
+ return result;
+
+ // TODO(ananta)
+ // We need to remove dependency on skia from this layer.
+ PPB_ImageData_API* image = static_cast<PPB_ImageData_API*>(
+ enter.object());
+ skia::PlatformCanvas* canvas = image->GetPlatformCanvas();
+ bool needs_unmapping = false;
+ if (!canvas) {
+ needs_unmapping = true;
+ image->Map();
+ canvas = image->GetPlatformCanvas();
+ if (!canvas)
+ return result; // Failure mapping.
+ }
+
+ WebKitForwarding::Font::TextRun run;
+ if (PPTextRunToTextRun(text, &run)) {
+ font_impl_->DrawTextAt(WebKitForwarding::Font::DrawTextParams(
+ canvas, run, position, color, clip, image_data_is_opaque));
+ result = PP_TRUE;
+ }
+
+ if (needs_unmapping)
+ image->Unmap();
+ return result;
}
-void WebKitForwardingImpl::CreateFontForwarding(
- base::WaitableEvent* event,
- const PP_FontDescription_Dev& desc,
- const std::string& desc_face,
- const ::ppapi::Preferences& prefs,
- Font** result) {
- TRACE_EVENT0("ppapi WebKit thread",
- "WebKitForwardingImpl::CreateFontForwarding");
- *result = new FontImpl(desc, desc_face, prefs);
- if (event)
- event->Signal();
+int32_t PPB_Font_Shared::MeasureText(const PP_TextRun_Dev* text) {
+ int32_t result = -1;
+ WebKitForwarding::Font::TextRun run;
+ if (PPTextRunToTextRun(text, &run))
+ font_impl_->MeasureText(run, &result);
+ return result;
+}
+
+uint32_t PPB_Font_Shared::CharacterOffsetForPixel(const PP_TextRun_Dev* text,
+ int32_t pixel_position) {
+ uint32_t result = -1;
+ WebKitForwarding::Font::TextRun run;
+ if (PPTextRunToTextRun(text, &run)) {
+ font_impl_->CharacterOffsetForPixel(run, pixel_position, &result);
+ }
+ return result;
+}
+
+int32_t PPB_Font_Shared::PixelOffsetForCharacter(const PP_TextRun_Dev* text,
+ uint32_t char_offset) {
+ int32_t result = -1;
+ WebKitForwarding::Font::TextRun run;
+ if (PPTextRunToTextRun(text, &run)) {
+ font_impl_->PixelOffsetForCharacter(run, char_offset, &result);
+ }
+ return result;
}
} // namespace ppapi
-} // namespace webkit
+
diff --git a/ppapi/shared_impl/private/ppb_font_shared.h b/ppapi/shared_impl/private/ppb_font_shared.h
new file mode 100644
index 0000000..3b852bf
--- /dev/null
+++ b/ppapi/shared_impl/private/ppb_font_shared.h
@@ -0,0 +1,72 @@
+// Copyright (c) 2011 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.
+
+#ifndef PPAPI_SHARED_IMPL_PRIVATE_PPB_FONT_SHARED_H_
+#define PPAPI_SHARED_IMPL_PRIVATE_PPB_FONT_SHARED_H_
+#pragma once
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_resource.h"
+#include "ppapi/c/pp_stdint.h"
+#include "ppapi/shared_impl/ppapi_preferences.h"
+#include "ppapi/shared_impl/ppapi_shared_export.h"
+#include "ppapi/shared_impl/resource.h"
+#include "ppapi/shared_impl/webkit_forwarding.h"
+#include "ppapi/thunk/ppb_font_api.h"
+
+struct PP_FontDescription_Dev;
+
+namespace ppapi {
+
+class PPAPI_SHARED_EXPORT PPB_Font_Shared
+ : public ::ppapi::Resource,
+ public ::ppapi::thunk::PPB_Font_API {
+ public:
+ // Validates the parameters in thee description. Can be called on any thread.
+ static bool IsPPFontDescriptionValid(const PP_FontDescription_Dev& desc);
+
+ virtual ~PPB_Font_Shared();
+
+ static PP_Resource CreateAsImpl(PP_Instance instance,
+ const PP_FontDescription_Dev& description,
+ const ::ppapi::Preferences& prefs);
+ static PP_Resource CreateAsProxy(PP_Instance instance,
+ const PP_FontDescription_Dev& description,
+ const ::ppapi::Preferences& prefs);
+
+ // Resource.
+ virtual ::ppapi::thunk::PPB_Font_API* AsPPB_Font_API() OVERRIDE;
+
+ // PPB_Font 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:
+ PPB_Font_Shared(PP_Instance instance, const PP_FontDescription_Dev& desc,
+ const ::ppapi::Preferences& prefs);
+
+ scoped_ptr< ::ppapi::WebKitForwarding::Font> font_impl_;
+
+ DISALLOW_COPY_AND_ASSIGN(PPB_Font_Shared);
+};
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_PRIVATE_PPB_FONT_SHARED_H_
diff --git a/ppapi/shared_impl/webkit_forwarding.h b/ppapi/shared_impl/webkit_forwarding.h
index d571aaa..2bef621 100644
--- a/ppapi/shared_impl/webkit_forwarding.h
+++ b/ppapi/shared_impl/webkit_forwarding.h
@@ -16,10 +16,6 @@ struct PP_FontMetrics_Dev;
struct PP_Point;
struct PP_Rect;
-namespace base {
-class WaitableEvent;
-}
-
namespace skia {
class PlatformCanvas;
}
@@ -67,37 +63,22 @@ class PPAPI_SHARED_EXPORT WebKitForwarding {
// on creating vars. Instead, the face name is placed into the given
// string. See class description for waitable_event documentation. If
// non-null, the given event will be set on completion.
- virtual void Describe(base::WaitableEvent* event,
- PP_FontDescription_Dev* description,
+ virtual void Describe(PP_FontDescription_Dev* description,
std::string* face,
PP_FontMetrics_Dev* metrics,
PP_Bool* result) = 0;
- virtual void DrawTextAt(base::WaitableEvent* event,
- const DrawTextParams& params) = 0;
- virtual void MeasureText(base::WaitableEvent* event,
- const TextRun& text,
+ virtual void DrawTextAt(const DrawTextParams& params) = 0;
+ virtual void MeasureText(const TextRun& text,
int32_t* result) = 0;
- virtual void CharacterOffsetForPixel(base::WaitableEvent* event,
- const TextRun& text,
+ virtual void CharacterOffsetForPixel(const TextRun& text,
int32_t pixel_position,
uint32_t* result) = 0;
- virtual void PixelOffsetForCharacter(base::WaitableEvent* event,
- const TextRun& text,
+ virtual void PixelOffsetForCharacter(const TextRun& text,
uint32_t char_offset,
int32_t* result) = 0;
};
virtual ~WebKitForwarding();
-
- // Creates a new font with the given description. The desc_face is the face
- // name already extracted from the description. The caller owns the result
- // pointer, which will never be NULL. If non-null, the given event will be
- // set on completion.
- virtual void CreateFontForwarding(base::WaitableEvent* event,
- const PP_FontDescription_Dev& desc,
- const std::string& desc_face,
- const Preferences& prefs,
- Font** result) = 0;
};
} // namespace ppapi
diff --git a/ppapi/thunk/ppb_font_api.h b/ppapi/thunk/ppb_font_api.h
index e3bac24..e85bb1b 100644
--- a/ppapi/thunk/ppb_font_api.h
+++ b/ppapi/thunk/ppb_font_api.h
@@ -7,6 +7,7 @@
#include "ppapi/c/dev/ppb_font_dev.h"
#include "ppapi/shared_impl/api_id.h"
+#include "ppapi/thunk/ppapi_thunk_export.h"
namespace ppapi {
namespace thunk {
@@ -22,7 +23,7 @@ class PPB_Font_FunctionAPI {
};
// API for font resources.
-class PPB_Font_API {
+class PPAPI_THUNK_EXPORT PPB_Font_API {
public:
virtual ~PPB_Font_API() {}
diff --git a/ppapi/thunk/ppb_image_data_api.h b/ppapi/thunk/ppb_image_data_api.h
index c22e899..b7a3e69 100644
--- a/ppapi/thunk/ppb_image_data_api.h
+++ b/ppapi/thunk/ppb_image_data_api.h
@@ -8,6 +8,10 @@
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/ppb_image_data.h"
+namespace skia {
+class PlatformCanvas;
+}
+
namespace ppapi {
namespace thunk {
@@ -21,6 +25,9 @@ class PPB_ImageData_API {
// Trusted inteface.
virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) = 0;
+
+ // The canvas will be NULL if the image is not mapped.
+ virtual skia::PlatformCanvas* GetPlatformCanvas() = 0;
};
} // namespace thunk
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index b0fa6ab..5894b9d 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -336,8 +336,6 @@
'../plugins/ppapi/resource_helper.h',
'../plugins/ppapi/string.cc',
'../plugins/ppapi/string.h',
- '../plugins/ppapi/webkit_forwarding_impl.cc',
- '../plugins/ppapi/webkit_forwarding_impl.h',
'../plugins/sad_plugin.cc',
'../plugins/sad_plugin.h',
'../plugins/webkit_plugins_export.h',
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index c6af869..5ca81c8 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -116,7 +116,6 @@
#include "webkit/plugins/ppapi/ppb_video_capture_impl.h"
#include "webkit/plugins/ppapi/ppb_video_decoder_impl.h"
#include "webkit/plugins/ppapi/ppb_video_layer_impl.h"
-#include "webkit/plugins/ppapi/webkit_forwarding_impl.h"
using ppapi::InputEventData;
using ppapi::PpapiGlobals;
@@ -591,12 +590,6 @@ PluginDelegate::PpapiBroker* PluginModule::GetBroker() {
return broker_;
}
-::ppapi::WebKitForwarding* PluginModule::GetWebKitForwarding() {
- if (!webkit_forwarding_.get())
- webkit_forwarding_.reset(new WebKitForwardingImpl);
- return webkit_forwarding_.get();
-}
-
bool PluginModule::InitializeModule(const EntryPoints& entry_points) {
DCHECK(!out_of_process_proxy_.get()) << "Don't call for proxied modules.";
DCHECK(entry_points.initialize_module != NULL);
diff --git a/webkit/plugins/ppapi/plugin_module.h b/webkit/plugins/ppapi/plugin_module.h
index 7634268..928f8ac 100644
--- a/webkit/plugins/ppapi/plugin_module.h
+++ b/webkit/plugins/ppapi/plugin_module.h
@@ -141,9 +141,6 @@ class WEBKIT_PLUGINS_EXPORT PluginModule :
void SetBroker(PluginDelegate::PpapiBroker* broker);
PluginDelegate::PpapiBroker* GetBroker();
- // Retrieves the forwarding interface used for talking to WebKit.
- ::ppapi::WebKitForwarding* GetWebKitForwarding();
-
private:
// Calls the InitializeModule entrypoint. The entrypoint must have been
// set and the plugin must not be out of process (we don't maintain
@@ -196,9 +193,6 @@ class WEBKIT_PLUGINS_EXPORT PluginModule :
PP_Bool (*reserve_instance_id_)(PP_Module, PP_Instance);
- // Lazily created by GetWebKitForwarding.
- scoped_ptr< ::ppapi::WebKitForwarding> webkit_forwarding_;
-
DISALLOW_COPY_AND_ASSIGN(PluginModule);
};
diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc
index c65fbcc..c1133ba 100644
--- a/webkit/plugins/ppapi/ppb_flash_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_impl.cc
@@ -89,7 +89,7 @@ PP_Bool DrawGlyphs(PP_Instance,
SkAutoUnref aur(typeface);
// Set up the canvas.
- SkCanvas* canvas = image_resource->mapped_canvas();
+ SkCanvas* canvas = image_resource->GetPlatformCanvas();
SkAutoCanvasRestore acr(canvas, true);
// Clip is applied in pixels before the transform.
diff --git a/webkit/plugins/ppapi/ppb_font_impl.cc b/webkit/plugins/ppapi/ppb_font_impl.cc
index 0c439d0..c18106a 100644
--- a/webkit/plugins/ppapi/ppb_font_impl.cc
+++ b/webkit/plugins/ppapi/ppb_font_impl.cc
@@ -4,147 +4,11 @@
#include "webkit/plugins/ppapi/ppb_font_impl.h"
-#include "ppapi/c/dev/ppb_font_dev.h"
-#include "ppapi/shared_impl/ppapi_preferences.h"
-#include "ppapi/shared_impl/ppb_font_shared.h"
-#include "ppapi/shared_impl/var.h"
-#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/thunk.h"
-#include "webkit/plugins/ppapi/common.h"
-#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
-#include "webkit/plugins/ppapi/resource_helper.h"
-#include "webkit/plugins/ppapi/string.h"
-
-using ppapi::StringVar;
-using ppapi::thunk::EnterResource;
-using ppapi::thunk::PPB_ImageData_API;
-using ppapi::WebKitForwarding;
namespace webkit {
-namespace ppapi {
-
-namespace {
-
-// Converts the given PP_TextRun to a TextRun, returning true on success.
-// False means the input was invalid.
-bool PPTextRunToTextRun(const PP_TextRun_Dev* run,
- WebKitForwarding::Font::TextRun* output) {
- StringVar* text_string = StringVar::FromPPVar(run->text);
- if (!text_string)
- return false;
-
- output->text = text_string->value();
- output->rtl = PPBoolToBool(run->rtl);
- output->override_direction = PPBoolToBool(run->override_direction);
- return true;
-}
-
-} // namespace
-
-PPB_Font_Impl::PPB_Font_Impl(PP_Instance pp_instance,
- const PP_FontDescription_Dev& desc)
- : Resource(pp_instance) {
- StringVar* face_name = StringVar::FromPPVar(desc.face);
-
- WebKitForwarding::Font* result = NULL;
- PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
- if (plugin_instance) {
- plugin_instance->module()->GetWebKitForwarding()->CreateFontForwarding(
- NULL, desc, face_name ? face_name->value() : std::string(),
- plugin_instance->delegate()->GetPreferences(), &result);
- }
- font_forwarding_.reset(result);
-}
-
-PPB_Font_Impl::~PPB_Font_Impl() {
-}
-
-// static
-PP_Resource PPB_Font_Impl::Create(PP_Instance instance,
- const PP_FontDescription_Dev& description) {
- if (!::ppapi::PPB_Font_Shared::IsPPFontDescriptionValid(description))
- return 0;
- return (new PPB_Font_Impl(instance, description))->GetReference();
-}
-
-::ppapi::thunk::PPB_Font_API* PPB_Font_Impl::AsPPB_Font_API() {
- return this;
-}
-PP_Bool PPB_Font_Impl::Describe(PP_FontDescription_Dev* description,
- PP_FontMetrics_Dev* metrics) {
- std::string face;
- PP_Bool result = PP_FALSE;
- font_forwarding_->Describe(NULL, description, &face, metrics, &result);
- if (!result)
- return PP_FALSE;
-
- PluginModule* plugin_module = ResourceHelper::GetPluginModule(this);
- if (!plugin_module)
- return PP_FALSE;
-
- // Convert the string.
- description->face = StringVar::StringToPPVar(face);
- return PP_TRUE;
-}
-
-PP_Bool PPB_Font_Impl::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) {
- // Get and map the image data we're painting to.
- EnterResource<PPB_ImageData_API> enter(image_data, true);
- if (enter.failed())
- return PP_FALSE;
- PPB_ImageData_Impl* image_resource =
- static_cast<PPB_ImageData_Impl*>(enter.object());
-
- ImageDataAutoMapper mapper(image_resource);
- if (!mapper.is_valid())
- return PP_FALSE;
-
- WebKitForwarding::Font::TextRun run;
- if (!PPTextRunToTextRun(text, &run))
- return PP_FALSE;
-
- font_forwarding_->DrawTextAt(NULL, WebKitForwarding::Font::DrawTextParams(
- image_resource->mapped_canvas(), run, position,
- color, clip, image_data_is_opaque));
- return PP_TRUE;
-}
-
-int32_t PPB_Font_Impl::MeasureText(const PP_TextRun_Dev* text) {
- int32_t result = -1;
- WebKitForwarding::Font::TextRun run;
- if (PPTextRunToTextRun(text, &run))
- font_forwarding_->MeasureText(NULL, run, &result);
- return result;
-}
-
-uint32_t PPB_Font_Impl::CharacterOffsetForPixel(const PP_TextRun_Dev* text,
- int32_t pixel_position) {
- uint32_t result = -1;
- WebKitForwarding::Font::TextRun run;
- if (PPTextRunToTextRun(text, &run)) {
- font_forwarding_->CharacterOffsetForPixel(NULL, run, pixel_position,
- &result);
- }
- return result;
-}
-
-int32_t PPB_Font_Impl::PixelOffsetForCharacter(const PP_TextRun_Dev* text,
- uint32_t char_offset) {
- int32_t result = -1;
- WebKitForwarding::Font::TextRun run;
- if (PPTextRunToTextRun(text, &run)) {
- font_forwarding_->PixelOffsetForCharacter(NULL, run, char_offset, &result);
- }
- return result;
-}
+namespace ppapi {
PPB_Font_FunctionImpl::PPB_Font_FunctionImpl(PluginInstance* instance)
: instance_(instance) {
@@ -158,10 +22,12 @@ PPB_Font_FunctionImpl::AsFont_FunctionAPI() {
return this;
}
+// TODO(ananta)
+// We need to wire this up to the proxy.
PP_Var PPB_Font_FunctionImpl::GetFontFamilies(PP_Instance instance) {
return PP_MakeUndefined();
}
} // namespace ppapi
-} // namespace webkit
+} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppb_font_impl.h b/webkit/plugins/ppapi/ppb_font_impl.h
index 4b9c7e0..c21b18e 100644
--- a/webkit/plugins/ppapi/ppb_font_impl.h
+++ b/webkit/plugins/ppapi/ppb_font_impl.h
@@ -6,11 +6,9 @@
#define WEBKIT_PLUGINS_PPAPI_PPB_FONT_IMPL_H_
#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "ppapi/c/dev/ppb_font_dev.h"
+#include "base/compiler_specific.h"
+#include "ppapi/c/pp_instance.h"
#include "ppapi/shared_impl/function_group_base.h"
-#include "ppapi/shared_impl/resource.h"
-#include "ppapi/shared_impl/webkit_forwarding.h"
#include "ppapi/thunk/ppb_font_api.h"
namespace webkit {
@@ -18,40 +16,6 @@ namespace ppapi {
class PluginInstance;
-class PPB_Font_Impl : public ::ppapi::Resource,
- public ::ppapi::thunk::PPB_Font_API {
- public:
- virtual ~PPB_Font_Impl();
-
- static PP_Resource Create(PP_Instance instance,
- const PP_FontDescription_Dev& description);
-
- // Resource.
- virtual ::ppapi::thunk::PPB_Font_API* AsPPB_Font_API() OVERRIDE;
-
- // PPB_Font 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:
- PPB_Font_Impl(PP_Instance instance, const PP_FontDescription_Dev& desc);
-
- scoped_ptr< ::ppapi::WebKitForwarding::Font> font_forwarding_;
-
- DISALLOW_COPY_AND_ASSIGN(PPB_Font_Impl);
-};
-
class PPB_Font_FunctionImpl : public ::ppapi::FunctionGroupBase,
public ::ppapi::thunk::PPB_Font_FunctionAPI {
public:
@@ -71,6 +35,7 @@ class PPB_Font_FunctionImpl : public ::ppapi::FunctionGroupBase,
};
} // namespace ppapi
-} // namespace webkit
+
+} // namespace webkit.
#endif // WEBKIT_PLUGINS_PPAPI_PPB_FONT_IMPL_H_
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index 027e8eb..ddfea5f 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -398,7 +398,7 @@ bool PPB_Graphics2D_Impl::ReadImageData(PP_Resource image,
// Convert the image data if the format does not match.
ConvertImageData(image_data_, src_irect, image_resource, dest_rect);
} else {
- skia::PlatformCanvas* dest_canvas = image_resource->mapped_canvas();
+ skia::PlatformCanvas* dest_canvas = image_resource->GetPlatformCanvas();
// We want to replace the contents of the bitmap rather than blend.
SkPaint paint;
@@ -583,7 +583,7 @@ void PPB_Graphics2D_Impl::ExecutePaintImageData(PPB_ImageData_Impl* image,
ConvertImageData(image, src_irect, image_data_, dest_rect);
} else {
// We're guaranteed to have a mapped canvas since we mapped it in Init().
- skia::PlatformCanvas* backing_canvas = image_data_->mapped_canvas();
+ skia::PlatformCanvas* backing_canvas = image_data_->GetPlatformCanvas();
// We want to replace the contents of the bitmap rather than blend.
SkPaint paint;
@@ -596,7 +596,7 @@ void PPB_Graphics2D_Impl::ExecutePaintImageData(PPB_ImageData_Impl* image,
void PPB_Graphics2D_Impl::ExecuteScroll(const gfx::Rect& clip,
int dx, int dy,
gfx::Rect* invalidated_rect) {
- gfx::ScrollCanvas(image_data_->mapped_canvas(),
+ gfx::ScrollCanvas(image_data_->GetPlatformCanvas(),
clip, gfx::Point(dx, dy));
*invalidated_rect = clip;
}
diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.cc b/webkit/plugins/ppapi/ppb_image_data_impl.cc
index 6563713..fa30601 100644
--- a/webkit/plugins/ppapi/ppb_image_data_impl.cc
+++ b/webkit/plugins/ppapi/ppb_image_data_impl.cc
@@ -111,6 +111,10 @@ int32_t PPB_ImageData_Impl::GetSharedMemory(int* handle,
return PP_OK;
}
+skia::PlatformCanvas* PPB_ImageData_Impl::GetPlatformCanvas() {
+ return mapped_canvas_.get();
+}
+
const SkBitmap* PPB_ImageData_Impl::GetMappedBitmap() const {
if (!mapped_canvas_.get())
return NULL;
diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.h b/webkit/plugins/ppapi/ppb_image_data_impl.h
index 64685d0..817b238 100644
--- a/webkit/plugins/ppapi/ppb_image_data_impl.h
+++ b/webkit/plugins/ppapi/ppb_image_data_impl.h
@@ -63,9 +63,8 @@ class PPB_ImageData_Impl : public ::ppapi::Resource,
virtual void* Map() OVERRIDE;
virtual void Unmap() OVERRIDE;
virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE;
+ virtual skia::PlatformCanvas* GetPlatformCanvas() OVERRIDE;
- // The mapped bitmap and canvas will be NULL if the image is not mapped.
- skia::PlatformCanvas* mapped_canvas() const { return mapped_canvas_.get(); }
const SkBitmap* GetMappedBitmap() const;
// Swaps the guts of this image data with another.
diff --git a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
index 97b80ff..3e3f2e9 100644
--- a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
+++ b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
@@ -134,7 +134,7 @@ void PPB_Scrollbar_Impl::ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier) {
PP_Bool PPB_Scrollbar_Impl::PaintInternal(const gfx::Rect& rect,
PPB_ImageData_Impl* image) {
ImageDataAutoMapper mapper(image);
- skia::PlatformCanvas* canvas = image->mapped_canvas();
+ skia::PlatformCanvas* canvas = image->GetPlatformCanvas();
if (!canvas || !scrollbar_.get())
return PP_FALSE;
scrollbar_->paint(webkit_glue::ToWebCanvas(canvas), rect);
diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc
index 1f3943b..b1480a0 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.cc
+++ b/webkit/plugins/ppapi/resource_creation_impl.cc
@@ -6,6 +6,7 @@
#include "ppapi/c/pp_size.h"
#include "ppapi/shared_impl/ppb_audio_config_shared.h"
+#include "ppapi/shared_impl/private/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/var.h"
@@ -21,7 +22,6 @@
#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
#include "webkit/plugins/ppapi/ppb_flash_menu_impl.h"
#include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h"
-#include "webkit/plugins/ppapi/ppb_font_impl.h"
#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
#include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
@@ -35,6 +35,7 @@
#include "webkit/plugins/ppapi/ppb_video_decoder_impl.h"
#include "webkit/plugins/ppapi/ppb_video_layer_impl.h"
#include "webkit/plugins/ppapi/ppb_websocket_impl.h"
+#include "webkit/plugins/ppapi/resource_helper.h"
using ppapi::InputEventData;
using ppapi::PPB_InputEvent_Shared;
@@ -142,7 +143,12 @@ PP_Resource ResourceCreationImpl::CreateFlashNetConnector(
PP_Resource ResourceCreationImpl::CreateFontObject(
PP_Instance instance,
const PP_FontDescription_Dev* description) {
- return PPB_Font_Impl::Create(instance, *description);
+ PluginInstance* plugin_instance =
+ ResourceHelper::PPInstanceToPluginInstance(instance);
+ if (!plugin_instance)
+ return 0;
+ return ::ppapi::PPB_Font_Shared::CreateAsImpl(
+ instance, *description, plugin_instance->delegate()->GetPreferences());
}
PP_Resource ResourceCreationImpl::CreateGraphics2D(
diff --git a/webkit/plugins/ppapi/resource_helper.cc b/webkit/plugins/ppapi/resource_helper.cc
index 1959961..0807e2e 100644
--- a/webkit/plugins/ppapi/resource_helper.cc
+++ b/webkit/plugins/ppapi/resource_helper.cc
@@ -17,7 +17,12 @@ namespace ppapi {
// static
PluginInstance* ResourceHelper::GetPluginInstance(
const ::ppapi::Resource* resource) {
- return HostGlobals::Get()->GetInstance(resource->pp_instance());
+ return PPInstanceToPluginInstance(resource->pp_instance());
+}
+
+PluginInstance* ResourceHelper::PPInstanceToPluginInstance(
+ PP_Instance instance) {
+ return HostGlobals::Get()->GetInstance(instance);
}
PluginModule* ResourceHelper::GetPluginModule(
diff --git a/webkit/plugins/ppapi/resource_helper.h b/webkit/plugins/ppapi/resource_helper.h
index 1f245a1..cca66f0 100644
--- a/webkit/plugins/ppapi/resource_helper.h
+++ b/webkit/plugins/ppapi/resource_helper.h
@@ -6,6 +6,7 @@
#define WEBKIT_PLUGINS_PPAPI_RESOURCE_HELPER_H_
#include "base/basictypes.h"
+#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "webkit/plugins/webkit_plugins_export.h"
@@ -40,6 +41,9 @@ class ResourceHelper {
// resource has outlived its instance.
static PluginDelegate* GetPluginDelegate(const ::ppapi::Resource* resource);
+ // Returns the instance implementation object for the pp_instance.
+ static PluginInstance* PPInstanceToPluginInstance(PP_Instance instance);
+
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ResourceHelper);
};
diff --git a/webkit/plugins/ppapi/webkit_forwarding_impl.h b/webkit/plugins/ppapi/webkit_forwarding_impl.h
deleted file mode 100644
index ee39754..0000000
--- a/webkit/plugins/ppapi/webkit_forwarding_impl.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2011 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 "ppapi/shared_impl/webkit_forwarding.h"
-
-#include "base/compiler_specific.h"
-#include "webkit/plugins/webkit_plugins_export.h"
-
-namespace ppapi {
-struct Preferences;
-}
-
-namespace webkit {
-namespace ppapi {
-
-class WebKitForwardingImpl : public ::ppapi::WebKitForwarding {
- public:
- WEBKIT_PLUGINS_EXPORT WebKitForwardingImpl();
- WEBKIT_PLUGINS_EXPORT virtual ~WebKitForwardingImpl();
-
- virtual void CreateFontForwarding(base::WaitableEvent* event,
- const PP_FontDescription_Dev& desc,
- const std::string& desc_face,
- const ::ppapi::Preferences& prefs,
- Font** result) OVERRIDE;
-};
-
-} // namespace ppapi
-} // namespace webkit