OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PPAPI_SHARED_IMPL_WEBKIT_FORWARDING_H_ |
| 6 #define PPAPI_SHARED_IMPL_WEBKIT_FORWARDING_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "ppapi/c/pp_bool.h" |
| 11 #include "ppapi/c/pp_stdint.h" |
| 12 |
| 13 struct PP_FontDescription_Dev; |
| 14 struct PP_FontMetrics_Dev; |
| 15 struct PP_Point; |
| 16 struct PP_Rect; |
| 17 |
| 18 namespace base { |
| 19 class WaitableEvent; |
| 20 } |
| 21 |
| 22 namespace skia { |
| 23 class PlatformCanvas; |
| 24 } |
| 25 |
| 26 namespace pp { |
| 27 namespace shared_impl { |
| 28 |
| 29 class WebKitForwarding { |
| 30 public: |
| 31 class Font { |
| 32 public: |
| 33 // C++ version of PP_TextRun_Dev. Since the functions below will be called |
| 34 // on an alternate thread in the proxy, and since there are different |
| 35 // methods of converting PP_Var -> strings in the plugin and the proxy, we |
| 36 // can't use PP_Vars in the Do* functions below. |
| 37 struct TextRun { |
| 38 std::string text; |
| 39 bool rtl; |
| 40 bool override_direction; |
| 41 }; |
| 42 |
| 43 // DoDrawText takes too many arguments to be used with base::Bind, so we |
| 44 // use this struct to hold them. |
| 45 struct DrawTextParams { |
| 46 DrawTextParams(skia::PlatformCanvas* destination_arg, |
| 47 const TextRun& text_arg, |
| 48 const PP_Point* position_arg, |
| 49 uint32_t color_arg, |
| 50 const PP_Rect* clip_arg, |
| 51 PP_Bool image_data_is_opaque_arg); |
| 52 ~DrawTextParams(); |
| 53 |
| 54 skia::PlatformCanvas* destination; |
| 55 const TextRun& text; |
| 56 const PP_Point* position; |
| 57 uint32_t color; |
| 58 const PP_Rect* clip; |
| 59 PP_Bool image_data_is_opaque; |
| 60 }; |
| 61 |
| 62 virtual ~Font(); |
| 63 |
| 64 // The face name in the description is not filled in to avoid a dependency |
| 65 // on creating vars. Instead, the face name is placed into the given |
| 66 // string. See class description for waitable_event documentation. If |
| 67 // non-null, the given event will be set on completion. |
| 68 virtual void Describe(base::WaitableEvent* event, |
| 69 PP_FontDescription_Dev* description, |
| 70 std::string* face, |
| 71 PP_FontMetrics_Dev* metrics, |
| 72 PP_Bool* result) = 0; |
| 73 virtual void DrawTextAt(base::WaitableEvent* event, |
| 74 const DrawTextParams& params) = 0; |
| 75 virtual void MeasureText(base::WaitableEvent* event, |
| 76 const TextRun& text, |
| 77 int32_t* result) = 0; |
| 78 virtual void CharacterOffsetForPixel(base::WaitableEvent* event, |
| 79 const TextRun& text, |
| 80 int32_t pixel_position, |
| 81 uint32_t* result) = 0; |
| 82 virtual void PixelOffsetForCharacter(base::WaitableEvent* event, |
| 83 const TextRun& text, |
| 84 uint32_t char_offset, |
| 85 int32_t* result) = 0; |
| 86 }; |
| 87 |
| 88 virtual ~WebKitForwarding(); |
| 89 |
| 90 // Creates a new font with the given description. The desc_face is the face |
| 91 // name already extracted from the description. The caller owns the result |
| 92 // pointer, which will never be NULL. If non-null, the given event will be |
| 93 // set on completion. |
| 94 virtual void CreateFontForwarding(base::WaitableEvent* event, |
| 95 const PP_FontDescription_Dev& desc, |
| 96 const std::string& desc_face, |
| 97 Font** result) = 0; |
| 98 |
| 99 }; |
| 100 |
| 101 } // namespace shared_impl |
| 102 } // namespace pp |
| 103 |
| 104 #endif // PPAPI_SHARED_IMPL_WEBKIT_FORWARDING_H_ |
OLD | NEW |