~ubuntu-branches/ubuntu/trusty/rlvm/trusty

« back to all changes in this revision

Viewing changes to src/Systems/Base/GraphicsSystem.hpp

  • Committer: Package Import Robot
  • Author(s): Ying-Chun Liu (PaulLiu)
  • Date: 2013-11-02 02:57:13 UTC
  • mfrom: (10.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20131102025713-yzg31grxr8i7xerh
Tags: 0.13-1
* New upstream release
  - rlvm will now warn on startup when it detects Japanese save data, but
    English patched game files, and offer to reset the save data.
  - Much better support for Little Busters. Most graphical glitches during
    the Little Busters Refrain have been fixed.
  - TCC tone curve effects have been reverse-engineered and implemented
    (thanks to lurkmoar)
  - Sepia scenes (and other graphical filters) should look much better.
  - Simple shake commands implemented (fancy per-layer shaking still
    unimplemented).
  - Make animations smooth: data should be uploaded to the graphics card
    before an animation loop starts, not while the animation loop is
    running.
  - Fixes finding system fonts on Linux
  - Thanks to Elliot Glaysher <glaysher@umich.edu>
* Remove upstreamed patches:
  - debian/patches/002_675426ad62bccf1de10b0ae31dd46331ec47aacb.patch
  - debian/patches/003_5dafabf5448635c4d4526d6e35ea7ec664a27261.patch
  - debian/patches/004_boost-drop-mt.patch
  - debian/patches/005_missing-include.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include <set>
40
40
#include <string>
41
41
#include <vector>
 
42
#include <queue>
42
43
 
43
44
#include "Systems/Base/CGMTable.hpp"
44
45
#include "Systems/Base/EventListener.hpp"
45
46
#include "Systems/Base/Rect.hpp"
46
 
 
 
47
#include "Systems/Base/ToneCurve.hpp"
 
48
 
 
49
#include "Utilities/LazyArray.hpp"
 
50
#include "lru_cache.hpp"
 
51
 
 
52
class ColourFilter;
47
53
class Gameexe;
48
54
class GraphicsObject;
49
55
class GraphicsObjectData;
50
56
class GraphicsStackFrame;
 
57
class HIKRenderer;
51
58
class HIKScript;
52
59
class MouseCursor;
53
60
class Renderable;
79
86
 
80
87
  // CG Table
81
88
  CGMTable cg_table;
 
89
  
 
90
  // tone curve table
 
91
  ToneCurve tone_curves;
82
92
 
83
93
  /// boost::serialization support
84
94
  template<class Archive>
168
178
 
169
179
  System& system() { return system_; }
170
180
 
 
181
  // Screen Shaking
 
182
 
 
183
  // Reads #SHAKE.spec and loads the offsets into the screen shaking queue.
 
184
  void QueueShakeSpec(int spec);
 
185
 
 
186
  // Returns the current screen origin. This is used for simple #SHAKE.* based
 
187
  // screen shaking. While the screen is not shaking, this returns (0,0).
 
188
  Point GetScreenOrigin();
 
189
 
 
190
  // Whether we are currently shaking.
 
191
  bool IsShaking() const;
 
192
 
 
193
  // How long the current frame in the shaking should last. 10ms if there are
 
194
  // no frames.
 
195
  int CurrentShakingFrameTime() const;
 
196
 
171
197
  // Mouse Cursor Management
172
198
 
173
199
  // Whether we are using a custom cursor. Verifies that there was a
212
238
 
213
239
  // Sets the current hik script. GraphicsSystem takes ownership, freeing the
214
240
  // current HIKScript if applicable. |script| can be NULL.
215
 
  void setHikScript(HIKScript* script);
216
 
  HIKScript* getHikScript() const { return hik_script_.get(); }
 
241
  void setHikRenderer(HIKRenderer* script);
 
242
  HIKRenderer* getHikRenderer() const { return hik_renderer_.get(); }
217
243
 
218
244
  // -----------------------------------------------------------------------
219
245
 
287
313
  virtual void forceRefresh();
288
314
 
289
315
  bool screenNeedsRefresh() const { return screen_needs_refresh_; }
290
 
  void screenRefreshed() { screen_needs_refresh_ = false; }
291
 
 
292
 
  virtual void beginFrame();
293
 
  virtual void endFrame();
 
316
  void screenRefreshed() {
 
317
    screen_needs_refresh_ = false;
 
318
    object_state_dirty_ = false;
 
319
  }
 
320
 
 
321
  // We keep a separate state about whether object state has been modified. We
 
322
  // do this so that background object mutation in automatic mode plays nicely
 
323
  // with LongOperations.
 
324
  void markObjectStateAsDirty() { object_state_dirty_ = true; }
 
325
  bool objectStateDirty() const { return object_state_dirty_; }
 
326
 
 
327
  virtual void beginFrame() = 0;
 
328
  virtual void endFrame() = 0;
294
329
  virtual boost::shared_ptr<Surface> endFrameToSurface() = 0;
295
330
 
296
331
  // Performs a full redraw of the screen.
317
352
 
318
353
  // Loads an image, optionally marking that this image has been loaded (if it
319
354
  // is in the game's CGM table).
320
 
  boost::shared_ptr<Surface> loadSurfaceFromFile(
 
355
  boost::shared_ptr<const Surface> getSurfaceNamedAndMarkViewed(
321
356
      RLMachine& machine, const std::string& short_filename);
322
357
 
323
358
  // Just loads an image. This shouldn't be used for images that are destined
324
359
  // for one of the DCs, since those can be CGs.
325
 
  virtual boost::shared_ptr<Surface> loadNonCGSurfaceFromFile(
326
 
      const std::string& short_filename) = 0;
 
360
  boost::shared_ptr<const Surface> getSurfaceNamed(
 
361
      const std::string& short_filename);
327
362
 
328
363
  virtual boost::shared_ptr<Surface> getHaikei() = 0;
329
364
 
331
366
 
332
367
  virtual boost::shared_ptr<Surface> buildSurface(const Size& size) = 0;
333
368
 
334
 
  virtual void fillScreenArea(const Rect& rect, const RGBAColour& colour) = 0;
 
369
  virtual ColourFilter* BuildColourFiller() = 0;
335
370
 
336
371
  // Clears and promotes objects.
337
372
  void clearAndPromoteObjects();
349
384
  GraphicsObject& getObject(int layer, int obj_number);
350
385
  void setObject(int layer, int obj_number, GraphicsObject& object);
351
386
 
 
387
  void clearObject(int obj_number);
 
388
 
352
389
  // Deallocates all graphics objects.
353
390
  void clearAllObjects();
354
391
 
380
417
  // Implementation of MouseMotionListener:
381
418
  virtual void mouseMotion(const Point& new_location);
382
419
 
383
 
 
384
420
  // Reset the system. Should clear all state for when a user loads a game.
385
421
  virtual void reset();
386
422
 
387
423
  // Access to the cgtable for the cg* functions.
388
424
  CGMTable& cgTable() { return globals_.cg_table; }
389
425
 
 
426
  // Access to the tone curve effects file
 
427
  ToneCurve& toneCurve() { return globals_.tone_curves; }
 
428
 
 
429
  // Gets the emoji surface, if any.
 
430
  boost::shared_ptr<const Surface> GetEmojiSurface();
 
431
 
 
432
  // We have a cache of HIK scripts. This is done so we can load HIKScripts
 
433
  // outside of loops.
 
434
  void PreloadHIKScript(System& system,
 
435
                        int slot,
 
436
                        const std::string& name,
 
437
                        const boost::filesystem::path& file);
 
438
  void ClearPreloadedHIKScript(int slot);
 
439
  void ClearAllPreloadedHIKScripts();
 
440
  boost::shared_ptr<HIKScript> GetHIKScript(
 
441
      System& system,
 
442
      const std::string& name,
 
443
      const boost::filesystem::path& file);
 
444
 
 
445
  // We have a cache of preloaded g00 files.
 
446
  void PreloadG00(int slot, const std::string& name);
 
447
  void ClearPreloadedG00(int slot);
 
448
  void ClearAllPreloadedG00();
 
449
  boost::shared_ptr<const Surface> GetPreloadedG00(const std::string& name);
 
450
 
390
451
 protected:
391
452
  typedef std::set<Renderable*> FinalRenderers;
392
453
 
405
466
  void drawFrame(std::ostream* tree);
406
467
 
407
468
 private:
 
469
  // Gets a platform appropriate surface loaded.
 
470
  virtual boost::shared_ptr<const Surface> loadSurfaceFromFile(
 
471
      const std::string& short_filename) = 0;
 
472
 
408
473
  // Default grp name (used in grp* and rec* functions where filename
409
474
  // is '???')
410
475
  std::string default_grp_name_;
422
487
  // Flag set to redraw the screen NOW
423
488
  bool screen_needs_refresh_;
424
489
 
 
490
  // Whether object state has been mutated since the last screen refresh.
 
491
  bool object_state_dirty_;
 
492
 
425
493
  // Whether it is the Graphics system's responsibility to redraw the
426
494
  // screen. Some LongOperations temporarily take this responsibility
427
495
  // to implement pretty fades and wipes
447
515
  // Rectangle of the screen.
448
516
  Rect screen_rect_;
449
517
 
 
518
  // Queued origin/time pairs. The front of the queue shall be the current
 
519
  // screen offset.
 
520
  std::queue<std::pair<Point, int> > screen_shake_queue_;
 
521
 
 
522
  // The last time |screen_shake_queue_| was modified.
 
523
  unsigned int time_at_last_queue_change_;
 
524
 
450
525
  // Immutable
451
526
  struct GraphicsObjectSettings;
452
527
  // Immutable global data that's constructed from the Gameexe.ini file.
483
558
  // Our parent system object.
484
559
  System& system_;
485
560
 
 
561
  // Preloaded HIKScripts.
 
562
  typedef std::pair<std::string, boost::shared_ptr<HIKScript> > HIKArrayItem;
 
563
  typedef LazyArray<HIKArrayItem> HIKScriptList;
 
564
  HIKScriptList preloaded_hik_scripts_;
 
565
 
 
566
  // Preloaded G00 images.
 
567
  typedef std::pair<std::string, boost::shared_ptr<const Surface> >
 
568
      G00ArrayItem;
 
569
  typedef LazyArray<G00ArrayItem> G00ScriptList;
 
570
  G00ScriptList preloaded_g00_;
 
571
 
 
572
  /**
 
573
   * LRU cache filled with the last fifteen accessed images.
 
574
   *
 
575
   * This cache's contents are assumed to be immutable.
 
576
   */
 
577
  LRUCache<std::string, boost::shared_ptr<const Surface> > image_cache_;
 
578
 
486
579
  // Possible background script which drives graphics to the screen.
487
 
  boost::scoped_ptr<HIKScript> hik_script_;
 
580
  boost::scoped_ptr<HIKRenderer> hik_renderer_;
488
581
 
489
582
  // boost::serialization support
490
583
  friend class boost::serialization::access;