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

Side by Side Diff: src/shared/ppapi_proxy/plugin_graphics_2d.cc

Issue 5974006: Convert srpc definitions from using int64 to using PP_Instance, PP_Module, an... (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 9 years, 12 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
OLDNEW
1 /* 1 /*
2 * Copyright 2010 The Native Client Authors. All rights reserved. 2 * Copyright 2010 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can 3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file. 4 * be found in the LICENSE file.
5 */ 5 */
6 6
7 #include "native_client/src/shared/ppapi_proxy/plugin_graphics_2d.h" 7 #include "native_client/src/shared/ppapi_proxy/plugin_graphics_2d.h"
8 8
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 19 matching lines...) Expand all
30 static_cast<nacl_abi_size_t>(sizeof(struct PP_Point)); 30 static_cast<nacl_abi_size_t>(sizeof(struct PP_Point));
31 const nacl_abi_size_t kPpRectBytes = 31 const nacl_abi_size_t kPpRectBytes =
32 static_cast<nacl_abi_size_t>(sizeof(struct PP_Rect)); 32 static_cast<nacl_abi_size_t>(sizeof(struct PP_Rect));
33 33
34 PP_Resource Create(PP_Module module, 34 PP_Resource Create(PP_Module module,
35 const struct PP_Size* size, 35 const struct PP_Size* size,
36 PP_Bool is_always_opaque) { 36 PP_Bool is_always_opaque) {
37 int32_t* size_as_int_ptr = 37 int32_t* size_as_int_ptr =
38 reinterpret_cast<int32_t*>(const_cast<struct PP_Size*>(size)); 38 reinterpret_cast<int32_t*>(const_cast<struct PP_Size*>(size));
39 int32_t is_always_opaque_as_int = static_cast<int32_t>(is_always_opaque); 39 int32_t is_always_opaque_as_int = static_cast<int32_t>(is_always_opaque);
40 int64_t resource; 40 PP_Resource resource;
41 NaClSrpcError retval = 41 NaClSrpcError retval =
42 PpbGraphics2DRpcClient::PPB_Graphics2D_Create( 42 PpbGraphics2DRpcClient::PPB_Graphics2D_Create(
43 GetMainSrpcChannel(), 43 GetMainSrpcChannel(),
44 static_cast<int64_t>(module), 44 module,
45 kPpSizeBytes, 45 kPpSizeBytes,
46 size_as_int_ptr, 46 size_as_int_ptr,
47 is_always_opaque_as_int, 47 is_always_opaque_as_int,
48 &resource); 48 &resource);
49 if (retval == NACL_SRPC_RESULT_OK) { 49 if (retval == NACL_SRPC_RESULT_OK) {
50 return static_cast<PP_Resource>(resource); 50 return resource;
51 } else { 51 } else {
52 return kInvalidResourceId; 52 return kInvalidResourceId;
53 } 53 }
54 } 54 }
55 55
56 PP_Bool IsGraphics2D(PP_Resource resource) { 56 PP_Bool IsGraphics2D(PP_Resource resource) {
57 return PluginResource::GetAs<PluginGraphics2D>(resource).get() 57 return PluginResource::GetAs<PluginGraphics2D>(resource).get()
58 ? PP_TRUE : PP_FALSE; 58 ? PP_TRUE : PP_FALSE;
59 } 59 }
60 60
61 PP_Bool Describe(PP_Resource graphics_2d, 61 PP_Bool Describe(PP_Resource graphics_2d,
62 struct PP_Size* size, 62 struct PP_Size* size,
63 PP_Bool* is_always_opaque) { 63 PP_Bool* is_always_opaque) {
64 int32_t is_always_opaque_as_int; 64 int32_t is_always_opaque_as_int;
65 nacl_abi_size_t size_ret = kPpSizeBytes; 65 nacl_abi_size_t size_ret = kPpSizeBytes;
66 int32_t result; 66 int32_t result;
67 NaClSrpcError retval = 67 NaClSrpcError retval =
68 PpbGraphics2DRpcClient::PPB_Graphics2D_Describe( 68 PpbGraphics2DRpcClient::PPB_Graphics2D_Describe(
69 GetMainSrpcChannel(), 69 GetMainSrpcChannel(),
70 static_cast<int64_t>(graphics_2d), 70 graphics_2d,
71 &size_ret, 71 &size_ret,
72 reinterpret_cast<int32_t*>(size), 72 reinterpret_cast<int32_t*>(size),
73 &is_always_opaque_as_int, 73 &is_always_opaque_as_int,
74 &result); 74 &result);
75 if (retval == NACL_SRPC_RESULT_OK || size_ret != kPpSizeBytes) { 75 if (retval == NACL_SRPC_RESULT_OK || size_ret != kPpSizeBytes) {
76 *is_always_opaque = is_always_opaque_as_int ? PP_TRUE : PP_FALSE; 76 *is_always_opaque = is_always_opaque_as_int ? PP_TRUE : PP_FALSE;
77 return result ? PP_TRUE : PP_FALSE; 77 return result ? PP_TRUE : PP_FALSE;
78 } else { 78 } else {
79 return PP_FALSE; 79 return PP_FALSE;
80 } 80 }
81 } 81 }
82 82
83 void PaintImageData(PP_Resource graphics_2d, 83 void PaintImageData(PP_Resource graphics_2d,
84 PP_Resource image, 84 PP_Resource image,
85 const struct PP_Point* top_left, 85 const struct PP_Point* top_left,
86 const struct PP_Rect* src_rect) { 86 const struct PP_Rect* src_rect) {
87 // TODO(sehr,polina): there is no way to report a failure through this 87 // TODO(sehr,polina): there is no way to report a failure through this
88 // interface design other than crash. Let's find one. 88 // interface design other than crash. Let's find one.
89 (void) PpbGraphics2DRpcClient::PPB_Graphics2D_PaintImageData( 89 (void) PpbGraphics2DRpcClient::PPB_Graphics2D_PaintImageData(
90 GetMainSrpcChannel(), 90 GetMainSrpcChannel(),
91 static_cast<int64_t>(graphics_2d), 91 graphics_2d,
92 static_cast<int64_t>(image), 92 image,
93 kPpPointBytes, 93 kPpPointBytes,
94 reinterpret_cast<int32_t*>(const_cast<struct PP_Point*>(top_left)), 94 reinterpret_cast<int32_t*>(const_cast<struct PP_Point*>(top_left)),
95 kPpRectBytes, 95 kPpRectBytes,
96 reinterpret_cast<int32_t*>(const_cast<struct PP_Rect*>(src_rect))); 96 reinterpret_cast<int32_t*>(const_cast<struct PP_Rect*>(src_rect)));
97 } 97 }
98 98
99 void Scroll(PP_Resource graphics_2d, 99 void Scroll(PP_Resource graphics_2d,
100 const struct PP_Rect* clip_rect, 100 const struct PP_Rect* clip_rect,
101 const struct PP_Point* amount) { 101 const struct PP_Point* amount) {
102 // TODO(sehr,polina): there is no way to report a failure through this 102 // TODO(sehr,polina): there is no way to report a failure through this
103 // interface design other than crash. Let's find one. 103 // interface design other than crash. Let's find one.
104 (void) PpbGraphics2DRpcClient::PPB_Graphics2D_Scroll( 104 (void) PpbGraphics2DRpcClient::PPB_Graphics2D_Scroll(
105 GetMainSrpcChannel(), 105 GetMainSrpcChannel(),
106 static_cast<int64_t>(graphics_2d), 106 graphics_2d,
107 kPpRectBytes, 107 kPpRectBytes,
108 reinterpret_cast<int32_t*>(const_cast<struct PP_Rect*>(clip_rect)), 108 reinterpret_cast<int32_t*>(const_cast<struct PP_Rect*>(clip_rect)),
109 kPpPointBytes, 109 kPpPointBytes,
110 reinterpret_cast<int32_t*>(const_cast<struct PP_Point*>(amount))); 110 reinterpret_cast<int32_t*>(const_cast<struct PP_Point*>(amount)));
111 } 111 }
112 112
113 void ReplaceContents(PP_Resource graphics_2d, PP_Resource image) { 113 void ReplaceContents(PP_Resource graphics_2d, PP_Resource image) {
114 (void) PpbGraphics2DRpcClient::PPB_Graphics2D_ReplaceContents( 114 (void) PpbGraphics2DRpcClient::PPB_Graphics2D_ReplaceContents(
115 GetMainSrpcChannel(), 115 GetMainSrpcChannel(),
nfullagar 2010/12/23 21:37:00 line above and two below could fit on one line?
noelallen_use_chromium 2010/12/23 22:23:23 Done.
116 static_cast<int64_t>(graphics_2d), 116 graphics_2d,
117 static_cast<int64_t>(image)); 117 image);
118 } 118 }
119 119
120 int32_t Flush(PP_Resource graphics_2d, 120 int32_t Flush(PP_Resource graphics_2d,
121 struct PP_CompletionCallback callback) { 121 struct PP_CompletionCallback callback) {
122 UNREFERENCED_PARAMETER(graphics_2d); 122 UNREFERENCED_PARAMETER(graphics_2d);
123 UNREFERENCED_PARAMETER(callback); 123 UNREFERENCED_PARAMETER(callback);
124 // TODO(sehr): implement the call on the upcall channel once the completion 124 // TODO(sehr): implement the call on the upcall channel once the completion
125 // callback implementation is in place. 125 // callback implementation is in place.
126 NACL_UNIMPLEMENTED(); 126 NACL_UNIMPLEMENTED();
127 return PP_ERROR_BADRESOURCE; 127 return PP_ERROR_BADRESOURCE;
128 } 128 }
129 129
130 } // namespace 130 } // namespace
131 131
132 const PPB_Graphics2D* PluginGraphics2D::GetInterface() { 132 const PPB_Graphics2D* PluginGraphics2D::GetInterface() {
133 static const PPB_Graphics2D intf = { 133 static const PPB_Graphics2D intf = {
134 Create, 134 Create,
135 IsGraphics2D, 135 IsGraphics2D,
136 Describe, 136 Describe,
137 PaintImageData, 137 PaintImageData,
138 Scroll, 138 Scroll,
139 ReplaceContents, 139 ReplaceContents,
140 Flush, 140 Flush,
141 }; 141 };
142 return &intf; 142 return &intf;
143 } 143 }
144 144
145 } // namespace ppapi_proxy 145 } // namespace ppapi_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698