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
3 // found in the LICENSE file.
5 #ifndef PPAPI_PROXY_BROWSER_FONT_TRUSTED_RESOURCE_H_
6 #define PPAPI_PROXY_BROWSER_FONT_TRUSTED_RESOURCE_H_
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ppapi/c/pp_bool.h"
13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_resource.h"
15 #include "ppapi/c/pp_stdint.h"
16 #include "ppapi/proxy/plugin_resource.h"
17 #include "ppapi/proxy/ppapi_proxy_export.h"
18 #include "ppapi/shared_impl/ppapi_preferences.h"
19 #include "ppapi/thunk/ppb_browser_font_trusted_api.h"
30 class PPAPI_PROXY_EXPORT BrowserFontResource_Trusted
31 : public PluginResource
,
32 public thunk::PPB_BrowserFont_Trusted_API
{
34 BrowserFontResource_Trusted(Connection connection
,
36 const PP_BrowserFont_Trusted_Description
& desc
,
37 const Preferences
& prefs
);
39 virtual ~BrowserFontResource_Trusted();
41 // Validates the parameters in thee description. Can be called on any thread.
42 static bool IsPPFontDescriptionValid(
43 const PP_BrowserFont_Trusted_Description
& desc
);
46 virtual ::ppapi::thunk::PPB_BrowserFont_Trusted_API
*
47 AsPPB_BrowserFont_Trusted_API() OVERRIDE
;
49 // PPB_BrowserFont_Trusted_API implementation.
50 virtual PP_Bool
Describe(PP_BrowserFont_Trusted_Description
* description
,
51 PP_BrowserFont_Trusted_Metrics
* metrics
) OVERRIDE
;
52 virtual PP_Bool
DrawTextAt(PP_Resource image_data
,
53 const PP_BrowserFont_Trusted_TextRun
* text
,
54 const PP_Point
* position
,
57 PP_Bool image_data_is_opaque
) OVERRIDE
;
58 virtual int32_t MeasureText(
59 const PP_BrowserFont_Trusted_TextRun
* text
) OVERRIDE
;
60 virtual uint32_t CharacterOffsetForPixel(
61 const PP_BrowserFont_Trusted_TextRun
* text
,
62 int32_t pixel_position
) OVERRIDE
;
63 virtual int32_t PixelOffsetForCharacter(
64 const PP_BrowserFont_Trusted_TextRun
* text
,
65 uint32_t char_offset
) OVERRIDE
;
68 // Internal version of DrawTextAt that takes a mapped PlatformCanvas.
69 void DrawTextToCanvas(SkCanvas
* destination
,
70 const PP_BrowserFont_Trusted_TextRun
& text
,
71 const PP_Point
* position
,
74 PP_Bool image_data_is_opaque
);
77 scoped_ptr
<WebKit::WebFont
> font_
;
79 DISALLOW_COPY_AND_ASSIGN(BrowserFontResource_Trusted
);
85 #endif // PPAPI_PROXY_BROWSER_FONT_TRUSTED_RESOURCE_H_