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"
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
{
35 ImageData(const ppapi::HostResource
& resource
,
36 const PP_ImageDataDesc
& desc
,
40 // Resource overrides.
41 virtual ppapi::thunk::PPB_ImageData_API
* AsPPB_ImageData_API() OVERRIDE
;
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
);
56 PP_ImageDataDesc desc_
;
59 // TODO(brettw) implement this (see .cc file).
61 scoped_ptr
<TransportDIB
> transport_dib_
;
63 // Null when the image isn't mapped.
64 scoped_ptr
<skia::PlatformCanvas
> mapped_canvas_
;
67 DISALLOW_COPY_AND_ASSIGN(ImageData
);
70 class PPB_ImageData_Proxy
: public InterfaceProxy
{
72 PPB_ImageData_Proxy(Dispatcher
* dispatcher
);
73 virtual ~PPB_ImageData_Proxy();
75 static PP_Resource
CreateProxyResource(PP_Instance instance
,
76 PP_ImageDataFormat format
,
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
;
87 void OnHostMsgCreate(PP_Instance instance
,
92 std::string
* image_data_desc
,
93 ImageHandle
* result_image_handle
);
95 DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Proxy
);
101 #endif // PPAPI_PPB_IMAGE_DATA_PROXY_H_