OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef PPAPI_CPP_DEV_FONT_DEV_H_ | 5 #ifndef PPAPI_CPP_DEV_FONT_DEV_H_ |
6 #define PPAPI_CPP_DEV_FONT_DEV_H_ | 6 #define PPAPI_CPP_DEV_FONT_DEV_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ppapi/c/dev/ppb_font_dev.h" | 10 #include "ppapi/c/dev/ppb_font_dev.h" |
11 #include "ppapi/cpp/resource.h" | 11 #include "ppapi/cpp/resource.h" |
12 #include "ppapi/cpp/var.h" | 12 #include "ppapi/cpp/var.h" |
13 | 13 |
14 struct PP_FontDescription_Dev; | 14 struct PP_FontDescription_Dev; |
15 | 15 |
16 namespace pp { | 16 namespace pp { |
17 | 17 |
18 class ImageData; | 18 class ImageData; |
19 class Instance; | 19 class InstanceHandle; |
20 class Point; | 20 class Point; |
21 class Rect; | 21 class Rect; |
22 | 22 |
23 // FontDescription_Dev --------------------------------------------------------- | 23 // FontDescription_Dev --------------------------------------------------------- |
24 | 24 |
25 class FontDescription_Dev { | 25 class FontDescription_Dev { |
26 public: | 26 public: |
27 FontDescription_Dev(); | 27 FontDescription_Dev(); |
28 FontDescription_Dev(const FontDescription_Dev& other); | 28 FontDescription_Dev(const FontDescription_Dev& other); |
29 ~FontDescription_Dev(); | 29 ~FontDescription_Dev(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 // Font ------------------------------------------------------------------------ | 97 // Font ------------------------------------------------------------------------ |
98 | 98 |
99 // Provides access to system fonts. | 99 // Provides access to system fonts. |
100 class Font_Dev : public Resource { | 100 class Font_Dev : public Resource { |
101 public: | 101 public: |
102 // Creates an is_null() Font object. | 102 // Creates an is_null() Font object. |
103 Font_Dev(); | 103 Font_Dev(); |
104 | 104 |
105 explicit Font_Dev(PP_Resource resource); | 105 explicit Font_Dev(PP_Resource resource); |
106 Font_Dev(Instance* instance, const FontDescription_Dev& description); | 106 Font_Dev(const InstanceHandle& instance, |
| 107 const FontDescription_Dev& description); |
107 Font_Dev(const Font_Dev& other); | 108 Font_Dev(const Font_Dev& other); |
108 | 109 |
109 Font_Dev& operator=(const Font_Dev& other); | 110 Font_Dev& operator=(const Font_Dev& other); |
110 | 111 |
111 // PPB_Font methods: | 112 // PPB_Font methods: |
112 static Var GetFontFamilies(Instance* instance); | 113 static Var GetFontFamilies(const InstanceHandle& instance); |
113 bool Describe(FontDescription_Dev* description, | 114 bool Describe(FontDescription_Dev* description, |
114 PP_FontMetrics_Dev* metrics) const; | 115 PP_FontMetrics_Dev* metrics) const; |
115 bool DrawTextAt(ImageData* dest, | 116 bool DrawTextAt(ImageData* dest, |
116 const TextRun_Dev& text, | 117 const TextRun_Dev& text, |
117 const Point& position, | 118 const Point& position, |
118 uint32_t color, | 119 uint32_t color, |
119 const Rect& clip, | 120 const Rect& clip, |
120 bool image_data_is_opaque) const; | 121 bool image_data_is_opaque) const; |
121 int32_t MeasureText(const TextRun_Dev& text) const; | 122 int32_t MeasureText(const TextRun_Dev& text) const; |
122 uint32_t CharacterOffsetForPixel(const TextRun_Dev& text, | 123 uint32_t CharacterOffsetForPixel(const TextRun_Dev& text, |
123 int32_t pixel_position) const; | 124 int32_t pixel_position) const; |
124 int32_t PixelOffsetForCharacter(const TextRun_Dev& text, | 125 int32_t PixelOffsetForCharacter(const TextRun_Dev& text, |
125 uint32_t char_offset) const; | 126 uint32_t char_offset) const; |
126 | 127 |
127 // Convenience function that assumes a left-to-right string with no clipping. | 128 // Convenience function that assumes a left-to-right string with no clipping. |
128 bool DrawSimpleText(ImageData* dest, | 129 bool DrawSimpleText(ImageData* dest, |
129 const std::string& text, | 130 const std::string& text, |
130 const Point& position, | 131 const Point& position, |
131 uint32_t color, | 132 uint32_t color, |
132 bool image_data_is_opaque = false) const; | 133 bool image_data_is_opaque = false) const; |
133 | 134 |
134 // Convenience function that assumes a left-to-right string. | 135 // Convenience function that assumes a left-to-right string. |
135 int32_t MeasureSimpleText(const std::string& text) const; | 136 int32_t MeasureSimpleText(const std::string& text) const; |
136 }; | 137 }; |
137 | 138 |
138 } // namespace pp | 139 } // namespace pp |
139 | 140 |
140 #endif // PPAPI_CPP_DEV_FONT_DEV_H_ | 141 #endif // PPAPI_CPP_DEV_FONT_DEV_H_ |
OLD | NEW |