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/shared_memory.h" | 9 #include "base/shared_memory.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 namespace ppapi { | 27 namespace ppapi { |
28 namespace proxy { | 28 namespace proxy { |
29 | 29 |
30 // 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 |
31 // 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. |
32 class ImageData : public ppapi::Resource, | 32 class ImageData : public ppapi::Resource, |
33 public ppapi::thunk::PPB_ImageData_API, | 33 public ppapi::thunk::PPB_ImageData_API, |
34 public ppapi::PPB_ImageData_Shared { | 34 public ppapi::PPB_ImageData_Shared { |
35 public: | 35 public: |
36 #if !defined(OS_NACL) | 36 #if !defined(OS_NACL) && !defined(NACL_WIN64) |
37 ImageData(const ppapi::HostResource& resource, | 37 ImageData(const ppapi::HostResource& resource, |
38 const PP_ImageDataDesc& desc, | 38 const PP_ImageDataDesc& desc, |
39 ImageHandle handle); | 39 ImageHandle handle); |
40 #else | 40 #else |
41 // In NaCl, we only allow creating an ImageData using a SharedMemoryHandle. | 41 // In NaCl, we only allow creating an ImageData using a SharedMemoryHandle. |
42 // ImageHandle can differ by host platform. We need something that is | 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 | 43 // more consistent across platforms for NaCl, so that we can communicate to |
44 // the host OS in a consistent way. | 44 // the host OS in a consistent way. |
45 ImageData(const ppapi::HostResource& resource, | 45 ImageData(const ppapi::HostResource& resource, |
46 const PP_ImageDataDesc& desc, | 46 const PP_ImageDataDesc& desc, |
47 const base::SharedMemoryHandle& handle); | 47 const base::SharedMemoryHandle& handle); |
48 #endif | 48 #endif |
49 virtual ~ImageData(); | 49 virtual ~ImageData(); |
50 | 50 |
51 // Resource overrides. | 51 // Resource overrides. |
52 virtual ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() OVERRIDE; | 52 virtual ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() OVERRIDE; |
53 | 53 |
54 // PPB_ImageData API. | 54 // PPB_ImageData API. |
55 virtual PP_Bool Describe(PP_ImageDataDesc* desc) OVERRIDE; | 55 virtual PP_Bool Describe(PP_ImageDataDesc* desc) OVERRIDE; |
56 virtual void* Map() OVERRIDE; | 56 virtual void* Map() OVERRIDE; |
57 virtual void Unmap() OVERRIDE; | 57 virtual void Unmap() OVERRIDE; |
58 virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE; | 58 virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE; |
59 virtual skia::PlatformCanvas* GetPlatformCanvas() OVERRIDE; | 59 virtual skia::PlatformCanvas* GetPlatformCanvas() OVERRIDE; |
60 virtual SkCanvas* GetCanvas() OVERRIDE; | 60 virtual SkCanvas* GetCanvas() OVERRIDE; |
61 | 61 |
62 const PP_ImageDataDesc& desc() const { return desc_; } | 62 const PP_ImageDataDesc& desc() const { return desc_; } |
63 | 63 |
64 #if !defined(OS_NACL) | 64 #if !defined(OS_NACL) && !defined(NACL_WIN64) |
65 static ImageHandle NullHandle(); | 65 static ImageHandle NullHandle(); |
66 static ImageHandle HandleFromInt(int32_t i); | 66 static ImageHandle HandleFromInt(int32_t i); |
67 #endif | 67 #endif |
68 | 68 |
69 private: | 69 private: |
70 PP_ImageDataDesc desc_; | 70 PP_ImageDataDesc desc_; |
71 | 71 |
72 #if defined(OS_NACL) | 72 #if defined(OS_NACL) || defined(NACL_WIN64) |
73 base::SharedMemory shm_; | 73 base::SharedMemory shm_; |
74 uint32 size_; | 74 uint32 size_; |
75 int map_count_; | 75 int map_count_; |
76 #else | 76 #else |
77 scoped_ptr<TransportDIB> transport_dib_; | 77 scoped_ptr<TransportDIB> transport_dib_; |
78 | 78 |
79 // Null when the image isn't mapped. | 79 // Null when the image isn't mapped. |
80 scoped_ptr<skia::PlatformCanvas> mapped_canvas_; | 80 scoped_ptr<skia::PlatformCanvas> mapped_canvas_; |
81 #endif | 81 #endif |
82 | 82 |
(...skipping 23 matching lines...) Expand all Loading... |
106 PP_Bool init_to_zero, | 106 PP_Bool init_to_zero, |
107 HostResource* result, | 107 HostResource* result, |
108 std::string* image_data_desc, | 108 std::string* image_data_desc, |
109 ImageHandle* result_image_handle); | 109 ImageHandle* result_image_handle); |
110 void OnHostMsgCreateNaCl(PP_Instance instance, | 110 void OnHostMsgCreateNaCl(PP_Instance instance, |
111 int32_t format, | 111 int32_t format, |
112 const PP_Size& size, | 112 const PP_Size& size, |
113 PP_Bool init_to_zero, | 113 PP_Bool init_to_zero, |
114 HostResource* result, | 114 HostResource* result, |
115 std::string* image_data_desc, | 115 std::string* image_data_desc, |
116 base::SharedMemoryHandle* result_image_handle); | 116 ppapi::proxy::SerializedHandle* result_image_handle); |
117 | 117 |
118 DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Proxy); | 118 DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Proxy); |
119 }; | 119 }; |
120 | 120 |
121 } // namespace proxy | 121 } // namespace proxy |
122 } // namespace ppapi | 122 } // namespace ppapi |
123 | 123 |
124 #endif // PPAPI_PPB_IMAGE_DATA_PROXY_H_ | 124 #endif // PPAPI_PPB_IMAGE_DATA_PROXY_H_ |
OLD | NEW |