Updates version of android sdk and api installed and creates ARM and x86 AVD's.
[chromium-blink-merge.git] / ppapi / proxy / ppb_image_data_proxy.h
blob0fcb72a3af9d95a9af22862c298e888181ddb9ea
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
3 // found in the LICENSE file.
5 #ifndef PPAPI_PPB_IMAGE_DATA_PROXY_H_
6 #define PPAPI_PPB_IMAGE_DATA_PROXY_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "build/build_config.h"
10 #include "ppapi/c/pp_bool.h"
11 #include "ppapi/c/pp_completion_callback.h"
12 #include "ppapi/c/pp_instance.h"
13 #include "ppapi/c/pp_module.h"
14 #include "ppapi/c/pp_resource.h"
15 #include "ppapi/c/pp_size.h"
16 #include "ppapi/c/pp_var.h"
17 #include "ppapi/c/ppb_image_data.h"
18 #include "ppapi/proxy/interface_proxy.h"
19 #include "ppapi/proxy/serialized_structs.h"
20 #include "ppapi/shared_impl/ppb_image_data_shared.h"
21 #include "ppapi/shared_impl/resource.h"
22 #include "ppapi/thunk/ppb_image_data_api.h"
24 class TransportDIB;
26 namespace ppapi {
27 namespace proxy {
29 // 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 class ImageData : public ppapi::Resource,
32 public ppapi::thunk::PPB_ImageData_API,
33 public ppapi::PPB_ImageData_Shared {
34 public:
35 ImageData(const ppapi::HostResource& resource,
36 const PP_ImageDataDesc& desc,
37 ImageHandle handle);
38 virtual ~ImageData();
40 // Resource overrides.
41 virtual ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() OVERRIDE;
43 // PPB_ImageData API.
44 virtual PP_Bool Describe(PP_ImageDataDesc* desc) OVERRIDE;
45 virtual void* Map() OVERRIDE;
46 virtual void Unmap() OVERRIDE;
47 virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE;
48 virtual skia::PlatformCanvas* GetPlatformCanvas() OVERRIDE;
50 const PP_ImageDataDesc& desc() const { return desc_; }
52 static ImageHandle NullHandle();
53 static ImageHandle HandleFromInt(int32_t i);
55 private:
56 PP_ImageDataDesc desc_;
58 #if defined(OS_NACL)
59 // TODO(brettw) implement this (see .cc file).
60 #else
61 scoped_ptr<TransportDIB> transport_dib_;
63 // Null when the image isn't mapped.
64 scoped_ptr<skia::PlatformCanvas> mapped_canvas_;
65 #endif
67 DISALLOW_COPY_AND_ASSIGN(ImageData);
70 class PPB_ImageData_Proxy : public InterfaceProxy {
71 public:
72 PPB_ImageData_Proxy(Dispatcher* dispatcher);
73 virtual ~PPB_ImageData_Proxy();
75 static PP_Resource CreateProxyResource(PP_Instance instance,
76 PP_ImageDataFormat format,
77 const PP_Size& size,
78 PP_Bool init_to_zero);
80 // InterfaceProxy implementation.
81 virtual bool OnMessageReceived(const IPC::Message& msg);
83 static const ApiID kApiID = API_ID_PPB_IMAGE_DATA;
85 private:
86 // Message handler.
87 void OnHostMsgCreate(PP_Instance instance,
88 int32_t format,
89 const PP_Size& size,
90 PP_Bool init_to_zero,
91 HostResource* result,
92 std::string* image_data_desc,
93 ImageHandle* result_image_handle);
95 DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Proxy);
98 } // namespace proxy
99 } // namespace ppapi
101 #endif // PPAPI_PPB_IMAGE_DATA_PROXY_H_