OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/thunk/thunk.h" | 5 #include "ppapi/thunk/thunk.h" |
6 #include "ppapi/thunk/enter.h" | 6 #include "ppapi/thunk/enter.h" |
7 #include "ppapi/thunk/ppb_context_3d_api.h" | |
8 #include "ppapi/thunk/ppb_graphics_3d_api.h" | 7 #include "ppapi/thunk/ppb_graphics_3d_api.h" |
9 #include "ppapi/thunk/resource_creation_api.h" | 8 #include "ppapi/thunk/resource_creation_api.h" |
10 | 9 |
11 namespace ppapi { | 10 namespace ppapi { |
12 namespace thunk { | 11 namespace thunk { |
13 | 12 |
14 namespace { | 13 namespace { |
15 | 14 |
16 typedef EnterResource<PPB_Context3D_API> EnterContext3D; | |
17 typedef EnterResource<PPB_Graphics3D_API> EnterGraphics3D; | 15 typedef EnterResource<PPB_Graphics3D_API> EnterGraphics3D; |
18 | 16 |
19 void* MapTexSubImage2DCHROMIUM(PP_Resource context, | 17 void* MapTexSubImage2DCHROMIUM(PP_Resource context, |
20 GLenum target, | 18 GLenum target, |
21 GLint level, | 19 GLint level, |
22 GLint xoffset, | 20 GLint xoffset, |
23 GLint yoffset, | 21 GLint yoffset, |
24 GLsizei width, | 22 GLsizei width, |
25 GLsizei height, | 23 GLsizei height, |
26 GLenum format, | 24 GLenum format, |
27 GLenum type, | 25 GLenum type, |
28 GLenum access) { | 26 GLenum access) { |
29 { | 27 EnterGraphics3D enter(context, true); |
30 EnterContext3D enter(context, false); | 28 if (enter.succeeded()) { |
31 if (enter.succeeded()) { | 29 return enter.object()->MapTexSubImage2DCHROMIUM( |
32 return enter.object()->MapTexSubImage2DCHROMIUM( | 30 target, level, xoffset, yoffset, width, height, format, type, access); |
33 target, level, xoffset, yoffset, width, height, format, type, access); | |
34 } | |
35 } | |
36 { | |
37 EnterGraphics3D enter(context, true); | |
38 if (enter.succeeded()) { | |
39 return enter.object()->MapTexSubImage2DCHROMIUM( | |
40 target, level, xoffset, yoffset, width, height, format, type, access); | |
41 } | |
42 } | 31 } |
43 return NULL; | 32 return NULL; |
44 } | 33 } |
45 | 34 |
46 void UnmapTexSubImage2DCHROMIUM(PP_Resource context, const void* mem) { | 35 void UnmapTexSubImage2DCHROMIUM(PP_Resource context, const void* mem) { |
47 { | 36 EnterGraphics3D enter(context, true); |
48 EnterContext3D enter(context, false); | 37 if (enter.succeeded()) |
49 if (enter.succeeded()) { | 38 enter.object()->UnmapTexSubImage2DCHROMIUM(mem); |
50 enter.object()->UnmapTexSubImage2DCHROMIUM(mem); | |
51 return; | |
52 } | |
53 } | |
54 { | |
55 EnterGraphics3D enter(context, true); | |
56 if (enter.succeeded()) { | |
57 enter.object()->UnmapTexSubImage2DCHROMIUM(mem); | |
58 return; | |
59 } | |
60 } | |
61 } | 39 } |
62 | 40 |
63 const PPB_GLESChromiumTextureMapping_Dev | 41 const PPB_GLESChromiumTextureMapping_Dev |
64 g_ppb_gles_chromium_texture_mapping_thunk = { | 42 g_ppb_gles_chromium_texture_mapping_thunk = { |
65 &MapTexSubImage2DCHROMIUM, | 43 &MapTexSubImage2DCHROMIUM, |
66 &UnmapTexSubImage2DCHROMIUM | 44 &UnmapTexSubImage2DCHROMIUM |
67 }; | 45 }; |
68 | 46 |
69 } // namespace | 47 } // namespace |
70 | 48 |
71 const PPB_GLESChromiumTextureMapping_Dev* | 49 const PPB_GLESChromiumTextureMapping_Dev* |
72 GetPPB_GLESChromiumTextureMapping_Dev_Thunk() { | 50 GetPPB_GLESChromiumTextureMapping_Dev_Thunk() { |
73 return &g_ppb_gles_chromium_texture_mapping_thunk; | 51 return &g_ppb_gles_chromium_texture_mapping_thunk; |
74 } | 52 } |
75 | 53 |
76 } // namespace thunk | 54 } // namespace thunk |
77 } // namespace ppapi | 55 } // namespace ppapi |
OLD | NEW |