OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SHARED_IMPL_PRIVATE_PPB_BROWSER_FONT_TRUSTED_SHARED_H_ | 5 #ifndef PPAPI_PROXY_BROWSER_FONT_TRUSTED_RESOURCE_H_ |
6 #define PPAPI_SHARED_IMPL_PRIVATE_PPB_BROWSER_FONT_TRUSTED_SHARED_H_ | 6 #define PPAPI_PROXY_BROWSER_FONT_TRUSTED_RESOURCE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "ppapi/c/pp_bool.h" | 12 #include "ppapi/c/pp_bool.h" |
13 #include "ppapi/c/pp_instance.h" | 13 #include "ppapi/c/pp_instance.h" |
14 #include "ppapi/c/pp_resource.h" | 14 #include "ppapi/c/pp_resource.h" |
15 #include "ppapi/c/pp_stdint.h" | 15 #include "ppapi/c/pp_stdint.h" |
| 16 #include "ppapi/proxy/plugin_resource.h" |
| 17 #include "ppapi/proxy/ppapi_proxy_export.h" |
16 #include "ppapi/shared_impl/ppapi_preferences.h" | 18 #include "ppapi/shared_impl/ppapi_preferences.h" |
17 #include "ppapi/shared_impl/ppapi_shared_export.h" | |
18 #include "ppapi/shared_impl/resource.h" | |
19 #include "ppapi/thunk/ppb_browser_font_trusted_api.h" | 19 #include "ppapi/thunk/ppb_browser_font_trusted_api.h" |
20 | 20 |
21 class SkCanvas; | 21 class SkCanvas; |
22 | 22 |
23 namespace WebKit { | 23 namespace WebKit { |
24 class WebFont; | 24 class WebFont; |
25 } | 25 } |
26 | 26 |
27 namespace ppapi { | 27 namespace ppapi { |
| 28 namespace proxy { |
28 | 29 |
29 class PPAPI_SHARED_EXPORT PPB_BrowserFont_Trusted_Shared | 30 class PPAPI_PROXY_EXPORT BrowserFontResource_Trusted |
30 : public Resource, | 31 : public PluginResource, |
31 public thunk::PPB_BrowserFont_Trusted_API { | 32 public thunk::PPB_BrowserFont_Trusted_API { |
32 public: | 33 public: |
| 34 BrowserFontResource_Trusted(Connection connection, |
| 35 PP_Instance instance, |
| 36 const PP_BrowserFont_Trusted_Description& desc, |
| 37 const Preferences& prefs); |
| 38 |
| 39 virtual ~BrowserFontResource_Trusted(); |
| 40 |
33 // Validates the parameters in thee description. Can be called on any thread. | 41 // Validates the parameters in thee description. Can be called on any thread. |
34 static bool IsPPFontDescriptionValid( | 42 static bool IsPPFontDescriptionValid( |
35 const PP_BrowserFont_Trusted_Description& desc); | 43 const PP_BrowserFont_Trusted_Description& desc); |
36 | 44 |
37 virtual ~PPB_BrowserFont_Trusted_Shared(); | 45 // Resource override. |
38 | |
39 static PP_Resource Create( | |
40 ResourceObjectType type, | |
41 PP_Instance instance, | |
42 const PP_BrowserFont_Trusted_Description& description, | |
43 const ::ppapi::Preferences& prefs); | |
44 | |
45 // Resource. | |
46 virtual ::ppapi::thunk::PPB_BrowserFont_Trusted_API* | 46 virtual ::ppapi::thunk::PPB_BrowserFont_Trusted_API* |
47 AsPPB_BrowserFont_Trusted_API() OVERRIDE; | 47 AsPPB_BrowserFont_Trusted_API() OVERRIDE; |
48 | 48 |
49 // PPB_Font implementation. | 49 // PPB_Font implementation. |
50 virtual PP_Bool Describe(PP_BrowserFont_Trusted_Description* description, | 50 virtual PP_Bool Describe(PP_BrowserFont_Trusted_Description* description, |
51 PP_BrowserFont_Trusted_Metrics* metrics) OVERRIDE; | 51 PP_BrowserFont_Trusted_Metrics* metrics) OVERRIDE; |
52 virtual PP_Bool DrawTextAt(PP_Resource image_data, | 52 virtual PP_Bool DrawTextAt(PP_Resource image_data, |
53 const PP_BrowserFont_Trusted_TextRun* text, | 53 const PP_BrowserFont_Trusted_TextRun* text, |
54 const PP_Point* position, | 54 const PP_Point* position, |
55 uint32_t color, | 55 uint32_t color, |
56 const PP_Rect* clip, | 56 const PP_Rect* clip, |
57 PP_Bool image_data_is_opaque) OVERRIDE; | 57 PP_Bool image_data_is_opaque) OVERRIDE; |
58 virtual int32_t MeasureText( | 58 virtual int32_t MeasureText( |
59 const PP_BrowserFont_Trusted_TextRun* text) OVERRIDE; | 59 const PP_BrowserFont_Trusted_TextRun* text) OVERRIDE; |
60 virtual uint32_t CharacterOffsetForPixel( | 60 virtual uint32_t CharacterOffsetForPixel( |
61 const PP_BrowserFont_Trusted_TextRun* text, | 61 const PP_BrowserFont_Trusted_TextRun* text, |
62 int32_t pixel_position) OVERRIDE; | 62 int32_t pixel_position) OVERRIDE; |
63 virtual int32_t PixelOffsetForCharacter( | 63 virtual int32_t PixelOffsetForCharacter( |
64 const PP_BrowserFont_Trusted_TextRun* text, | 64 const PP_BrowserFont_Trusted_TextRun* text, |
65 uint32_t char_offset) OVERRIDE; | 65 uint32_t char_offset) OVERRIDE; |
66 | 66 |
67 private: | 67 private: |
68 PPB_BrowserFont_Trusted_Shared(ResourceObjectType type, | |
69 PP_Instance instance, | |
70 const PP_BrowserFont_Trusted_Description& desc, | |
71 const Preferences& prefs); | |
72 | |
73 // Internal version of DrawTextAt that takes a mapped PlatformCanvas. | 68 // Internal version of DrawTextAt that takes a mapped PlatformCanvas. |
74 void DrawTextToCanvas(SkCanvas* destination, | 69 void DrawTextToCanvas(SkCanvas* destination, |
75 const PP_BrowserFont_Trusted_TextRun& text, | 70 const PP_BrowserFont_Trusted_TextRun& text, |
76 const PP_Point* position, | 71 const PP_Point* position, |
77 uint32_t color, | 72 uint32_t color, |
78 const PP_Rect* clip, | 73 const PP_Rect* clip, |
79 PP_Bool image_data_is_opaque); | 74 PP_Bool image_data_is_opaque); |
80 | 75 |
| 76 private: |
81 scoped_ptr<WebKit::WebFont> font_; | 77 scoped_ptr<WebKit::WebFont> font_; |
82 | 78 |
83 DISALLOW_COPY_AND_ASSIGN(PPB_BrowserFont_Trusted_Shared); | 79 DISALLOW_COPY_AND_ASSIGN(BrowserFontResource_Trusted); |
84 }; | 80 }; |
85 | 81 |
| 82 } // namespace proxy |
86 } // namespace ppapi | 83 } // namespace ppapi |
87 | 84 |
88 #endif // PPAPI_SHARED_IMPL_PRIVATE_PPB_BROWSER_FONT_TRUSTED_SHARED_H_ | 85 #endif // PPAPI_PROXY_BROWSER_FONT_TRUSTED_RESOURCE_H_ |
OLD | NEW |