OLD | NEW |
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 #ifndef PPAPI_PPB_IMAGE_DATA_PROXY_H_ | 5 #ifndef PPAPI_PPB_IMAGE_DATA_PROXY_H_ |
6 #define PPAPI_PPB_IMAGE_DATA_PROXY_H_ | 6 #define PPAPI_PPB_IMAGE_DATA_PROXY_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 class SerializedHandle; | 32 class SerializedHandle; |
33 | 33 |
34 // ImageData is an abstract base class for image data resources. Unlike most | 34 // ImageData is an abstract base class for image data resources. Unlike most |
35 // resources, ImageData must be public in the header since a number of other | 35 // resources, ImageData must be public in the header since a number of other |
36 // resources need to access it. | 36 // resources need to access it. |
37 class PPAPI_PROXY_EXPORT ImageData | 37 class PPAPI_PROXY_EXPORT ImageData |
38 : public ppapi::Resource, | 38 : public ppapi::Resource, |
39 public NON_EXPORTED_BASE(ppapi::thunk::PPB_ImageData_API), | 39 public NON_EXPORTED_BASE(ppapi::thunk::PPB_ImageData_API), |
40 public ppapi::PPB_ImageData_Shared { | 40 public ppapi::PPB_ImageData_Shared { |
41 public: | 41 public: |
42 virtual ~ImageData(); | 42 ~ImageData() override; |
43 | 43 |
44 // Resource overrides. | 44 // Resource overrides. |
45 virtual ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() override; | 45 ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() override; |
46 virtual void LastPluginRefWasDeleted() override; | 46 void LastPluginRefWasDeleted() override; |
47 virtual void InstanceWasDeleted() override; | 47 void InstanceWasDeleted() override; |
48 | 48 |
49 // PPB_ImageData API. | 49 // PPB_ImageData API. |
50 virtual PP_Bool Describe(PP_ImageDataDesc* desc) override; | 50 PP_Bool Describe(PP_ImageDataDesc* desc) override; |
51 virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) override; | 51 int32_t GetSharedMemory(int* handle, uint32_t* byte_count) override; |
52 virtual void SetIsCandidateForReuse() override; | 52 void SetIsCandidateForReuse() override; |
53 | 53 |
54 PPB_ImageData_Shared::ImageDataType type() const { return type_; } | 54 PPB_ImageData_Shared::ImageDataType type() const { return type_; } |
55 const PP_ImageDataDesc& desc() const { return desc_; } | 55 const PP_ImageDataDesc& desc() const { return desc_; } |
56 | 56 |
57 // Prepares this image data to be recycled to the plugin. Clears the contents | 57 // Prepares this image data to be recycled to the plugin. Clears the contents |
58 // if zero_contents is true. | 58 // if zero_contents is true. |
59 void RecycleToPlugin(bool zero_contents); | 59 void RecycleToPlugin(bool zero_contents); |
60 | 60 |
61 protected: | 61 protected: |
62 ImageData(const ppapi::HostResource& resource, | 62 ImageData(const ppapi::HostResource& resource, |
(...skipping 11 matching lines...) Expand all Loading... |
74 | 74 |
75 // PlatformImageData is a full featured image data resource which can access | 75 // PlatformImageData is a full featured image data resource which can access |
76 // the underlying platform-specific canvas and ImageHandle. This can't be used | 76 // the underlying platform-specific canvas and ImageHandle. This can't be used |
77 // by NaCl apps. | 77 // by NaCl apps. |
78 #if !defined(OS_NACL) | 78 #if !defined(OS_NACL) |
79 class PPAPI_PROXY_EXPORT PlatformImageData : public ImageData { | 79 class PPAPI_PROXY_EXPORT PlatformImageData : public ImageData { |
80 public: | 80 public: |
81 PlatformImageData(const ppapi::HostResource& resource, | 81 PlatformImageData(const ppapi::HostResource& resource, |
82 const PP_ImageDataDesc& desc, | 82 const PP_ImageDataDesc& desc, |
83 ImageHandle handle); | 83 ImageHandle handle); |
84 virtual ~PlatformImageData(); | 84 ~PlatformImageData() override; |
85 | 85 |
86 // PPB_ImageData API. | 86 // PPB_ImageData API. |
87 virtual void* Map() override; | 87 void* Map() override; |
88 virtual void Unmap() override; | 88 void Unmap() override; |
89 virtual SkCanvas* GetPlatformCanvas() override; | 89 SkCanvas* GetPlatformCanvas() override; |
90 virtual SkCanvas* GetCanvas() override; | 90 SkCanvas* GetCanvas() override; |
91 | 91 |
92 static ImageHandle NullHandle(); | 92 static ImageHandle NullHandle(); |
93 static ImageHandle HandleFromInt(int32_t i); | 93 static ImageHandle HandleFromInt(int32_t i); |
94 | 94 |
95 private: | 95 private: |
96 scoped_ptr<TransportDIB> transport_dib_; | 96 scoped_ptr<TransportDIB> transport_dib_; |
97 | 97 |
98 // Null when the image isn't mapped. | 98 // Null when the image isn't mapped. |
99 scoped_ptr<SkCanvas> mapped_canvas_; | 99 scoped_ptr<SkCanvas> mapped_canvas_; |
100 | 100 |
101 DISALLOW_COPY_AND_ASSIGN(PlatformImageData); | 101 DISALLOW_COPY_AND_ASSIGN(PlatformImageData); |
102 }; | 102 }; |
103 #endif // !defined(OS_NACL) | 103 #endif // !defined(OS_NACL) |
104 | 104 |
105 // SimpleImageData is a simple, platform-independent image data resource which | 105 // SimpleImageData is a simple, platform-independent image data resource which |
106 // can be used by NaCl. It can also be used by trusted apps when access to the | 106 // can be used by NaCl. It can also be used by trusted apps when access to the |
107 // platform canvas isn't needed. | 107 // platform canvas isn't needed. |
108 class PPAPI_PROXY_EXPORT SimpleImageData : public ImageData { | 108 class PPAPI_PROXY_EXPORT SimpleImageData : public ImageData { |
109 public: | 109 public: |
110 SimpleImageData(const ppapi::HostResource& resource, | 110 SimpleImageData(const ppapi::HostResource& resource, |
111 const PP_ImageDataDesc& desc, | 111 const PP_ImageDataDesc& desc, |
112 const base::SharedMemoryHandle& handle); | 112 const base::SharedMemoryHandle& handle); |
113 virtual ~SimpleImageData(); | 113 ~SimpleImageData() override; |
114 | 114 |
115 // PPB_ImageData API. | 115 // PPB_ImageData API. |
116 virtual void* Map() override; | 116 void* Map() override; |
117 virtual void Unmap() override; | 117 void Unmap() override; |
118 virtual SkCanvas* GetPlatformCanvas() override; | 118 SkCanvas* GetPlatformCanvas() override; |
119 virtual SkCanvas* GetCanvas() override; | 119 SkCanvas* GetCanvas() override; |
120 | 120 |
121 private: | 121 private: |
122 base::SharedMemory shm_; | 122 base::SharedMemory shm_; |
123 uint32 size_; | 123 uint32 size_; |
124 int map_count_; | 124 int map_count_; |
125 | 125 |
126 DISALLOW_COPY_AND_ASSIGN(SimpleImageData); | 126 DISALLOW_COPY_AND_ASSIGN(SimpleImageData); |
127 }; | 127 }; |
128 | 128 |
129 class PPB_ImageData_Proxy : public InterfaceProxy { | 129 class PPB_ImageData_Proxy : public InterfaceProxy { |
130 public: | 130 public: |
131 PPB_ImageData_Proxy(Dispatcher* dispatcher); | 131 PPB_ImageData_Proxy(Dispatcher* dispatcher); |
132 virtual ~PPB_ImageData_Proxy(); | 132 ~PPB_ImageData_Proxy() override; |
133 | 133 |
134 static PP_Resource CreateProxyResource( | 134 static PP_Resource CreateProxyResource( |
135 PP_Instance instance, | 135 PP_Instance instance, |
136 PPB_ImageData_Shared::ImageDataType type, | 136 PPB_ImageData_Shared::ImageDataType type, |
137 PP_ImageDataFormat format, | 137 PP_ImageDataFormat format, |
138 const PP_Size& size, | 138 const PP_Size& size, |
139 PP_Bool init_to_zero); | 139 PP_Bool init_to_zero); |
140 | 140 |
141 // InterfaceProxy implementation. | 141 // InterfaceProxy implementation. |
142 virtual bool OnMessageReceived(const IPC::Message& msg); | 142 bool OnMessageReceived(const IPC::Message& msg) override; |
143 | 143 |
144 // Utility for creating ImageData resources. | 144 // Utility for creating ImageData resources. |
145 // This can only be called on the host side of the proxy. | 145 // This can only be called on the host side of the proxy. |
146 // On failure, will return invalid resource (0). On success it will return a | 146 // On failure, will return invalid resource (0). On success it will return a |
147 // valid resource and the out params will be written. | 147 // valid resource and the out params will be written. |
148 // |desc| contains the result of Describe. | 148 // |desc| contains the result of Describe. |
149 // |image_handle| and |byte_count| contain the result of GetSharedMemory. | 149 // |image_handle| and |byte_count| contain the result of GetSharedMemory. |
150 // NOTE: if |init_to_zero| is false, you should write over the entire image | 150 // NOTE: if |init_to_zero| is false, you should write over the entire image |
151 // to avoid leaking sensitive data to a less privileged process. | 151 // to avoid leaking sensitive data to a less privileged process. |
152 PPAPI_PROXY_EXPORT static PP_Resource CreateImageData( | 152 PPAPI_PROXY_EXPORT static PP_Resource CreateImageData( |
(...skipping 30 matching lines...) Expand all Loading... |
183 // Host->Plugin message handlers. | 183 // Host->Plugin message handlers. |
184 void OnPluginMsgNotifyUnusedImageData(const HostResource& old_image_data); | 184 void OnPluginMsgNotifyUnusedImageData(const HostResource& old_image_data); |
185 | 185 |
186 DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Proxy); | 186 DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Proxy); |
187 }; | 187 }; |
188 | 188 |
189 } // namespace proxy | 189 } // namespace proxy |
190 } // namespace ppapi | 190 } // namespace ppapi |
191 | 191 |
192 #endif // PPAPI_PPB_IMAGE_DATA_PROXY_H_ | 192 #endif // PPAPI_PPB_IMAGE_DATA_PROXY_H_ |
OLD | NEW |