summaryrefslogtreecommitdiffstats
path: root/ppapi/thunk
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-10 21:17:48 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-10 21:17:48 +0000
commit7a1f7c6f6c982287b3f6bb2acded619f3824416c (patch)
tree82ff404c4bcf84520c21ea7f0526ad5a40661641 /ppapi/thunk
parentbafaee12825a06890f114a282880e135a8b0b1ae (diff)
downloadchromium_src-7a1f7c6f6c982287b3f6bb2acded619f3824416c.zip
chromium_src-7a1f7c6f6c982287b3f6bb2acded619f3824416c.tar.gz
chromium_src-7a1f7c6f6c982287b3f6bb2acded619f3824416c.tar.bz2
Make the Pepper proxy support in-process font rendering.
This implements a WebKit thread in the PPAPI plugin process so we can do the font calls without IPC. The existing font support was refactored into a virtual class (to prevent PPAPI from depending on WebKit and creating a circular GYP dependency). This moves the renderer sandbox support into content/common so that it can be used by the PPAPI process. Review URL: http://codereview.chromium.org/6981001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84856 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk')
-rw-r--r--ppapi/thunk/ppb_font_api.h33
-rw-r--r--ppapi/thunk/ppb_font_thunk.cc93
-rw-r--r--ppapi/thunk/ppb_image_data_api.h6
-rw-r--r--ppapi/thunk/resource_creation_api.h5
-rw-r--r--ppapi/thunk/thunk.h2
5 files changed, 136 insertions, 3 deletions
diff --git a/ppapi/thunk/ppb_font_api.h b/ppapi/thunk/ppb_font_api.h
new file mode 100644
index 0000000..b711545
--- /dev/null
+++ b/ppapi/thunk/ppb_font_api.h
@@ -0,0 +1,33 @@
+// 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_THUNK_PPB_FONT_API_H_
+#define PPAPI_THUNK_PPB_FONT_API_H_
+
+#include "ppapi/c/dev/ppb_font_dev.h"
+
+namespace ppapi {
+namespace thunk {
+
+class PPB_Font_API {
+ public:
+ virtual PP_Bool Describe(PP_FontDescription_Dev* description,
+ PP_FontMetrics_Dev* metrics) = 0;
+ 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) = 0;
+ virtual int32_t MeasureText(const PP_TextRun_Dev* text) = 0;
+ virtual uint32_t CharacterOffsetForPixel(const PP_TextRun_Dev* text,
+ int32_t pixel_position) = 0;
+ virtual int32_t PixelOffsetForCharacter(const PP_TextRun_Dev* text,
+ uint32_t char_offset) = 0;
+};
+
+} // namespace thunk
+} // namespace ppapi
+
+#endif // PPAPI_THUNK_PPB_FONT_API_H_
diff --git a/ppapi/thunk/ppb_font_thunk.cc b/ppapi/thunk/ppb_font_thunk.cc
new file mode 100644
index 0000000..eac573e
--- /dev/null
+++ b/ppapi/thunk/ppb_font_thunk.cc
@@ -0,0 +1,93 @@
+// 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/thunk/thunk.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_font_api.h"
+#include "ppapi/thunk/resource_creation_api.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+PP_Resource Create(PP_Instance instance,
+ const PP_FontDescription_Dev* description) {
+ EnterFunction<ResourceCreationAPI> enter(instance, true);
+ if (enter.failed())
+ return 0;
+ return enter.functions()->CreateFontObject(instance, description);
+}
+
+PP_Bool IsFont(PP_Resource resource) {
+ EnterResource<PPB_Font_API> enter(resource, false);
+ return enter.succeeded() ? PP_TRUE : PP_FALSE;
+}
+
+PP_Bool Describe(PP_Resource font_id,
+ PP_FontDescription_Dev* description,
+ PP_FontMetrics_Dev* metrics) {
+ EnterResource<PPB_Font_API> enter(font_id, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return enter.object()->Describe(description, metrics);
+}
+
+PP_Bool DrawTextAt(PP_Resource font_id,
+ 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) {
+ EnterResource<PPB_Font_API> enter(font_id, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return enter.object()->DrawTextAt(image_data, text, position, color, clip,
+ image_data_is_opaque);
+}
+
+int32_t MeasureText(PP_Resource font_id, const PP_TextRun_Dev* text) {
+ EnterResource<PPB_Font_API> enter(font_id, true);
+ if (enter.failed())
+ return -1;
+ return enter.object()->MeasureText(text);
+}
+
+uint32_t CharacterOffsetForPixel(PP_Resource font_id,
+ const PP_TextRun_Dev* text,
+ int32_t pixel_position) {
+ EnterResource<PPB_Font_API> enter(font_id, true);
+ if (enter.failed())
+ return -1;
+ return enter.object()->CharacterOffsetForPixel(text, pixel_position);
+}
+
+int32_t PixelOffsetForCharacter(PP_Resource font_id,
+ const PP_TextRun_Dev* text,
+ uint32_t char_offset) {
+ EnterResource<PPB_Font_API> enter(font_id, true);
+ if (enter.failed())
+ return -1;
+ return enter.object()->PixelOffsetForCharacter(text, char_offset);
+}
+
+const PPB_Font_Dev g_ppb_font_thunk = {
+ &Create,
+ &IsFont,
+ &Describe,
+ &DrawTextAt,
+ &MeasureText,
+ &CharacterOffsetForPixel,
+ &PixelOffsetForCharacter
+};
+
+} // namespace
+
+const PPB_Font_Dev* GetPPB_Font_Thunk() {
+ return &g_ppb_font_thunk;
+}
+
+} // namespace thunk
+} // namespace ppapi
diff --git a/ppapi/thunk/ppb_image_data_api.h b/ppapi/thunk/ppb_image_data_api.h
index 6cfbc43..cce38b29 100644
--- a/ppapi/thunk/ppb_image_data_api.h
+++ b/ppapi/thunk/ppb_image_data_api.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef PPAPI_THUNK_IMAGE_DATA_API_H_
-#define PPAPI_THUNK_IMAGE_DATA_API_H_
+#ifndef PPAPI_THUNK_PPB_IMAGE_DATA_API_H_
+#define PPAPI_THUNK_PPB_IMAGE_DATA_API_H_
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/ppb_image_data.h"
@@ -21,4 +21,4 @@ class PPB_ImageData_API {
} // namespace thunk
} // namespace ppapi
-#endif // PPAPI_THUNK_IMAGE_DATA_API_H_
+#endif // PPAPI_THUNK_PPB_IMAGE_DATA_API_H_
diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h
index bb81776..c6561b9 100644
--- a/ppapi/thunk/resource_creation_api.h
+++ b/ppapi/thunk/resource_creation_api.h
@@ -11,6 +11,7 @@
#include "ppapi/c/ppb_image_data.h"
#include "ppapi/proxy/interface_id.h"
+struct PP_FontDescription_Dev;
struct PP_Size;
namespace ppapi {
@@ -26,6 +27,10 @@ class ResourceCreationAPI {
static const ::pp::proxy::InterfaceID interface_id =
::pp::proxy::INTERFACE_ID_RESOURCE_CREATION;
+ // Note: can't be called CreateFont due to Windows #defines.
+ virtual PP_Resource CreateFontObject(
+ PP_Instance instance,
+ const PP_FontDescription_Dev* description) = 0;
virtual PP_Resource CreateGraphics2D(PP_Instance instance,
const PP_Size& size,
PP_Bool is_always_opaque) = 0;
diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h
index 39ae8f9..49bb515 100644
--- a/ppapi/thunk/thunk.h
+++ b/ppapi/thunk/thunk.h
@@ -7,12 +7,14 @@
#include "base/synchronization/lock.h"
+struct PPB_Font_Dev;
struct PPB_Graphics2D;
struct PPB_ImageData;
namespace ppapi {
namespace thunk {
+const PPB_Font_Dev* GetPPB_Font_Thunk();
const PPB_Graphics2D* GetPPB_Graphics2D_Thunk();
const PPB_ImageData* GetPPB_ImageData_Thunk();