diff options
Diffstat (limited to 'mojo/examples/pepper_container_app')
-rw-r--r-- | mojo/examples/pepper_container_app/pepper_container_app.cc | 25 | ||||
-rw-r--r-- | mojo/examples/pepper_container_app/type_converters.h | 70 |
2 files changed, 46 insertions, 49 deletions
diff --git a/mojo/examples/pepper_container_app/pepper_container_app.cc b/mojo/examples/pepper_container_app/pepper_container_app.cc index 33c03d5..8d8b4e9 100644 --- a/mojo/examples/pepper_container_app/pepper_container_app.cc +++ b/mojo/examples/pepper_container_app/pepper_container_app.cc @@ -12,7 +12,6 @@ #include "mojo/examples/pepper_container_app/plugin_module.h" #include "mojo/examples/pepper_container_app/type_converters.h" #include "mojo/public/cpp/application/application.h" -#include "mojo/public/cpp/bindings/allocation_scope.h" #include "mojo/public/cpp/gles2/gles2.h" #include "mojo/public/cpp/system/core.h" #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" @@ -34,18 +33,16 @@ class PepperContainerApp: public Application, virtual ~PepperContainerApp() {} - virtual void Initialize() MOJO_OVERRIDE { - mojo::AllocationScope scope; - + virtual void Initialize() MOJO_OVERRIDE { ConnectTo("mojo:mojo_native_viewport_service", &viewport_); viewport_.set_client(this); - Rect::Builder rect; - rect.set_x(10); - rect.set_y(10); - rect.set_width(800); - rect.set_height(600); - viewport_->Create(rect.Finish()); + RectPtr rect(Rect::New()); + rect->x = 10; + rect->y = 10; + rect->width = 800; + rect->height = 600; + viewport_->Create(rect.Pass()); viewport_->Show(); } @@ -69,16 +66,16 @@ class PepperContainerApp: public Application, base::MessageLoop::current()->Quit(); } - virtual void OnBoundsChanged(const Rect& bounds) OVERRIDE { + virtual void OnBoundsChanged(RectPtr bounds) OVERRIDE { ppapi::ProxyAutoLock lock; if (plugin_instance_) - plugin_instance_->DidChangeView(bounds); + plugin_instance_->DidChangeView(bounds.To<PP_Rect>()); } - virtual void OnEvent(const Event& event, + virtual void OnEvent(EventPtr event, const mojo::Callback<void()>& callback) OVERRIDE { - if (!event.location().is_null()) { + if (!event->location.is_null()) { ppapi::ProxyAutoLock lock; // TODO(yzshen): Handle events. diff --git a/mojo/examples/pepper_container_app/type_converters.h b/mojo/examples/pepper_container_app/type_converters.h index fc4c113..cfb5c02 100644 --- a/mojo/examples/pepper_container_app/type_converters.h +++ b/mojo/examples/pepper_container_app/type_converters.h @@ -14,59 +14,59 @@ namespace mojo { template <> -class TypeConverter<Point, PP_Point> { +class TypeConverter<PointPtr, PP_Point> { public: - static Point ConvertFrom(const PP_Point& input, Buffer* buf) { - Point::Builder point(buf); - point.set_x(input.x); - point.set_y(input.y); - return point.Finish(); + static PointPtr ConvertFrom(const PP_Point& input) { + PointPtr point(Point::New()); + point->x = input.x; + point->y = input.y; + return point.Pass(); } - static PP_Point ConvertTo(const Point& input) { - return PP_MakePoint(static_cast<int32_t>(input.x()), - static_cast<int32_t>(input.y())); + static PP_Point ConvertTo(const PointPtr& input) { + if (!input) + return PP_MakePoint(0, 0); + return PP_MakePoint(static_cast<int32_t>(input->x), + static_cast<int32_t>(input->y)); } - - MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION(); }; template <> -class TypeConverter<Size, PP_Size> { +class TypeConverter<SizePtr, PP_Size> { public: - static Size ConvertFrom(const PP_Size& input, Buffer* buf) { - Size::Builder size(buf); - size.set_width(input.width); - size.set_height(input.height); - return size.Finish(); + static SizePtr ConvertFrom(const PP_Size& input) { + SizePtr size(Size::New()); + size->width = input.width; + size->height = input.height; + return size.Pass(); } - static PP_Size ConvertTo(const Size& input) { - return PP_MakeSize(static_cast<int32_t>(input.width()), - static_cast<int32_t>(input.height())); + static PP_Size ConvertTo(const SizePtr& input) { + if (!input) + return PP_MakeSize(0, 0); + return PP_MakeSize(static_cast<int32_t>(input->width), + static_cast<int32_t>(input->height)); } - - MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION(); }; template <> -class TypeConverter<Rect, PP_Rect> { +class TypeConverter<RectPtr, PP_Rect> { public: - static Rect ConvertFrom(const PP_Rect& input, Buffer* buf) { - Rect::Builder rect(buf); - rect.set_x(input.point.x); - rect.set_y(input.point.y); - rect.set_width(input.size.width); - rect.set_height(input.size.height); - return rect.Finish(); + static RectPtr ConvertFrom(const PP_Rect& input) { + RectPtr rect(Rect::New()); + rect->x = input.point.x; + rect->y = input.point.y; + rect->width = input.size.width; + rect->height = input.size.height; + return rect.Pass(); } - static PP_Rect ConvertTo(const Rect& input) { - return PP_MakeRectFromXYWH(input.x(), input.y(), - input.width(), input.height()); + static PP_Rect ConvertTo(const RectPtr& input) { + if (!input) + return PP_MakeRectFromXYWH(0, 0, 0, 0); + return PP_MakeRectFromXYWH(input->x, input->y, + input->width, input->height); } - - MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION(); }; } // namespace mojo |