Roll src/third_party/WebKit dccf813:8daf7c3 (svn 194467:194468)
[chromium-blink-merge.git] / ppapi / thunk / ppb_image_data_thunk.cc
blob343372c9f2f6924fb4a7d0477b8e254d577db926
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 // From ppb_image_data.idl modified Tue May 7 14:43:00 2013.
7 #include <string.h>
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/ppb_image_data.h"
11 #include "ppapi/shared_impl/ppb_image_data_shared.h"
12 #include "ppapi/shared_impl/tracked_callback.h"
13 #include "ppapi/thunk/enter.h"
14 #include "ppapi/thunk/ppapi_thunk_export.h"
15 #include "ppapi/thunk/ppb_image_data_api.h"
17 namespace ppapi {
18 namespace thunk {
20 namespace {
22 PP_ImageDataFormat GetNativeImageDataFormat(void) {
23 VLOG(4) << "PPB_ImageData::GetNativeImageDataFormat()";
24 return PPB_ImageData_Shared::GetNativeImageDataFormat();
27 PP_Bool IsImageDataFormatSupported(PP_ImageDataFormat format) {
28 VLOG(4) << "PPB_ImageData::IsImageDataFormatSupported()";
29 return PPB_ImageData_Shared::IsImageDataFormatSupported(format);
32 PP_Resource Create(PP_Instance instance,
33 PP_ImageDataFormat format,
34 const struct PP_Size* size,
35 PP_Bool init_to_zero) {
36 VLOG(4) << "PPB_ImageData::Create()";
37 EnterResourceCreation enter(instance);
38 if (enter.failed())
39 return 0;
40 return enter.functions()->CreateImageData(instance, format, size,
41 init_to_zero);
44 PP_Bool IsImageData(PP_Resource image_data) {
45 VLOG(4) << "PPB_ImageData::IsImageData()";
46 EnterResource<PPB_ImageData_API> enter(image_data, false);
47 return PP_FromBool(enter.succeeded());
50 PP_Bool Describe(PP_Resource image_data, struct PP_ImageDataDesc* desc) {
51 VLOG(4) << "PPB_ImageData::Describe()";
52 EnterResource<PPB_ImageData_API> enter(image_data, true);
53 if (enter.failed()) {
54 memset(desc, 0, sizeof(*desc));
55 return PP_FALSE;
57 return enter.object()->Describe(desc);
60 void* Map(PP_Resource image_data) {
61 VLOG(4) << "PPB_ImageData::Map()";
62 EnterResource<PPB_ImageData_API> enter(image_data, true);
63 if (enter.failed())
64 return NULL;
65 return enter.object()->Map();
68 void Unmap(PP_Resource image_data) {
69 VLOG(4) << "PPB_ImageData::Unmap()";
70 EnterResource<PPB_ImageData_API> enter(image_data, true);
71 if (enter.failed())
72 return;
73 enter.object()->Unmap();
76 const PPB_ImageData_1_0 g_ppb_imagedata_thunk_1_0 = {
77 &GetNativeImageDataFormat,
78 &IsImageDataFormatSupported,
79 &Create,
80 &IsImageData,
81 &Describe,
82 &Map,
83 &Unmap};
85 } // namespace
87 PPAPI_THUNK_EXPORT const PPB_ImageData_1_0* GetPPB_ImageData_1_0_Thunk() {
88 return &g_ppb_imagedata_thunk_1_0;
91 } // namespace thunk
92 } // namespace ppapi