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" | 7 #include "ppapi/thunk/ppb_context_3d_api.h" |
| 8 #include "ppapi/thunk/ppb_graphics_3d_api.h" |
8 #include "ppapi/thunk/resource_creation_api.h" | 9 #include "ppapi/thunk/resource_creation_api.h" |
9 | 10 |
10 namespace ppapi { | 11 namespace ppapi { |
11 namespace thunk { | 12 namespace thunk { |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 typedef EnterResource<PPB_Context3D_API> EnterContext3D; | 16 typedef EnterResource<PPB_Context3D_API> EnterContext3D; |
| 17 typedef EnterResource<PPB_Graphics3D_API> EnterGraphics3D; |
16 | 18 |
17 void* MapTexSubImage2DCHROMIUM(PP_Resource context, | 19 void* MapTexSubImage2DCHROMIUM(PP_Resource context, |
18 GLenum target, | 20 GLenum target, |
19 GLint level, | 21 GLint level, |
20 GLint xoffset, | 22 GLint xoffset, |
21 GLint yoffset, | 23 GLint yoffset, |
22 GLsizei width, | 24 GLsizei width, |
23 GLsizei height, | 25 GLsizei height, |
24 GLenum format, | 26 GLenum format, |
25 GLenum type, | 27 GLenum type, |
26 GLenum access) { | 28 GLenum access) { |
27 EnterContext3D enter(context, true); | 29 { |
28 if (enter.failed()) | 30 EnterContext3D enter(context, false); |
29 return NULL; | 31 if (enter.succeeded()) { |
30 return enter.object()->MapTexSubImage2DCHROMIUM( | 32 return enter.object()->MapTexSubImage2DCHROMIUM( |
31 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 } |
| 43 return NULL; |
32 } | 44 } |
33 | 45 |
34 void UnmapTexSubImage2DCHROMIUM(PP_Resource context, const void* mem) { | 46 void UnmapTexSubImage2DCHROMIUM(PP_Resource context, const void* mem) { |
35 EnterContext3D enter(context, true); | 47 { |
36 if (enter.succeeded()) | 48 EnterContext3D enter(context, false); |
37 enter.object()->UnmapTexSubImage2DCHROMIUM(mem); | 49 if (enter.succeeded()) { |
| 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 } |
38 } | 61 } |
39 | 62 |
40 const PPB_GLESChromiumTextureMapping_Dev | 63 const PPB_GLESChromiumTextureMapping_Dev |
41 g_ppb_gles_chromium_texture_mapping_thunk = { | 64 g_ppb_gles_chromium_texture_mapping_thunk = { |
42 &MapTexSubImage2DCHROMIUM, | 65 &MapTexSubImage2DCHROMIUM, |
43 &UnmapTexSubImage2DCHROMIUM | 66 &UnmapTexSubImage2DCHROMIUM |
44 }; | 67 }; |
45 | 68 |
46 } // namespace | 69 } // namespace |
47 | 70 |
48 const PPB_GLESChromiumTextureMapping_Dev* | 71 const PPB_GLESChromiumTextureMapping_Dev* |
49 GetPPB_GLESChromiumTextureMapping_Thunk() { | 72 GetPPB_GLESChromiumTextureMapping_Thunk() { |
50 return &g_ppb_gles_chromium_texture_mapping_thunk; | 73 return &g_ppb_gles_chromium_texture_mapping_thunk; |
51 } | 74 } |
52 | 75 |
53 } // namespace thunk | 76 } // namespace thunk |
54 } // namespace ppapi | 77 } // namespace ppapi |
OLD | NEW |