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 Fri Apr 26 08:49:08 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/ppb_graphics_2d_api.h"
15 #include "ppapi/thunk/ppb_instance_api.h"
16 #include "ppapi/thunk/resource_creation_api.h"
17 #include "ppapi/thunk/thunk.h"
24 PP_Resource Create(PP_Instance instance,
25 const struct PP_Size* size,
26 PP_Bool is_always_opaque) {
27 VLOG(4) << "PPB_Graphics2D::Create()";
28 EnterResourceCreation enter(instance);
31 return enter.functions()->CreateGraphics2D(instance, size, is_always_opaque);
34 PP_Bool IsGraphics2D(PP_Resource resource) {
35 VLOG(4) << "PPB_Graphics2D::IsGraphics2D()";
36 EnterResource<PPB_Graphics2D_API> enter(resource, false);
37 return PP_FromBool(enter.succeeded());
40 PP_Bool Describe(PP_Resource graphics_2d,
42 PP_Bool* is_always_opaque) {
43 VLOG(4) << "PPB_Graphics2D::Describe()";
44 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true);
46 memset(size, 0, sizeof(*size));
47 memset(is_always_opaque, 0, sizeof(*is_always_opaque));
50 return enter.object()->Describe(size, is_always_opaque);
53 void PaintImageData(PP_Resource graphics_2d,
54 PP_Resource image_data,
55 const struct PP_Point* top_left,
56 const struct PP_Rect* src_rect) {
57 VLOG(4) << "PPB_Graphics2D::PaintImageData()";
58 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true);
61 enter.object()->PaintImageData(image_data, top_left, src_rect);
64 void Scroll(PP_Resource graphics_2d,
65 const struct PP_Rect* clip_rect,
66 const struct PP_Point* amount) {
67 VLOG(4) << "PPB_Graphics2D::Scroll()";
68 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true);
71 enter.object()->Scroll(clip_rect, amount);
74 void ReplaceContents(PP_Resource graphics_2d, PP_Resource image_data) {
75 VLOG(4) << "PPB_Graphics2D::ReplaceContents()";
76 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true);
79 enter.object()->ReplaceContents(image_data);
82 int32_t Flush(PP_Resource graphics_2d, struct PP_CompletionCallback callback) {
83 VLOG(4) << "PPB_Graphics2D::Flush()";
84 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, callback, true);
86 return enter.retval();
87 return enter.SetResult(enter.object()->Flush(enter.callback()));
90 PP_Bool SetScale(PP_Resource resource, float scale) {
91 VLOG(4) << "PPB_Graphics2D::SetScale()";
92 EnterResource<PPB_Graphics2D_API> enter(resource, true);
95 return enter.object()->SetScale(scale);
98 float GetScale(PP_Resource resource) {
99 VLOG(4) << "PPB_Graphics2D::GetScale()";
100 EnterResource<PPB_Graphics2D_API> enter(resource, true);
103 return enter.object()->GetScale();
106 const PPB_Graphics2D_1_0 g_ppb_graphics2d_thunk_1_0 = {
116 const PPB_Graphics2D_1_1 g_ppb_graphics2d_thunk_1_1 = {
130 const PPB_Graphics2D_1_0* GetPPB_Graphics2D_1_0_Thunk() {
131 return &g_ppb_graphics2d_thunk_1_0;
134 const PPB_Graphics2D_1_1* GetPPB_Graphics2D_1_1_Thunk() {
135 return &g_ppb_graphics2d_thunk_1_1;