| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/c/pp_completion_callback.h" | 5 #include "ppapi/c/pp_completion_callback.h" |
| 6 #include "ppapi/c/pp_errors.h" | 6 #include "ppapi/c/pp_errors.h" |
| 7 #include "ppapi/c/ppb_graphics_2d.h" | 7 #include "ppapi/c/ppb_graphics_2d.h" |
| 8 #include "ppapi/c/private/ppb_graphics_2d_private.h" |
| 8 #include "ppapi/thunk/enter.h" | 9 #include "ppapi/thunk/enter.h" |
| 9 #include "ppapi/thunk/ppb_graphics_2d_api.h" | 10 #include "ppapi/thunk/ppb_graphics_2d_api.h" |
| 10 #include "ppapi/thunk/resource_creation_api.h" | 11 #include "ppapi/thunk/resource_creation_api.h" |
| 11 #include "ppapi/thunk/thunk.h" | 12 #include "ppapi/thunk/thunk.h" |
| 12 | 13 |
| 13 namespace ppapi { | 14 namespace ppapi { |
| 14 namespace thunk { | 15 namespace thunk { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 typedef EnterResource<PPB_Graphics2D_API> EnterGraphics2D; | 19 typedef EnterResource<PPB_Graphics2D_API> EnterGraphics2D; |
| 19 | 20 |
| 20 PP_Resource Create(PP_Instance instance, | 21 PP_Resource Create(PP_Instance instance, |
| 21 const PP_Size* size, | 22 const PP_Size* size, |
| 22 PP_Bool is_always_opaque) { | 23 PP_Bool is_always_opaque) { |
| 23 EnterResourceCreation enter(instance); | 24 EnterResourceCreation enter(instance); |
| 24 if (enter.failed()) | 25 if (enter.failed()) |
| 25 return 0; | 26 return 0; |
| 26 return enter.functions()->CreateGraphics2D(instance, *size, is_always_opaque); | 27 return enter.functions()->CreateGraphics2D(instance, |
| 28 *size, |
| 29 is_always_opaque, |
| 30 1.0f); |
| 31 } |
| 32 |
| 33 PP_Resource CreateWithScale(PP_Instance instance, |
| 34 const PP_Size* size, |
| 35 PP_Bool is_always_opaque, |
| 36 float scale) { |
| 37 EnterResourceCreation enter(instance); |
| 38 if (enter.failed()) |
| 39 return 0; |
| 40 return enter.functions()->CreateGraphics2D(instance, |
| 41 *size, |
| 42 is_always_opaque, |
| 43 scale); |
| 27 } | 44 } |
| 28 | 45 |
| 29 PP_Bool IsGraphics2D(PP_Resource resource) { | 46 PP_Bool IsGraphics2D(PP_Resource resource) { |
| 30 EnterGraphics2D enter(resource, false); | 47 EnterGraphics2D enter(resource, false); |
| 31 return enter.succeeded() ? PP_TRUE : PP_FALSE; | 48 return enter.succeeded() ? PP_TRUE : PP_FALSE; |
| 32 } | 49 } |
| 33 | 50 |
| 34 PP_Bool Describe(PP_Resource graphics_2d, | 51 PP_Bool Describe(PP_Resource graphics_2d, |
| 35 PP_Size* size, | 52 PP_Size* size, |
| 36 PP_Bool* is_always_opaque) { | 53 PP_Bool* is_always_opaque) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 const PPB_Graphics2D g_ppb_graphics_2d_thunk = { | 98 const PPB_Graphics2D g_ppb_graphics_2d_thunk = { |
| 82 &Create, | 99 &Create, |
| 83 &IsGraphics2D, | 100 &IsGraphics2D, |
| 84 &Describe, | 101 &Describe, |
| 85 &PaintImageData, | 102 &PaintImageData, |
| 86 &Scroll, | 103 &Scroll, |
| 87 &ReplaceContents, | 104 &ReplaceContents, |
| 88 &Flush | 105 &Flush |
| 89 }; | 106 }; |
| 90 | 107 |
| 108 const PPB_Graphics2D_Private g_ppb_graphics_2d_private_thunk = { |
| 109 &CreateWithScale |
| 110 }; |
| 111 |
| 91 } // namespace | 112 } // namespace |
| 92 | 113 |
| 93 const PPB_Graphics2D_1_0* GetPPB_Graphics2D_1_0_Thunk() { | 114 const PPB_Graphics2D_1_0* GetPPB_Graphics2D_1_0_Thunk() { |
| 94 return &g_ppb_graphics_2d_thunk; | 115 return &g_ppb_graphics_2d_thunk; |
| 95 } | 116 } |
| 96 | 117 |
| 118 const PPB_Graphics2D_Private_0_1* GetPPB_Graphics2D_Private_0_1_Thunk() { |
| 119 return &g_ppb_graphics_2d_private_thunk; |
| 120 } |
| 121 |
| 97 } // namespace thunk | 122 } // namespace thunk |
| 98 } // namespace ppapi | 123 } // namespace ppapi |
| OLD | NEW |