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