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

Side by Side Diff: ppapi/proxy/ppb_image_data_proxy.h

Issue 10790063: PPAPI/NaCl: Make ImageData for NaCl just use shared memory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make PPB_ImageData_API base non-exported Created 8 years, 4 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/ppb_buffer_proxy.cc ('k') | ppapi/proxy/ppb_image_data_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 #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/shared_memory.h"
9 #include "build/build_config.h" 10 #include "build/build_config.h"
10 #include "ppapi/c/pp_bool.h" 11 #include "ppapi/c/pp_bool.h"
11 #include "ppapi/c/pp_completion_callback.h" 12 #include "ppapi/c/pp_completion_callback.h"
12 #include "ppapi/c/pp_instance.h" 13 #include "ppapi/c/pp_instance.h"
13 #include "ppapi/c/pp_module.h" 14 #include "ppapi/c/pp_module.h"
14 #include "ppapi/c/pp_resource.h" 15 #include "ppapi/c/pp_resource.h"
15 #include "ppapi/c/pp_size.h" 16 #include "ppapi/c/pp_size.h"
16 #include "ppapi/c/pp_var.h" 17 #include "ppapi/c/pp_var.h"
17 #include "ppapi/c/ppb_image_data.h" 18 #include "ppapi/c/ppb_image_data.h"
18 #include "ppapi/proxy/interface_proxy.h" 19 #include "ppapi/proxy/interface_proxy.h"
19 #include "ppapi/proxy/serialized_structs.h" 20 #include "ppapi/proxy/serialized_structs.h"
20 #include "ppapi/shared_impl/ppb_image_data_shared.h" 21 #include "ppapi/shared_impl/ppb_image_data_shared.h"
21 #include "ppapi/shared_impl/resource.h" 22 #include "ppapi/shared_impl/resource.h"
22 #include "ppapi/thunk/ppb_image_data_api.h" 23 #include "ppapi/thunk/ppb_image_data_api.h"
23 24
24 class TransportDIB; 25 class TransportDIB;
25 26
26 namespace ppapi { 27 namespace ppapi {
27 namespace proxy { 28 namespace proxy {
28 29
29 // The proxied image data resource. Unlike most resources, this needs to be 30 // The proxied image data resource. Unlike most resources, this needs to be
30 // public in the header since a number of other resources need to access it. 31 // public in the header since a number of other resources need to access it.
31 class ImageData : public ppapi::Resource, 32 class ImageData : public ppapi::Resource,
32 public ppapi::thunk::PPB_ImageData_API, 33 public ppapi::thunk::PPB_ImageData_API,
33 public ppapi::PPB_ImageData_Shared { 34 public ppapi::PPB_ImageData_Shared {
34 public: 35 public:
36 #if !defined(OS_NACL)
35 ImageData(const ppapi::HostResource& resource, 37 ImageData(const ppapi::HostResource& resource,
36 const PP_ImageDataDesc& desc, 38 const PP_ImageDataDesc& desc,
37 ImageHandle handle); 39 ImageHandle handle);
40 #else
41 // In NaCl, we only allow creating an ImageData using a SharedMemoryHandle.
42 // ImageHandle can differ by host platform. We need something that is
43 // more consistent across platforms for NaCl, so that we can communicate to
44 // the host OS in a consistent way.
45 ImageData(const ppapi::HostResource& resource,
46 const PP_ImageDataDesc& desc,
47 const base::SharedMemoryHandle& handle);
48 #endif
38 virtual ~ImageData(); 49 virtual ~ImageData();
39 50
40 // Resource overrides. 51 // Resource overrides.
41 virtual ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() OVERRIDE; 52 virtual ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() OVERRIDE;
42 53
43 // PPB_ImageData API. 54 // PPB_ImageData API.
44 virtual PP_Bool Describe(PP_ImageDataDesc* desc) OVERRIDE; 55 virtual PP_Bool Describe(PP_ImageDataDesc* desc) OVERRIDE;
45 virtual void* Map() OVERRIDE; 56 virtual void* Map() OVERRIDE;
46 virtual void Unmap() OVERRIDE; 57 virtual void Unmap() OVERRIDE;
47 virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE; 58 virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE;
48 virtual skia::PlatformCanvas* GetPlatformCanvas() OVERRIDE; 59 virtual skia::PlatformCanvas* GetPlatformCanvas() OVERRIDE;
60 virtual SkCanvas* GetCanvas() OVERRIDE;
49 61
50 const PP_ImageDataDesc& desc() const { return desc_; } 62 const PP_ImageDataDesc& desc() const { return desc_; }
51 63
64 #if !defined(OS_NACL)
52 static ImageHandle NullHandle(); 65 static ImageHandle NullHandle();
53 static ImageHandle HandleFromInt(int32_t i); 66 static ImageHandle HandleFromInt(int32_t i);
67 #endif
54 68
55 private: 69 private:
56 PP_ImageDataDesc desc_; 70 PP_ImageDataDesc desc_;
57 71
58 #if defined(OS_NACL) 72 #if defined(OS_NACL)
59 // TODO(brettw) implement this (see .cc file). 73 base::SharedMemory shm_;
74 uint32 size_;
75 int map_count_;
60 #else 76 #else
61 scoped_ptr<TransportDIB> transport_dib_; 77 scoped_ptr<TransportDIB> transport_dib_;
62 78
63 // Null when the image isn't mapped. 79 // Null when the image isn't mapped.
64 scoped_ptr<skia::PlatformCanvas> mapped_canvas_; 80 scoped_ptr<skia::PlatformCanvas> mapped_canvas_;
65 #endif 81 #endif
66 82
67 DISALLOW_COPY_AND_ASSIGN(ImageData); 83 DISALLOW_COPY_AND_ASSIGN(ImageData);
68 }; 84 };
69 85
70 class PPB_ImageData_Proxy : public InterfaceProxy { 86 class PPB_ImageData_Proxy : public InterfaceProxy {
71 public: 87 public:
72 PPB_ImageData_Proxy(Dispatcher* dispatcher); 88 PPB_ImageData_Proxy(Dispatcher* dispatcher);
73 virtual ~PPB_ImageData_Proxy(); 89 virtual ~PPB_ImageData_Proxy();
74 90
75 static PP_Resource CreateProxyResource(PP_Instance instance, 91 static PP_Resource CreateProxyResource(PP_Instance instance,
76 PP_ImageDataFormat format, 92 PP_ImageDataFormat format,
77 const PP_Size& size, 93 const PP_Size& size,
78 PP_Bool init_to_zero); 94 PP_Bool init_to_zero);
79 95
80 // InterfaceProxy implementation. 96 // InterfaceProxy implementation.
81 virtual bool OnMessageReceived(const IPC::Message& msg); 97 virtual bool OnMessageReceived(const IPC::Message& msg);
82 98
83 static const ApiID kApiID = API_ID_PPB_IMAGE_DATA; 99 static const ApiID kApiID = API_ID_PPB_IMAGE_DATA;
84 100
85 private: 101 private:
86 // Message handler. 102 // Message handlers.
87 void OnHostMsgCreate(PP_Instance instance, 103 void OnHostMsgCreate(PP_Instance instance,
88 int32_t format, 104 int32_t format,
89 const PP_Size& size, 105 const PP_Size& size,
90 PP_Bool init_to_zero, 106 PP_Bool init_to_zero,
91 HostResource* result, 107 HostResource* result,
92 std::string* image_data_desc, 108 std::string* image_data_desc,
93 ImageHandle* result_image_handle); 109 ImageHandle* result_image_handle);
110 void OnHostMsgCreateNaCl(PP_Instance instance,
111 int32_t format,
112 const PP_Size& size,
113 PP_Bool init_to_zero,
114 HostResource* result,
115 std::string* image_data_desc,
116 base::SharedMemoryHandle* result_image_handle);
94 117
95 DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Proxy); 118 DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Proxy);
96 }; 119 };
97 120
98 } // namespace proxy 121 } // namespace proxy
99 } // namespace ppapi 122 } // namespace ppapi
100 123
101 #endif // PPAPI_PPB_IMAGE_DATA_PROXY_H_ 124 #endif // PPAPI_PPB_IMAGE_DATA_PROXY_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_buffer_proxy.cc ('k') | ppapi/proxy/ppb_image_data_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698