|
@@ -506,6 +506,7 @@ bool Image::SetSize(int width, int height, int depth, unsigned components)
|
|
|
components_ = components;
|
|
components_ = components;
|
|
|
compressedFormat_ = CF_NONE;
|
|
compressedFormat_ = CF_NONE;
|
|
|
numCompressedLevels_ = 0;
|
|
numCompressedLevels_ = 0;
|
|
|
|
|
+ nextLevel_.Reset();
|
|
|
|
|
|
|
|
SetMemoryUse(width * height * depth * components);
|
|
SetMemoryUse(width * height * depth * components);
|
|
|
return true;
|
|
return true;
|
|
@@ -556,7 +557,14 @@ void Image::SetData(const unsigned char* pixelData)
|
|
|
if (!data_)
|
|
if (!data_)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
|
|
+ if (IsCompressed())
|
|
|
|
|
+ {
|
|
|
|
|
+ LOGERROR("Can not set new pixel data for a compressed image");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
memcpy(data_.Get(), pixelData, width_ * height_ * depth_ * components_);
|
|
memcpy(data_.Get(), pixelData, width_ * height_ * depth_ * components_);
|
|
|
|
|
+ nextLevel_.Reset();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool Image::LoadColorLUT(Deserializer& source)
|
|
bool Image::LoadColorLUT(Deserializer& source)
|
|
@@ -937,6 +945,11 @@ SharedPtr<Image> Image::GetNextLevel() const
|
|
|
return SharedPtr<Image>();
|
|
return SharedPtr<Image>();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (nextLevel_)
|
|
|
|
|
+ return nextLevel_;
|
|
|
|
|
+
|
|
|
|
|
+ PROFILE(CalculateImageMipLevel);
|
|
|
|
|
+
|
|
|
int widthOut = width_ / 2;
|
|
int widthOut = width_ / 2;
|
|
|
int heightOut = height_ / 2;
|
|
int heightOut = height_ / 2;
|
|
|
int depthOut = depth_ / 2;
|
|
int depthOut = depth_ / 2;
|
|
@@ -1374,6 +1387,27 @@ SDL_Surface* Image::GetSDLSurface(const IntRect& rect) const
|
|
|
return surface;
|
|
return surface;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void Image::PrecalculateLevels()
|
|
|
|
|
+{
|
|
|
|
|
+ if (!data_ || IsCompressed())
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ PROFILE(PrecalculateImageMipLevels);
|
|
|
|
|
+
|
|
|
|
|
+ nextLevel_.Reset();
|
|
|
|
|
+
|
|
|
|
|
+ if (width_ > 1 || height_ > 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ SharedPtr<Image> current = GetNextLevel();
|
|
|
|
|
+ nextLevel_ = current;
|
|
|
|
|
+ while (current && (current->width_ > 1 || current->height_ > 1))
|
|
|
|
|
+ {
|
|
|
|
|
+ current->nextLevel_ = current->GetNextLevel();
|
|
|
|
|
+ current = current->nextLevel_;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
unsigned char* Image::GetImageData(Deserializer& source, int& width, int& height, unsigned& components)
|
|
unsigned char* Image::GetImageData(Deserializer& source, int& width, int& height, unsigned& components)
|
|
|
{
|
|
{
|
|
|
unsigned dataSize = source.GetSize();
|
|
unsigned dataSize = source.GetSize();
|