ManaPlus
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes | Friends
Image Class Reference

#include <image.h>

Inheritance diagram for Image:
Resource MemoryCounter SubImage

Public Member Functions

 ~Image ()
 
void unload ()
 
bool isLoaded () const
 
int getWidth () const A_INLINE
 
int getHeight () const A_INLINE
 
bool hasAlphaChannel () const
 
virtual void setAlpha (const float alpha)
 
virtual ImagegetSubImage (const int x, const int y, const int width, const int height)
 
ImageSDLgetScaledImage (const int width, const int height) const
 
uint8_t * SDLgetAlphaChannel () const
 
void SDLCleanCache ()
 
void SDLTerminateAlphaCache ()
 
int getTextureWidth () const
 
int getTextureHeight () const
 
GLuint getGLImage () const
 
void decRef ()
 
bool isHasAlphaChannel () const
 
bool isAlphaVisible () const
 
void setAlphaVisible (const bool b)
 
bool isAlphaCalculated () const
 
void setAlphaCalculated (const bool b)
 
SDL_Surface * getSDLSurface ()
 
int calcMemoryLocal () const
 
virtual ImageTypeT getType () const
 
- Public Member Functions inherited from Resource
 Resource ()
 
 ~Resource ()
 
virtual void incRef ()
 
int calcMemoryLocal () const
 
std::string getCounterName () const
 
- Public Member Functions inherited from MemoryCounter
 MemoryCounter ()
 
virtual ~MemoryCounter ()
 
int calcMemory (const int level) const
 
virtual int calcMemoryChilds (const int level) const
 

Data Fields

GLuint mGLImage
 
int mTexWidth
 
int mTexHeight
 
SDL_Rect mBounds
 
float mAlpha
 
- Data Fields inherited from Resource
time_t mTimeStamp
 
std::string mIdPath
 
std::string mSource
 
unsigned int mRefCount
 
bool mProtected
 
bool mNotCount
 

Protected Member Functions

 Image (SDL_Surface *const image, const bool hasAlphaChannel, uint8_t *const alphaChannel)
 
SDL_Surface * getByAlpha (const float alpha)
 
 Image (const GLuint glimage, const int width, const int height, const int texWidth, const int texHeight)
 

Protected Attributes

SDL_Surface * mSDLSurface
 
uint8_t * mAlphaChannel
 
std::map< float, SDL_Surface * > mAlphaCache
 
bool mLoaded
 
bool mHasAlphaChannel
 
bool mUseAlphaCache
 
bool mIsAlphaVisible
 
bool mIsAlphaCalculated
 

Friends

class CompoundSprite
 
class Graphics
 
class ImageHelper
 
class SDLGraphics
 
class SDLImageHelper
 
class SurfaceGraphics
 
class TestLauncher
 
class AtlasManager
 
class MobileOpenGL2Graphics
 
class MobileOpenGLGraphics
 
class ModernOpenGLGraphics
 
class NormalOpenGLGraphics
 
class NullOpenGLGraphics
 
class SafeOpenGLGraphics
 
class OpenGLImageHelper
 
class SafeOpenGLImageHelper
 

Detailed Description

Defines a class for loading and storing images.

Definition at line 67 of file image.h.

Constructor & Destructor Documentation

◆ ~Image()

Image::~Image ( )

Destructor.

Definition at line 206 of file image.cpp.

207 {
208 #ifdef DEBUG_IMAGES
209  logger->log("delete image: %p", static_cast<void*>(this));
210  logger->log(" %s, %s", mIdPath.c_str(), mSource.c_str());
211 #endif // DEBUG_IMAGES
212 
213  unload();
214 }

References Logger::log(), logger, Resource::mIdPath, Resource::mSource, and unload().

◆ Image() [1/2]

Image::Image ( SDL_Surface *const  image,
const bool  hasAlphaChannel,
uint8_t *const  alphaChannel 
)
protected

SDL Constructor

Definition at line 126 of file image.cpp.

127  :
128  Resource(),
129 #ifdef USE_OPENGL
130  mGLImage(0),
131  mTexWidth(0),
132  mTexHeight(0),
133 #endif // USE_OPENGL
134  mBounds(),
135  mAlpha(1.0F),
136  mSDLSurface(image),
137 #ifdef USE_SDL2
138  mTexture(nullptr),
139 #endif // USE_SDL2
140  mAlphaChannel(alphaChannel),
141  mAlphaCache(),
142  mLoaded(false),
143  mHasAlphaChannel(hasAlphaChannel0),
145  mIsAlphaVisible(hasAlphaChannel0),
146  mIsAlphaCalculated(false)
147 {
148 #ifdef DEBUG_IMAGES
149  logger->log("created image: %p", static_cast<void*>(this));
150 #endif // DEBUG_IMAGES
151 
152  mBounds.x = 0;
153  mBounds.y = 0;
154 
155  if (mSDLSurface != nullptr)
156  {
157  mBounds.w = CAST_U16(mSDLSurface->w);
158  mBounds.h = CAST_U16(mSDLSurface->h);
159 
160  mLoaded = true;
161  }
162  else
163  {
164  mBounds.w = 0;
165  mBounds.h = 0;
166  }
167 }

References CAST_U16, Logger::log(), logger, mBounds, mLoaded, and mSDLSurface.

Referenced by calcMemoryLocal().

◆ Image() [2/2]

Image::Image ( const GLuint  glimage,
const int  width,
const int  height,
const int  texWidth,
const int  texHeight 
)
protected

OpenGL Constructor.

Definition at line 170 of file image.cpp.

171  :
172  Resource(),
173  mGLImage(glimage),
174  mTexWidth(texWidth),
175  mTexHeight(texHeight),
176  mBounds(),
177  mAlpha(1.0F),
178  mSDLSurface(nullptr),
179 #ifdef USE_SDL2
180  mTexture(nullptr),
181 #endif // USE_SDL2
182  mAlphaChannel(nullptr),
183  mAlphaCache(),
184  mLoaded(false),
185  mHasAlphaChannel(true),
186  mUseAlphaCache(false),
187  mIsAlphaVisible(true),
188  mIsAlphaCalculated(false)
189 {
190 #ifdef DEBUG_IMAGES
191  logger->log("created image: %p", static_cast<void*>(this));
192 #endif // DEBUG_IMAGES
193 
194  mBounds.x = 0;
195  mBounds.y = 0;
196  mBounds.w = CAST_U16(width);
197  mBounds.h = CAST_U16(height);
198 
199  if (mGLImage != 0U)
200  {
201  mLoaded = true;
202  }
203 }

References CAST_U16, Logger::log(), logger, mBounds, mGLImage, and mLoaded.

Member Function Documentation

◆ calcMemoryLocal()

int Image::calcMemoryLocal ( ) const
virtual

Reimplemented from MemoryCounter.

Reimplemented in SubImage.

Definition at line 507 of file image.cpp.

508 {
509  // +++ this calculation can be wrong for SDL2
510  int sz = static_cast<int>(sizeof(Image) +
511  sizeof(std::map<float, SDL_Surface*>)) +
513  if (mSDLSurface != nullptr)
514  {
515  sz += CAST_S32(mAlphaCache.size()) *
517  }
518  return sz;
519 }

References Resource::calcMemoryLocal(), CAST_S32, MemoryManager::getSurfaceSize(), Image(), mAlphaCache, and mSDLSurface.

Referenced by SubImage::calcMemoryLocal().

◆ decRef()

void Image::decRef ( )
virtual

Decrements the reference count and deletes the object if no references are left.

Returns
true if the object was deleted false otherwise.

Reimplemented from Resource.

Reimplemented in SubImage.

Definition at line 522 of file image.cpp.

523 {
524  if ((mGLImage != 0U) && mRefCount <= 1)
527 }

References Resource::decRef(), OpenGLImageHelper::invalidate(), mGLImage, and Resource::mRefCount.

Referenced by DragDrop::clear(), AtlasManager::convertAtlas(), AtlasManager::convertEmptyAtlas(), Minimap::deleteMapImage(), DragDrop::dragCommand(), DragDrop::dragItem(), DragDrop::dragSkill(), OutfitWindow::draw(), ParticleEmitter::getImageSet(), ImageSetLoader::load(), TextCommand::loadImage(), main(), ParticleEmitter::ParticleEmitter(), Theme::readSkin(), MapReader::readTileset(), OutfitWindow::safeDraw(), ItemContainer::setCellBackgroundImage(), Item::setId(), Tab::setImage(), ItemPopup::setItem(), Window::setResizable(), MapItem::setType(), ActorSprite::setupSpriteDisplay(), Theme::unloadRect(), AmbientLayer::~AmbientLayer(), AtlasResource::~AtlasResource(), AvatarListBox::~AvatarListBox(), Desktop::~Desktop(), DragDrop::~DragDrop(), DropDown::~DropDown(), EquipmentWindow::~EquipmentWindow(), Icon::~Icon(), ImageSprite::~ImageSprite(), Item::~Item(), ItemContainer::~ItemContainer(), ItemPopup::~ItemPopup(), LangListModel::~LangListModel(), LinePart::~LinePart(), MapItem::~MapItem(), Particle::~Particle(), ParticleEmitter::~ParticleEmitter(), QuestsWindow::~QuestsWindow(), ScrollArea::~ScrollArea(), ShortcutContainer::~ShortcutContainer(), SkillData::~SkillData(), Skin::~Skin(), SubImage::~SubImage(), Tab::~Tab(), Text::~Text(), TextCommand::~TextCommand(), and Window::~Window().

◆ getByAlpha()

SDL_Surface * Image::getByAlpha ( const float  alpha)
protected

Definition at line 277 of file image.cpp.

278 {
279  const std::map<float, SDL_Surface*>::const_iterator
280  it = mAlphaCache.find(alpha);
281  if (it != mAlphaCache.end())
282  return (*it).second;
283  return nullptr;
284 }

References mAlphaCache.

Referenced by setAlpha().

◆ getGLImage()

GLuint Image::getGLImage ( ) const
inline

Definition at line 183 of file image.h.

184  { return mGLImage; }

References mGLImage.

Referenced by ResourceManager::logResource().

◆ getHeight()

int Image::getHeight ( ) const
inline

◆ getSDLSurface()

SDL_Surface* Image::getSDLSurface ( )
inline

Definition at line 208 of file image.h.

209  { return mSDLSurface; }

References mSDLSurface.

Referenced by main().

◆ getSubImage()

Image * Image::getSubImage ( const int  x,
const int  y,
const int  width,
const int  height 
)
virtual

Creates a new image with the desired clipping rectangle.

Returns
NULL if creation failed and a valid object otherwise.

Reimplemented in SubImage.

Definition at line 466 of file image.cpp.

468 {
469  // Create a new clipped sub-image
470 #ifdef USE_OPENGL
472  if (mode == RENDER_NORMAL_OPENGL ||
473  mode == RENDER_SAFE_OPENGL ||
474  mode == RENDER_GLES_OPENGL ||
475  mode == RENDER_GLES2_OPENGL ||
476  mode == RENDER_MODERN_OPENGL)
477  {
478  return new SubImage(this,
479  mGLImage,
480  x, y,
481  width, height,
483  }
484 #endif // USE_OPENGL
485 
486 #ifdef USE_SDL2
487 #ifndef USE_OPENGL
488  const RenderType mode = ImageHelper::mUseOpenGL;
489 #endif // USE_OPENGL
490 
491  if (mode == RENDER_SOFTWARE)
492  return new SubImage(this, mSDLSurface, x, y, width, height);
493  else
494  return new SubImage(this, mTexture, x, y, width, height);
495 #else // USE_SDL2
496 
497  return new SubImage(this, mSDLSurface, x, y, width, height);
498 #endif // USE_SDL2
499 }

References mGLImage, mSDLSurface, mTexHeight, mTexWidth, ImageHelper::mUseOpenGL, RENDER_GLES2_OPENGL, RENDER_GLES_OPENGL, RENDER_MODERN_OPENGL, RENDER_NORMAL_OPENGL, RENDER_SAFE_OPENGL, RENDER_SOFTWARE, ImageType::SubImage, x, and y.

Referenced by AtlasManager::convertAtlas(), AtlasManager::convertEmptyAtlas(), SubImage::getSubImage(), ImageSet::ImageSet(), anonymous_namespace{subimageloader.cpp}::SubImageLoader::load(), and TestLauncher::testTextures().

◆ getTextureHeight()

int Image::getTextureHeight ( ) const
inline

Definition at line 180 of file image.h.

181  { return mTexHeight; }

References mTexHeight.

◆ getTextureWidth()

int Image::getTextureWidth ( ) const
inline

Definition at line 177 of file image.h.

178  { return mTexWidth; }

References mTexWidth.

◆ getType()

virtual ImageTypeT Image::getType ( ) const
inlinevirtual

Reimplemented in SubImage.

Definition at line 213 of file image.h.

214  { return ImageType::Image; }

References ImageType::Image.

Referenced by MapReader::readTileset().

◆ getWidth()

int Image::getWidth ( ) const
inline

◆ hasAlphaChannel()

bool Image::hasAlphaChannel ( ) const

Tells if the image has got an alpha channel

Returns
true if it's true, false otherwise.

Definition at line 264 of file image.cpp.

265 {
266  if (mLoaded)
267  return mHasAlphaChannel;
268 
269 #ifdef USE_OPENGL
271  return true;
272 #endif // USE_OPENGL
273 
274  return false;
275 }

References mHasAlphaChannel, mLoaded, ImageHelper::mUseOpenGL, and RENDER_SOFTWARE.

Referenced by SubImage::SubImage().

◆ isAlphaCalculated()

bool Image::isAlphaCalculated ( ) const
inline

Definition at line 202 of file image.h.

203  { return mIsAlphaCalculated; }

References mIsAlphaCalculated.

◆ isAlphaVisible()

bool Image::isAlphaVisible ( ) const
inline

Definition at line 196 of file image.h.

197  { return mIsAlphaVisible; }

References mIsAlphaVisible.

◆ isHasAlphaChannel()

bool Image::isHasAlphaChannel ( ) const
inline

Definition at line 193 of file image.h.

194  { return mHasAlphaChannel; }

References mHasAlphaChannel.

◆ isLoaded()

bool Image::isLoaded ( ) const
inline

Tells is the image is loaded

Definition at line 116 of file image.h.

117  { return mLoaded; }

References mLoaded.

◆ SDLCleanCache()

void Image::SDLCleanCache ( )

Definition at line 216 of file image.cpp.

217 {
218  for (std::map<float, SDL_Surface*>::iterator
219  i = mAlphaCache.begin(), i_end = mAlphaCache.end();
220  i != i_end; ++i)
221  {
222  if (mSDLSurface != i->second)
224  i->second = nullptr;
225  }
226  mAlphaCache.clear();
227 }

References mAlphaCache, mSDLSurface, and ResourceManager::scheduleDelete().

Referenced by SDLTerminateAlphaCache(), setAlpha(), and unload().

◆ SDLgetAlphaChannel()

uint8_t* Image::SDLgetAlphaChannel ( ) const
inline

Get the alpha Channel of a SDL surface.

Definition at line 169 of file image.h.

170  { return mAlphaChannel; }

References mAlphaChannel.

Referenced by SubImage::SubImage().

◆ SDLgetScaledImage()

Image * Image::SDLgetScaledImage ( const int  width,
const int  height 
) const

Gets an scaled instance of an image.

Parameters
widthThe desired width of the scaled image.
heightThe desired height of the scaled image.
Returns
A new Image* object.

Definition at line 436 of file image.cpp.

437 {
438  // No scaling on incorrect new values.
439  if (width == 0 || height == 0)
440  return nullptr;
441 
442  // No scaling when there is ... no different given size ...
443  if (width == mBounds.w && height == mBounds.h)
444  return nullptr;
445 
446  Image* scaledImage = nullptr;
447 
448  if (mSDLSurface != nullptr)
449  {
450  SDL_Surface *const scaledSurface = zoomSurface(mSDLSurface,
451  static_cast<double>(width) / mBounds.w,
452  static_cast<double>(height) / mBounds.h,
453  1);
454 
455  // The load function takes care of the SDL<->OpenGL implementation
456  // and about freeing the given SDL_surface*.
457  if (scaledSurface != nullptr)
458  {
459  scaledImage = imageHelper->loadSurface(scaledSurface);
460  MSDL_FreeSurface(scaledSurface);
461  }
462  }
463  return scaledImage;
464 }

References imageHelper, ImageHelper::loadSurface(), mBounds, MSDL_FreeSurface, mSDLSurface, and zoomSurface().

Referenced by anonymous_namespace{rescaledloader.cpp}::RescaledLoader::load().

◆ SDLTerminateAlphaCache()

void Image::SDLTerminateAlphaCache ( )

Definition at line 501 of file image.cpp.

502 {
503  SDLCleanCache();
504  mUseAlphaCache = false;
505 }

References mUseAlphaCache, and SDLCleanCache().

Referenced by SubImage::SubImage().

◆ setAlpha()

void Image::setAlpha ( const float  alpha)
virtual

Sets the alpha value of this image.

< Blit uses source alpha blending

< Surface is in video memory

< Use asynchronous blits if possible

< Surface is RLE encoded

< Surface is in video memory

< Use asynchronous blits if possible

< Surface is RLE encoded

Definition at line 286 of file image.cpp.

287 {
288  if (mAlpha == alpha || !ImageHelper::mEnableAlpha)
289  return;
290 
291  if (alpha < 0.0F || alpha > 1.0F)
292  return;
293 
294  if (mSDLSurface != nullptr)
295  {
296  if (mUseAlphaCache)
297  {
298  SDL_Surface *surface = getByAlpha(mAlpha);
299  if (surface == nullptr)
300  {
301  if (mAlphaCache.size() > 100)
302  {
303 #ifdef DEBUG_ALPHA_CACHE
304  logger->log("cleanCache");
305  for (std::map<float, SDL_Surface*>::const_iterator
306  i = mAlphaCache.begin(), i_end = mAlphaCache.end();
307  i != i_end; ++i)
308  {
309  logger->log("alpha: " + toString(i->first));
310  }
311 #endif // DEBUG_ALPHA_CACHE
312 
313  SDLCleanCache();
314  }
315  surface = mSDLSurface;
316  if (surface != nullptr)
317  mAlphaCache[mAlpha] = surface;
318  }
319  else
320  {
321  logger->log("cache bug");
322  }
323 
324  surface = getByAlpha(alpha);
325  if (surface != nullptr)
326  {
327  if (mSDLSurface == surface)
328  logger->log("bug");
329  mAlphaCache.erase(alpha);
330  mSDLSurface = surface;
331  mAlpha = alpha;
332  return;
333  }
335  if (mSDLSurface == nullptr)
336  return;
337  }
338 
339  mAlpha = alpha;
340 
341  if (!mHasAlphaChannel)
342  {
343 #ifdef USE_SDL2
344  SDL_SetSurfaceAlphaMod(mSDLSurface,
345  CAST_U8(255 * mAlpha));
346 #else // USE_SDL2
347 
348  // Set the alpha value this image is drawn at
349  SDL_SetAlpha(mSDLSurface, SDL_SRCALPHA,
350  CAST_U8(255 * mAlpha));
351 #endif // USE_SDL2
352  }
353  else
354  {
355  if (SDL_MUSTLOCK(mSDLSurface))
356  SDL_LockSurface(mSDLSurface);
357 
358  const int bx = mBounds.x;
359  const int by = mBounds.y;
360  const int bw = mBounds.w;
361  const int bh = mBounds.h;
362  const int bxw = bx + bw;
363  const int sw = mSDLSurface->w;
364  const int maxHeight = std::min(by + bh, mSDLSurface->h);
365  const int maxWidth = std::min(bxw, sw);
366  const int i1 = by * sw + bx;
367  const SDL_PixelFormat * const fmt = mSDLSurface->format;
368  const uint32_t amask = fmt->Amask;
369  const uint32_t invMask = ~fmt->Amask;
370  const uint8_t aloss = fmt->Aloss;
371  const uint8_t ashift = fmt->Ashift;
372 
373  if ((bx == 0) && bxw == sw)
374  {
375  const int i2 = (maxHeight - 1) * sw + maxWidth - 1;
376  for (int i = i1; i <= i2; i++)
377  {
378  const uint8_t sourceAlpha = mAlphaChannel[i];
379  if (sourceAlpha > 0)
380  {
381  const uint8_t a = CAST_U8(
382  static_cast<float>(sourceAlpha) * mAlpha);
383 
384  uint32_t c = (static_cast<uint32_t*>(
385  mSDLSurface->pixels))[i];
386  c &= invMask;
387  c |= ((a >> aloss) << ashift & amask);
388  (static_cast<uint32_t*>(mSDLSurface->pixels))[i] = c;
389  }
390  }
391  }
392  else
393  {
394  for (int y = by; y < maxHeight; y ++)
395  {
396  const int idx = y * sw;
397  const int x1 = idx + bx;
398  const int x2 = idx + maxWidth;
399  for (int i = x1; i < x2; i ++)
400  {
401  const uint8_t sourceAlpha = mAlphaChannel[i];
402  if (sourceAlpha > 0)
403  {
404  const uint8_t a = CAST_U8(
405  static_cast<float>(sourceAlpha) * mAlpha);
406 
407  uint32_t c = (static_cast<uint32_t*>(
408  mSDLSurface->pixels))[i];
409  c &= invMask;
410  c |= ((a >> aloss) << ashift & amask);
411  (static_cast<uint32_t*>(
412  mSDLSurface->pixels))[i] = c;
413  }
414  }
415  }
416  }
417 
418  if (SDL_MUSTLOCK(mSDLSurface))
419  SDL_UnlockSurface(mSDLSurface);
420  }
421  }
422 #ifdef USE_SDL2
423  else if (mTexture)
424  {
425  mAlpha = alpha;
426  SDL_SetTextureAlphaMod(mTexture,
427  CAST_U8(255 * mAlpha));
428  }
429 #endif // USE_SDL2
430  else
431  {
432  mAlpha = alpha;
433  }
434 }

References CAST_U8, getByAlpha(), Logger::log(), logger, mAlpha, mAlphaCache, mAlphaChannel, mBounds, ImageHelper::mEnableAlpha, mHasAlphaChannel, mSDLSurface, mUseAlphaCache, SDLCleanCache(), SDLImageHelper::SDLDuplicateSurface(), Catch::toString(), and y.

Referenced by OpenGLImageHelper::createTextSurface(), SafeOpenGLImageHelper::createTextSurface(), ImageSprite::draw(), SpellShortcutContainer::draw(), ItemShortcutContainer::draw(), VirtShortcutContainer::draw(), ShopListBox::draw(), EquipmentWindow::draw(), ItemContainer::draw(), PlayerBox::draw(), Gui::draw(), Being::drawCompound(), CompoundSprite::drawSimple(), Font::drawString(), DropDown::DropDown(), EmoteShortcutContainer::EmoteShortcutContainer(), SpellShortcutContainer::safeDraw(), ItemShortcutContainer::safeDraw(), VirtShortcutContainer::safeDraw(), EquipmentWindow::safeDraw(), ItemContainer::safeDraw(), Minimap::setMap(), ShortcutContainer::ShortcutContainer(), TestLauncher::testDraw(), Text::Text(), DropDown::updateAlpha(), Skin::updateAlpha(), Tab::updateAlpha(), Slider::updateAlpha(), TextField::updateAlpha(), CheckBox::updateAlpha(), RadioButton::updateAlpha(), ScrollArea::updateAlpha(), and Button::updateAlpha().

◆ setAlphaCalculated()

void Image::setAlphaCalculated ( const bool  b)
inline

Definition at line 205 of file image.h.

206  { mIsAlphaCalculated = b; }

References mIsAlphaCalculated.

◆ setAlphaVisible()

void Image::setAlphaVisible ( const bool  b)
inline

Definition at line 199 of file image.h.

200  { mIsAlphaVisible = b; }

References mIsAlphaVisible.

◆ unload()

void Image::unload ( )

Frees the resources created by SDL.

Definition at line 229 of file image.cpp.

230 {
231  mLoaded = false;
232 
233  if (mSDLSurface != nullptr)
234  {
235  SDLCleanCache();
236  // Free the image surface.
238  mSDLSurface = nullptr;
239 
240  delete [] mAlphaChannel;
241  mAlphaChannel = nullptr;
242  }
243 #ifdef USE_SDL2
244  if (mTexture)
245  {
246  SDL_DestroyTexture(mTexture);
247  mTexture = nullptr;
248  }
249 #endif // USE_SDL2
250 
251 #ifdef USE_OPENGL
252  if (mGLImage != 0U)
253  {
254  glDeleteTextures(1, &mGLImage);
255  mGLImage = 0;
256 #ifdef DEBUG_OPENGL_LEAKS
257  if (textures_count > 0)
258  textures_count --;
259 #endif // DEBUG_OPENGL_LEAKS
260  }
261 #endif // USE_OPENGL
262 }

References mAlphaChannel, mGLImage, mLoaded, MSDL_FreeSurface, mSDLSurface, SDLCleanCache(), and textures_count.

Referenced by ~Image().

Friends And Related Function Documentation

◆ AtlasManager

friend class AtlasManager
friend

Definition at line 82 of file image.h.

◆ CompoundSprite

friend class CompoundSprite
friend

Definition at line 69 of file image.h.

◆ Graphics

friend class Graphics
friend

Definition at line 70 of file image.h.

◆ ImageHelper

friend class ImageHelper
friend

Definition at line 71 of file image.h.

◆ MobileOpenGL2Graphics

friend class MobileOpenGL2Graphics
friend

Definition at line 83 of file image.h.

◆ MobileOpenGLGraphics

friend class MobileOpenGLGraphics
friend

Definition at line 84 of file image.h.

◆ ModernOpenGLGraphics

friend class ModernOpenGLGraphics
friend

Definition at line 85 of file image.h.

◆ NormalOpenGLGraphics

friend class NormalOpenGLGraphics
friend

Definition at line 86 of file image.h.

◆ NullOpenGLGraphics

friend class NullOpenGLGraphics
friend

Definition at line 87 of file image.h.

◆ OpenGLImageHelper

friend class OpenGLImageHelper
friend

Definition at line 89 of file image.h.

◆ SafeOpenGLGraphics

friend class SafeOpenGLGraphics
friend

Definition at line 88 of file image.h.

◆ SafeOpenGLImageHelper

friend class SafeOpenGLImageHelper
friend

Definition at line 91 of file image.h.

◆ SDLGraphics

friend class SDLGraphics
friend

Definition at line 72 of file image.h.

◆ SDLImageHelper

friend class SDLImageHelper
friend

Definition at line 73 of file image.h.

◆ SurfaceGraphics

friend class SurfaceGraphics
friend

Definition at line 74 of file image.h.

◆ TestLauncher

friend class TestLauncher
friend

Definition at line 80 of file image.h.

Field Documentation

◆ mAlpha

float Image::mAlpha

Definition at line 218 of file image.h.

Referenced by SDLImageHelper::createTextSurface(), ImageSprite::ImageSprite(), and setAlpha().

◆ mAlphaCache

std::map<float, SDL_Surface*> Image::mAlphaCache
protected

Definition at line 245 of file image.h.

Referenced by calcMemoryLocal(), getByAlpha(), SDLCleanCache(), and setAlpha().

◆ mAlphaChannel

uint8_t* Image::mAlphaChannel
protected

Alpha Channel pointer used for 32bit based SDL surfaces

Definition at line 243 of file image.h.

Referenced by SDLgetAlphaChannel(), setAlpha(), SubImage::SubImage(), unload(), and SubImage::~SubImage().

◆ mBounds

SDL_Rect Image::mBounds

◆ mGLImage

GLuint Image::mGLImage

◆ mHasAlphaChannel

bool Image::mHasAlphaChannel
protected

Definition at line 248 of file image.h.

Referenced by hasAlphaChannel(), isHasAlphaChannel(), setAlpha(), and SubImage::SubImage().

◆ mIsAlphaCalculated

bool Image::mIsAlphaCalculated
protected

Definition at line 251 of file image.h.

Referenced by isAlphaCalculated(), and setAlphaCalculated().

◆ mIsAlphaVisible

bool Image::mIsAlphaVisible
protected

Definition at line 250 of file image.h.

Referenced by isAlphaVisible(), setAlphaVisible(), and SubImage::SubImage().

◆ mLoaded

bool Image::mLoaded
protected

Definition at line 247 of file image.h.

Referenced by hasAlphaChannel(), Image(), isLoaded(), and unload().

◆ mSDLSurface

SDL_Surface* Image::mSDLSurface
protected

◆ mTexHeight

int Image::mTexHeight

Definition at line 190 of file image.h.

Referenced by getSubImage(), and getTextureHeight().

◆ mTexWidth

int Image::mTexWidth

Definition at line 189 of file image.h.

Referenced by getSubImage(), and getTextureWidth().

◆ mUseAlphaCache

bool Image::mUseAlphaCache
protected

Definition at line 249 of file image.h.

Referenced by SDLTerminateAlphaCache(), setAlpha(), and SubImage::SubImage().


The documentation for this class was generated from the following files:
Image::mIsAlphaCalculated
bool mIsAlphaCalculated
Definition: image.h:251
Image::SDLCleanCache
void SDLCleanCache()
Definition: image.cpp:216
Image::mLoaded
bool mLoaded
Definition: image.h:247
SDLImageHelper::mEnableAlphaCache
static bool mEnableAlphaCache
Definition: sdlimagehelper.h:99
RenderType
RenderType
Definition: rendertype.h:24
imageHelper
ImageHelper * imageHelper
Definition: imagehelper.cpp:43
RENDER_NORMAL_OPENGL
@ RENDER_NORMAL_OPENGL
Definition: rendertype.h:27
ImageType::SubImage
@ SubImage
Definition: imagetype.h:29
ImageType::Image
@ Image
Definition: imagetype.h:28
Image
Definition: image.h:67
MSDL_FreeSurface
#define MSDL_FreeSurface(surface)
Definition: debug.h:53
Image::Image
Image(SDL_Surface *const image, const bool hasAlphaChannel, uint8_t *const alphaChannel)
Definition: image.cpp:126
textures_count
int textures_count
Definition: client.cpp:137
Catch::toString
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
logger
Logger * logger
Definition: logger.cpp:88
Image::unload
void unload()
Definition: image.cpp:229
CAST_U8
#define CAST_U8
Definition: cast.h:26
Image::mHasAlphaChannel
bool mHasAlphaChannel
Definition: image.h:248
Image::mIsAlphaVisible
bool mIsAlphaVisible
Definition: image.h:250
RENDER_GLES_OPENGL
@ RENDER_GLES_OPENGL
Definition: rendertype.h:29
Image::mAlphaChannel
uint8_t * mAlphaChannel
Definition: image.h:243
Image::mSDLSurface
SDL_Surface * mSDLSurface
Definition: image.h:237
ImageHelper::mUseOpenGL
static RenderType mUseOpenGL
Definition: imagehelper.h:117
Image::mAlpha
float mAlpha
Definition: image.h:218
SDLImageHelper::SDLDuplicateSurface
static SDL_Surface * SDLDuplicateSurface(SDL_Surface *const tmpImage)
Definition: sdlimagehelper.cpp:209
RENDER_MODERN_OPENGL
@ RENDER_MODERN_OPENGL
Definition: rendertype.h:31
Resource::mSource
std::string mSource
Definition: resource.h:84
zoomSurface
SDL_Surface * zoomSurface(SDL_Surface *src, double zoomx, double zoomy, int smooth)
Zoom a surface by independent horizontal and vertical factors with optional smoothing.
Definition: SDL2_rotozoom.cpp:1590
Image::mTexHeight
int mTexHeight
Definition: image.h:190
Image::mUseAlphaCache
bool mUseAlphaCache
Definition: image.h:249
x
x
Definition: graphics_calcImageRect.hpp:72
Image::getByAlpha
SDL_Surface * getByAlpha(const float alpha)
Definition: image.cpp:277
OpenGLImageHelper::invalidate
static void invalidate(const GLuint textureId)
Definition: openglimagehelper.cpp:485
RENDER_SOFTWARE
@ RENDER_SOFTWARE
Definition: rendertype.h:26
CAST_U16
#define CAST_U16
Definition: cast.h:28
ImageHelper::mEnableAlpha
static bool mEnableAlpha
Definition: imagehelper.h:116
Image::mBounds
SDL_Rect mBounds
Definition: image.h:216
RENDER_SAFE_OPENGL
@ RENDER_SAFE_OPENGL
Definition: rendertype.h:28
Image::mGLImage
GLuint mGLImage
Definition: image.h:188
Resource::Resource
Resource()
Definition: resource.h:39
Resource::decRef
virtual void decRef()
Definition: resource.cpp:49
Image::mAlphaCache
std::map< float, SDL_Surface * > mAlphaCache
Definition: image.h:245
ResourceManager::scheduleDelete
void scheduleDelete(SDL_Surface *const surface)
Definition: resourcemanager.cpp:629
CAST_S32
#define CAST_S32
Definition: cast.h:29
Resource::calcMemoryLocal
int calcMemoryLocal() const
Definition: resource.cpp:75
ImageHelper::loadSurface
virtual Image * loadSurface(SDL_Surface *const)
Definition: imagehelper.h:72
RENDER_GLES2_OPENGL
@ RENDER_GLES2_OPENGL
Definition: rendertype.h:32
y
y
Definition: graphics_calcImageRect.hpp:72
Image::mTexWidth
int mTexWidth
Definition: image.h:189
Resource::mRefCount
unsigned int mRefCount
Definition: resource.h:86
Logger::log
void log(const char *const log_text,...)
Definition: logger.cpp:268
Resource::mIdPath
std::string mIdPath
Definition: resource.h:83
MemoryManager::getSurfaceSize
static int getSurfaceSize(const SDL_Surface *const surface)
Definition: memorymanager.cpp:44