Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: webkit/plugins/ppapi/ppb_font_impl.cc

Issue 9192038: Relanding this with fixes to the mac dbg builder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/plugins/ppapi/ppb_font_impl.h ('k') | webkit/plugins/ppapi/ppb_graphics_2d_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_font_impl.cc
===================================================================
--- webkit/plugins/ppapi/ppb_font_impl.cc (revision 118405)
+++ webkit/plugins/ppapi/ppb_font_impl.cc (working copy)
@@ -4,148 +4,12 @@
#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;
-}
-
PPB_Font_FunctionImpl::PPB_Font_FunctionImpl(PluginInstance* instance)
: instance_(instance) {
}
@@ -158,10 +22,12 @@
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
« no previous file with comments | « webkit/plugins/ppapi/ppb_font_impl.h ('k') | webkit/plugins/ppapi/ppb_graphics_2d_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698