OLD | NEW |
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 #include "ppapi/proxy/ppb_image_data_proxy.h" | 5 #include "ppapi/proxy/ppb_image_data_proxy.h" |
6 | 6 |
7 #include <string.h> // For memcpy | 7 #include <string.h> // For memcpy |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "ppapi/c/pp_completion_callback.h" | 13 #include "ppapi/c/pp_completion_callback.h" |
14 #include "ppapi/c/pp_errors.h" | 14 #include "ppapi/c/pp_errors.h" |
15 #include "ppapi/c/pp_resource.h" | 15 #include "ppapi/c/pp_resource.h" |
16 #include "ppapi/proxy/plugin_dispatcher.h" | 16 #include "ppapi/proxy/plugin_dispatcher.h" |
17 #include "ppapi/proxy/plugin_resource_tracker.h" | 17 #include "ppapi/proxy/plugin_resource_tracker.h" |
18 #include "ppapi/proxy/ppapi_messages.h" | 18 #include "ppapi/proxy/ppapi_messages.h" |
19 #include "ppapi/shared_impl/host_resource.h" | 19 #include "ppapi/shared_impl/host_resource.h" |
20 #include "ppapi/shared_impl/resource.h" | 20 #include "ppapi/shared_impl/resource.h" |
21 #include "ppapi/thunk/thunk.h" | 21 #include "ppapi/thunk/thunk.h" |
22 #include "skia/ext/platform_canvas.h" | 22 #include "skia/ext/platform_canvas.h" |
23 #include "ui/gfx/surface/transport_dib.h" | 23 #include "ui/gfx/surface/transport_dib.h" |
24 | 24 |
25 using ppapi::HostResource; | 25 namespace ppapi { |
26 using ppapi::Resource; | |
27 | |
28 namespace pp { | |
29 namespace proxy { | 26 namespace proxy { |
30 | 27 |
31 namespace { | 28 namespace { |
32 | 29 |
33 InterfaceProxy* CreateImageDataProxy(Dispatcher* dispatcher, | 30 InterfaceProxy* CreateImageDataProxy(Dispatcher* dispatcher, |
34 const void* target_interface) { | 31 const void* target_interface) { |
35 return new PPB_ImageData_Proxy(dispatcher, target_interface); | 32 return new PPB_ImageData_Proxy(dispatcher, target_interface); |
36 } | 33 } |
37 | 34 |
38 } // namespace | 35 } // namespace |
39 | 36 |
40 // PPB_ImageData_Proxy --------------------------------------------------------- | 37 // PPB_ImageData_Proxy --------------------------------------------------------- |
41 | 38 |
42 PPB_ImageData_Proxy::PPB_ImageData_Proxy(Dispatcher* dispatcher, | 39 PPB_ImageData_Proxy::PPB_ImageData_Proxy(Dispatcher* dispatcher, |
43 const void* target_interface) | 40 const void* target_interface) |
44 : InterfaceProxy(dispatcher, target_interface) { | 41 : InterfaceProxy(dispatcher, target_interface) { |
45 } | 42 } |
46 | 43 |
47 PPB_ImageData_Proxy::~PPB_ImageData_Proxy() { | 44 PPB_ImageData_Proxy::~PPB_ImageData_Proxy() { |
48 } | 45 } |
49 | 46 |
50 // static | 47 // static |
51 const InterfaceProxy::Info* PPB_ImageData_Proxy::GetInfo() { | 48 const InterfaceProxy::Info* PPB_ImageData_Proxy::GetInfo() { |
52 static const Info info = { | 49 static const Info info = { |
53 ::ppapi::thunk::GetPPB_ImageData_Thunk(), | 50 thunk::GetPPB_ImageData_Thunk(), |
54 PPB_IMAGEDATA_INTERFACE, | 51 PPB_IMAGEDATA_INTERFACE, |
55 INTERFACE_ID_PPB_IMAGE_DATA, | 52 INTERFACE_ID_PPB_IMAGE_DATA, |
56 false, | 53 false, |
57 &CreateImageDataProxy, | 54 &CreateImageDataProxy, |
58 }; | 55 }; |
59 return &info; | 56 return &info; |
60 } | 57 } |
61 | 58 |
62 bool PPB_ImageData_Proxy::OnMessageReceived(const IPC::Message& msg) { | 59 bool PPB_ImageData_Proxy::OnMessageReceived(const IPC::Message& msg) { |
63 return false; | 60 return false; |
64 } | 61 } |
65 | 62 |
66 // ImageData ------------------------------------------------------------------- | 63 // ImageData ------------------------------------------------------------------- |
67 | 64 |
68 ImageData::ImageData(const HostResource& resource, | 65 ImageData::ImageData(const HostResource& resource, |
69 const PP_ImageDataDesc& desc, | 66 const PP_ImageDataDesc& desc, |
70 ImageHandle handle) | 67 ImageHandle handle) |
71 : Resource(resource), | 68 : Resource(resource), |
72 desc_(desc) { | 69 desc_(desc) { |
73 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
74 transport_dib_.reset(TransportDIB::CreateWithHandle(handle)); | 71 transport_dib_.reset(TransportDIB::CreateWithHandle(handle)); |
75 #else | 72 #else |
76 transport_dib_.reset(TransportDIB::Map(handle)); | 73 transport_dib_.reset(TransportDIB::Map(handle)); |
77 #endif | 74 #endif |
78 } | 75 } |
79 | 76 |
80 ImageData::~ImageData() { | 77 ImageData::~ImageData() { |
81 } | 78 } |
82 | 79 |
83 ::ppapi::thunk::PPB_ImageData_API* ImageData::AsPPB_ImageData_API() { | 80 thunk::PPB_ImageData_API* ImageData::AsPPB_ImageData_API() { |
84 return this; | 81 return this; |
85 } | 82 } |
86 | 83 |
87 PP_Bool ImageData::Describe(PP_ImageDataDesc* desc) { | 84 PP_Bool ImageData::Describe(PP_ImageDataDesc* desc) { |
88 memcpy(desc, &desc_, sizeof(PP_ImageDataDesc)); | 85 memcpy(desc, &desc_, sizeof(PP_ImageDataDesc)); |
89 return PP_TRUE; | 86 return PP_TRUE; |
90 } | 87 } |
91 | 88 |
92 void* ImageData::Map() { | 89 void* ImageData::Map() { |
93 if (!mapped_canvas_.get()) { | 90 if (!mapped_canvas_.get()) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 #if defined(OS_WIN) | 125 #if defined(OS_WIN) |
129 return reinterpret_cast<ImageHandle>(i); | 126 return reinterpret_cast<ImageHandle>(i); |
130 #elif defined(OS_MACOSX) | 127 #elif defined(OS_MACOSX) |
131 return ImageHandle(i, false); | 128 return ImageHandle(i, false); |
132 #else | 129 #else |
133 return static_cast<ImageHandle>(i); | 130 return static_cast<ImageHandle>(i); |
134 #endif | 131 #endif |
135 } | 132 } |
136 | 133 |
137 } // namespace proxy | 134 } // namespace proxy |
138 } // namespace pp | 135 } // namespace ppapi |
OLD | NEW |