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

Side by Side Diff: ppapi/proxy/ppb_flash_proxy.cc

Issue 10905227: Introduce PPB_Flash_Font. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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
« no previous file with comments | « ppapi/proxy/ppapi_param_traits.cc ('k') | ppapi/proxy/ppb_pdf_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ppapi/proxy/ppb_flash_proxy.h" 5 #include "ppapi/proxy/ppb_flash_proxy.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 15 matching lines...) Expand all
26 #include "ppapi/proxy/serialized_var.h" 26 #include "ppapi/proxy/serialized_var.h"
27 #include "ppapi/shared_impl/dir_contents.h" 27 #include "ppapi/shared_impl/dir_contents.h"
28 #include "ppapi/shared_impl/file_type_conversion.h" 28 #include "ppapi/shared_impl/file_type_conversion.h"
29 #include "ppapi/shared_impl/ppapi_globals.h" 29 #include "ppapi/shared_impl/ppapi_globals.h"
30 #include "ppapi/shared_impl/proxy_lock.h" 30 #include "ppapi/shared_impl/proxy_lock.h"
31 #include "ppapi/shared_impl/resource.h" 31 #include "ppapi/shared_impl/resource.h"
32 #include "ppapi/shared_impl/resource_tracker.h" 32 #include "ppapi/shared_impl/resource_tracker.h"
33 #include "ppapi/shared_impl/scoped_pp_resource.h" 33 #include "ppapi/shared_impl/scoped_pp_resource.h"
34 #include "ppapi/shared_impl/time_conversion.h" 34 #include "ppapi/shared_impl/time_conversion.h"
35 #include "ppapi/shared_impl/var.h" 35 #include "ppapi/shared_impl/var.h"
36 #include "ppapi/shared_impl/var_tracker.h"
36 #include "ppapi/thunk/enter.h" 37 #include "ppapi/thunk/enter.h"
37 #include "ppapi/thunk/ppb_instance_api.h" 38 #include "ppapi/thunk/ppb_instance_api.h"
38 #include "ppapi/thunk/ppb_url_request_info_api.h" 39 #include "ppapi/thunk/ppb_url_request_info_api.h"
39 #include "ppapi/thunk/resource_creation_api.h" 40 #include "ppapi/thunk/resource_creation_api.h"
40 41
41 using ppapi::thunk::EnterInstanceNoLock; 42 using ppapi::thunk::EnterInstanceNoLock;
42 using ppapi::thunk::EnterResourceNoLock; 43 using ppapi::thunk::EnterResourceNoLock;
43 44
44 namespace ppapi { 45 namespace ppapi {
45 namespace proxy { 46 namespace proxy {
46 47
47 namespace { 48 namespace {
48 49
49 IPC::PlatformFileForTransit PlatformFileToPlatformFileForTransit( 50 IPC::PlatformFileForTransit PlatformFileToPlatformFileForTransit(
50 Dispatcher* dispatcher, 51 Dispatcher* dispatcher,
51 int32_t* error, 52 int32_t* error,
52 base::PlatformFile file) { 53 base::PlatformFile file) {
53 if (*error != PP_OK) 54 if (*error != PP_OK)
54 return IPC::InvalidPlatformFileForTransit(); 55 return IPC::InvalidPlatformFileForTransit();
55 IPC::PlatformFileForTransit out_handle = 56 IPC::PlatformFileForTransit out_handle =
56 dispatcher->ShareHandleWithRemote(file, true); 57 dispatcher->ShareHandleWithRemote(file, true);
57 if (out_handle == IPC::InvalidPlatformFileForTransit()) 58 if (out_handle == IPC::InvalidPlatformFileForTransit())
58 *error = PP_ERROR_NOACCESS; 59 *error = PP_ERROR_NOACCESS;
59 return out_handle; 60 return out_handle;
60 } 61 }
61 62
62 void InvokePrinting(PP_Instance instance) { 63 void InvokePrinting(PP_Instance instance) {
64 ProxyAutoLock lock;
65
63 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); 66 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
64 if (dispatcher) { 67 if (dispatcher) {
65 dispatcher->Send(new PpapiHostMsg_PPBFlash_InvokePrinting( 68 dispatcher->Send(new PpapiHostMsg_PPBFlash_InvokePrinting(
66 API_ID_PPB_FLASH, instance)); 69 API_ID_PPB_FLASH, instance));
67 } 70 }
68 } 71 }
69 72
70 const PPB_Flash_Print_1_0 g_flash_print_interface = { 73 const PPB_Flash_Print_1_0 g_flash_print_interface = {
71 &InvokePrinting 74 &InvokePrinting
72 }; 75 };
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 PpapiGlobals::Get()->GetResourceTracker()->GetResource(pp_image_data); 158 PpapiGlobals::Get()->GetResourceTracker()->GetResource(pp_image_data);
156 if (!image_data) 159 if (!image_data)
157 return PP_FALSE; 160 return PP_FALSE;
158 // The instance parameter isn't strictly necessary but we check that it 161 // The instance parameter isn't strictly necessary but we check that it
159 // matches anyway. 162 // matches anyway.
160 if (image_data->pp_instance() != instance) 163 if (image_data->pp_instance() != instance)
161 return PP_FALSE; 164 return PP_FALSE;
162 165
163 PPBFlash_DrawGlyphs_Params params; 166 PPBFlash_DrawGlyphs_Params params;
164 params.image_data = image_data->host_resource(); 167 params.image_data = image_data->host_resource();
165 params.font_desc.SetFromPPFontDescription(dispatcher(), *font_desc, true); 168 params.font_desc.SetFromPPFontDescription(*font_desc);
166 params.color = color; 169 params.color = color;
167 params.position = *position; 170 params.position = *position;
168 params.clip = *clip; 171 params.clip = *clip;
169 for (int i = 0; i < 3; i++) { 172 for (int i = 0; i < 3; i++) {
170 for (int j = 0; j < 3; j++) 173 for (int j = 0; j < 3; j++)
171 params.transformation[i][j] = transformation[i][j]; 174 params.transformation[i][j] = transformation[i][j];
172 } 175 }
173 params.allow_subpixel_aa = allow_subpixel_aa; 176 params.allow_subpixel_aa = allow_subpixel_aa;
174 177
175 params.glyph_indices.insert(params.glyph_indices.begin(), 178 params.glyph_indices.insert(params.glyph_indices.begin(),
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 627
625 void PPB_Flash_Proxy::OnHostMsgDrawGlyphs( 628 void PPB_Flash_Proxy::OnHostMsgDrawGlyphs(
626 PP_Instance instance, 629 PP_Instance instance,
627 const PPBFlash_DrawGlyphs_Params& params, 630 const PPBFlash_DrawGlyphs_Params& params,
628 PP_Bool* result) { 631 PP_Bool* result) {
629 *result = PP_FALSE; 632 *result = PP_FALSE;
630 EnterInstanceNoLock enter(instance); 633 EnterInstanceNoLock enter(instance);
631 if (enter.failed()) 634 if (enter.failed())
632 return; 635 return;
633 636
634 PP_FontDescription_Dev font_desc;
635 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false);
636
637 if (params.glyph_indices.size() != params.glyph_advances.size() || 637 if (params.glyph_indices.size() != params.glyph_advances.size() ||
638 params.glyph_indices.empty()) 638 params.glyph_indices.empty())
639 return; 639 return;
640 640
641 PP_FontDescription_Dev font_desc;
642 params.font_desc.SetToPPFontDescription(&font_desc);
643
641 *result = enter.functions()->GetFlashAPI()->DrawGlyphs( 644 *result = enter.functions()->GetFlashAPI()->DrawGlyphs(
642 0, // Unused instance param. 645 0, // Unused instance param.
643 params.image_data.host_resource(), &font_desc, 646 params.image_data.host_resource(), &font_desc,
644 params.color, &params.position, &params.clip, 647 params.color, &params.position, &params.clip,
645 const_cast<float(*)[3]>(params.transformation), 648 const_cast<float(*)[3]>(params.transformation),
646 params.allow_subpixel_aa, 649 params.allow_subpixel_aa,
647 static_cast<uint32_t>(params.glyph_indices.size()), 650 static_cast<uint32_t>(params.glyph_indices.size()),
648 const_cast<uint16_t*>(&params.glyph_indices[0]), 651 const_cast<uint16_t*>(&params.glyph_indices[0]),
649 const_cast<PP_Point*>(&params.glyph_advances[0])); 652 const_cast<PP_Point*>(&params.glyph_advances[0]));
653
654 // SetToPPFontDescription() creates a var which is owned by the caller.
655 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(font_desc.face);
650 } 656 }
651 657
652 void PPB_Flash_Proxy::OnHostMsgGetProxyForURL(PP_Instance instance, 658 void PPB_Flash_Proxy::OnHostMsgGetProxyForURL(PP_Instance instance,
653 const std::string& url, 659 const std::string& url,
654 SerializedVarReturnValue result) { 660 SerializedVarReturnValue result) {
655 EnterInstanceNoLock enter(instance); 661 EnterInstanceNoLock enter(instance);
656 if (enter.succeeded()) { 662 if (enter.succeeded()) {
657 result.Return(dispatcher(), 663 result.Return(dispatcher(),
658 enter.functions()->GetFlashAPI()->GetProxyForURL( 664 enter.functions()->GetFlashAPI()->GetProxyForURL(
659 instance, url.c_str())); 665 instance, url.c_str()));
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 // It's rarely used enough that we just request this interface when needed. 881 // It's rarely used enough that we just request this interface when needed.
876 const PPB_Flash_Print_1_0* print_interface = 882 const PPB_Flash_Print_1_0* print_interface =
877 static_cast<const PPB_Flash_Print_1_0*>( 883 static_cast<const PPB_Flash_Print_1_0*>(
878 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0)); 884 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0));
879 if (print_interface) 885 if (print_interface)
880 print_interface->InvokePrinting(instance); 886 print_interface->InvokePrinting(instance);
881 } 887 }
882 888
883 } // namespace proxy 889 } // namespace proxy
884 } // namespace ppapi 890 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppapi_param_traits.cc ('k') | ppapi/proxy/ppb_pdf_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698