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 #include "ppapi/c/pp_errors.h"
6 #include "ppapi/c/ppb_image_data.h"
7 #include "ppapi/shared_impl/ppb_image_data_shared.h"
8 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/ppb_image_data_api.h"
10 #include "ppapi/thunk/resource_creation_api.h"
11 #include "ppapi/thunk/thunk.h"
18 PP_ImageDataFormat
GetNativeImageDataFormat() {
19 return ppapi::PPB_ImageData_Shared::GetNativeImageDataFormat();
22 PP_Bool
IsImageDataFormatSupported(PP_ImageDataFormat format
) {
23 return ppapi::PPB_ImageData_Shared::IsImageDataFormatSupported(format
)
27 PP_Resource
Create(PP_Instance instance
,
28 PP_ImageDataFormat format
,
30 PP_Bool init_to_zero
) {
31 EnterResourceCreation
enter(instance
);
34 return enter
.functions()->CreateImageData(instance
, format
,
38 PP_Bool
IsImageData(PP_Resource resource
) {
39 EnterResource
<PPB_ImageData_API
> enter(resource
, false);
40 return enter
.succeeded() ? PP_TRUE
: PP_FALSE
;
43 PP_Bool
Describe(PP_Resource resource
, PP_ImageDataDesc
* desc
) {
44 // Give predictable values on failure.
45 memset(desc
, 0, sizeof(PP_ImageDataDesc
));
47 EnterResource
<PPB_ImageData_API
> enter(resource
, true);
50 return enter
.object()->Describe(desc
);
53 void* Map(PP_Resource resource
) {
54 EnterResource
<PPB_ImageData_API
> enter(resource
, true);
57 return enter
.object()->Map();
60 void Unmap(PP_Resource resource
) {
61 EnterResource
<PPB_ImageData_API
> enter(resource
, true);
64 enter
.object()->Unmap();
67 const PPB_ImageData g_ppb_image_data_thunk
= {
68 &GetNativeImageDataFormat
,
69 &IsImageDataFormatSupported
,
79 const PPB_ImageData_1_0
* GetPPB_ImageData_1_0_Thunk() {
80 return &g_ppb_image_data_thunk
;