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/pp_completion_callback.h"
6 #include "ppapi/c/pp_errors.h"
7 #include "ppapi/c/ppb_graphics_2d.h"
8 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/ppb_graphics_2d_api.h"
10 #include "ppapi/thunk/resource_creation_api.h"
11 #include "ppapi/thunk/thunk.h"
18 typedef EnterResource
<PPB_Graphics2D_API
> EnterGraphics2D
;
20 PP_Resource
Create(PP_Instance instance
,
22 PP_Bool is_always_opaque
) {
23 EnterResourceCreation
enter(instance
);
26 return enter
.functions()->CreateGraphics2D(instance
, *size
, is_always_opaque
);
29 PP_Bool
IsGraphics2D(PP_Resource resource
) {
30 EnterGraphics2D
enter(resource
, false);
31 return enter
.succeeded() ? PP_TRUE
: PP_FALSE
;
34 PP_Bool
Describe(PP_Resource graphics_2d
,
36 PP_Bool
* is_always_opaque
) {
37 EnterGraphics2D
enter(graphics_2d
, true);
41 *is_always_opaque
= PP_FALSE
;
44 return enter
.object()->Describe(size
, is_always_opaque
);
47 void PaintImageData(PP_Resource graphics_2d
,
48 PP_Resource image_data
,
49 const PP_Point
* top_left
,
50 const PP_Rect
* src_rect
) {
51 EnterGraphics2D
enter(graphics_2d
, true);
54 enter
.object()->PaintImageData(image_data
, top_left
, src_rect
);
57 void Scroll(PP_Resource graphics_2d
,
58 const PP_Rect
* clip_rect
,
59 const PP_Point
* amount
) {
60 EnterGraphics2D
enter(graphics_2d
, true);
63 enter
.object()->Scroll(clip_rect
, amount
);
66 void ReplaceContents(PP_Resource graphics_2d
, PP_Resource image_data
) {
67 EnterGraphics2D
enter(graphics_2d
, true);
70 enter
.object()->ReplaceContents(image_data
);
73 int32_t Flush(PP_Resource graphics_2d
,
74 PP_CompletionCallback callback
) {
75 EnterGraphics2D
enter(graphics_2d
, callback
, true);
77 return enter
.retval();
78 return enter
.SetResult(enter
.object()->Flush(callback
));
81 const PPB_Graphics2D g_ppb_graphics_2d_thunk
= {
93 const PPB_Graphics2D_1_0
* GetPPB_Graphics2D_1_0_Thunk() {
94 return &g_ppb_graphics_2d_thunk
;