blend2d-bindings 0.1.0-arm64-darwin
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ChangeLog +26 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/examples/test.rb +46 -0
- data/examples/util/setup_blend2d.rb +46 -0
- data/lib/blend2d.rb +95 -0
- data/lib/blend2d_api.rb +255 -0
- data/lib/blend2d_array.rb +319 -0
- data/lib/blend2d_bitarray.rb +275 -0
- data/lib/blend2d_bitset.rb +311 -0
- data/lib/blend2d_context.rb +1613 -0
- data/lib/blend2d_filesystem.rb +211 -0
- data/lib/blend2d_font.rb +281 -0
- data/lib/blend2d_fontdata.rb +209 -0
- data/lib/blend2d_fontdefs.rb +552 -0
- data/lib/blend2d_fontface.rb +345 -0
- data/lib/blend2d_fontfeaturesettings.rb +210 -0
- data/lib/blend2d_fontmanager.rb +187 -0
- data/lib/blend2d_fontvariationsettings.rb +210 -0
- data/lib/blend2d_format.rb +112 -0
- data/lib/blend2d_geometry.rb +424 -0
- data/lib/blend2d_glyphbuffer.rb +141 -0
- data/lib/blend2d_glyphrun.rb +101 -0
- data/lib/blend2d_gradient.rb +429 -0
- data/lib/blend2d_image.rb +291 -0
- data/lib/blend2d_imagecodec.rb +219 -0
- data/lib/blend2d_imagedecoder.rb +168 -0
- data/lib/blend2d_imageencoder.rb +159 -0
- data/lib/blend2d_matrix.rb +132 -0
- data/lib/blend2d_object.rb +326 -0
- data/lib/blend2d_path.rb +511 -0
- data/lib/blend2d_pattern.rb +202 -0
- data/lib/blend2d_pixelconverter.rb +109 -0
- data/lib/blend2d_random.rb +77 -0
- data/lib/blend2d_rgba.rb +95 -0
- data/lib/blend2d_runtime.rb +259 -0
- data/lib/blend2d_string.rb +245 -0
- data/lib/blend2d_var.rb +294 -0
- data/lib/libblend2d.arm64.dylib +0 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fc80904ffc490a54e55f51588bc933c62858747187fddc29414e2a5cce83b705
|
4
|
+
data.tar.gz: c11f142700423ce054b707eeb548c9d3449e462efe273a86dcf63cd90eee0492
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 25b5fef0190ba486a9941dc56270395989eba3cc23ee4887cd3366294a7df95d5073c7ab94713d8a1b91e5bf143686c829eb451f8e56bdce3230b9fb5ba7c68f
|
7
|
+
data.tar.gz: f031ca363547f78ffc30b00d64fcbe21745961a65e082d3904db775ef9d429128816b35d2a75f07fae4dfe736cc2d306ba5d53ba7958ed327a2daca548a687f3
|
data/ChangeLog
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
2024-12-31 vaiorabbit <http://twitter.com/vaiorabbit>
|
2
|
+
|
3
|
+
* Updated with latest Blend2D ( https://github.com/blend2d/blend2d/commit/16088c4ffb41813d9f0511fb2a6896f5608a4706 )
|
4
|
+
* Added AsmJit support
|
5
|
+
* examples/particles : Added
|
6
|
+
|
7
|
+
2024-04-13 vaiorabbit <http://twitter.com/vaiorabbit>
|
8
|
+
|
9
|
+
* Updated with latest Blend2D ( https://github.com/blend2d/blend2d/commit/235997a8f829f54b56925c7332b8f0bc5b49bcf6 )
|
10
|
+
|
11
|
+
2024-01-14 vaiorabbit <http://twitter.com/vaiorabbit>
|
12
|
+
|
13
|
+
* examples/ellipticarc : Added
|
14
|
+
|
15
|
+
2024-01-13 vaiorabbit <http://twitter.com/vaiorabbit>
|
16
|
+
|
17
|
+
* Fixed using ambiguous types
|
18
|
+
|
19
|
+
2024-01-08 vaiorabbit <http://twitter.com/vaiorabbit>
|
20
|
+
|
21
|
+
* Add build scripts
|
22
|
+
* examples/circles : Added
|
23
|
+
|
24
|
+
2024-01-05 vaiorabbit <http://twitter.com/vaiorabbit>
|
25
|
+
|
26
|
+
* initial commmit
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Ruby-Blend2D : Blend2D bindings for Ruby
|
2
|
+
Copyright (c) 2024-2025 vaiorabbit <http://twitter.com/vaiorabbit>
|
3
|
+
|
4
|
+
This software is provided 'as-is', without any express or implied
|
5
|
+
warranty. In no event will the authors be held liable for any damages
|
6
|
+
arising from the use of this software.
|
7
|
+
|
8
|
+
Permission is granted to anyone to use this software for any purpose,
|
9
|
+
including commercial applications, and to alter it and redistribute it
|
10
|
+
freely, subject to the following restrictions:
|
11
|
+
|
12
|
+
1. The origin of this software must not be misrepresented; you must not
|
13
|
+
claim that you wrote the original software. If you use this software
|
14
|
+
in a product, an acknowledgment in the product documentation would be
|
15
|
+
appreciated but is not required.
|
16
|
+
|
17
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
18
|
+
misrepresented as being the original software.
|
19
|
+
|
20
|
+
3. This notice may not be removed or altered from any source
|
21
|
+
distribution.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
<!-- -*- mode:markdown; coding:utf-8; -*- -->
|
2
|
+
|
3
|
+
# Blend2D bindings for Ruby #
|
4
|
+
|
5
|
+
* Created : 2024-01-05
|
6
|
+
* Last modified : 2025-01-01
|
7
|
+
|
8
|
+
Provides Ruby bindings for Blend2D
|
9
|
+
* https://blend2d.com
|
10
|
+
* https://github.com/blend2d/blend2d
|
11
|
+
|
12
|
+
## License ##
|
13
|
+
|
14
|
+
All shared libraries found in `lib` directory are built on top of Blend2D ( https://github.com/blend2d/blend2d ) and are available under the zlib License.
|
15
|
+
* https://github.com/blend2d/blend2d/blob/master/LICENSE.md
|
16
|
+
|
17
|
+
All ruby codes here are available under the zlib/libpng License ( http://opensource.org/licenses/Zlib ).
|
18
|
+
|
19
|
+
```
|
20
|
+
Ruby-Blend2D : Blend2D bindings for Ruby
|
21
|
+
Copyright (c) 2024-2025 vaiorabbit <http://twitter.com/vaiorabbit>
|
22
|
+
|
23
|
+
This software is provided 'as-is', without any express or implied
|
24
|
+
warranty. In no event will the authors be held liable for any damages
|
25
|
+
arising from the use of this software.
|
26
|
+
|
27
|
+
Permission is granted to anyone to use this software for any purpose,
|
28
|
+
including commercial applications, and to alter it and redistribute it
|
29
|
+
freely, subject to the following restrictions:
|
30
|
+
|
31
|
+
1. The origin of this software must not be misrepresented; you must not
|
32
|
+
claim that you wrote the original software. If you use this software
|
33
|
+
in a product, an acknowledgment in the product documentation would be
|
34
|
+
appreciated but is not required.
|
35
|
+
|
36
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
37
|
+
misrepresented as being the original software.
|
38
|
+
|
39
|
+
3. This notice may not be removed or altered from any source
|
40
|
+
distribution.
|
41
|
+
```
|
data/examples/test.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Visit https://github.com/vaiorabbit/blend2d-bindings/tree/main/examples for more examples.
|
2
|
+
require_relative 'util/setup_blend2d'
|
3
|
+
|
4
|
+
if __FILE__ == $PROGRAM_NAME
|
5
|
+
img = BLImageCore.create_as(480, 480, BL_FORMAT_PRGB32)
|
6
|
+
|
7
|
+
ctx = BLContextCore.create_as(img, nil)
|
8
|
+
ctx.clearAll()
|
9
|
+
|
10
|
+
# First shape
|
11
|
+
radialValues = BLRadialGradientValues.create_as(180, 180, 180, 180, 180, 0.0)
|
12
|
+
radial = BLGradientCore.create_as(BL_GRADIENT_TYPE_RADIAL, radialValues, BL_EXTEND_MODE_PAD, nil, 0, nil)
|
13
|
+
radial.addStopRgba32(0.0, 0xFFFFFFFF)
|
14
|
+
radial.addStopRgba32(1.0, 0xFFFF6F3F)
|
15
|
+
|
16
|
+
circle = BLCircle.create_as(180, 180, 160)
|
17
|
+
|
18
|
+
ctx.fillGeometryExt(BL_GEOMETRY_TYPE_CIRCLE, circle, radial)
|
19
|
+
radial.destroy()
|
20
|
+
radial = nil
|
21
|
+
|
22
|
+
# Second shape
|
23
|
+
linearValues = BLLinearGradientValues.create_as(195, 195, 470, 470)
|
24
|
+
linear = BLGradientCore.create_as(BL_GRADIENT_TYPE_LINEAR, linearValues, BL_EXTEND_MODE_PAD, nil, 0, nil)
|
25
|
+
linear.addStopRgba32(0.0, 0xFFFFFFFF)
|
26
|
+
linear.addStopRgba32(1.0, 0xFF3F9FFF)
|
27
|
+
|
28
|
+
ctx.setCompOp(BL_COMP_OP_DIFFERENCE)
|
29
|
+
roundRect = BLRoundRect.create_as(195, 195, 270, 270, 25, 25)
|
30
|
+
r = ctx.fillGeometryExt(BL_GEOMETRY_TYPE_ROUND_RECT, roundRect, linear)
|
31
|
+
|
32
|
+
linear.destroy()
|
33
|
+
linear = nil
|
34
|
+
|
35
|
+
ctx.destroy()
|
36
|
+
ctx = nil
|
37
|
+
|
38
|
+
codec = BLImageCodecCore.new
|
39
|
+
codec.initByName("PNG", "PNG".chars.length, nil)
|
40
|
+
img.writeToFile("test.png", codec)
|
41
|
+
codec.destroy()
|
42
|
+
codec = nil
|
43
|
+
|
44
|
+
img.destroy()
|
45
|
+
img = nil
|
46
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
def blend2d_bindings_gem_available?
|
2
|
+
Gem::Specification.find_by_name('blend2d-bindings')
|
3
|
+
rescue Gem::LoadError
|
4
|
+
false
|
5
|
+
rescue
|
6
|
+
Gem.available?('blend2d-bindings')
|
7
|
+
end
|
8
|
+
|
9
|
+
if blend2d_bindings_gem_available?
|
10
|
+
# puts("Loading from Gem system path.")
|
11
|
+
require 'blend2d'
|
12
|
+
|
13
|
+
s = Gem::Specification.find_by_name('blend2d-bindings')
|
14
|
+
shared_lib_path = s.full_gem_path + '/lib/'
|
15
|
+
|
16
|
+
case RUBY_PLATFORM
|
17
|
+
when /mswin|msys|mingw|cygwin/
|
18
|
+
Blend2D.load_lib(shared_lib_path + 'libblend2d.dll')
|
19
|
+
when /darwin/
|
20
|
+
arch = RUBY_PLATFORM.split('-')[0]
|
21
|
+
Blend2D.load_lib(shared_lib_path + "libblend2d.#{arch}.dylib")
|
22
|
+
when /linux/
|
23
|
+
arch = RUBY_PLATFORM.split('-')[0]
|
24
|
+
Blend2D.load_lib(shared_lib_path + "libblend2d.#{arch}.so")
|
25
|
+
else
|
26
|
+
raise RuntimeError, "setup_dll.rb : Unknown OS: #{RUBY_PLATFORM}"
|
27
|
+
end
|
28
|
+
else
|
29
|
+
# puts("Loaging from local path.")
|
30
|
+
require '../lib/blend2d'
|
31
|
+
|
32
|
+
case RUBY_PLATFORM
|
33
|
+
when /mswin|msys|mingw|cygwin/
|
34
|
+
Blend2D.load_lib(Dir.pwd + '/../lib/' + 'libblend2d.dll')
|
35
|
+
when /darwin/
|
36
|
+
arch = RUBY_PLATFORM.split('-')[0]
|
37
|
+
Blend2D.load_lib(Dir.pwd + '/../lib/' + "libblend2d.#{arch}.dylib")
|
38
|
+
when /linux/
|
39
|
+
arch = RUBY_PLATFORM.split('-')[0]
|
40
|
+
Blend2D.load_lib(Dir.pwd + '/../lib/' + "libblend2d.#{arch}.so")
|
41
|
+
else
|
42
|
+
raise RuntimeError, "setup_dll.rb : Unknown OS: #{RUBY_PLATFORM}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
include Blend2D
|
data/lib/blend2d.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# Ruby-Blend2D : Yet another Blend2D wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/blend2d-bindings
|
4
|
+
|
5
|
+
require 'ffi'
|
6
|
+
require_relative 'blend2d_api.rb'
|
7
|
+
require_relative 'blend2d_array.rb'
|
8
|
+
require_relative 'blend2d_bitarray.rb'
|
9
|
+
require_relative 'blend2d_bitset.rb'
|
10
|
+
require_relative 'blend2d_context.rb'
|
11
|
+
require_relative 'blend2d_filesystem.rb'
|
12
|
+
require_relative 'blend2d_font.rb'
|
13
|
+
require_relative 'blend2d_fontdata.rb'
|
14
|
+
require_relative 'blend2d_fontdefs.rb'
|
15
|
+
require_relative 'blend2d_fontface.rb'
|
16
|
+
require_relative 'blend2d_fontfeaturesettings.rb'
|
17
|
+
require_relative 'blend2d_fontmanager.rb'
|
18
|
+
require_relative 'blend2d_fontvariationsettings.rb'
|
19
|
+
require_relative 'blend2d_format.rb'
|
20
|
+
require_relative 'blend2d_geometry.rb'
|
21
|
+
require_relative 'blend2d_glyphbuffer.rb'
|
22
|
+
require_relative 'blend2d_glyphrun.rb'
|
23
|
+
require_relative 'blend2d_gradient.rb'
|
24
|
+
require_relative 'blend2d_image.rb'
|
25
|
+
require_relative 'blend2d_imagecodec.rb'
|
26
|
+
require_relative 'blend2d_imagedecoder.rb'
|
27
|
+
require_relative 'blend2d_imageencoder.rb'
|
28
|
+
require_relative 'blend2d_matrix.rb'
|
29
|
+
require_relative 'blend2d_object.rb'
|
30
|
+
require_relative 'blend2d_path.rb'
|
31
|
+
require_relative 'blend2d_pattern.rb'
|
32
|
+
require_relative 'blend2d_pixelconverter.rb'
|
33
|
+
require_relative 'blend2d_random.rb'
|
34
|
+
require_relative 'blend2d_rgba.rb'
|
35
|
+
require_relative 'blend2d_runtime.rb'
|
36
|
+
require_relative 'blend2d_string.rb'
|
37
|
+
require_relative 'blend2d_var.rb'
|
38
|
+
|
39
|
+
module Blend2D
|
40
|
+
extend FFI::Library
|
41
|
+
|
42
|
+
@@blend2d_import_done = false
|
43
|
+
def self.load_lib(libpath, output_error = false)
|
44
|
+
|
45
|
+
unless @@blend2d_import_done
|
46
|
+
# Ref.: Using Multiple and Alternate Libraries
|
47
|
+
# https://github.com/ffi/ffi/wiki/Using-Multiple-and-Alternate-Libraries
|
48
|
+
begin
|
49
|
+
lib_paths = [libpath].compact
|
50
|
+
ffi_lib_flags :now, :global
|
51
|
+
ffi_lib *lib_paths
|
52
|
+
setup_symbols(output_error)
|
53
|
+
rescue => error
|
54
|
+
$stderr.puts("[Warning] Failed to load libraries (#{error}).") if output_error
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.setup_symbols(output_error = false)
|
61
|
+
setup_api_symbols(output_error)
|
62
|
+
setup_array_symbols(output_error)
|
63
|
+
setup_bitarray_symbols(output_error)
|
64
|
+
setup_bitset_symbols(output_error)
|
65
|
+
setup_context_symbols(output_error)
|
66
|
+
setup_filesystem_symbols(output_error)
|
67
|
+
setup_font_symbols(output_error)
|
68
|
+
setup_fontdata_symbols(output_error)
|
69
|
+
setup_fontdefs_symbols(output_error)
|
70
|
+
setup_fontface_symbols(output_error)
|
71
|
+
setup_fontfeaturesettings_symbols(output_error)
|
72
|
+
setup_fontmanager_symbols(output_error)
|
73
|
+
setup_fontvariationsettings_symbols(output_error)
|
74
|
+
setup_format_symbols(output_error)
|
75
|
+
setup_geometry_symbols(output_error)
|
76
|
+
setup_glyphbuffer_symbols(output_error)
|
77
|
+
setup_glyphrun_symbols(output_error)
|
78
|
+
setup_gradient_symbols(output_error)
|
79
|
+
setup_image_symbols(output_error)
|
80
|
+
setup_imagecodec_symbols(output_error)
|
81
|
+
setup_imagedecoder_symbols(output_error)
|
82
|
+
setup_imageencoder_symbols(output_error)
|
83
|
+
setup_matrix_symbols(output_error)
|
84
|
+
setup_object_symbols(output_error)
|
85
|
+
setup_path_symbols(output_error)
|
86
|
+
setup_pattern_symbols(output_error)
|
87
|
+
setup_pixelconverter_symbols(output_error)
|
88
|
+
setup_random_symbols(output_error)
|
89
|
+
setup_rgba_symbols(output_error)
|
90
|
+
setup_runtime_symbols(output_error)
|
91
|
+
setup_string_symbols(output_error)
|
92
|
+
setup_var_symbols(output_error)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
data/lib/blend2d_api.rb
ADDED
@@ -0,0 +1,255 @@
|
|
1
|
+
# Ruby-Blend2D : Yet another Blend2D wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/blend2d-bindings
|
4
|
+
#
|
5
|
+
# [NOTICE] Autogenerated. Do not edit.
|
6
|
+
|
7
|
+
require 'ffi'
|
8
|
+
|
9
|
+
module Blend2D
|
10
|
+
extend FFI::Library
|
11
|
+
# Define/Macro
|
12
|
+
|
13
|
+
|
14
|
+
# Enum
|
15
|
+
|
16
|
+
BL_SUCCESS = 0
|
17
|
+
BL_ERROR_START_INDEX = 65536
|
18
|
+
BL_ERROR_OUT_OF_MEMORY = 65536
|
19
|
+
BL_ERROR_INVALID_VALUE = 65537
|
20
|
+
BL_ERROR_INVALID_STATE = 65538
|
21
|
+
BL_ERROR_INVALID_HANDLE = 65539
|
22
|
+
BL_ERROR_INVALID_CONVERSION = 65540
|
23
|
+
BL_ERROR_OVERFLOW = 65541
|
24
|
+
BL_ERROR_NOT_INITIALIZED = 65542
|
25
|
+
BL_ERROR_NOT_IMPLEMENTED = 65543
|
26
|
+
BL_ERROR_NOT_PERMITTED = 65544
|
27
|
+
BL_ERROR_IO = 65545
|
28
|
+
BL_ERROR_BUSY = 65546
|
29
|
+
BL_ERROR_INTERRUPTED = 65547
|
30
|
+
BL_ERROR_TRY_AGAIN = 65548
|
31
|
+
BL_ERROR_TIMED_OUT = 65549
|
32
|
+
BL_ERROR_BROKEN_PIPE = 65550
|
33
|
+
BL_ERROR_INVALID_SEEK = 65551
|
34
|
+
BL_ERROR_SYMLINK_LOOP = 65552
|
35
|
+
BL_ERROR_FILE_TOO_LARGE = 65553
|
36
|
+
BL_ERROR_ALREADY_EXISTS = 65554
|
37
|
+
BL_ERROR_ACCESS_DENIED = 65555
|
38
|
+
BL_ERROR_MEDIA_CHANGED = 65556
|
39
|
+
BL_ERROR_READ_ONLY_FS = 65557
|
40
|
+
BL_ERROR_NO_DEVICE = 65558
|
41
|
+
BL_ERROR_NO_ENTRY = 65559
|
42
|
+
BL_ERROR_NO_MEDIA = 65560
|
43
|
+
BL_ERROR_NO_MORE_DATA = 65561
|
44
|
+
BL_ERROR_NO_MORE_FILES = 65562
|
45
|
+
BL_ERROR_NO_SPACE_LEFT = 65563
|
46
|
+
BL_ERROR_NOT_EMPTY = 65564
|
47
|
+
BL_ERROR_NOT_FILE = 65565
|
48
|
+
BL_ERROR_NOT_DIRECTORY = 65566
|
49
|
+
BL_ERROR_NOT_SAME_DEVICE = 65567
|
50
|
+
BL_ERROR_NOT_BLOCK_DEVICE = 65568
|
51
|
+
BL_ERROR_INVALID_FILE_NAME = 65569
|
52
|
+
BL_ERROR_FILE_NAME_TOO_LONG = 65570
|
53
|
+
BL_ERROR_TOO_MANY_OPEN_FILES = 65571
|
54
|
+
BL_ERROR_TOO_MANY_OPEN_FILES_BY_OS = 65572
|
55
|
+
BL_ERROR_TOO_MANY_LINKS = 65573
|
56
|
+
BL_ERROR_TOO_MANY_THREADS = 65574
|
57
|
+
BL_ERROR_THREAD_POOL_EXHAUSTED = 65575
|
58
|
+
BL_ERROR_FILE_EMPTY = 65576
|
59
|
+
BL_ERROR_OPEN_FAILED = 65577
|
60
|
+
BL_ERROR_NOT_ROOT_DEVICE = 65578
|
61
|
+
BL_ERROR_UNKNOWN_SYSTEM_ERROR = 65579
|
62
|
+
BL_ERROR_INVALID_ALIGNMENT = 65580
|
63
|
+
BL_ERROR_INVALID_SIGNATURE = 65581
|
64
|
+
BL_ERROR_INVALID_DATA = 65582
|
65
|
+
BL_ERROR_INVALID_STRING = 65583
|
66
|
+
BL_ERROR_INVALID_KEY = 65584
|
67
|
+
BL_ERROR_DATA_TRUNCATED = 65585
|
68
|
+
BL_ERROR_DATA_TOO_LARGE = 65586
|
69
|
+
BL_ERROR_DECOMPRESSION_FAILED = 65587
|
70
|
+
BL_ERROR_INVALID_GEOMETRY = 65588
|
71
|
+
BL_ERROR_NO_MATCHING_VERTEX = 65589
|
72
|
+
BL_ERROR_INVALID_CREATE_FLAGS = 65590
|
73
|
+
BL_ERROR_NO_MATCHING_COOKIE = 65591
|
74
|
+
BL_ERROR_NO_STATES_TO_RESTORE = 65592
|
75
|
+
BL_ERROR_TOO_MANY_SAVED_STATES = 65593
|
76
|
+
BL_ERROR_IMAGE_TOO_LARGE = 65594
|
77
|
+
BL_ERROR_IMAGE_NO_MATCHING_CODEC = 65595
|
78
|
+
BL_ERROR_IMAGE_UNKNOWN_FILE_FORMAT = 65596
|
79
|
+
BL_ERROR_IMAGE_DECODER_NOT_PROVIDED = 65597
|
80
|
+
BL_ERROR_IMAGE_ENCODER_NOT_PROVIDED = 65598
|
81
|
+
BL_ERROR_PNG_MULTIPLE_IHDR = 65599
|
82
|
+
BL_ERROR_PNG_INVALID_IDAT = 65600
|
83
|
+
BL_ERROR_PNG_INVALID_IEND = 65601
|
84
|
+
BL_ERROR_PNG_INVALID_PLTE = 65602
|
85
|
+
BL_ERROR_PNG_INVALID_TRNS = 65603
|
86
|
+
BL_ERROR_PNG_INVALID_FILTER = 65604
|
87
|
+
BL_ERROR_JPEG_UNSUPPORTED_FEATURE = 65605
|
88
|
+
BL_ERROR_JPEG_INVALID_SOS = 65606
|
89
|
+
BL_ERROR_JPEG_INVALID_SOF = 65607
|
90
|
+
BL_ERROR_JPEG_MULTIPLE_SOF = 65608
|
91
|
+
BL_ERROR_JPEG_UNSUPPORTED_SOF = 65609
|
92
|
+
BL_ERROR_FONT_NOT_INITIALIZED = 65610
|
93
|
+
BL_ERROR_FONT_NO_MATCH = 65611
|
94
|
+
BL_ERROR_FONT_NO_CHARACTER_MAPPING = 65612
|
95
|
+
BL_ERROR_FONT_MISSING_IMPORTANT_TABLE = 65613
|
96
|
+
BL_ERROR_FONT_FEATURE_NOT_AVAILABLE = 65614
|
97
|
+
BL_ERROR_FONT_CFF_INVALID_DATA = 65615
|
98
|
+
BL_ERROR_FONT_PROGRAM_TERMINATED = 65616
|
99
|
+
BL_ERROR_GLYPH_SUBSTITUTION_TOO_LARGE = 65617
|
100
|
+
BL_ERROR_INVALID_GLYPH = 65618
|
101
|
+
BL_ERROR_FORCE_UINT = -1
|
102
|
+
BL_BYTE_ORDER_LE = 0
|
103
|
+
BL_BYTE_ORDER_BE = 1
|
104
|
+
BL_BYTE_ORDER_NATIVE = 0
|
105
|
+
BL_BYTE_ORDER_SWAPPED = 1
|
106
|
+
BL_BYTE_ORDER_FORCE_UINT = -1
|
107
|
+
BL_DATA_ACCESS_NO_FLAGS = 0
|
108
|
+
BL_DATA_ACCESS_READ = 1
|
109
|
+
BL_DATA_ACCESS_WRITE = 2
|
110
|
+
BL_DATA_ACCESS_RW = 3
|
111
|
+
BL_DATA_ACCESS_FORCE_UINT = -1
|
112
|
+
BL_DATA_SOURCE_TYPE_NONE = 0
|
113
|
+
BL_DATA_SOURCE_TYPE_MEMORY = 1
|
114
|
+
BL_DATA_SOURCE_TYPE_FILE = 2
|
115
|
+
BL_DATA_SOURCE_TYPE_CUSTOM = 3
|
116
|
+
BL_DATA_SOURCE_TYPE_MAX_VALUE = 3
|
117
|
+
BL_DATA_SOURCE_TYPE_FORCE_UINT = -1
|
118
|
+
BL_MODIFY_OP_ASSIGN_FIT = 0
|
119
|
+
BL_MODIFY_OP_ASSIGN_GROW = 1
|
120
|
+
BL_MODIFY_OP_APPEND_FIT = 2
|
121
|
+
BL_MODIFY_OP_APPEND_GROW = 3
|
122
|
+
BL_MODIFY_OP_MAX_VALUE = 3
|
123
|
+
BL_MODIFY_OP_FORCE_UINT = -1
|
124
|
+
BL_BOOLEAN_OP_COPY = 0
|
125
|
+
BL_BOOLEAN_OP_AND = 1
|
126
|
+
BL_BOOLEAN_OP_OR = 2
|
127
|
+
BL_BOOLEAN_OP_XOR = 3
|
128
|
+
BL_BOOLEAN_OP_AND_NOT = 4
|
129
|
+
BL_BOOLEAN_OP_NOT_AND = 5
|
130
|
+
BL_BOOLEAN_OP_MAX_VALUE = 5
|
131
|
+
BL_BOOLEAN_OP_FORCE_UINT = -1
|
132
|
+
BL_EXTEND_MODE_PAD = 0
|
133
|
+
BL_EXTEND_MODE_REPEAT = 1
|
134
|
+
BL_EXTEND_MODE_REFLECT = 2
|
135
|
+
BL_EXTEND_MODE_PAD_X_PAD_Y = 0
|
136
|
+
BL_EXTEND_MODE_PAD_X_REPEAT_Y = 3
|
137
|
+
BL_EXTEND_MODE_PAD_X_REFLECT_Y = 4
|
138
|
+
BL_EXTEND_MODE_REPEAT_X_REPEAT_Y = 1
|
139
|
+
BL_EXTEND_MODE_REPEAT_X_PAD_Y = 5
|
140
|
+
BL_EXTEND_MODE_REPEAT_X_REFLECT_Y = 6
|
141
|
+
BL_EXTEND_MODE_REFLECT_X_REFLECT_Y = 2
|
142
|
+
BL_EXTEND_MODE_REFLECT_X_PAD_Y = 7
|
143
|
+
BL_EXTEND_MODE_REFLECT_X_REPEAT_Y = 8
|
144
|
+
BL_EXTEND_MODE_SIMPLE_MAX_VALUE = 2
|
145
|
+
BL_EXTEND_MODE_COMPLEX_MAX_VALUE = 8
|
146
|
+
BL_EXTEND_MODE_MAX_VALUE = 8
|
147
|
+
BL_EXTEND_MODE_FORCE_UINT = -1
|
148
|
+
BL_TEXT_ENCODING_UTF8 = 0
|
149
|
+
BL_TEXT_ENCODING_UTF16 = 1
|
150
|
+
BL_TEXT_ENCODING_UTF32 = 2
|
151
|
+
BL_TEXT_ENCODING_LATIN1 = 3
|
152
|
+
BL_TEXT_ENCODING_WCHAR = 1
|
153
|
+
BL_TEXT_ENCODING_MAX_VALUE = 3
|
154
|
+
BL_TEXT_ENCODING_FORCE_UINT = -1
|
155
|
+
|
156
|
+
# Typedef
|
157
|
+
|
158
|
+
typedef :uint, :BLResult
|
159
|
+
typedef :uint, :BLTag
|
160
|
+
typedef :ulong_long, :BLUniqueId
|
161
|
+
typedef :void, :BLUnknown
|
162
|
+
callback :BLDebugMessageSinkFunc, [:pointer, :ulong_long, :pointer], :void
|
163
|
+
typedef :int, :BLResultCode
|
164
|
+
typedef :int, :BLByteOrder
|
165
|
+
typedef :int, :BLDataAccessFlags
|
166
|
+
typedef :int, :BLDataSourceType
|
167
|
+
typedef :int, :BLModifyOp
|
168
|
+
typedef :int, :BLBooleanOp
|
169
|
+
typedef :int, :BLExtendMode
|
170
|
+
typedef :int, :BLTextEncoding
|
171
|
+
|
172
|
+
# Struct
|
173
|
+
|
174
|
+
class BLRange < FFI::Struct
|
175
|
+
layout(
|
176
|
+
:start, :ulong_long,
|
177
|
+
:end, :ulong_long,
|
178
|
+
)
|
179
|
+
def start = self[:start]
|
180
|
+
def start=(v) self[:start] = v end
|
181
|
+
def end = self[:end]
|
182
|
+
def end=(v) self[:end] = v end
|
183
|
+
def self.create_as(_start_, _end_)
|
184
|
+
instance = BLRange.new
|
185
|
+
instance[:start] = _start_
|
186
|
+
instance[:end] = _end_
|
187
|
+
instance
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
class BLArrayView < FFI::Struct
|
192
|
+
layout(
|
193
|
+
:data, :pointer,
|
194
|
+
:size, :ulong_long,
|
195
|
+
)
|
196
|
+
def data = self[:data]
|
197
|
+
def data=(v) self[:data] = v end
|
198
|
+
def size = self[:size]
|
199
|
+
def size=(v) self[:size] = v end
|
200
|
+
def self.create_as(_data_, _size_)
|
201
|
+
instance = BLArrayView.new
|
202
|
+
instance[:data] = _data_
|
203
|
+
instance[:size] = _size_
|
204
|
+
instance
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
class BLStringView < FFI::Struct
|
209
|
+
layout(
|
210
|
+
:data, :pointer,
|
211
|
+
:size, :ulong_long,
|
212
|
+
)
|
213
|
+
def data = self[:data]
|
214
|
+
def data=(v) self[:data] = v end
|
215
|
+
def size = self[:size]
|
216
|
+
def size=(v) self[:size] = v end
|
217
|
+
def self.create_as(_data_, _size_)
|
218
|
+
instance = BLStringView.new
|
219
|
+
instance[:data] = _data_
|
220
|
+
instance[:size] = _size_
|
221
|
+
instance
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
# Function
|
227
|
+
|
228
|
+
def self.setup_api_symbols(output_error = false)
|
229
|
+
symbols = [
|
230
|
+
:blTraceError,
|
231
|
+
:blRuntimeAssertionFailure,
|
232
|
+
]
|
233
|
+
apis = {
|
234
|
+
:blTraceError => :blTraceError,
|
235
|
+
:blRuntimeAssertionFailure => :blRuntimeAssertionFailure,
|
236
|
+
}
|
237
|
+
args = {
|
238
|
+
:blTraceError => [:uint],
|
239
|
+
:blRuntimeAssertionFailure => [:pointer, :int, :pointer],
|
240
|
+
}
|
241
|
+
retvals = {
|
242
|
+
:blTraceError => :uint,
|
243
|
+
:blRuntimeAssertionFailure => :void,
|
244
|
+
}
|
245
|
+
symbols.each do |sym|
|
246
|
+
begin
|
247
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
248
|
+
rescue FFI::NotFoundError => error
|
249
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
end
|
255
|
+
|