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