rays 0.3.11 → 0.3.13
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 +4 -4
- data/.doc/ext/rays/image.cpp +10 -0
- data/.doc/ext/rays/painter.cpp +49 -1
- data/.doc/ext/rays/shader.cpp +8 -6
- data/.github/workflows/release-gem.yml +5 -16
- data/.github/workflows/utils.rb +88 -17
- data/ChangeLog.md +26 -0
- data/README.md +164 -5
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/ext/rays/extconf.rb +3 -4
- data/ext/rays/image.cpp +11 -0
- data/ext/rays/painter.cpp +53 -1
- data/ext/rays/shader.cpp +8 -6
- data/include/rays/coord.h +6 -6
- data/include/rays/defs.h +2 -0
- data/include/rays/image.h +11 -1
- data/include/rays/painter.h +19 -0
- data/include/rays/ruby.h +2 -2
- data/include/rays/shader.h +5 -3
- data/include/rays.h +2 -2
- data/lib/rays/extension.rb +8 -2
- data/lib/rays/image.rb +2 -1
- data/lib/rays/shader.rb +13 -4
- data/rays.gemspec +3 -4
- data/src/color_space.cpp +1 -1
- data/src/coord.h +10 -0
- data/src/font.cpp +1 -1
- data/src/image.cpp +85 -10
- data/src/opengl/painter.cpp +559 -214
- data/src/opengl/render_buffer.cpp +1 -1
- data/src/opengl/sdl/opengl.cpp +6 -0
- data/src/opengl/shader.cpp +68 -51
- data/src/opengl/shader.h +10 -6
- data/src/opengl/shader_program.cpp +21 -7
- data/src/opengl/shader_program.h +2 -1
- data/src/opengl/shader_source.cpp +2 -4
- data/src/opengl/texture.cpp +18 -6
- data/src/osx/bitmap.mm +1 -1
- data/src/painter.cpp +80 -26
- data/src/painter.h +26 -13
- data/src/sdl/font.cpp +358 -9
- data/src/sdl/rays.cpp +5 -0
- data/src/texture.h +6 -0
- data/test/test_painter.rb +36 -25
- data/test/test_painter_batch.rb +254 -0
- metadata +8 -6
data/ext/rays/painter.cpp
CHANGED
|
@@ -266,7 +266,17 @@ RUCY_DEFN(image)
|
|
|
266
266
|
CHECK;
|
|
267
267
|
check_arg_count(__FILE__, __LINE__, "Painter#image", argc, 1, 3, 5, 7, 9);
|
|
268
268
|
|
|
269
|
-
|
|
269
|
+
RUCY_SYM(to_image);
|
|
270
|
+
std::unique_ptr<Rays::Image> pimage;
|
|
271
|
+
|
|
272
|
+
const Rays::Image* image = NULL;
|
|
273
|
+
if (argv[0].is_a(Rays::image_class()))
|
|
274
|
+
image = to<Rays::Image*>(argv[0]);
|
|
275
|
+
else if (argv[0].respond_to(to_image))
|
|
276
|
+
{
|
|
277
|
+
pimage.reset(new Rays::Image(to<const Rays::Image&>(argv[0].call(to_image))));
|
|
278
|
+
image = pimage.get();
|
|
279
|
+
}
|
|
270
280
|
if (!image)
|
|
271
281
|
argument_error(__FILE__, __LINE__, "%s is not an image.", argv[0].inspect().c_str());
|
|
272
282
|
|
|
@@ -810,6 +820,42 @@ RUCY_DEF0(pop_matrix)
|
|
|
810
820
|
RUCY_END
|
|
811
821
|
|
|
812
822
|
|
|
823
|
+
static
|
|
824
|
+
RUCY_DEF1(set_debug, debug)
|
|
825
|
+
{
|
|
826
|
+
CHECK;
|
|
827
|
+
if (debug)
|
|
828
|
+
THIS->remove_flag(Rays::Painter::FLAG_BATCHING);
|
|
829
|
+
else
|
|
830
|
+
THIS-> add_flag(Rays::Painter::FLAG_BATCHING);
|
|
831
|
+
return debug;
|
|
832
|
+
}
|
|
833
|
+
RUCY_END
|
|
834
|
+
|
|
835
|
+
static
|
|
836
|
+
RUCY_DEF0(get_debug)
|
|
837
|
+
{
|
|
838
|
+
CHECK;
|
|
839
|
+
return value(!THIS->has_flag(Rays::Painter::FLAG_BATCHING));
|
|
840
|
+
}
|
|
841
|
+
RUCY_END
|
|
842
|
+
|
|
843
|
+
static
|
|
844
|
+
RUCY_DEF1(set_global_debug, debug)
|
|
845
|
+
{
|
|
846
|
+
Rays::Painter::set_debug(debug);
|
|
847
|
+
return debug;
|
|
848
|
+
}
|
|
849
|
+
RUCY_END
|
|
850
|
+
|
|
851
|
+
static
|
|
852
|
+
RUCY_DEF0(get_global_debug)
|
|
853
|
+
{
|
|
854
|
+
return value(Rays::Painter::debug());
|
|
855
|
+
}
|
|
856
|
+
RUCY_END
|
|
857
|
+
|
|
858
|
+
|
|
813
859
|
static Class cPainter;
|
|
814
860
|
|
|
815
861
|
void
|
|
@@ -890,6 +936,12 @@ Init_rays_painter ()
|
|
|
890
936
|
cPainter.define_method("matrix", get_matrix);
|
|
891
937
|
cPainter.define_method("push_matrix", push_matrix);
|
|
892
938
|
cPainter.define_method( "pop_matrix", pop_matrix);
|
|
939
|
+
|
|
940
|
+
cPainter.define_method("debug=", set_debug);
|
|
941
|
+
cPainter.define_method("debug?", get_debug);
|
|
942
|
+
|
|
943
|
+
cPainter.define_singleton_method("debug=", set_global_debug);
|
|
944
|
+
cPainter.define_singleton_method("debug?", get_global_debug);
|
|
893
945
|
}
|
|
894
946
|
|
|
895
947
|
|
data/ext/rays/shader.cpp
CHANGED
|
@@ -67,15 +67,17 @@ make_env (const Value& names, const Value& ignore_no_uniform_location_error)
|
|
|
67
67
|
to_name_list(names, 0),
|
|
68
68
|
to_name_list(names, 1),
|
|
69
69
|
to_name_list(names, 2),
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
to_name_list(names, 3),
|
|
71
|
+
to_name_list(names, 4),
|
|
72
72
|
to_name( names, 5),
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
to_name( names, 6),
|
|
74
|
+
to_name( names, 7),
|
|
75
|
+
to_name( names, 8),
|
|
76
|
+
to_name( names, 9),
|
|
77
77
|
to_name_list(names, 10),
|
|
78
78
|
to_name_list(names, 11),
|
|
79
|
+
to_name_list(names, 12),
|
|
80
|
+
to_name_list(names, 13),
|
|
79
81
|
flags);
|
|
80
82
|
}
|
|
81
83
|
|
data/include/rays/coord.h
CHANGED
|
@@ -25,9 +25,9 @@ namespace Rays
|
|
|
25
25
|
coord array[SIZE];
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
This& reset (coord value = 0);
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
This& reset (coord x, coord y);
|
|
31
31
|
|
|
32
32
|
size_t size () const;
|
|
33
33
|
|
|
@@ -58,9 +58,9 @@ namespace Rays
|
|
|
58
58
|
|
|
59
59
|
This& operator = (const Coord2& rhs);
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
This& reset (coord value = 0);
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
This& reset (coord x, coord y, coord z = 0);
|
|
64
64
|
|
|
65
65
|
size_t size () const;
|
|
66
66
|
|
|
@@ -93,9 +93,9 @@ namespace Rays
|
|
|
93
93
|
|
|
94
94
|
This& operator = (const Coord3& rhs);
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
This& reset (coord value = 0);
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
This& reset (coord x, coord y, coord z = 0, coord w = 1);
|
|
99
99
|
|
|
100
100
|
size_t size () const;
|
|
101
101
|
|
data/include/rays/defs.h
CHANGED
data/include/rays/image.h
CHANGED
|
@@ -61,10 +61,20 @@ namespace Rays
|
|
|
61
61
|
|
|
62
62
|
bool operator ! () const;
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
friend bool operator == (const This& lhs, const This& rhs);
|
|
65
|
+
|
|
66
|
+
friend bool operator != (const This& lhs, const This& rhs);
|
|
67
|
+
|
|
68
|
+
struct Data
|
|
69
|
+
{
|
|
70
|
+
virtual ~Data ();
|
|
71
|
+
virtual void preprocess (const Image* image) const;
|
|
72
|
+
};
|
|
65
73
|
|
|
66
74
|
Xot::PSharedImpl<Data> self;
|
|
67
75
|
|
|
76
|
+
Image (Data* data);
|
|
77
|
+
|
|
68
78
|
};// Image
|
|
69
79
|
|
|
70
80
|
|
data/include/rays/painter.h
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
#include <xot/pimpl.h>
|
|
8
|
+
#include <xot/util.h>
|
|
8
9
|
#include <rays/defs.h>
|
|
9
10
|
#include <rays/point.h>
|
|
10
11
|
|
|
@@ -29,6 +30,15 @@ namespace Rays
|
|
|
29
30
|
|
|
30
31
|
public:
|
|
31
32
|
|
|
33
|
+
enum Flag
|
|
34
|
+
{
|
|
35
|
+
|
|
36
|
+
FLAG_BATCHING = Xot::bit(0),
|
|
37
|
+
|
|
38
|
+
FLAG_LAST = FLAG_BATCHING
|
|
39
|
+
|
|
40
|
+
};// Flag
|
|
41
|
+
|
|
32
42
|
Painter ();
|
|
33
43
|
|
|
34
44
|
~Painter ();
|
|
@@ -322,10 +332,19 @@ namespace Rays
|
|
|
322
332
|
void pop_matrix ();
|
|
323
333
|
|
|
324
334
|
|
|
335
|
+
void add_flag (uint flags);
|
|
336
|
+
|
|
337
|
+
void remove_flag (uint flags);
|
|
338
|
+
|
|
339
|
+
bool has_flag (uint flags) const;
|
|
340
|
+
|
|
325
341
|
operator bool () const;
|
|
326
342
|
|
|
327
343
|
bool operator ! () const;
|
|
328
344
|
|
|
345
|
+
static void set_debug (bool debug);
|
|
346
|
+
|
|
347
|
+
static bool debug ();
|
|
329
348
|
|
|
330
349
|
struct Data;
|
|
331
350
|
|
data/include/rays/ruby.h
CHANGED
data/include/rays/shader.h
CHANGED
|
@@ -98,15 +98,17 @@ namespace Rays
|
|
|
98
98
|
ShaderEnv (
|
|
99
99
|
const NameList& attribute_position_names = {},
|
|
100
100
|
const NameList& attribute_texcoord_names = {},
|
|
101
|
+
const NameList& attribute_texcoord_min_names = {},
|
|
102
|
+
const NameList& attribute_texcoord_max_names = {},
|
|
101
103
|
const NameList& attribute_color_names = {},
|
|
102
104
|
const char* varying_position_name = NULL,
|
|
103
105
|
const char* varying_texcoord_name = NULL,
|
|
106
|
+
const char* varying_texcoord_min_name = NULL,
|
|
107
|
+
const char* varying_texcoord_max_name = NULL,
|
|
104
108
|
const char* varying_color_name = NULL,
|
|
105
109
|
const NameList& uniform_position_matrix_names = {},
|
|
106
110
|
const NameList& uniform_texcoord_matrix_names = {},
|
|
107
|
-
const NameList&
|
|
108
|
-
const NameList& uniform_texcoord_max_names = {},
|
|
109
|
-
const NameList& uniform_texcoord_offset_names = {},
|
|
111
|
+
const NameList& uniform_texcoord_pixel_names = {},
|
|
110
112
|
const NameList& uniform_texture_names = {},
|
|
111
113
|
uint flags = 0);
|
|
112
114
|
|
data/include/rays.h
CHANGED
data/lib/rays/extension.rb
CHANGED
|
@@ -5,8 +5,10 @@ module Rays
|
|
|
5
5
|
|
|
6
6
|
module_function
|
|
7
7
|
|
|
8
|
-
def name()
|
|
9
|
-
super.split('::')[-2]
|
|
8
|
+
def name(downcase = false)
|
|
9
|
+
super().split('::')[-2].then {|s|
|
|
10
|
+
downcase ? s.gsub(/([a-z])([A-Z])/) {"#{$1}-#{$2}"}.downcase : s
|
|
11
|
+
}
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
def version()
|
|
@@ -29,6 +31,10 @@ module Rays
|
|
|
29
31
|
root_dir 'ext'
|
|
30
32
|
end
|
|
31
33
|
|
|
34
|
+
def lib_name()
|
|
35
|
+
"#{name true}.dll" if /mswin|ming|cygwin/.match? RUBY_PLATFORM
|
|
36
|
+
end
|
|
37
|
+
|
|
32
38
|
end# Extension
|
|
33
39
|
|
|
34
40
|
|
data/lib/rays/image.rb
CHANGED
data/lib/rays/shader.rb
CHANGED
|
@@ -17,10 +17,19 @@ module Rays
|
|
|
17
17
|
setup(
|
|
18
18
|
fragment_shader_source, vertex_shader_source,
|
|
19
19
|
builtin_variable_names&.values_at(
|
|
20
|
-
:attribute_position,
|
|
21
|
-
|
|
22
|
-
:
|
|
23
|
-
:
|
|
20
|
+
:attribute_position,
|
|
21
|
+
:attribute_texcoord,
|
|
22
|
+
:attribute_texcoord_min,
|
|
23
|
+
:attribute_texcoord_max,
|
|
24
|
+
:attribute_color,
|
|
25
|
+
:varying_position,
|
|
26
|
+
:varying_texcoord,
|
|
27
|
+
:varying_texcoord_min,
|
|
28
|
+
:varying_texcoord_max,
|
|
29
|
+
:varying_color,
|
|
30
|
+
:uniform_position_matrix,
|
|
31
|
+
:uniform_texcoord_matrix,
|
|
32
|
+
:uniform_texcoord_pixel,
|
|
24
33
|
:uniform_texture),
|
|
25
34
|
ignore_no_uniform_location_error)
|
|
26
35
|
|
data/rays.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
ext = Rays::Extension
|
|
13
|
-
name = ext.name
|
|
13
|
+
name = ext.name true
|
|
14
14
|
rdocs = glob.call *%w[README .doc/ext/**/*.cpp]
|
|
15
15
|
|
|
16
16
|
s.name = name
|
|
@@ -25,14 +25,13 @@ Gem::Specification.new do |s|
|
|
|
25
25
|
s.platform = Gem::Platform::RUBY
|
|
26
26
|
s.required_ruby_version = '>= 3.0.0'
|
|
27
27
|
|
|
28
|
-
s.add_dependency 'xot', '~> 0.3.
|
|
29
|
-
s.add_dependency 'rucy', '~> 0.3.
|
|
28
|
+
s.add_dependency 'xot', '~> 0.3.13'
|
|
29
|
+
s.add_dependency 'rucy', '~> 0.3.13'
|
|
30
30
|
|
|
31
31
|
s.files = `git ls-files`.split $/
|
|
32
32
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
|
33
33
|
s.test_files = s.files.grep %r{^(test|spec|features)/}
|
|
34
34
|
s.extra_rdoc_files = rdocs.to_a
|
|
35
|
-
s.has_rdoc = true
|
|
36
35
|
|
|
37
36
|
s.metadata['msys2_mingw_dependencies'] = 'glew'
|
|
38
37
|
|
data/src/color_space.cpp
CHANGED
|
@@ -133,7 +133,7 @@ namespace Rays
|
|
|
133
133
|
ColorSpace::has_alpha () const
|
|
134
134
|
{
|
|
135
135
|
return
|
|
136
|
-
(ALPHA_FIRST <= type_ && type_ <= ALPHA_LAST) ||
|
|
136
|
+
(ALPHA_FIRST <= (int) type_ && (int) type_ <= ALPHA_LAST) ||
|
|
137
137
|
type_ == RGBA_8888 || type_ == ARGB_8888 ||
|
|
138
138
|
type_ == BGRA_8888 || type_ == ABGR_8888 ||
|
|
139
139
|
type_ == RGBA_float || type_ == ARGB_float ||
|
data/src/coord.h
CHANGED
|
@@ -21,12 +21,22 @@ namespace Rays
|
|
|
21
21
|
|
|
22
22
|
inline const Vec3& to_glm (const Coord3& val) {return *(const Vec3*) &val;}
|
|
23
23
|
|
|
24
|
+
inline Vec4& to_glm ( Coord4& val) {return *( Vec4*) &val;}
|
|
25
|
+
|
|
26
|
+
inline const Vec4& to_glm (const Coord4& val) {return *(const Vec4*) &val;}
|
|
27
|
+
|
|
24
28
|
template <typename T>
|
|
25
29
|
inline T& to_rays ( Vec3& val) {return *( T*) &val;}
|
|
26
30
|
|
|
27
31
|
template <typename T>
|
|
28
32
|
inline const T& to_rays (const Vec3& val) {return *(const T*) &val;}
|
|
29
33
|
|
|
34
|
+
template <typename T>
|
|
35
|
+
inline T& to_rays ( Vec4& val) {return *( T*) &val;}
|
|
36
|
+
|
|
37
|
+
template <typename T>
|
|
38
|
+
inline const T& to_rays (const Vec4& val) {return *(const T*) &val;}
|
|
39
|
+
|
|
30
40
|
|
|
31
41
|
}// Rays
|
|
32
42
|
|
data/src/font.cpp
CHANGED
data/src/image.cpp
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
#if 0
|
|
13
|
-
#define PRINT_MODIFIED_FLAGS(message)
|
|
13
|
+
#define PRINT_MODIFIED_FLAGS(message) get_data(this)->print_modified_flags(message)
|
|
14
14
|
#else
|
|
15
15
|
#define PRINT_MODIFIED_FLAGS(message)
|
|
16
16
|
#endif
|
|
@@ -20,16 +20,16 @@ namespace Rays
|
|
|
20
20
|
{
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
struct Image::Data
|
|
23
|
+
struct ImageData : Image::Data
|
|
24
24
|
{
|
|
25
25
|
|
|
26
26
|
int width = 0, height = 0;
|
|
27
27
|
|
|
28
|
-
ColorSpace color_space;
|
|
29
|
-
|
|
30
28
|
float pixel_density = 1;
|
|
31
29
|
|
|
32
|
-
bool smooth
|
|
30
|
+
bool smooth = false;
|
|
31
|
+
|
|
32
|
+
ColorSpace color_space;
|
|
33
33
|
|
|
34
34
|
mutable Bitmap bitmap;
|
|
35
35
|
|
|
@@ -48,10 +48,23 @@ namespace Rays
|
|
|
48
48
|
};// Image::Data
|
|
49
49
|
|
|
50
50
|
|
|
51
|
+
static ImageData*
|
|
52
|
+
get_data (Image* image)
|
|
53
|
+
{
|
|
54
|
+
return (ImageData*) image->self.get();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static const ImageData*
|
|
58
|
+
get_data (const Image* image)
|
|
59
|
+
{
|
|
60
|
+
return (const ImageData*) image->self.get();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
51
64
|
static void
|
|
52
65
|
clear_modified_flags (Image* image)
|
|
53
66
|
{
|
|
54
|
-
|
|
67
|
+
ImageData* self = get_data(image);
|
|
55
68
|
|
|
56
69
|
if (self->bitmap) Bitmap_set_modified(&self->bitmap, false);
|
|
57
70
|
if (self->texture) self->texture.set_modified(false);
|
|
@@ -61,7 +74,7 @@ namespace Rays
|
|
|
61
74
|
invalidate_texture (Image* image)
|
|
62
75
|
{
|
|
63
76
|
image->bitmap();// update bitmap
|
|
64
|
-
image->
|
|
77
|
+
get_data(image)->texture = Texture();
|
|
65
78
|
}
|
|
66
79
|
|
|
67
80
|
static Bitmap&
|
|
@@ -69,7 +82,7 @@ namespace Rays
|
|
|
69
82
|
{
|
|
70
83
|
assert(image);
|
|
71
84
|
|
|
72
|
-
|
|
85
|
+
ImageData* self = get_data(image);
|
|
73
86
|
|
|
74
87
|
if (!*image)
|
|
75
88
|
{
|
|
@@ -112,7 +125,7 @@ namespace Rays
|
|
|
112
125
|
Texture&
|
|
113
126
|
Image_get_texture (Image& image)
|
|
114
127
|
{
|
|
115
|
-
|
|
128
|
+
ImageData* self = get_data(&image);
|
|
116
129
|
|
|
117
130
|
if (!image)
|
|
118
131
|
{
|
|
@@ -171,17 +184,30 @@ namespace Rays
|
|
|
171
184
|
}
|
|
172
185
|
|
|
173
186
|
|
|
187
|
+
Image::Data::~Data ()
|
|
188
|
+
{
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
void
|
|
192
|
+
Image::Data::preprocess (const Image*) const
|
|
193
|
+
{
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
174
197
|
Image::Image ()
|
|
198
|
+
: self(new ImageData())
|
|
175
199
|
{
|
|
176
200
|
}
|
|
177
201
|
|
|
178
202
|
Image::Image (
|
|
179
203
|
int width, int height, const ColorSpace& cs,
|
|
180
204
|
float pixel_density, bool smooth)
|
|
205
|
+
: self(new ImageData())
|
|
181
206
|
{
|
|
182
207
|
if (pixel_density <= 0)
|
|
183
208
|
argument_error(__FILE__, __LINE__, "invalid pixel_density.");
|
|
184
209
|
|
|
210
|
+
ImageData* self = get_data(this);
|
|
185
211
|
self->width = (int) (width * pixel_density);
|
|
186
212
|
self->height = (int) (height * pixel_density);
|
|
187
213
|
self->color_space = cs;
|
|
@@ -190,10 +216,12 @@ namespace Rays
|
|
|
190
216
|
}
|
|
191
217
|
|
|
192
218
|
Image::Image (const Bitmap& bitmap, float pixel_density, bool smooth)
|
|
219
|
+
: self(new ImageData())
|
|
193
220
|
{
|
|
194
221
|
if (pixel_density <= 0)
|
|
195
222
|
argument_error(__FILE__, __LINE__, "invalid pixel_density.");
|
|
196
223
|
|
|
224
|
+
ImageData* self = get_data(this);
|
|
197
225
|
self->bitmap = bitmap;
|
|
198
226
|
self->width = bitmap.width();
|
|
199
227
|
self->height = bitmap.height();
|
|
@@ -202,6 +230,11 @@ namespace Rays
|
|
|
202
230
|
self->smooth = smooth;
|
|
203
231
|
}
|
|
204
232
|
|
|
233
|
+
Image::Image (Data* data)
|
|
234
|
+
: self(data)
|
|
235
|
+
{
|
|
236
|
+
}
|
|
237
|
+
|
|
205
238
|
Image::~Image ()
|
|
206
239
|
{
|
|
207
240
|
}
|
|
@@ -209,12 +242,16 @@ namespace Rays
|
|
|
209
242
|
Image
|
|
210
243
|
Image::dup () const
|
|
211
244
|
{
|
|
245
|
+
self->preprocess(this);
|
|
246
|
+
|
|
212
247
|
return Image(bitmap().dup(), pixel_density());
|
|
213
248
|
}
|
|
214
249
|
|
|
215
250
|
void
|
|
216
251
|
Image::save (const char* path)
|
|
217
252
|
{
|
|
253
|
+
self->preprocess(this);
|
|
254
|
+
|
|
218
255
|
if (!*this)
|
|
219
256
|
invalid_state_error(__FILE__, __LINE__);
|
|
220
257
|
|
|
@@ -224,32 +261,47 @@ namespace Rays
|
|
|
224
261
|
coord
|
|
225
262
|
Image::width () const
|
|
226
263
|
{
|
|
264
|
+
self->preprocess(this);
|
|
265
|
+
|
|
266
|
+
const ImageData* self = get_data(this);
|
|
227
267
|
return self->width / self->pixel_density;
|
|
228
268
|
}
|
|
229
269
|
|
|
230
270
|
coord
|
|
231
271
|
Image::height () const
|
|
232
272
|
{
|
|
273
|
+
self->preprocess(this);
|
|
274
|
+
|
|
275
|
+
const ImageData* self = get_data(this);
|
|
233
276
|
return self->height / self->pixel_density;
|
|
234
277
|
}
|
|
235
278
|
|
|
236
279
|
const ColorSpace&
|
|
237
280
|
Image::color_space () const
|
|
238
281
|
{
|
|
282
|
+
self->preprocess(this);
|
|
283
|
+
|
|
284
|
+
const ImageData* self = get_data(this);
|
|
239
285
|
return self->color_space;
|
|
240
286
|
}
|
|
241
287
|
|
|
242
288
|
float
|
|
243
289
|
Image::pixel_density () const
|
|
244
290
|
{
|
|
291
|
+
self->preprocess(this);
|
|
292
|
+
|
|
293
|
+
const ImageData* self = get_data(this);
|
|
245
294
|
return self->pixel_density;
|
|
246
295
|
}
|
|
247
296
|
|
|
248
297
|
void
|
|
249
298
|
Image::set_smooth (bool smooth)
|
|
250
299
|
{
|
|
251
|
-
|
|
300
|
+
self->preprocess(this);
|
|
301
|
+
|
|
302
|
+
ImageData* self = get_data(this);
|
|
252
303
|
|
|
304
|
+
if (smooth == self->smooth) return;
|
|
253
305
|
self->smooth = smooth;
|
|
254
306
|
invalidate_texture(this);
|
|
255
307
|
}
|
|
@@ -257,12 +309,17 @@ namespace Rays
|
|
|
257
309
|
bool
|
|
258
310
|
Image::smooth () const
|
|
259
311
|
{
|
|
312
|
+
self->preprocess(this);
|
|
313
|
+
|
|
314
|
+
const ImageData* self = get_data(this);
|
|
260
315
|
return self->smooth;
|
|
261
316
|
}
|
|
262
317
|
|
|
263
318
|
Painter
|
|
264
319
|
Image::painter ()
|
|
265
320
|
{
|
|
321
|
+
self->preprocess(this);
|
|
322
|
+
|
|
266
323
|
Painter p;
|
|
267
324
|
p.bind(*this);
|
|
268
325
|
return p;
|
|
@@ -271,6 +328,9 @@ namespace Rays
|
|
|
271
328
|
Bitmap&
|
|
272
329
|
Image::bitmap (bool modify)
|
|
273
330
|
{
|
|
331
|
+
self->preprocess(this);
|
|
332
|
+
|
|
333
|
+
ImageData* self = get_data(this);
|
|
274
334
|
if (modify)
|
|
275
335
|
{
|
|
276
336
|
if (!self->bitmap) get_bitmap(this);
|
|
@@ -287,6 +347,9 @@ namespace Rays
|
|
|
287
347
|
|
|
288
348
|
Image::operator bool () const
|
|
289
349
|
{
|
|
350
|
+
self->preprocess(this);
|
|
351
|
+
|
|
352
|
+
const ImageData* self = get_data(this);
|
|
290
353
|
return
|
|
291
354
|
self->width > 0 &&
|
|
292
355
|
self->height > 0 &&
|
|
@@ -300,5 +363,17 @@ namespace Rays
|
|
|
300
363
|
return !operator bool();
|
|
301
364
|
}
|
|
302
365
|
|
|
366
|
+
bool
|
|
367
|
+
operator == (const Image& lhs, const Image& rhs)
|
|
368
|
+
{
|
|
369
|
+
return lhs.self == rhs.self;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
bool
|
|
373
|
+
operator != (const Image& lhs, const Image& rhs)
|
|
374
|
+
{
|
|
375
|
+
return !operator==(lhs, rhs);
|
|
376
|
+
}
|
|
377
|
+
|
|
303
378
|
|
|
304
379
|
}// Rays
|