gosu 0.12.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/Gosu/Audio.hpp +23 -25
  3. data/Gosu/Graphics.hpp +16 -12
  4. data/Gosu/Image.hpp +3 -0
  5. data/Gosu/Version.hpp +2 -2
  6. data/lib/gosu.rb +2 -2
  7. data/lib/gosu/compat.rb +1 -1
  8. data/lib/gosu/patches.rb +5 -0
  9. data/lib/gosu/swig_patches.rb +1 -1
  10. data/rdoc/gosu.rb +10 -10
  11. data/src/Audio.cpp +93 -228
  12. data/src/AudioImpl.cpp +94 -0
  13. data/src/AudioImpl.hpp +33 -0
  14. data/src/AudioToolboxFile.hpp +14 -18
  15. data/src/Bitmap.cpp +36 -30
  16. data/src/BitmapIO.cpp +14 -23
  17. data/src/BlockAllocator.cpp +7 -10
  18. data/src/BlockAllocator.hpp +2 -4
  19. data/src/Channel.cpp +89 -0
  20. data/src/Color.cpp +4 -9
  21. data/src/DirectoriesApple.cpp +13 -13
  22. data/src/DirectoriesUnix.cpp +8 -7
  23. data/src/DirectoriesWin.cpp +12 -11
  24. data/src/EmptyImageData.hpp +54 -0
  25. data/src/FileUnix.cpp +12 -9
  26. data/src/FileWin.cpp +8 -7
  27. data/src/Font.cpp +12 -13
  28. data/src/FormattedString.cpp +237 -0
  29. data/src/FormattedString.hpp +14 -265
  30. data/src/GosuViewController.cpp +2 -5
  31. data/src/Graphics.cpp +38 -39
  32. data/src/IO.cpp +11 -10
  33. data/src/Image.cpp +16 -9
  34. data/src/Input.cpp +16 -15
  35. data/src/InputUIKit.cpp +8 -7
  36. data/src/Macro.cpp +11 -11
  37. data/src/Math.cpp +9 -8
  38. data/src/RubyGosu.cxx +129 -99
  39. data/src/TextApple.cpp +19 -13
  40. data/src/TextInput.cpp +23 -22
  41. data/src/TextWin.cpp +17 -19
  42. data/src/Texture.cpp +15 -10
  43. data/src/Transform.cpp +13 -17
  44. data/src/Utility.cpp +3 -2
  45. data/src/UtilityApple.cpp +10 -11
  46. data/src/UtilityWin.cpp +2 -1
  47. data/src/Version.cpp +5 -4
  48. data/src/WinMain.cpp +3 -3
  49. data/src/WinUtility.cpp +7 -6
  50. data/src/Window.cpp +11 -10
  51. data/src/WindowUIKit.cpp +9 -8
  52. data/src/stb_image.h +782 -480
  53. data/src/stb_image_write.h +425 -15
  54. data/src/stb_vorbis.c +82 -32
  55. metadata +8 -4
  56. data/src/ALChannelManagement.hpp +0 -119
@@ -1,4 +1,4 @@
1
- // Ogg Vorbis audio decoder - v1.09 - public domain
1
+ // Ogg Vorbis audio decoder - v1.11 - public domain
2
2
  // http://nothings.org/stb_vorbis/
3
3
  //
4
4
  // Original version written by Sean Barrett in 2007.
@@ -9,12 +9,7 @@
9
9
  //
10
10
  // LICENSE
11
11
  //
12
- // This software is dual-licensed to the public domain and under the following
13
- // license: you are granted a perpetual, irrevocable license to copy, modify,
14
- // publish, and distribute this file as you see fit.
15
- //
16
- // No warranty for any purpose is expressed or implied by the author (nor
17
- // by RAD Game Tools). Report bugs and send enhancements to the author.
12
+ // See end of file for license information.
18
13
  //
19
14
  // Limitations:
20
15
  //
@@ -34,9 +29,11 @@
34
29
  // Bernhard Wodo Evan Balster alxprd@github
35
30
  // Tom Beaumont Ingo Leitgeb Nicolas Guillemot
36
31
  // Phillip Bennefall Rohit Thiago Goulart
37
- // manxorist@github saga musix
32
+ // manxorist@github saga musix github:infatum
38
33
  //
39
34
  // Partial history:
35
+ // 1.11 - 2017/07/23 - fix MinGW compilation
36
+ // 1.10 - 2017/03/03 - more robust seeking; fix negative ilog(); clear error in open_memory
40
37
  // 1.09 - 2016/04/04 - back out 'truncation of last frame' fix from previous version
41
38
  // 1.08 - 2016/04/02 - warnings; setup memory leaks; truncation of last frame
42
39
  // 1.07 - 2015/01/16 - fixes for crashes on invalid files; warning fixes; const
@@ -275,7 +272,7 @@ extern int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number);
275
272
  // do not need to seek to EXACTLY the target sample when using get_samples_*,
276
273
  // you can also use seek_frame().
277
274
 
278
- extern void stb_vorbis_seek_start(stb_vorbis *f);
275
+ extern int stb_vorbis_seek_start(stb_vorbis *f);
279
276
  // this function is equivalent to stb_vorbis_seek(f,0)
280
277
 
281
278
  extern unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f);
@@ -555,7 +552,7 @@ enum STBVorbisError
555
552
  #include <math.h>
556
553
 
557
554
  // find definition of alloca if it's not in stdlib.h:
558
- #ifdef _MSC_VER
555
+ #if defined(_MSC_VER) || defined(__MINGW32__)
559
556
  #include <malloc.h>
560
557
  #endif
561
558
  #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__)
@@ -580,6 +577,7 @@ enum STBVorbisError
580
577
  #undef __forceinline
581
578
  #endif
582
579
  #define __forceinline
580
+ #define alloca __builtin_alloca
583
581
  #elif !defined(_MSC_VER)
584
582
  #if __GNUC__
585
583
  #define __forceinline inline
@@ -986,17 +984,18 @@ static int ilog(int32 n)
986
984
  {
987
985
  static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 };
988
986
 
987
+ if (n < 0) return 0; // signed n returns 0
988
+
989
989
  // 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29)
990
990
  if (n < (1 << 14))
991
- if (n < (1 << 4)) return 0 + log2_4[n ];
992
- else if (n < (1 << 9)) return 5 + log2_4[n >> 5];
991
+ if (n < (1 << 4)) return 0 + log2_4[n ];
992
+ else if (n < (1 << 9)) return 5 + log2_4[n >> 5];
993
993
  else return 10 + log2_4[n >> 10];
994
994
  else if (n < (1 << 24))
995
- if (n < (1 << 19)) return 15 + log2_4[n >> 15];
995
+ if (n < (1 << 19)) return 15 + log2_4[n >> 15];
996
996
  else return 20 + log2_4[n >> 20];
997
- else if (n < (1 << 29)) return 25 + log2_4[n >> 25];
998
- else if (n < (1 << 31)) return 30 + log2_4[n >> 30];
999
- else return 0; // signed n returns 0
997
+ else if (n < (1 << 29)) return 25 + log2_4[n >> 25];
998
+ else return 30 + log2_4[n >> 30];
1000
999
  }
1001
1000
 
1002
1001
  #ifndef M_PI
@@ -1269,13 +1268,13 @@ static void neighbors(uint16 *x, int n, int *plow, int *phigh)
1269
1268
  // this has been repurposed so y is now the original index instead of y
1270
1269
  typedef struct
1271
1270
  {
1272
- uint16 x,y;
1273
- } stbv__point;
1271
+ uint16 x,id;
1272
+ } stbv__floor_ordering;
1274
1273
 
1275
1274
  static int STBV_CDECL point_compare(const void *p, const void *q)
1276
1275
  {
1277
- stbv__point *a = (stbv__point *) p;
1278
- stbv__point *b = (stbv__point *) q;
1276
+ stbv__floor_ordering *a = (stbv__floor_ordering *) p;
1277
+ stbv__floor_ordering *b = (stbv__floor_ordering *) q;
1279
1278
  return a->x < b->x ? -1 : a->x > b->x;
1280
1279
  }
1281
1280
 
@@ -3484,11 +3483,13 @@ static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right)
3484
3483
  return right - left;
3485
3484
  }
3486
3485
 
3487
- static void vorbis_pump_first_frame(stb_vorbis *f)
3486
+ static int vorbis_pump_first_frame(stb_vorbis *f)
3488
3487
  {
3489
- int len, right, left;
3490
- if (vorbis_decode_packet(f, &len, &left, &right))
3488
+ int len, right, left, res;
3489
+ res = vorbis_decode_packet(f, &len, &left, &right);
3490
+ if (res)
3491
3491
  vorbis_finish_frame(f, len, left, right);
3492
+ return res;
3492
3493
  }
3493
3494
 
3494
3495
  #ifndef STB_VORBIS_NO_PUSHDATA_API
@@ -3871,7 +3872,7 @@ static int start_decoder(vorb *f)
3871
3872
  g->book_list[j] = get_bits(f,8);
3872
3873
  return error(f, VORBIS_feature_not_supported);
3873
3874
  } else {
3874
- stbv__point p[31*8+2];
3875
+ stbv__floor_ordering p[31*8+2];
3875
3876
  Floor1 *g = &f->floor_config[i].floor1;
3876
3877
  int max_class = -1;
3877
3878
  g->partitions = get_bits(f, 5);
@@ -3907,11 +3908,11 @@ static int start_decoder(vorb *f)
3907
3908
  // precompute the sorting
3908
3909
  for (j=0; j < g->values; ++j) {
3909
3910
  p[j].x = g->Xlist[j];
3910
- p[j].y = j;
3911
+ p[j].id = j;
3911
3912
  }
3912
3913
  qsort(p, g->values, sizeof(p[0]), point_compare);
3913
3914
  for (j=0; j < g->values; ++j)
3914
- g->sorted_order[j] = (uint8) p[j].y;
3915
+ g->sorted_order[j] = (uint8) p[j].id;
3915
3916
  // precompute the neighbors
3916
3917
  for (j=2; j < g->values; ++j) {
3917
3918
  int low,hi;
@@ -4615,8 +4616,9 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number)
4615
4616
 
4616
4617
  // starting from the start is handled differently
4617
4618
  if (sample_number <= left.last_decoded_sample) {
4618
- stb_vorbis_seek_start(f);
4619
- return 1;
4619
+ if (stb_vorbis_seek_start(f))
4620
+ return 1;
4621
+ return 0;
4620
4622
  }
4621
4623
 
4622
4624
  while (left.page_end != right.page_start) {
@@ -4717,7 +4719,10 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number)
4717
4719
  skip(f, f->segments[i]);
4718
4720
 
4719
4721
  // start decoding (optimizable - this frame is generally discarded)
4720
- vorbis_pump_first_frame(f);
4722
+ if (!vorbis_pump_first_frame(f))
4723
+ return 0;
4724
+ if (f->current_loc > sample_number)
4725
+ return error(f, VORBIS_seek_failed);
4721
4726
  return 1;
4722
4727
 
4723
4728
  error:
@@ -4808,14 +4813,14 @@ int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number)
4808
4813
  return 1;
4809
4814
  }
4810
4815
 
4811
- void stb_vorbis_seek_start(stb_vorbis *f)
4816
+ int stb_vorbis_seek_start(stb_vorbis *f)
4812
4817
  {
4813
- if (IS_PUSH_MODE(f)) { error(f, VORBIS_invalid_api_mixing); return; }
4818
+ if (IS_PUSH_MODE(f)) { return error(f, VORBIS_invalid_api_mixing); }
4814
4819
  set_file_offset(f, f->first_audio_page_offset);
4815
4820
  f->previous_length = 0;
4816
4821
  f->first_decode = TRUE;
4817
4822
  f->next_seg = -1;
4818
- vorbis_pump_first_frame(f);
4823
+ return vorbis_pump_first_frame(f);
4819
4824
  }
4820
4825
 
4821
4826
  unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f)
@@ -4980,6 +4985,7 @@ stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *err
4980
4985
  if (f) {
4981
4986
  *f = p;
4982
4987
  vorbis_pump_first_frame(f);
4988
+ if (error) *error = VORBIS__no_error;
4983
4989
  return f;
4984
4990
  }
4985
4991
  }
@@ -5345,6 +5351,7 @@ int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, in
5345
5351
  #endif // STB_VORBIS_NO_PULLDATA_API
5346
5352
 
5347
5353
  /* Version history
5354
+ 1.10 - 2017/03/03 - more robust seeking; fix negative ilog(); clear error in open_memory
5348
5355
  1.09 - 2016/04/04 - back out 'avoid discarding last frame' fix from previous version
5349
5356
  1.08 - 2016/04/02 - fixed multiple warnings; fix setup memory leaks;
5350
5357
  avoid discarding last frame of audio data
@@ -5397,3 +5404,46 @@ int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, in
5397
5404
  */
5398
5405
 
5399
5406
  #endif // STB_VORBIS_HEADER_ONLY
5407
+
5408
+
5409
+ /*
5410
+ ------------------------------------------------------------------------------
5411
+ This software is available under 2 licenses -- choose whichever you prefer.
5412
+ ------------------------------------------------------------------------------
5413
+ ALTERNATIVE A - MIT License
5414
+ Copyright (c) 2017 Sean Barrett
5415
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
5416
+ this software and associated documentation files (the "Software"), to deal in
5417
+ the Software without restriction, including without limitation the rights to
5418
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
5419
+ of the Software, and to permit persons to whom the Software is furnished to do
5420
+ so, subject to the following conditions:
5421
+ The above copyright notice and this permission notice shall be included in all
5422
+ copies or substantial portions of the Software.
5423
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5424
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5425
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5426
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5427
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5428
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5429
+ SOFTWARE.
5430
+ ------------------------------------------------------------------------------
5431
+ ALTERNATIVE B - Public Domain (www.unlicense.org)
5432
+ This is free and unencumbered software released into the public domain.
5433
+ Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
5434
+ software, either in source code form or as a compiled binary, for any purpose,
5435
+ commercial or non-commercial, and by any means.
5436
+ In jurisdictions that recognize copyright laws, the author or authors of this
5437
+ software dedicate any and all copyright interest in the software to the public
5438
+ domain. We make this dedication for the benefit of the public at large and to
5439
+ the detriment of our heirs and successors. We intend this dedication to be an
5440
+ overt act of relinquishment in perpetuity of all present and future rights to
5441
+ this software under copyright law.
5442
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5443
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5444
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5445
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
5446
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
5447
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5448
+ ------------------------------------------------------------------------------
5449
+ */
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Raschke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-19 00:00:00.000000000 Z
11
+ date: 2017-11-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  2D game development library.
@@ -60,14 +60,16 @@ files:
60
60
  - lib/gosu/swig_patches.rb
61
61
  - lib/gosu/zen.rb
62
62
  - rdoc/gosu.rb
63
- - src/ALChannelManagement.hpp
64
63
  - src/Audio.cpp
65
64
  - src/AudioFile.hpp
65
+ - src/AudioImpl.cpp
66
+ - src/AudioImpl.hpp
66
67
  - src/AudioToolboxFile.hpp
67
68
  - src/Bitmap.cpp
68
69
  - src/BitmapIO.cpp
69
70
  - src/BlockAllocator.cpp
70
71
  - src/BlockAllocator.hpp
72
+ - src/Channel.cpp
71
73
  - src/ClipRectStack.hpp
72
74
  - src/Color.cpp
73
75
  - src/DirectoriesApple.cpp
@@ -75,9 +77,11 @@ files:
75
77
  - src/DirectoriesWin.cpp
76
78
  - src/DrawOp.hpp
77
79
  - src/DrawOpQueue.hpp
80
+ - src/EmptyImageData.hpp
78
81
  - src/FileUnix.cpp
79
82
  - src/FileWin.cpp
80
83
  - src/Font.cpp
84
+ - src/FormattedString.cpp
81
85
  - src/FormattedString.hpp
82
86
  - src/GosuAppDelegate.cpp
83
87
  - src/GosuAppDelegate.h
@@ -157,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
161
  version: '0'
158
162
  requirements: []
159
163
  rubyforge_project:
160
- rubygems_version: 2.6.11
164
+ rubygems_version: 2.6.14
161
165
  signing_key:
162
166
  specification_version: 4
163
167
  summary: 2D game development library.
@@ -1,119 +0,0 @@
1
- #include <Gosu/Platform.hpp>
2
- #include <cstdlib>
3
- #include <algorithm>
4
- #include <memory>
5
- #ifdef GOSU_IS_MAC
6
- #include <OpenAL/al.h>
7
- #include <OpenAL/alc.h>
8
- #else
9
- #include <AL/al.h>
10
- #include <AL/alc.h>
11
- #endif
12
-
13
- namespace Gosu
14
- {
15
- class ALChannelManagement
16
- {
17
- ALChannelManagement(const ALChannelManagement&) = delete;
18
- ALChannelManagement& operator=(const ALChannelManagement&) = delete;
19
- ALChannelManagement(ALChannelManagement&&) = delete;
20
- ALChannelManagement& operator=(ALChannelManagement&&) = delete;
21
-
22
- static ALCdevice* al_device;
23
- static ALCcontext* al_context;
24
-
25
- #ifdef GOSU_IS_IPHONE
26
- // iOS system limit.
27
- enum { NUM_SOURCES = 32 };
28
- #else
29
- enum { NUM_SOURCES = 255 };
30
- #endif
31
- static ALuint al_sources[NUM_SOURCES];
32
- static ALuint current_token;
33
- static ALuint current_tokens[NUM_SOURCES];
34
-
35
- public:
36
- enum { NO_TOKEN = -1, NO_SOURCE = -1, NO_FREE_CHANNEL = -1 };
37
-
38
- static ALCdevice* device()
39
- {
40
- return al_device;
41
- }
42
-
43
- static ALCcontext* context()
44
- {
45
- return al_context;
46
- }
47
-
48
- ALChannelManagement()
49
- {
50
- // Open preferred device
51
- al_device = alcOpenDevice(0);
52
- al_context = alcCreateContext(al_device, 0);
53
- alcMakeContextCurrent(al_context);
54
- alGenSources(NUM_SOURCES, al_sources);
55
- std::fill(current_tokens, current_tokens + NUM_SOURCES, static_cast<ALuint>(NO_TOKEN));
56
- }
57
-
58
- ~ALChannelManagement()
59
- {
60
- alDeleteSources(NUM_SOURCES, al_sources);
61
- alcMakeContextCurrent(0);
62
- alcDestroyContext(al_context);
63
- alcCloseDevice(al_device);
64
- }
65
-
66
- std::pair<int, int> reserve_channel()
67
- {
68
- int i;
69
- for (i = 1; i <= NUM_SOURCES; ++i) {
70
- if (i == NUM_SOURCES) {
71
- return std::make_pair<int, int>(NO_FREE_CHANNEL, NO_TOKEN);
72
- }
73
- if (current_tokens[i] == NO_TOKEN) {
74
- break;
75
- }
76
- ALint state;
77
- alGetSourcei(al_sources[i], AL_SOURCE_STATE, &state);
78
- if (state != AL_PLAYING && state != AL_PAUSED) {
79
- break;
80
- }
81
- }
82
- ++current_token;
83
- current_tokens[i] = current_token;
84
- return std::make_pair(i, int(current_token));
85
- }
86
-
87
- int source_if_still_playing(int channel, int token) const
88
- {
89
- if (channel != NO_FREE_CHANNEL && current_tokens[channel] == token) {
90
- return al_sources[channel];
91
- }
92
- else {
93
- return NO_SOURCE;
94
- }
95
- }
96
-
97
- int source_for_songs() const
98
- {
99
- return al_sources[0];
100
- }
101
- };
102
- ALCdevice* ALChannelManagement::al_device = 0;
103
- ALCcontext* ALChannelManagement::al_context = 0;
104
- ALuint ALChannelManagement::al_sources[NUM_SOURCES];
105
- ALuint ALChannelManagement::current_token = 0;
106
- ALuint ALChannelManagement::current_tokens[NUM_SOURCES];
107
-
108
- std::unique_ptr<ALChannelManagement> al_channel_management;
109
-
110
- void release_all_openal_resources()
111
- {
112
- al_channel_management.reset();
113
- }
114
-
115
- ALCcontext *shared_openal_context()
116
- {
117
- return ALChannelManagement::context();
118
- }
119
- }