Index: webkit/plugins/ppapi/ppb_font_impl.cc |
=================================================================== |
--- webkit/plugins/ppapi/ppb_font_impl.cc (revision 0) |
+++ webkit/plugins/ppapi/ppb_font_impl.cc (working copy) |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "webkit/glue/plugins/pepper_font.h" |
+#include "webkit/plugins/ppapi/ppb_font_impl.h" |
#include "base/logging.h" |
#include "base/utf_string_conversions.h" |
@@ -14,11 +14,11 @@ |
#include "third_party/WebKit/WebKit/chromium/public/WebFloatPoint.h" |
#include "third_party/WebKit/WebKit/chromium/public/WebFloatRect.h" |
#include "third_party/WebKit/WebKit/chromium/public/WebTextRun.h" |
-#include "webkit/glue/plugins/pepper_common.h" |
-#include "webkit/glue/plugins/pepper_image_data.h" |
-#include "webkit/glue/plugins/pepper_plugin_module.h" |
-#include "webkit/glue/plugins/pepper_string.h" |
-#include "webkit/glue/plugins/pepper_var.h" |
+#include "webkit/plugins/ppapi/common.h" |
+#include "webkit/plugins/ppapi/plugin_module.h" |
+#include "webkit/plugins/ppapi/ppb_image_data_impl.h" |
+#include "webkit/plugins/ppapi/string.h" |
+#include "webkit/plugins/ppapi/var.h" |
#include "webkit/glue/webkit_glue.h" |
using WebKit::WebFloatPoint; |
@@ -28,7 +28,8 @@ |
using WebKit::WebRect; |
using WebKit::WebTextRun; |
-namespace pepper { |
+namespace webkit { |
+namespace ppapi { |
namespace { |
@@ -117,18 +118,18 @@ |
if (!IsPPFontDescriptionValid(*description)) |
return 0; |
- scoped_refptr<Font> font(new Font(module, *description)); |
+ scoped_refptr<PPB_Font_Impl> font(new PPB_Font_Impl(module, *description)); |
return font->GetReference(); |
} |
PP_Bool IsFont(PP_Resource resource) { |
- return BoolToPPBool(!!Resource::GetAs<Font>(resource).get()); |
+ return BoolToPPBool(!!Resource::GetAs<PPB_Font_Impl>(resource).get()); |
} |
PP_Bool Describe(PP_Resource font_id, |
- PP_FontDescription_Dev* description, |
- PP_FontMetrics_Dev* metrics) { |
- scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); |
+ PP_FontDescription_Dev* description, |
+ PP_FontMetrics_Dev* metrics) { |
+ scoped_refptr<PPB_Font_Impl> font(Resource::GetAs<PPB_Font_Impl>(font_id)); |
if (!font.get()) |
return PP_FALSE; |
return BoolToPPBool(font->Describe(description, metrics)); |
@@ -141,7 +142,7 @@ |
uint32_t color, |
const PP_Rect* clip, |
PP_Bool image_data_is_opaque) { |
- scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); |
+ scoped_refptr<PPB_Font_Impl> font(Resource::GetAs<PPB_Font_Impl>(font_id)); |
if (!font.get()) |
return PP_FALSE; |
return BoolToPPBool(font->DrawTextAt(image_data, text, position, color, clip, |
@@ -149,7 +150,7 @@ |
} |
int32_t MeasureText(PP_Resource font_id, const PP_TextRun_Dev* text) { |
- scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); |
+ scoped_refptr<PPB_Font_Impl> font(Resource::GetAs<PPB_Font_Impl>(font_id)); |
if (!font.get()) |
return -1; |
return font->MeasureText(text); |
@@ -158,7 +159,7 @@ |
uint32_t CharacterOffsetForPixel(PP_Resource font_id, |
const PP_TextRun_Dev* text, |
int32_t pixel_position) { |
- scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); |
+ scoped_refptr<PPB_Font_Impl> font(Resource::GetAs<PPB_Font_Impl>(font_id)); |
if (!font.get()) |
return false; |
return font->CharacterOffsetForPixel(text, pixel_position); |
@@ -167,7 +168,7 @@ |
int32_t PixelOffsetForCharacter(PP_Resource font_id, |
const PP_TextRun_Dev* text, |
uint32_t char_offset) { |
- scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); |
+ scoped_refptr<PPB_Font_Impl> font(Resource::GetAs<PPB_Font_Impl>(font_id)); |
if (!font.get()) |
return false; |
return font->PixelOffsetForCharacter(text, char_offset); |
@@ -185,26 +186,27 @@ |
} // namespace |
-Font::Font(PluginModule* module, const PP_FontDescription_Dev& desc) |
+PPB_Font_Impl::PPB_Font_Impl(PluginModule* module, |
+ const PP_FontDescription_Dev& desc) |
: Resource(module) { |
WebFontDescription web_font_desc = PPFontDescToWebFontDesc(desc); |
font_.reset(WebFont::create(web_font_desc)); |
} |
-Font::~Font() { |
+PPB_Font_Impl::~PPB_Font_Impl() { |
} |
// static |
-const PPB_Font_Dev* Font::GetInterface() { |
+const PPB_Font_Dev* PPB_Font_Impl::GetInterface() { |
return &ppb_font; |
} |
-Font* Font::AsFont() { |
+PPB_Font_Impl* PPB_Font_Impl::AsPPB_Font_Impl() { |
return this; |
} |
-bool Font::Describe(PP_FontDescription_Dev* description, |
- PP_FontMetrics_Dev* metrics) { |
+bool PPB_Font_Impl::Describe(PP_FontDescription_Dev* description, |
+ PP_FontMetrics_Dev* metrics) { |
if (description->face.type != PP_VARTYPE_UNDEFINED) |
return false; |
@@ -229,19 +231,19 @@ |
return true; |
} |
-bool Font::DrawTextAt(PP_Resource image_data, |
- const PP_TextRun_Dev* text, |
- const PP_Point* position, |
- uint32_t color, |
- const PP_Rect* clip, |
- bool image_data_is_opaque) { |
+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, |
+ bool image_data_is_opaque) { |
WebTextRun run; |
if (!PPTextRunToWebTextRun(text, &run)) |
return false; |
// Get and map the image data we're painting to. |
- scoped_refptr<ImageData> image_resource( |
- Resource::GetAs<ImageData>(image_data)); |
+ scoped_refptr<PPB_ImageData_Impl> image_resource( |
+ Resource::GetAs<PPB_ImageData_Impl>(image_data)); |
if (!image_resource.get()) |
return false; |
ImageDataAutoMapper mapper(image_resource); |
@@ -265,15 +267,15 @@ |
return true; |
} |
-int32_t Font::MeasureText(const PP_TextRun_Dev* text) { |
+int32_t PPB_Font_Impl::MeasureText(const PP_TextRun_Dev* text) { |
WebTextRun run; |
if (!PPTextRunToWebTextRun(text, &run)) |
return -1; |
return font_->calculateWidth(run); |
} |
-uint32_t Font::CharacterOffsetForPixel(const PP_TextRun_Dev* text, |
- int32_t pixel_position) { |
+uint32_t PPB_Font_Impl::CharacterOffsetForPixel(const PP_TextRun_Dev* text, |
+ int32_t pixel_position) { |
WebTextRun run; |
if (!PPTextRunToWebTextRun(text, &run)) |
return -1; |
@@ -282,8 +284,8 @@ |
run, static_cast<float>(pixel_position))); |
} |
-int32_t Font::PixelOffsetForCharacter(const PP_TextRun_Dev* text, |
- uint32_t char_offset) { |
+int32_t PPB_Font_Impl::PixelOffsetForCharacter(const PP_TextRun_Dev* text, |
+ uint32_t char_offset) { |
WebTextRun run; |
if (!PPTextRunToWebTextRun(text, &run)) |
return -1; |
@@ -295,4 +297,6 @@ |
return static_cast<int>(rect.width); |
} |
-} // namespace pepper |
+} // namespace ppapi |
+} // namespace webkit |
+ |