OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/glue/plugins/pepper_font.h" | 5 #include "webkit/glue/plugins/pepper_font.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "ppapi/c/dev/ppb_font_dev.h" | 9 #include "ppapi/c/dev/ppb_font_dev.h" |
10 #include "ppapi/c/pp_rect.h" | 10 #include "ppapi/c/pp_rect.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 PP_Bool Describe(PP_Resource font_id, | 128 PP_Bool Describe(PP_Resource font_id, |
129 PP_FontDescription_Dev* description, | 129 PP_FontDescription_Dev* description, |
130 PP_FontMetrics_Dev* metrics) { | 130 PP_FontMetrics_Dev* metrics) { |
131 scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); | 131 scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); |
132 if (!font.get()) | 132 if (!font.get()) |
133 return PP_FALSE; | 133 return PP_FALSE; |
134 return BoolToPPBool(font->Describe(description, metrics)); | 134 return BoolToPPBool(font->Describe(description, metrics)); |
135 } | 135 } |
136 | 136 |
137 PP_Bool DrawTextAt(PP_Resource font_id, | 137 PP_Bool DrawTextAt(PP_Resource font_id, |
138 PP_Resource image_data, | 138 PP_Resource image_data, |
139 const PP_TextRun_Dev* text, | 139 const PP_TextRun_Dev* text, |
140 const PP_Point* position, | 140 const PP_Point* position, |
141 uint32_t color, | 141 uint32_t color, |
142 const PP_Rect* clip, | 142 const PP_Rect* clip, |
143 PP_Bool image_data_is_opaque) { | 143 PP_Bool image_data_is_opaque) { |
144 scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); | 144 scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); |
145 if (!font.get()) | 145 if (!font.get()) |
146 return PP_FALSE; | 146 return PP_FALSE; |
147 return BoolToPPBool(font->DrawTextAt(image_data, text, position, color, clip, | 147 return BoolToPPBool(font->DrawTextAt(image_data, text, position, color, clip, |
148 PPBoolToBool(image_data_is_opaque))); | 148 PPBoolToBool(image_data_is_opaque))); |
149 } | 149 } |
150 | 150 |
151 int32_t MeasureText(PP_Resource font_id, const PP_TextRun_Dev* text) { | 151 int32_t MeasureText(PP_Resource font_id, const PP_TextRun_Dev* text) { |
152 scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); | 152 scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); |
153 if (!font.get()) | 153 if (!font.get()) |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 return -1; | 285 return -1; |
286 if (char_offset >= run.text.length()) | 286 if (char_offset >= run.text.length()) |
287 return -1; | 287 return -1; |
288 | 288 |
289 WebFloatRect rect = font_->selectionRectForText( | 289 WebFloatRect rect = font_->selectionRectForText( |
290 run, WebFloatPoint(0.0f, 0.0f), font_->height(), 0, char_offset); | 290 run, WebFloatPoint(0.0f, 0.0f), font_->height(), 0, char_offset); |
291 return static_cast<int>(rect.width); | 291 return static_cast<int>(rect.width); |
292 } | 292 } |
293 | 293 |
294 } // namespace pepper | 294 } // namespace pepper |
OLD | NEW |