| 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/dev/ppb_graphics_2d_dev.h" | 5 // From ppb_graphics_2d.idl modified Fri Apr 26 08:49:08 2013. |
| 6 |
| 7 #include <string.h> |
| 8 |
| 6 #include "ppapi/c/pp_completion_callback.h" | 9 #include "ppapi/c/pp_completion_callback.h" |
| 7 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/c/ppb_graphics_2d.h" | 11 #include "ppapi/c/ppb_graphics_2d.h" |
| 9 #include "ppapi/shared_impl/tracked_callback.h" | 12 #include "ppapi/shared_impl/tracked_callback.h" |
| 10 #include "ppapi/thunk/enter.h" | 13 #include "ppapi/thunk/enter.h" |
| 11 #include "ppapi/thunk/ppb_graphics_2d_api.h" | 14 #include "ppapi/thunk/ppb_graphics_2d_api.h" |
| 15 #include "ppapi/thunk/ppb_instance_api.h" |
| 12 #include "ppapi/thunk/resource_creation_api.h" | 16 #include "ppapi/thunk/resource_creation_api.h" |
| 13 #include "ppapi/thunk/thunk.h" | 17 #include "ppapi/thunk/thunk.h" |
| 14 | 18 |
| 15 namespace ppapi { | 19 namespace ppapi { |
| 16 namespace thunk { | 20 namespace thunk { |
| 17 | 21 |
| 18 namespace { | 22 namespace { |
| 19 | 23 |
| 20 typedef EnterResource<PPB_Graphics2D_API> EnterGraphics2D; | |
| 21 | |
| 22 PP_Resource Create(PP_Instance instance, | 24 PP_Resource Create(PP_Instance instance, |
| 23 const PP_Size* size, | 25 const struct PP_Size* size, |
| 24 PP_Bool is_always_opaque) { | 26 PP_Bool is_always_opaque) { |
| 27 VLOG(4) << "PPB_Graphics2D::Create()"; |
| 25 EnterResourceCreation enter(instance); | 28 EnterResourceCreation enter(instance); |
| 26 if (enter.failed()) | 29 if (enter.failed()) |
| 27 return 0; | 30 return 0; |
| 28 return enter.functions()->CreateGraphics2D(instance, *size, is_always_opaque); | 31 return enter.functions()->CreateGraphics2D(instance, size, is_always_opaque); |
| 29 } | 32 } |
| 30 | 33 |
| 31 PP_Bool IsGraphics2D(PP_Resource resource) { | 34 PP_Bool IsGraphics2D(PP_Resource resource) { |
| 32 EnterGraphics2D enter(resource, false); | 35 VLOG(4) << "PPB_Graphics2D::IsGraphics2D()"; |
| 33 return enter.succeeded() ? PP_TRUE : PP_FALSE; | 36 EnterResource<PPB_Graphics2D_API> enter(resource, false); |
| 37 return PP_FromBool(enter.succeeded()); |
| 34 } | 38 } |
| 35 | 39 |
| 36 PP_Bool Describe(PP_Resource graphics_2d, | 40 PP_Bool Describe(PP_Resource graphics_2d, |
| 37 PP_Size* size, | 41 struct PP_Size* size, |
| 38 PP_Bool* is_always_opaque) { | 42 PP_Bool* is_always_opaque) { |
| 39 EnterGraphics2D enter(graphics_2d, true); | 43 VLOG(4) << "PPB_Graphics2D::Describe()"; |
| 44 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true); |
| 40 if (enter.failed()) { | 45 if (enter.failed()) { |
| 41 size->width = 0; | 46 memset(size, 0, sizeof(*size)); |
| 42 size->height = 0; | 47 memset(is_always_opaque, 0, sizeof(*is_always_opaque)); |
| 43 *is_always_opaque = PP_FALSE; | |
| 44 return PP_FALSE; | 48 return PP_FALSE; |
| 45 } | 49 } |
| 46 return enter.object()->Describe(size, is_always_opaque); | 50 return enter.object()->Describe(size, is_always_opaque); |
| 47 } | 51 } |
| 48 | 52 |
| 49 void PaintImageData(PP_Resource graphics_2d, | 53 void PaintImageData(PP_Resource graphics_2d, |
| 50 PP_Resource image_data, | 54 PP_Resource image_data, |
| 51 const PP_Point* top_left, | 55 const struct PP_Point* top_left, |
| 52 const PP_Rect* src_rect) { | 56 const struct PP_Rect* src_rect) { |
| 53 EnterGraphics2D enter(graphics_2d, true); | 57 VLOG(4) << "PPB_Graphics2D::PaintImageData()"; |
| 58 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true); |
| 54 if (enter.failed()) | 59 if (enter.failed()) |
| 55 return; | 60 return; |
| 56 enter.object()->PaintImageData(image_data, top_left, src_rect); | 61 enter.object()->PaintImageData(image_data, top_left, src_rect); |
| 57 } | 62 } |
| 58 | 63 |
| 59 void Scroll(PP_Resource graphics_2d, | 64 void Scroll(PP_Resource graphics_2d, |
| 60 const PP_Rect* clip_rect, | 65 const struct PP_Rect* clip_rect, |
| 61 const PP_Point* amount) { | 66 const struct PP_Point* amount) { |
| 62 EnterGraphics2D enter(graphics_2d, true); | 67 VLOG(4) << "PPB_Graphics2D::Scroll()"; |
| 68 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true); |
| 63 if (enter.failed()) | 69 if (enter.failed()) |
| 64 return; | 70 return; |
| 65 enter.object()->Scroll(clip_rect, amount); | 71 enter.object()->Scroll(clip_rect, amount); |
| 66 } | 72 } |
| 67 | 73 |
| 68 void ReplaceContents(PP_Resource graphics_2d, PP_Resource image_data) { | 74 void ReplaceContents(PP_Resource graphics_2d, PP_Resource image_data) { |
| 69 EnterGraphics2D enter(graphics_2d, true); | 75 VLOG(4) << "PPB_Graphics2D::ReplaceContents()"; |
| 76 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true); |
| 70 if (enter.failed()) | 77 if (enter.failed()) |
| 71 return; | 78 return; |
| 72 enter.object()->ReplaceContents(image_data); | 79 enter.object()->ReplaceContents(image_data); |
| 73 } | 80 } |
| 74 | 81 |
| 75 int32_t Flush(PP_Resource graphics_2d, PP_CompletionCallback callback) { | 82 int32_t Flush(PP_Resource graphics_2d, struct PP_CompletionCallback callback) { |
| 76 EnterGraphics2D enter(graphics_2d, callback, true); | 83 VLOG(4) << "PPB_Graphics2D::Flush()"; |
| 84 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, callback, true); |
| 77 if (enter.failed()) | 85 if (enter.failed()) |
| 78 return enter.retval(); | 86 return enter.retval(); |
| 79 return enter.SetResult(enter.object()->Flush(enter.callback(), NULL)); | 87 return enter.SetResult(enter.object()->Flush(enter.callback())); |
| 80 } | 88 } |
| 81 | 89 |
| 82 PP_Bool SetScale(PP_Resource graphics_2d, float scale) { | 90 PP_Bool SetScale(PP_Resource resource, float scale) { |
| 83 EnterGraphics2D enter(graphics_2d, true); | 91 VLOG(4) << "PPB_Graphics2D::SetScale()"; |
| 92 EnterResource<PPB_Graphics2D_API> enter(resource, true); |
| 84 if (enter.failed()) | 93 if (enter.failed()) |
| 85 return PP_FALSE; | 94 return PP_FALSE; |
| 86 return PP_FromBool(enter.object()->SetScale(scale)); | 95 return enter.object()->SetScale(scale); |
| 87 } | 96 } |
| 88 | 97 |
| 89 float GetScale(PP_Resource graphics_2d) { | 98 float GetScale(PP_Resource resource) { |
| 90 EnterGraphics2D enter(graphics_2d, true); | 99 VLOG(4) << "PPB_Graphics2D::GetScale()"; |
| 100 EnterResource<PPB_Graphics2D_API> enter(resource, true); |
| 91 if (enter.failed()) | 101 if (enter.failed()) |
| 92 return 0.0f; | 102 return 0.0f; |
| 93 return enter.object()->GetScale(); | 103 return enter.object()->GetScale(); |
| 94 } | 104 } |
| 95 | 105 |
| 96 const PPB_Graphics2D_1_0 g_ppb_graphics_2d_1_0_thunk = { | 106 const PPB_Graphics2D_1_0 g_ppb_graphics2d_thunk_1_0 = { |
| 97 &Create, | 107 &Create, |
| 98 &IsGraphics2D, | 108 &IsGraphics2D, |
| 99 &Describe, | 109 &Describe, |
| 100 &PaintImageData, | 110 &PaintImageData, |
| 101 &Scroll, | 111 &Scroll, |
| 102 &ReplaceContents, | 112 &ReplaceContents, |
| 103 &Flush | 113 &Flush |
| 104 }; | 114 }; |
| 105 | 115 |
| 106 const PPB_Graphics2D_1_1 g_ppb_graphics_2d_1_1_thunk = { | 116 const PPB_Graphics2D_1_1 g_ppb_graphics2d_thunk_1_1 = { |
| 107 &Create, | 117 &Create, |
| 108 &IsGraphics2D, | 118 &IsGraphics2D, |
| 109 &Describe, | 119 &Describe, |
| 110 &PaintImageData, | 120 &PaintImageData, |
| 111 &Scroll, | 121 &Scroll, |
| 112 &ReplaceContents, | 122 &ReplaceContents, |
| 113 &Flush, | 123 &Flush, |
| 114 &SetScale, | 124 &SetScale, |
| 115 &GetScale | 125 &GetScale |
| 116 }; | 126 }; |
| 117 | 127 |
| 118 const PPB_Graphics2D_Dev g_ppb_graphics_2d_dev_thunk = { | |
| 119 &SetScale, | |
| 120 &GetScale | |
| 121 }; | |
| 122 | |
| 123 } // namespace | 128 } // namespace |
| 124 | 129 |
| 125 const PPB_Graphics2D_1_0* GetPPB_Graphics2D_1_0_Thunk() { | 130 const PPB_Graphics2D_1_0* GetPPB_Graphics2D_1_0_Thunk() { |
| 126 return &g_ppb_graphics_2d_1_0_thunk; | 131 return &g_ppb_graphics2d_thunk_1_0; |
| 127 } | 132 } |
| 128 | 133 |
| 129 const PPB_Graphics2D_1_1* GetPPB_Graphics2D_1_1_Thunk() { | 134 const PPB_Graphics2D_1_1* GetPPB_Graphics2D_1_1_Thunk() { |
| 130 return &g_ppb_graphics_2d_1_1_thunk; | 135 return &g_ppb_graphics2d_thunk_1_1; |
| 131 } | |
| 132 | |
| 133 const PPB_Graphics2D_Dev_0_1* GetPPB_Graphics2D_Dev_0_1_Thunk() { | |
| 134 return &g_ppb_graphics_2d_dev_thunk; | |
| 135 } | 136 } |
| 136 | 137 |
| 137 } // namespace thunk | 138 } // namespace thunk |
| 138 } // namespace ppapi | 139 } // namespace ppapi |
| OLD | NEW |