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 #include "ppapi/c/dev/ppb_graphics_2d_dev.h"
6 #include "ppapi/c/pp_completion_callback.h"
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/ppb_graphics_2d.h"
9 #include "ppapi/shared_impl/tracked_callback.h"
10 #include "ppapi/thunk/enter.h"
11 #include "ppapi/thunk/ppb_graphics_2d_api.h"
12 #include "ppapi/thunk/resource_creation_api.h"
13 #include "ppapi/thunk/thunk.h"
20 typedef EnterResource
<PPB_Graphics2D_API
> EnterGraphics2D
;
22 PP_Resource
Create(PP_Instance instance
,
24 PP_Bool is_always_opaque
) {
25 EnterResourceCreation
enter(instance
);
28 return enter
.functions()->CreateGraphics2D(instance
, *size
, is_always_opaque
);
31 PP_Bool
IsGraphics2D(PP_Resource resource
) {
32 EnterGraphics2D
enter(resource
, false);
33 return enter
.succeeded() ? PP_TRUE
: PP_FALSE
;
36 PP_Bool
Describe(PP_Resource graphics_2d
,
38 PP_Bool
* is_always_opaque
) {
39 EnterGraphics2D
enter(graphics_2d
, true);
43 *is_always_opaque
= PP_FALSE
;
46 return enter
.object()->Describe(size
, is_always_opaque
);
49 void PaintImageData(PP_Resource graphics_2d
,
50 PP_Resource image_data
,
51 const PP_Point
* top_left
,
52 const PP_Rect
* src_rect
) {
53 EnterGraphics2D
enter(graphics_2d
, true);
56 enter
.object()->PaintImageData(image_data
, top_left
, src_rect
);
59 void Scroll(PP_Resource graphics_2d
,
60 const PP_Rect
* clip_rect
,
61 const PP_Point
* amount
) {
62 EnterGraphics2D
enter(graphics_2d
, true);
65 enter
.object()->Scroll(clip_rect
, amount
);
68 void ReplaceContents(PP_Resource graphics_2d
, PP_Resource image_data
) {
69 EnterGraphics2D
enter(graphics_2d
, true);
72 enter
.object()->ReplaceContents(image_data
);
75 int32_t Flush(PP_Resource graphics_2d
, PP_CompletionCallback callback
) {
76 EnterGraphics2D
enter(graphics_2d
, callback
, true);
78 return enter
.retval();
79 return enter
.SetResult(enter
.object()->Flush(enter
.callback(), NULL
));
82 PP_Bool
SetScale(PP_Resource graphics_2d
, float scale
) {
83 EnterGraphics2D
enter(graphics_2d
, true);
86 return PP_FromBool(enter
.object()->SetScale(scale
));
89 float GetScale(PP_Resource graphics_2d
) {
90 EnterGraphics2D
enter(graphics_2d
, true);
93 return enter
.object()->GetScale();
96 const PPB_Graphics2D_1_0 g_ppb_graphics_2d_1_0_thunk
= {
106 const PPB_Graphics2D_1_1 g_ppb_graphics_2d_1_1_thunk
= {
118 const PPB_Graphics2D_Dev g_ppb_graphics_2d_dev_thunk
= {
125 const PPB_Graphics2D_1_0
* GetPPB_Graphics2D_1_0_Thunk() {
126 return &g_ppb_graphics_2d_1_0_thunk
;
129 const PPB_Graphics2D_1_1
* GetPPB_Graphics2D_1_1_Thunk() {
130 return &g_ppb_graphics_2d_1_1_thunk
;
133 const PPB_Graphics2D_Dev_0_1
* GetPPB_Graphics2D_Dev_0_1_Thunk() {
134 return &g_ppb_graphics_2d_dev_thunk
;