Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: ppapi/thunk/ppb_image_data_thunk.cc

Issue 6905088: New thunk system for Pepper proxy and implementation (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 #include "ppapi/c/pp_errors.h"
6 #include "ppapi/c/ppb_image_data.h"
7 #include "ppapi/shared_impl/image_data_impl.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
12 namespace ppapi {
13 namespace thunk {
14
15 namespace {
16
17 PP_ImageDataFormat GetNativeImageDataFormat() {
18 return shared_impl::ImageDataImpl::GetNativeImageDataFormat();
19 }
20
21 PP_Bool IsImageDataFormatSupported(PP_ImageDataFormat format) {
22 return shared_impl::ImageDataImpl::IsImageDataFormatSupported(format);
23 }
24
25 PP_Resource Create(PP_Instance instance,
26 PP_ImageDataFormat format,
27 const PP_Size* size,
28 PP_Bool init_to_zero) {
29 EnterFunction<ResourceCreationAPI> enter(instance, true);
30 if (enter.failed())
31 return 0;
32 return enter.functions()->CreateImageData(instance, format,
33 *size, init_to_zero);
34 }
35
36 PP_Bool IsImageData(PP_Resource resource) {
37 EnterResource<PPB_ImageData_API> enter(resource, false);
38 return enter.succeeded() ? PP_TRUE : PP_FALSE;
39 }
40
41 PP_Bool Describe(PP_Resource resource, PP_ImageDataDesc* desc) {
42 // Give predictable values on failure.
43 memset(desc, 0, sizeof(PP_ImageDataDesc));
44
45 EnterResource<PPB_ImageData_API> enter(resource, true);
46 if (enter.failed())
47 return PP_FALSE;
48 return enter.object()->Describe(desc);
49 }
50
51 void* Map(PP_Resource resource) {
52 EnterResource<PPB_ImageData_API> enter(resource, true);
53 if (enter.failed())
54 return NULL;
55 return enter.object()->Map();
56 }
57
58 void Unmap(PP_Resource resource) {
59 EnterResource<PPB_ImageData_API> enter(resource, true);
60 if (enter.failed())
61 return;
62 enter.object()->Unmap();
63 }
64
65 const PPB_ImageData g_ppb_image_data_thunk = {
66 &GetNativeImageDataFormat,
67 &IsImageDataFormatSupported,
68 &Create,
69 &IsImageData,
70 &Describe,
71 &Map,
72 &Unmap,
73 };
74
75 } // namespace
76
77 const PPB_ImageData* GetPPB_ImageData_Thunk() {
78 return &g_ppb_image_data_thunk;
79 }
80
81 } // namespace thunk
82 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698