Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Side by Side Diff: ppapi/thunk/ppb_graphics_2d_thunk.cc

Issue 6905088: New thunk system for Pepper proxy and implementation (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
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
12 namespace ppapi {
13 namespace thunk {
14
15 namespace {
16
17 PP_Resource Create(PP_Instance instance,
18 const PP_Size* size,
19 PP_Bool is_always_opaque) {
20 EnterFunction<ResourceCreationAPI> enter(instance, true);
21 if (enter.failed())
22 return 0;
23 return enter.functions()->CreateGraphics2D(instance, *size, is_always_opaque);
24 }
25
26 PP_Bool IsGraphics2D(PP_Resource resource) {
27 EnterResource<PPB_Graphics2D_API> enter(resource, false);
28 return enter.succeeded() ? PP_TRUE : PP_FALSE;
29 }
30
31 PP_Bool Describe(PP_Resource graphics_2d,
32 PP_Size* size,
33 PP_Bool* is_always_opaque) {
34 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true);
35 if (enter.failed()) {
36 size->width = 0;
37 size->height = 0;
38 *is_always_opaque = PP_FALSE;
39 return PP_FALSE;
40 }
41 return enter.object()->Describe(size, is_always_opaque);
42 }
43
44 void PaintImageData(PP_Resource graphics_2d,
45 PP_Resource image_data,
46 const PP_Point* top_left,
47 const PP_Rect* src_rect) {
48 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true);
49 if (enter.failed())
50 return;
51 enter.object()->PaintImageData(image_data, top_left, src_rect);
52 }
53
54 void Scroll(PP_Resource graphics_2d,
55 const PP_Rect* clip_rect,
56 const PP_Point* amount) {
57 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true);
58 if (enter.failed())
59 return;
60 enter.object()->Scroll(clip_rect, amount);
61 }
62
63 void ReplaceContents(PP_Resource graphics_2d, PP_Resource image_data) {
64 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true);
65 if (enter.failed())
66 return;
67 enter.object()->ReplaceContents(image_data);
68 }
69
70 int32_t Flush(PP_Resource graphics_2d,
71 PP_CompletionCallback callback) {
72 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true);
73 if (enter.failed())
74 return PP_ERROR_BADARGUMENT;
75 return enter.object()->Flush(callback);
76 }
77
78 const PPB_Graphics2D g_ppb_graphics_2d_thunk = {
79 &Create,
80 &IsGraphics2D,
81 &Describe,
82 &PaintImageData,
83 &Scroll,
84 &ReplaceContents,
85 &Flush
86 };
87
88 } // namespace
89
90 const PPB_Graphics2D* GetPPB_Graphics2D_Thunk() {
91 return &g_ppb_graphics_2d_thunk;
92 }
93
94 } // namespace thunk
95 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698