PageRenderTime 23ms CodeModel.GetById 9ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/xbmc/guilib/GUIBorderedImage.cpp

http://github.com/xbmc/xbmc
C++ | 72 lines | 54 code | 10 blank | 8 comment | 5 complexity | cf962efed6b53aa5a82fa0d346e73f5c MD5 | raw file
 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#include "GUIBorderedImage.h"
10
11CGUIBorderedImage::CGUIBorderedImage(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& texture, const CTextureInfo& borderTexture, const CRect &borderSize)
12   : CGUIImage(parentID, controlID, posX + borderSize.x1, posY + borderSize.y1, width - borderSize.x1 - borderSize.x2, height - borderSize.y1 - borderSize.y2, texture),
13     m_borderImage(posX, posY, width, height, borderTexture),
14     m_borderSize(borderSize)
15{
16  ControlType = GUICONTROL_BORDEREDIMAGE;
17}
18
19CGUIBorderedImage::CGUIBorderedImage(const CGUIBorderedImage &right)
20: CGUIImage(right), m_borderImage(right.m_borderImage), m_borderSize(right.m_borderSize)
21{
22  ControlType = GUICONTROL_BORDEREDIMAGE;
23}
24
25CGUIBorderedImage::~CGUIBorderedImage(void) = default;
26
27void CGUIBorderedImage::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
28{
29  CGUIImage::Process(currentTime, dirtyregions);
30  if (!m_borderImage.GetFileName().empty() && m_texture.ReadyToRender())
31  {
32    CRect rect = CRect(m_texture.GetXPosition(), m_texture.GetYPosition(), m_texture.GetXPosition() + m_texture.GetWidth(), m_texture.GetYPosition() + m_texture.GetHeight());
33    rect.Intersect(m_texture.GetRenderRect());
34    m_borderImage.SetPosition(rect.x1 - m_borderSize.x1, rect.y1 - m_borderSize.y1);
35    m_borderImage.SetWidth(rect.Width() + m_borderSize.x1 + m_borderSize.x2);
36    m_borderImage.SetHeight(rect.Height() + m_borderSize.y1 + m_borderSize.y2);
37    m_borderImage.SetDiffuseColor(m_diffuseColor);
38    if (m_borderImage.Process(currentTime))
39      MarkDirtyRegion();
40  }
41}
42
43void CGUIBorderedImage::Render()
44{
45  if (!m_borderImage.GetFileName().empty() && m_texture.ReadyToRender())
46    m_borderImage.Render();
47  CGUIImage::Render();
48}
49
50CRect CGUIBorderedImage::CalcRenderRegion() const
51{
52  // have to union the image as well as fading images may still exist that are bigger than our current border image
53  return CGUIImage::CalcRenderRegion().Union(m_borderImage.GetRenderRect());
54}
55
56void CGUIBorderedImage::AllocResources()
57{
58  m_borderImage.AllocResources();
59  CGUIImage::AllocResources();
60}
61
62void CGUIBorderedImage::FreeResources(bool immediately)
63{
64  m_borderImage.FreeResources(immediately);
65  CGUIImage::FreeResources(immediately);
66}
67
68void CGUIBorderedImage::DynamicResourceAlloc(bool bOnOff)
69{
70  m_borderImage.DynamicResourceAlloc(bOnOff);
71  CGUIImage::DynamicResourceAlloc(bOnOff);
72}