1 // -*- Mode: C++; tab-width:2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi:tw=80:et:ts=2:sts=2
3 //
4 // -----------------------------------------------------------------------
5 //
6 // This file is part of RLVM, a RealLive virtual machine clone.
7 //
8 // -----------------------------------------------------------------------
9 //
10 // Copyright (C) 2006 Elliot Glaysher
11 //
12 // This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation; either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
25 //
26 // -----------------------------------------------------------------------
27 
28 #ifndef SRC_EFFECTS_BLIND_EFFECT_H_
29 #define SRC_EFFECTS_BLIND_EFFECT_H_
30 
31 #include "effects/effect.h"
32 
33 // Base class for implementing \#SEL transition style \#10, Blind.
34 class BlindEffect : public Effect {
35  public:
36   BlindEffect(RLMachine& machine,
37               std::shared_ptr<Surface> src,
38               std::shared_ptr<Surface> dst,
39               const Size& screen_size,
40               int time,
41               int blindSize);
42   virtual ~BlindEffect();
43 
44  protected:
blind_size()45   const int blind_size() const { return blind_size_; }
46 
47   void ComputeGrowing(RLMachine& machine, int maxSize, int currentTime);
48   void ComputeDecreasing(RLMachine& machine, int maxSize, int currentTime);
49 
50   virtual void RenderPolygon(int polyStart, int polyEnd) = 0;
51 
52  private:
53   virtual bool BlitOriginalImage() const final;
54 
55   int blind_size_;
56 };
57 
58 class BlindTopToBottomEffect : public BlindEffect {
59  public:
60   BlindTopToBottomEffect(RLMachine& machine,
61                          std::shared_ptr<Surface> src,
62                          std::shared_ptr<Surface> dst,
63                          const Size& screen_size,
64                          int time,
65                          int blindSize);
66   virtual ~BlindTopToBottomEffect();
67 
68  protected:
69   virtual void PerformEffectForTime(RLMachine& machine,
70                                     int currentTime) override;
71   virtual void RenderPolygon(int polyStart, int polyEnd) override;
72 };
73 
74 class BlindBottomToTopEffect : public BlindEffect {
75  public:
76   BlindBottomToTopEffect(RLMachine& machine,
77                          std::shared_ptr<Surface> src,
78                          std::shared_ptr<Surface> dst,
79                          const Size& screen_size,
80                          int time,
81                          int blindSize);
82   virtual ~BlindBottomToTopEffect();
83 
84  protected:
85   virtual void PerformEffectForTime(RLMachine& machine,
86                                     int currentTime) final;
87   virtual void RenderPolygon(int polyStart, int polyEnd) final;
88 };
89 
90 class BlindLeftToRightEffect : public BlindEffect {
91  public:
92   BlindLeftToRightEffect(RLMachine& machine,
93                          std::shared_ptr<Surface> src,
94                          std::shared_ptr<Surface> dst,
95                          const Size& screen_size,
96                          int time,
97                          int blindSize);
98   virtual ~BlindLeftToRightEffect();
99 
100  protected:
101   virtual void PerformEffectForTime(RLMachine& machine,
102                                     int currentTime) final;
103   virtual void RenderPolygon(int polyStart, int polyEnd) final;
104 };
105 
106 class BlindRightToLeftEffect : public BlindEffect {
107  public:
108   BlindRightToLeftEffect(RLMachine& machine,
109                          std::shared_ptr<Surface> src,
110                          std::shared_ptr<Surface> dst,
111                          const Size& screen_size,
112                          int time,
113                          int blindSize);
114   virtual ~BlindRightToLeftEffect();
115 
116  protected:
117   virtual void PerformEffectForTime(RLMachine& machine,
118                                     int currentTime) final;
119   virtual void RenderPolygon(int polyStart, int polyEnd) final;
120 };
121 
122 #endif  // SRC_EFFECTS_BLIND_EFFECT_H_
123