1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// 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.
#include "webkit/plugins/ppapi/ppb_widget_impl.h"
#include "ppapi/c/dev/ppp_widget_dev.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_input_event_api.h"
#include "ppapi/thunk/ppb_widget_api.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"
#include "webkit/plugins/ppapi/resource_helper.h"
using ppapi::thunk::EnterResourceNoLock;
using ppapi::thunk::PPB_ImageData_API;
using ppapi::thunk::PPB_InputEvent_API;
using ppapi::thunk::PPB_Widget_API;
namespace webkit {
namespace ppapi {
PPB_Widget_Impl::PPB_Widget_Impl(PP_Instance instance)
: Resource(::ppapi::OBJECT_IS_IMPL, instance),
scale_(1.0f) {
memset(&location_, 0, sizeof(location_));
}
PPB_Widget_Impl::~PPB_Widget_Impl() {
}
PPB_Widget_API* PPB_Widget_Impl::AsPPB_Widget_API() {
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()));
}
PP_Bool PPB_Widget_Impl::HandleEvent(PP_Resource pp_input_event) {
EnterResourceNoLock<PPB_InputEvent_API> enter(pp_input_event, true);
if (enter.failed())
return PP_FALSE;
return HandleEventInternal(enter.object()->GetInputEventData());
}
PP_Bool PPB_Widget_Impl::GetLocation(PP_Rect* location) {
*location = location_;
return PP_TRUE;
}
void PPB_Widget_Impl::SetLocation(const PP_Rect* location) {
location_ = *location;
SetLocationInternal(location);
}
void PPB_Widget_Impl::SetScale(float scale) {
scale_ = scale;
}
void PPB_Widget_Impl::Invalidate(const PP_Rect* dirty) {
PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
if (!plugin_instance)
return;
const PPP_Widget_Dev* widget = static_cast<const PPP_Widget_Dev*>(
plugin_instance->module()->GetPluginInterface(PPP_WIDGET_DEV_INTERFACE));
if (!widget)
return;
widget->Invalidate(pp_instance(), pp_resource(), dirty);
}
} // namespace ppapi
} // namespace webkit
|