Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: ppapi/proxy/ppb_font_proxy.h

Issue 6981001: Make the Pepper proxy support in-process font rendering. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_PROXY_PPB_FONT_PROXY_H_ 5 #ifndef PPAPI_PROXY_PPB_FONT_PROXY_H_
6 #define PPAPI_PROXY_PPB_FONT_PROXY_H_ 6 #define PPAPI_PROXY_PPB_FONT_PROXY_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "ppapi/c/pp_instance.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "ppapi/c/pp_resource.h"
11 #include "ppapi/proxy/host_resource.h" 10 #include "ppapi/proxy/host_resource.h"
12 #include "ppapi/proxy/interface_proxy.h" 11 #include "ppapi/proxy/interface_proxy.h"
12 #include "ppapi/proxy/plugin_resource.h"
13 #include "ppapi/shared_impl/font_impl.h"
14 #include "ppapi/thunk/ppb_font_api.h"
13 15
14 struct PPB_Font_Dev; 16 struct PPB_Font_Dev;
15 17
16 namespace pp { 18 namespace pp {
17 namespace proxy { 19 namespace proxy {
18 20
19 struct PPBFont_DrawTextAt_Params;
20 struct SerializedFontDescription;
21 class SerializedVarReceiveInput; 21 class SerializedVarReceiveInput;
22 22
23 class PPB_Font_Proxy : public InterfaceProxy { 23 class PPB_Font_Proxy : public InterfaceProxy {
24 public: 24 public:
25 PPB_Font_Proxy(Dispatcher* dispatcher, const void* target_interface); 25 PPB_Font_Proxy(Dispatcher* dispatcher, const void* target_interface);
26 virtual ~PPB_Font_Proxy(); 26 virtual ~PPB_Font_Proxy();
27 27
28 static const Info* GetInfo(); 28 static const Info* GetInfo();
29 29
30 const PPB_Font_Dev* ppb_font_target() const {
31 return static_cast<const PPB_Font_Dev*>(target_interface());
32 }
33
34 // InterfaceProxy implementation. 30 // InterfaceProxy implementation.
35 virtual bool OnMessageReceived(const IPC::Message& msg); 31 virtual bool OnMessageReceived(const IPC::Message& msg);
36 32
37 private: 33 private:
38 // Message handlers. 34 DISALLOW_COPY_AND_ASSIGN(PPB_Font_Proxy);
39 void OnMsgCreate(PP_Instance instance, 35 };
40 const SerializedFontDescription& in_description,
41 HostResource* result,
42 SerializedFontDescription* out_description,
43 std::string* out_metrics);
44 void OnMsgDrawTextAt(SerializedVarReceiveInput text,
45 const PPBFont_DrawTextAt_Params& params,
46 PP_Bool* result);
47 void OnMsgMeasureText(HostResource font,
48 SerializedVarReceiveInput text,
49 PP_Bool text_is_rtl,
50 PP_Bool override_direction,
51 int32_t* result);
52 void OnMsgCharacterOffsetForPixel(HostResource font,
53 SerializedVarReceiveInput text,
54 PP_Bool text_is_rtl,
55 PP_Bool override_direction,
56 int32_t pixel_pos,
57 uint32_t* result);
58 void OnMsgPixelOffsetForCharacter(HostResource font,
59 SerializedVarReceiveInput text,
60 PP_Bool text_is_rtl,
61 PP_Bool override_direction,
62 uint32_t char_offset,
63 int32_t* result);
64 36
65 DISALLOW_COPY_AND_ASSIGN(PPB_Font_Proxy); 37 class Font : public PluginResource,
38 public ppapi::thunk::PPB_Font_API,
39 public pp::shared_impl::FontImpl {
40 public:
41 // Note that there isn't a "real" resource in the renderer backing a font,
42 // it lives entirely in the plugin process. So the resource ID in the host
43 // resource should be 0. However, various code assumes the instance in the
44 // host resource is valid (this is how resources are associated with
45 // instances), so that should be set.
46 Font(const HostResource& resource, const PP_FontDescription_Dev& desc);
47 virtual ~Font();
48
49 // ResourceObjectBase.
50 virtual ppapi::thunk::PPB_Font_API* AsFont_API() OVERRIDE;
51
52 // PluginResource overrides.
53 virtual Font* AsFont() OVERRIDE;
54
55 // PPB_Font_API implementation.
56 virtual PP_Bool Describe(PP_FontDescription_Dev* description,
57 PP_FontMetrics_Dev* metrics) OVERRIDE;
58 virtual PP_Bool DrawTextAt(PP_Resource image_data,
59 const PP_TextRun_Dev* text,
60 const PP_Point* position,
61 uint32_t color,
62 const PP_Rect* clip,
63 PP_Bool image_data_is_opaque) OVERRIDE;
64 virtual int32_t MeasureText(const PP_TextRun_Dev* text) OVERRIDE;
65 virtual uint32_t CharacterOffsetForPixel(const PP_TextRun_Dev* text,
66 int32_t pixel_position) OVERRIDE;
67 virtual int32_t PixelOffsetForCharacter(const PP_TextRun_Dev* text,
68 uint32_t char_offset) OVERRIDE;
69
70 private:
71 // Posts the given closure to the WebKit thread and waits on the
72 // webkit_event_ for the task to continue.
73 void RunOnWebKitThread(const base::Closure& task);
74
75 base::WaitableEvent webkit_event_;
76
77 DISALLOW_COPY_AND_ASSIGN(Font);
66 }; 78 };
67 79
68 } // namespace proxy 80 } // namespace proxy
69 } // namespace pp 81 } // namespace pp
70 82
71 #endif // PPAPI_PROXY_PPB_FONT_PROXY_H_ 83 #endif // PPAPI_PROXY_PPB_FONT_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698