kodi
SlideShowPicture.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "guilib/DirtyRegion.h"
12 #include "threads/CriticalSection.h"
13 #include "utils/ColorUtils.h"
14 
15 #include <memory>
16 #include <string>
17 
18 class CTexture;
19 
21 {
22 public:
23  enum DISPLAY_EFFECT { EFFECT_NONE = 0, EFFECT_FLOAT, EFFECT_ZOOM, EFFECT_RANDOM, EFFECT_PANORAMA, EFFECT_NO_TIMEOUT };
24  enum TRANSITION_EFFECT { TRANSITION_NONE = 0, FADEIN_FADEOUT, CROSSFADE, TRANSITION_ZOOM, TRANSITION_ROTATE };
25 
26  struct TRANSITION
27  {
28  TRANSITION_EFFECT type = TRANSITION_NONE;
29  int start = 0;
30  int length = 0;
31  };
32 
33  static std::unique_ptr<CSlideShowPic> CreateSlideShowPicture();
34 
35  CSlideShowPic();
36  virtual ~CSlideShowPic();
37 
38  void SetTexture(int iSlideNumber,
39  std::unique_ptr<CTexture> pTexture,
40  DISPLAY_EFFECT dispEffect = EFFECT_RANDOM,
41  TRANSITION_EFFECT transEffect = FADEIN_FADEOUT);
42  void UpdateTexture(std::unique_ptr<CTexture> pTexture);
43 
44  bool IsLoaded() const { return m_bIsLoaded; }
45  void UnLoad() { m_bIsLoaded = false; }
46  void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
47  void Render();
48  void Close();
49  void Reset(DISPLAY_EFFECT dispEffect = EFFECT_RANDOM, TRANSITION_EFFECT transEffect = FADEIN_FADEOUT);
50  DISPLAY_EFFECT DisplayEffect() const { return m_displayEffect; }
51  bool DisplayEffectNeedChange(DISPLAY_EFFECT newDispEffect) const;
52  bool IsStarted() const { return m_iCounter > 0; }
53  bool IsFinished() const { return m_bIsFinished; }
54  bool DrawNextImage() const { return m_bDrawNextImage; }
55 
56  int GetWidth() const { return (int)m_fWidth; }
57  int GetHeight() const { return (int)m_fHeight; }
58 
59  void Keep();
60  bool StartTransition();
61  int GetTransitionTime(int iType) const;
62  void SetTransitionTime(int iType, int iTime);
63 
64  int SlideNumber() const { return m_iSlideNumber; }
65 
66  void Zoom(float fZoomAmount, bool immediate = false);
67  void Rotate(float fRotateAngle, bool immediate = false);
68  void Pause(bool bPause);
69  void SetInSlideshow(bool slideshow);
70  void SetOriginalSize(int iOriginalWidth, int iOriginalHeight, bool bFullSize);
71  bool FullSize() const { return m_bFullSize; }
72  int GetOriginalWidth();
73  int GetOriginalHeight();
74 
75  void Move(float dX, float dY);
76  float GetZoom() const { return m_fZoomAmount; }
77 
78  bool m_bIsComic;
79  bool m_bCanMoveHorizontally;
80  bool m_bCanMoveVertically;
81 
82 protected:
83  virtual void Render(float* x, float* y, CTexture* pTexture, UTILS::COLOR::Color color) = 0;
84 
85 private:
86  void SetTexture_Internal(int iSlideNumber,
87  std::unique_ptr<CTexture> pTexture,
88  DISPLAY_EFFECT dispEffect = EFFECT_RANDOM,
89  TRANSITION_EFFECT transEffect = FADEIN_FADEOUT);
90  void UpdateVertices(float cur_x[4], float cur_y[4], const float new_x[4], const float new_y[4], CDirtyRegionList &dirtyregions);
91 
92  std::unique_ptr<CTexture> m_pImage;
93 
94  int m_iOriginalWidth;
95  int m_iOriginalHeight;
96  int m_iSlideNumber;
97  bool m_bIsLoaded;
98  bool m_bIsFinished;
99  bool m_bDrawNextImage;
100  bool m_bIsDirty;
101  std::string m_strFileName;
102  float m_fWidth;
103  float m_fHeight;
104  UTILS::COLOR::Color m_alpha = 0;
105  // stuff relative to middle position
106  float m_fPosX;
107  float m_fPosY;
108  float m_fPosZ;
109  float m_fVelocityX;
110  float m_fVelocityY;
111  float m_fVelocityZ;
112  float m_fZoomAmount;
113  float m_fZoomLeft;
114  float m_fZoomTop;
115  float m_ax[4]{}, m_ay[4]{};
116  float m_sx[4]{}, m_sy[4]{};
117  float m_bx[4]{}, m_by[4]{};
118  float m_ox[4]{}, m_oy[4]{};
119 
120  // transition and display effects
121  DISPLAY_EFFECT m_displayEffect = EFFECT_NONE;
122  TRANSITION m_transitionStart;
123  TRANSITION m_transitionEnd;
124  TRANSITION m_transitionTemp; // used for rotations + zooms
125  float m_fAngle; // angle (between 0 and 2pi to display the image)
126  float m_fTransitionAngle;
127  float m_fTransitionZoom;
128  int m_iCounter = 0;
129  int m_iTotalFrames;
130  bool m_bPause;
131  bool m_bNoEffect;
132  bool m_bFullSize;
133  bool m_bTransitionImmediately;
134 
135  CCriticalSection m_textureAccess;
136 };
Definition: SlideShowPicture.h:20
void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
Definition: SlideShowPicture.cpp:273
Base texture class, subclasses of which depend on the render spec (DX, GL etc.)
Definition: Texture.h:34
Definition: SlideShowPicture.h:26