1 // Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 //
5 // ---------------------------------------------------------------------------
6 //
7 // This file was generated by the CEF translator tool. If making changes by
8 // hand only do so within the body of existing method and function
9 // implementations. See the translator.README.txt file in the tools directory
10 // for more information.
11 //
12 // $hash=e9ee6df7e0e77e54dea7e2c1e4b24cdc88b79344$
13 //
14
15 #include "libcef_dll/cpptoc/image_cpptoc.h"
16 #include "libcef_dll/cpptoc/binary_value_cpptoc.h"
17 #include "libcef_dll/shutdown_checker.h"
18
19 // GLOBAL FUNCTIONS - Body may be edited by hand.
20
cef_image_create()21 CEF_EXPORT cef_image_t* cef_image_create() {
22 shutdown_checker::AssertNotShutdown();
23
24 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
25
26 // Execute
27 CefRefPtr<CefImage> _retval = CefImage::CreateImage();
28
29 // Return type: refptr_same
30 return CefImageCppToC::Wrap(_retval);
31 }
32
33 namespace {
34
35 // MEMBER FUNCTIONS - Body may be edited by hand.
36
image_is_empty(struct _cef_image_t * self)37 int CEF_CALLBACK image_is_empty(struct _cef_image_t* self) {
38 shutdown_checker::AssertNotShutdown();
39
40 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
41
42 DCHECK(self);
43 if (!self)
44 return 0;
45
46 // Execute
47 bool _retval = CefImageCppToC::Get(self)->IsEmpty();
48
49 // Return type: bool
50 return _retval;
51 }
52
image_is_same(struct _cef_image_t * self,struct _cef_image_t * that)53 int CEF_CALLBACK image_is_same(struct _cef_image_t* self,
54 struct _cef_image_t* that) {
55 shutdown_checker::AssertNotShutdown();
56
57 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
58
59 DCHECK(self);
60 if (!self)
61 return 0;
62 // Verify param: that; type: refptr_same
63 DCHECK(that);
64 if (!that)
65 return 0;
66
67 // Execute
68 bool _retval =
69 CefImageCppToC::Get(self)->IsSame(CefImageCppToC::Unwrap(that));
70
71 // Return type: bool
72 return _retval;
73 }
74
image_add_bitmap(struct _cef_image_t * self,float scale_factor,int pixel_width,int pixel_height,cef_color_type_t color_type,cef_alpha_type_t alpha_type,const void * pixel_data,size_t pixel_data_size)75 int CEF_CALLBACK image_add_bitmap(struct _cef_image_t* self,
76 float scale_factor,
77 int pixel_width,
78 int pixel_height,
79 cef_color_type_t color_type,
80 cef_alpha_type_t alpha_type,
81 const void* pixel_data,
82 size_t pixel_data_size) {
83 shutdown_checker::AssertNotShutdown();
84
85 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
86
87 DCHECK(self);
88 if (!self)
89 return 0;
90 // Verify param: pixel_data; type: simple_byaddr
91 DCHECK(pixel_data);
92 if (!pixel_data)
93 return 0;
94
95 // Execute
96 bool _retval = CefImageCppToC::Get(self)->AddBitmap(
97 scale_factor, pixel_width, pixel_height, color_type, alpha_type,
98 pixel_data, pixel_data_size);
99
100 // Return type: bool
101 return _retval;
102 }
103
image_add_png(struct _cef_image_t * self,float scale_factor,const void * png_data,size_t png_data_size)104 int CEF_CALLBACK image_add_png(struct _cef_image_t* self,
105 float scale_factor,
106 const void* png_data,
107 size_t png_data_size) {
108 shutdown_checker::AssertNotShutdown();
109
110 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
111
112 DCHECK(self);
113 if (!self)
114 return 0;
115 // Verify param: png_data; type: simple_byaddr
116 DCHECK(png_data);
117 if (!png_data)
118 return 0;
119
120 // Execute
121 bool _retval =
122 CefImageCppToC::Get(self)->AddPNG(scale_factor, png_data, png_data_size);
123
124 // Return type: bool
125 return _retval;
126 }
127
image_add_jpeg(struct _cef_image_t * self,float scale_factor,const void * jpeg_data,size_t jpeg_data_size)128 int CEF_CALLBACK image_add_jpeg(struct _cef_image_t* self,
129 float scale_factor,
130 const void* jpeg_data,
131 size_t jpeg_data_size) {
132 shutdown_checker::AssertNotShutdown();
133
134 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
135
136 DCHECK(self);
137 if (!self)
138 return 0;
139 // Verify param: jpeg_data; type: simple_byaddr
140 DCHECK(jpeg_data);
141 if (!jpeg_data)
142 return 0;
143
144 // Execute
145 bool _retval = CefImageCppToC::Get(self)->AddJPEG(scale_factor, jpeg_data,
146 jpeg_data_size);
147
148 // Return type: bool
149 return _retval;
150 }
151
image_get_width(struct _cef_image_t * self)152 size_t CEF_CALLBACK image_get_width(struct _cef_image_t* self) {
153 shutdown_checker::AssertNotShutdown();
154
155 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
156
157 DCHECK(self);
158 if (!self)
159 return 0;
160
161 // Execute
162 size_t _retval = CefImageCppToC::Get(self)->GetWidth();
163
164 // Return type: simple
165 return _retval;
166 }
167
image_get_height(struct _cef_image_t * self)168 size_t CEF_CALLBACK image_get_height(struct _cef_image_t* self) {
169 shutdown_checker::AssertNotShutdown();
170
171 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
172
173 DCHECK(self);
174 if (!self)
175 return 0;
176
177 // Execute
178 size_t _retval = CefImageCppToC::Get(self)->GetHeight();
179
180 // Return type: simple
181 return _retval;
182 }
183
image_has_representation(struct _cef_image_t * self,float scale_factor)184 int CEF_CALLBACK image_has_representation(struct _cef_image_t* self,
185 float scale_factor) {
186 shutdown_checker::AssertNotShutdown();
187
188 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
189
190 DCHECK(self);
191 if (!self)
192 return 0;
193
194 // Execute
195 bool _retval = CefImageCppToC::Get(self)->HasRepresentation(scale_factor);
196
197 // Return type: bool
198 return _retval;
199 }
200
image_remove_representation(struct _cef_image_t * self,float scale_factor)201 int CEF_CALLBACK image_remove_representation(struct _cef_image_t* self,
202 float scale_factor) {
203 shutdown_checker::AssertNotShutdown();
204
205 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
206
207 DCHECK(self);
208 if (!self)
209 return 0;
210
211 // Execute
212 bool _retval = CefImageCppToC::Get(self)->RemoveRepresentation(scale_factor);
213
214 // Return type: bool
215 return _retval;
216 }
217
image_get_representation_info(struct _cef_image_t * self,float scale_factor,float * actual_scale_factor,int * pixel_width,int * pixel_height)218 int CEF_CALLBACK image_get_representation_info(struct _cef_image_t* self,
219 float scale_factor,
220 float* actual_scale_factor,
221 int* pixel_width,
222 int* pixel_height) {
223 shutdown_checker::AssertNotShutdown();
224
225 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
226
227 DCHECK(self);
228 if (!self)
229 return 0;
230 // Verify param: actual_scale_factor; type: simple_byref
231 DCHECK(actual_scale_factor);
232 if (!actual_scale_factor)
233 return 0;
234 // Verify param: pixel_width; type: simple_byref
235 DCHECK(pixel_width);
236 if (!pixel_width)
237 return 0;
238 // Verify param: pixel_height; type: simple_byref
239 DCHECK(pixel_height);
240 if (!pixel_height)
241 return 0;
242
243 // Translate param: actual_scale_factor; type: simple_byref
244 float actual_scale_factorVal = actual_scale_factor ? *actual_scale_factor : 0;
245 // Translate param: pixel_width; type: simple_byref
246 int pixel_widthVal = pixel_width ? *pixel_width : 0;
247 // Translate param: pixel_height; type: simple_byref
248 int pixel_heightVal = pixel_height ? *pixel_height : 0;
249
250 // Execute
251 bool _retval = CefImageCppToC::Get(self)->GetRepresentationInfo(
252 scale_factor, actual_scale_factorVal, pixel_widthVal, pixel_heightVal);
253
254 // Restore param: actual_scale_factor; type: simple_byref
255 if (actual_scale_factor)
256 *actual_scale_factor = actual_scale_factorVal;
257 // Restore param: pixel_width; type: simple_byref
258 if (pixel_width)
259 *pixel_width = pixel_widthVal;
260 // Restore param: pixel_height; type: simple_byref
261 if (pixel_height)
262 *pixel_height = pixel_heightVal;
263
264 // Return type: bool
265 return _retval;
266 }
267
268 struct _cef_binary_value_t* CEF_CALLBACK
image_get_as_bitmap(struct _cef_image_t * self,float scale_factor,cef_color_type_t color_type,cef_alpha_type_t alpha_type,int * pixel_width,int * pixel_height)269 image_get_as_bitmap(struct _cef_image_t* self,
270 float scale_factor,
271 cef_color_type_t color_type,
272 cef_alpha_type_t alpha_type,
273 int* pixel_width,
274 int* pixel_height) {
275 shutdown_checker::AssertNotShutdown();
276
277 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
278
279 DCHECK(self);
280 if (!self)
281 return NULL;
282 // Verify param: pixel_width; type: simple_byref
283 DCHECK(pixel_width);
284 if (!pixel_width)
285 return NULL;
286 // Verify param: pixel_height; type: simple_byref
287 DCHECK(pixel_height);
288 if (!pixel_height)
289 return NULL;
290
291 // Translate param: pixel_width; type: simple_byref
292 int pixel_widthVal = pixel_width ? *pixel_width : 0;
293 // Translate param: pixel_height; type: simple_byref
294 int pixel_heightVal = pixel_height ? *pixel_height : 0;
295
296 // Execute
297 CefRefPtr<CefBinaryValue> _retval = CefImageCppToC::Get(self)->GetAsBitmap(
298 scale_factor, color_type, alpha_type, pixel_widthVal, pixel_heightVal);
299
300 // Restore param: pixel_width; type: simple_byref
301 if (pixel_width)
302 *pixel_width = pixel_widthVal;
303 // Restore param: pixel_height; type: simple_byref
304 if (pixel_height)
305 *pixel_height = pixel_heightVal;
306
307 // Return type: refptr_same
308 return CefBinaryValueCppToC::Wrap(_retval);
309 }
310
311 struct _cef_binary_value_t* CEF_CALLBACK
image_get_as_png(struct _cef_image_t * self,float scale_factor,int with_transparency,int * pixel_width,int * pixel_height)312 image_get_as_png(struct _cef_image_t* self,
313 float scale_factor,
314 int with_transparency,
315 int* pixel_width,
316 int* pixel_height) {
317 shutdown_checker::AssertNotShutdown();
318
319 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
320
321 DCHECK(self);
322 if (!self)
323 return NULL;
324 // Verify param: pixel_width; type: simple_byref
325 DCHECK(pixel_width);
326 if (!pixel_width)
327 return NULL;
328 // Verify param: pixel_height; type: simple_byref
329 DCHECK(pixel_height);
330 if (!pixel_height)
331 return NULL;
332
333 // Translate param: pixel_width; type: simple_byref
334 int pixel_widthVal = pixel_width ? *pixel_width : 0;
335 // Translate param: pixel_height; type: simple_byref
336 int pixel_heightVal = pixel_height ? *pixel_height : 0;
337
338 // Execute
339 CefRefPtr<CefBinaryValue> _retval = CefImageCppToC::Get(self)->GetAsPNG(
340 scale_factor, with_transparency ? true : false, pixel_widthVal,
341 pixel_heightVal);
342
343 // Restore param: pixel_width; type: simple_byref
344 if (pixel_width)
345 *pixel_width = pixel_widthVal;
346 // Restore param: pixel_height; type: simple_byref
347 if (pixel_height)
348 *pixel_height = pixel_heightVal;
349
350 // Return type: refptr_same
351 return CefBinaryValueCppToC::Wrap(_retval);
352 }
353
354 struct _cef_binary_value_t* CEF_CALLBACK
image_get_as_jpeg(struct _cef_image_t * self,float scale_factor,int quality,int * pixel_width,int * pixel_height)355 image_get_as_jpeg(struct _cef_image_t* self,
356 float scale_factor,
357 int quality,
358 int* pixel_width,
359 int* pixel_height) {
360 shutdown_checker::AssertNotShutdown();
361
362 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
363
364 DCHECK(self);
365 if (!self)
366 return NULL;
367 // Verify param: pixel_width; type: simple_byref
368 DCHECK(pixel_width);
369 if (!pixel_width)
370 return NULL;
371 // Verify param: pixel_height; type: simple_byref
372 DCHECK(pixel_height);
373 if (!pixel_height)
374 return NULL;
375
376 // Translate param: pixel_width; type: simple_byref
377 int pixel_widthVal = pixel_width ? *pixel_width : 0;
378 // Translate param: pixel_height; type: simple_byref
379 int pixel_heightVal = pixel_height ? *pixel_height : 0;
380
381 // Execute
382 CefRefPtr<CefBinaryValue> _retval = CefImageCppToC::Get(self)->GetAsJPEG(
383 scale_factor, quality, pixel_widthVal, pixel_heightVal);
384
385 // Restore param: pixel_width; type: simple_byref
386 if (pixel_width)
387 *pixel_width = pixel_widthVal;
388 // Restore param: pixel_height; type: simple_byref
389 if (pixel_height)
390 *pixel_height = pixel_heightVal;
391
392 // Return type: refptr_same
393 return CefBinaryValueCppToC::Wrap(_retval);
394 }
395
396 } // namespace
397
398 // CONSTRUCTOR - Do not edit by hand.
399
CefImageCppToC()400 CefImageCppToC::CefImageCppToC() {
401 GetStruct()->is_empty = image_is_empty;
402 GetStruct()->is_same = image_is_same;
403 GetStruct()->add_bitmap = image_add_bitmap;
404 GetStruct()->add_png = image_add_png;
405 GetStruct()->add_jpeg = image_add_jpeg;
406 GetStruct()->get_width = image_get_width;
407 GetStruct()->get_height = image_get_height;
408 GetStruct()->has_representation = image_has_representation;
409 GetStruct()->remove_representation = image_remove_representation;
410 GetStruct()->get_representation_info = image_get_representation_info;
411 GetStruct()->get_as_bitmap = image_get_as_bitmap;
412 GetStruct()->get_as_png = image_get_as_png;
413 GetStruct()->get_as_jpeg = image_get_as_jpeg;
414 }
415
416 // DESTRUCTOR - Do not edit by hand.
417
~CefImageCppToC()418 CefImageCppToC::~CefImageCppToC() {
419 shutdown_checker::AssertNotShutdown();
420 }
421
422 template <>
423 CefRefPtr<CefImage>
UnwrapDerived(CefWrapperType type,cef_image_t * s)424 CefCppToCRefCounted<CefImageCppToC, CefImage, cef_image_t>::UnwrapDerived(
425 CefWrapperType type,
426 cef_image_t* s) {
427 NOTREACHED() << "Unexpected class type: " << type;
428 return nullptr;
429 }
430
431 template <>
432 CefWrapperType
433 CefCppToCRefCounted<CefImageCppToC, CefImage, cef_image_t>::kWrapperType =
434 WT_IMAGE;
435