| Index: webkit/plugins/ppapi/ppb_widget_impl.cc
|
| ===================================================================
|
| --- webkit/plugins/ppapi/ppb_widget_impl.cc (revision 89672)
|
| +++ webkit/plugins/ppapi/ppb_widget_impl.cc (working copy)
|
| @@ -4,70 +4,19 @@
|
|
|
| #include "webkit/plugins/ppapi/ppb_widget_impl.h"
|
|
|
| -#include "base/logging.h"
|
| -#include "ppapi/c/dev/ppb_widget_dev.h"
|
| #include "ppapi/c/dev/ppp_widget_dev.h"
|
| -#include "ppapi/c/pp_completion_callback.h"
|
| -#include "ppapi/c/pp_errors.h"
|
| -#include "webkit/plugins/ppapi/common.h"
|
| +#include "ppapi/thunk/enter.h"
|
| #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
|
| #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
|
| #include "webkit/plugins/ppapi/plugin_module.h"
|
|
|
| +using ppapi::thunk::EnterResourceNoLock;
|
| +using ppapi::thunk::PPB_ImageData_API;
|
| +using ppapi::thunk::PPB_Widget_API;
|
| +
|
| namespace webkit {
|
| namespace ppapi {
|
|
|
| -namespace {
|
| -
|
| -PP_Bool IsWidget(PP_Resource resource) {
|
| - return BoolToPPBool(!!Resource::GetAs<PPB_Widget_Impl>(resource));
|
| -}
|
| -
|
| -PP_Bool Paint(PP_Resource resource,
|
| - const PP_Rect* rect,
|
| - PP_Resource image_id) {
|
| - scoped_refptr<PPB_Widget_Impl> widget(
|
| - Resource::GetAs<PPB_Widget_Impl>(resource));
|
| - if (!widget)
|
| - return PP_FALSE;
|
| -
|
| - scoped_refptr<PPB_ImageData_Impl> image(
|
| - Resource::GetAs<PPB_ImageData_Impl>(image_id));
|
| - if (!image)
|
| - return PP_FALSE;
|
| -
|
| - return BoolToPPBool(widget->Paint(rect, image));
|
| -}
|
| -
|
| -PP_Bool HandleEvent(PP_Resource resource, const PP_InputEvent* event) {
|
| - scoped_refptr<PPB_Widget_Impl> widget(
|
| - Resource::GetAs<PPB_Widget_Impl>(resource));
|
| - return BoolToPPBool(widget && widget->HandleEvent(event));
|
| -}
|
| -
|
| -PP_Bool GetLocation(PP_Resource resource, PP_Rect* location) {
|
| - scoped_refptr<PPB_Widget_Impl> widget(
|
| - Resource::GetAs<PPB_Widget_Impl>(resource));
|
| - return BoolToPPBool(widget && widget->GetLocation(location));
|
| -}
|
| -
|
| -void SetLocation(PP_Resource resource, const PP_Rect* location) {
|
| - scoped_refptr<PPB_Widget_Impl> widget(
|
| - Resource::GetAs<PPB_Widget_Impl>(resource));
|
| - if (widget)
|
| - widget->SetLocation(location);
|
| -}
|
| -
|
| -const PPB_Widget_Dev ppb_widget = {
|
| - &IsWidget,
|
| - &Paint,
|
| - &HandleEvent,
|
| - &GetLocation,
|
| - &SetLocation,
|
| -};
|
| -
|
| -} // namespace
|
| -
|
| PPB_Widget_Impl::PPB_Widget_Impl(PluginInstance* instance)
|
| : Resource(instance) {
|
| }
|
| @@ -75,18 +24,22 @@
|
| PPB_Widget_Impl::~PPB_Widget_Impl() {
|
| }
|
|
|
| -// static
|
| -const PPB_Widget_Dev* PPB_Widget_Impl::GetInterface() {
|
| - return &ppb_widget;
|
| +PPB_Widget_API* PPB_Widget_Impl::AsPPB_Widget_API() {
|
| + return this;
|
| }
|
|
|
| -PPB_Widget_Impl* PPB_Widget_Impl::AsPPB_Widget_Impl() {
|
| - return this;
|
| +PP_Bool PPB_Widget_Impl::Paint(const PP_Rect* rect, PP_Resource image_id) {
|
| + EnterResourceNoLock<PPB_ImageData_API> enter(image_id, true);
|
| + if (enter.failed())
|
| + return PP_FALSE;
|
| + return PaintInternal(gfx::Rect(rect->point.x, rect->point.y,
|
| + rect->size.width, rect->size.height),
|
| + static_cast<PPB_ImageData_Impl*>(enter.object()));
|
| }
|
|
|
| -bool PPB_Widget_Impl::GetLocation(PP_Rect* location) {
|
| +PP_Bool PPB_Widget_Impl::GetLocation(PP_Rect* location) {
|
| *location = location_;
|
| - return true;
|
| + return PP_TRUE;
|
| }
|
|
|
| void PPB_Widget_Impl::SetLocation(const PP_Rect* location) {
|
|
|