diff options
author | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-30 18:12:49 +0000 |
---|---|---|
committer | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-30 18:12:49 +0000 |
commit | de059facfbe5010fb882952d31d056d739e9f4f0 (patch) | |
tree | e21a6b88d3b78cf0dbc36941b4f841453f017e1b /ppapi/thunk | |
parent | d093fe8b399a72855e3e6e97146d41823c1b75bf (diff) | |
download | chromium_src-de059facfbe5010fb882952d31d056d739e9f4f0.zip chromium_src-de059facfbe5010fb882952d31d056d739e9f4f0.tar.gz chromium_src-de059facfbe5010fb882952d31d056d739e9f4f0.tar.bz2 |
Pepper: Autogenerate thunk for PPB_Graphics2D.
This change fixes a typo in the IDL, and cleans up the API a little bit so we
can generate a thunk for it. The implementation in webkit is vestigal and was removed.
Tested:
browser_tests --gtest_filter="*Graphics2D*"
BUG=
Review URL: https://chromiumcodereview.appspot.com/14335005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197409 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk')
-rw-r--r-- | ppapi/thunk/ppb_graphics_2d_api.h | 17 | ||||
-rw-r--r-- | ppapi/thunk/ppb_graphics_2d_dev_thunk.cc | 49 | ||||
-rw-r--r-- | ppapi/thunk/ppb_graphics_2d_thunk.cc | 81 | ||||
-rw-r--r-- | ppapi/thunk/resource_creation_api.h | 2 |
4 files changed, 95 insertions, 54 deletions
diff --git a/ppapi/thunk/ppb_graphics_2d_api.h b/ppapi/thunk/ppb_graphics_2d_api.h index e6357c3..4e1bda3 100644 --- a/ppapi/thunk/ppb_graphics_2d_api.h +++ b/ppapi/thunk/ppb_graphics_2d_api.h @@ -31,20 +31,11 @@ class PPAPI_THUNK_EXPORT PPB_Graphics2D_API { virtual void Scroll(const PP_Rect* clip_rect, const PP_Point* amount) = 0; virtual void ReplaceContents(PP_Resource image_data) = 0; - virtual bool SetScale(float scale) = 0; - virtual float GetScale() = 0; + virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) = 0; - // When |old_image_data| is non-null and the flush is executing a replace - // contents (which leaves the "old" ImageData unowned), the resource ID of - // the old image data will be placed into |*old_image_data| synchronously - // (not when the flush callback completes). - // - // When this happens, a reference to this resource will be transferred to the - // caller. If there is no replace contents operation, old_image_data will be - // ignored. If |*old_image_data| is null, then the old image data will be - // destroyed if there was one. - virtual int32_t Flush(scoped_refptr<TrackedCallback> callback, - PP_Resource* old_image_data) = 0; + // Dev interface. + virtual PP_Bool SetScale(float scale) = 0; + virtual float GetScale() = 0; // Test only virtual bool ReadImageData(PP_Resource image, const PP_Point* top_left) = 0; diff --git a/ppapi/thunk/ppb_graphics_2d_dev_thunk.cc b/ppapi/thunk/ppb_graphics_2d_dev_thunk.cc new file mode 100644 index 0000000..760ecee --- /dev/null +++ b/ppapi/thunk/ppb_graphics_2d_dev_thunk.cc @@ -0,0 +1,49 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// From dev/ppb_graphics_2d_dev.idl modified Fri Apr 26 08:52:02 2013. + +#include "ppapi/c/dev/ppb_graphics_2d_dev.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_graphics_2d_api.h" +#include "ppapi/thunk/ppb_instance_api.h" +#include "ppapi/thunk/resource_creation_api.h" +#include "ppapi/thunk/thunk.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Bool SetScale(PP_Resource resource, float scale) { + VLOG(4) << "PPB_Graphics2D_Dev::SetScale()"; + EnterResource<PPB_Graphics2D_API> enter(resource, true); + if (enter.failed()) + return PP_FALSE; + return enter.object()->SetScale(scale); +} + +float GetScale(PP_Resource resource) { + VLOG(4) << "PPB_Graphics2D_Dev::GetScale()"; + EnterResource<PPB_Graphics2D_API> enter(resource, true); + if (enter.failed()) + return 0.0f; + return enter.object()->GetScale(); +} + +const PPB_Graphics2D_Dev_0_1 g_ppb_graphics2d_dev_thunk_0_1 = { + &SetScale, + &GetScale +}; + +} // namespace + +const PPB_Graphics2D_Dev_0_1* GetPPB_Graphics2D_Dev_0_1_Thunk() { + return &g_ppb_graphics2d_dev_thunk_0_1; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_graphics_2d_thunk.cc b/ppapi/thunk/ppb_graphics_2d_thunk.cc index 073129d..9eefee2 100644 --- a/ppapi/thunk/ppb_graphics_2d_thunk.cc +++ b/ppapi/thunk/ppb_graphics_2d_thunk.cc @@ -2,13 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ppapi/c/dev/ppb_graphics_2d_dev.h" +// From ppb_graphics_2d.idl modified Fri Apr 26 08:49:08 2013. + +#include <string.h> + #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_graphics_2d.h" #include "ppapi/shared_impl/tracked_callback.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_graphics_2d_api.h" +#include "ppapi/thunk/ppb_instance_api.h" #include "ppapi/thunk/resource_creation_api.h" #include "ppapi/thunk/thunk.h" @@ -17,30 +21,30 @@ namespace thunk { namespace { -typedef EnterResource<PPB_Graphics2D_API> EnterGraphics2D; - PP_Resource Create(PP_Instance instance, - const PP_Size* size, + const struct PP_Size* size, PP_Bool is_always_opaque) { + VLOG(4) << "PPB_Graphics2D::Create()"; EnterResourceCreation enter(instance); if (enter.failed()) return 0; - return enter.functions()->CreateGraphics2D(instance, *size, is_always_opaque); + return enter.functions()->CreateGraphics2D(instance, size, is_always_opaque); } PP_Bool IsGraphics2D(PP_Resource resource) { - EnterGraphics2D enter(resource, false); - return enter.succeeded() ? PP_TRUE : PP_FALSE; + VLOG(4) << "PPB_Graphics2D::IsGraphics2D()"; + EnterResource<PPB_Graphics2D_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); } PP_Bool Describe(PP_Resource graphics_2d, - PP_Size* size, + struct PP_Size* size, PP_Bool* is_always_opaque) { - EnterGraphics2D enter(graphics_2d, true); + VLOG(4) << "PPB_Graphics2D::Describe()"; + EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true); if (enter.failed()) { - size->width = 0; - size->height = 0; - *is_always_opaque = PP_FALSE; + memset(size, 0, sizeof(*size)); + memset(is_always_opaque, 0, sizeof(*is_always_opaque)); return PP_FALSE; } return enter.object()->Describe(size, is_always_opaque); @@ -48,52 +52,58 @@ PP_Bool Describe(PP_Resource graphics_2d, void PaintImageData(PP_Resource graphics_2d, PP_Resource image_data, - const PP_Point* top_left, - const PP_Rect* src_rect) { - EnterGraphics2D enter(graphics_2d, true); + const struct PP_Point* top_left, + const struct PP_Rect* src_rect) { + VLOG(4) << "PPB_Graphics2D::PaintImageData()"; + EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true); if (enter.failed()) return; enter.object()->PaintImageData(image_data, top_left, src_rect); } void Scroll(PP_Resource graphics_2d, - const PP_Rect* clip_rect, - const PP_Point* amount) { - EnterGraphics2D enter(graphics_2d, true); + const struct PP_Rect* clip_rect, + const struct PP_Point* amount) { + VLOG(4) << "PPB_Graphics2D::Scroll()"; + EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true); if (enter.failed()) return; enter.object()->Scroll(clip_rect, amount); } void ReplaceContents(PP_Resource graphics_2d, PP_Resource image_data) { - EnterGraphics2D enter(graphics_2d, true); + VLOG(4) << "PPB_Graphics2D::ReplaceContents()"; + EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true); if (enter.failed()) return; enter.object()->ReplaceContents(image_data); } -int32_t Flush(PP_Resource graphics_2d, PP_CompletionCallback callback) { - EnterGraphics2D enter(graphics_2d, callback, true); +int32_t Flush(PP_Resource graphics_2d, struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_Graphics2D::Flush()"; + EnterResource<PPB_Graphics2D_API> enter(graphics_2d, callback, true); if (enter.failed()) return enter.retval(); - return enter.SetResult(enter.object()->Flush(enter.callback(), NULL)); + return enter.SetResult(enter.object()->Flush(enter.callback())); } -PP_Bool SetScale(PP_Resource graphics_2d, float scale) { - EnterGraphics2D enter(graphics_2d, true); +PP_Bool SetScale(PP_Resource resource, float scale) { + VLOG(4) << "PPB_Graphics2D::SetScale()"; + EnterResource<PPB_Graphics2D_API> enter(resource, true); if (enter.failed()) return PP_FALSE; - return PP_FromBool(enter.object()->SetScale(scale)); + return enter.object()->SetScale(scale); } -float GetScale(PP_Resource graphics_2d) { - EnterGraphics2D enter(graphics_2d, true); +float GetScale(PP_Resource resource) { + VLOG(4) << "PPB_Graphics2D::GetScale()"; + EnterResource<PPB_Graphics2D_API> enter(resource, true); if (enter.failed()) return 0.0f; return enter.object()->GetScale(); } -const PPB_Graphics2D_1_0 g_ppb_graphics_2d_1_0_thunk = { +const PPB_Graphics2D_1_0 g_ppb_graphics2d_thunk_1_0 = { &Create, &IsGraphics2D, &Describe, @@ -103,7 +113,7 @@ const PPB_Graphics2D_1_0 g_ppb_graphics_2d_1_0_thunk = { &Flush }; -const PPB_Graphics2D_1_1 g_ppb_graphics_2d_1_1_thunk = { +const PPB_Graphics2D_1_1 g_ppb_graphics2d_thunk_1_1 = { &Create, &IsGraphics2D, &Describe, @@ -115,23 +125,14 @@ const PPB_Graphics2D_1_1 g_ppb_graphics_2d_1_1_thunk = { &GetScale }; -const PPB_Graphics2D_Dev g_ppb_graphics_2d_dev_thunk = { - &SetScale, - &GetScale -}; - } // namespace const PPB_Graphics2D_1_0* GetPPB_Graphics2D_1_0_Thunk() { - return &g_ppb_graphics_2d_1_0_thunk; + return &g_ppb_graphics2d_thunk_1_0; } const PPB_Graphics2D_1_1* GetPPB_Graphics2D_1_1_Thunk() { - return &g_ppb_graphics_2d_1_1_thunk; -} - -const PPB_Graphics2D_Dev_0_1* GetPPB_Graphics2D_Dev_0_1_Thunk() { - return &g_ppb_graphics_2d_dev_thunk; + return &g_ppb_graphics2d_thunk_1_1; } } // namespace thunk diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index 1a4713e..0581239 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -119,7 +119,7 @@ class ResourceCreationAPI { PP_FileChooserMode_Dev mode, const PP_Var& accept_types) = 0; virtual PP_Resource CreateGraphics2D(PP_Instance instance, - const PP_Size& size, + const PP_Size* size, PP_Bool is_always_opaque) = 0; virtual PP_Resource CreateGraphics3D(PP_Instance instance, PP_Resource share_context, |