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
3 // found in the LICENSE file.
5 // From ppb_graphics_2d.idl modified Wed May 15 13:57:07 2013.
9 #include "ppapi/c/pp_completion_callback.h"
10 #include "ppapi/c/pp_errors.h"
11 #include "ppapi/c/ppb_graphics_2d.h"
12 #include "ppapi/shared_impl/tracked_callback.h"
13 #include "ppapi/thunk/enter.h"
14 #include "ppapi/thunk/ppapi_thunk_export.h"
15 #include "ppapi/thunk/ppb_graphics_2d_api.h"
22 PP_Resource
Create(PP_Instance instance
,
23 const struct PP_Size
* size
,
24 PP_Bool is_always_opaque
) {
25 VLOG(4) << "PPB_Graphics2D::Create()";
26 EnterResourceCreation
enter(instance
);
29 return enter
.functions()->CreateGraphics2D(instance
, size
, is_always_opaque
);
32 PP_Bool
IsGraphics2D(PP_Resource resource
) {
33 VLOG(4) << "PPB_Graphics2D::IsGraphics2D()";
34 EnterResource
<PPB_Graphics2D_API
> enter(resource
, false);
35 return PP_FromBool(enter
.succeeded());
38 PP_Bool
Describe(PP_Resource graphics_2d
,
40 PP_Bool
* is_always_opaque
) {
41 VLOG(4) << "PPB_Graphics2D::Describe()";
42 EnterResource
<PPB_Graphics2D_API
> enter(graphics_2d
, true);
44 memset(size
, 0, sizeof(*size
));
45 memset(is_always_opaque
, 0, sizeof(*is_always_opaque
));
48 return enter
.object()->Describe(size
, is_always_opaque
);
51 void PaintImageData(PP_Resource graphics_2d
,
52 PP_Resource image_data
,
53 const struct PP_Point
* top_left
,
54 const struct PP_Rect
* src_rect
) {
55 VLOG(4) << "PPB_Graphics2D::PaintImageData()";
56 EnterResource
<PPB_Graphics2D_API
> enter(graphics_2d
, true);
59 enter
.object()->PaintImageData(image_data
, top_left
, src_rect
);
62 void Scroll(PP_Resource graphics_2d
,
63 const struct PP_Rect
* clip_rect
,
64 const struct PP_Point
* amount
) {
65 VLOG(4) << "PPB_Graphics2D::Scroll()";
66 EnterResource
<PPB_Graphics2D_API
> enter(graphics_2d
, true);
69 enter
.object()->Scroll(clip_rect
, amount
);
72 void ReplaceContents(PP_Resource graphics_2d
, PP_Resource image_data
) {
73 VLOG(4) << "PPB_Graphics2D::ReplaceContents()";
74 EnterResource
<PPB_Graphics2D_API
> enter(graphics_2d
, true);
77 enter
.object()->ReplaceContents(image_data
);
80 int32_t Flush(PP_Resource graphics_2d
, struct PP_CompletionCallback callback
) {
81 VLOG(4) << "PPB_Graphics2D::Flush()";
82 EnterResource
<PPB_Graphics2D_API
> enter(graphics_2d
, callback
, true);
84 return enter
.retval();
85 return enter
.SetResult(enter
.object()->Flush(enter
.callback()));
88 PP_Bool
SetScale(PP_Resource resource
, float scale
) {
89 VLOG(4) << "PPB_Graphics2D::SetScale()";
90 EnterResource
<PPB_Graphics2D_API
> enter(resource
, true);
93 return enter
.object()->SetScale(scale
);
96 float GetScale(PP_Resource resource
) {
97 VLOG(4) << "PPB_Graphics2D::GetScale()";
98 EnterResource
<PPB_Graphics2D_API
> enter(resource
, true);
101 return enter
.object()->GetScale();
104 const PPB_Graphics2D_1_0 g_ppb_graphics2d_thunk_1_0
= {&Create
,
112 const PPB_Graphics2D_1_1 g_ppb_graphics2d_thunk_1_1
= {&Create
,
124 PPAPI_THUNK_EXPORT
const PPB_Graphics2D_1_0
* GetPPB_Graphics2D_1_0_Thunk() {
125 return &g_ppb_graphics2d_thunk_1_0
;
128 PPAPI_THUNK_EXPORT
const PPB_Graphics2D_1_1
* GetPPB_Graphics2D_1_1_Thunk() {
129 return &g_ppb_graphics2d_thunk_1_1
;