1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

Added a method OpenGLContext::setImageCacheSize to provide explicit control over the amount of GPU space that is used for the internal image cache.

This commit is contained in:
jules 2015-03-26 18:12:07 +00:00
parent 0217203b50
commit c240ca4eaf
3 changed files with 13 additions and 2 deletions

View file

@ -596,6 +596,7 @@ private:
OpenGLContext::OpenGLContext()
: nativeContext (nullptr), renderer (nullptr), currentRenderScale (1.0),
contextToShareWith (nullptr), versionRequired (OpenGLContext::defaultGLVersion),
imageCacheMaxSize (8 * 1024 * 1024),
renderComponents (true), useMultisampling (false), continuousRepaint (false)
{
}
@ -812,6 +813,9 @@ void OpenGLContext::setAssociatedObject (const char* name, ReferenceCountedObjec
}
}
void OpenGLContext::setImageCacheSize (size_t newSize) noexcept { imageCacheMaxSize = newSize; }
size_t OpenGLContext::getImageCacheSize() const noexcept { return imageCacheMaxSize; }
void OpenGLContext::copyTexture (const Rectangle<int>& targetClipArea,
const Rectangle<int>& anchorPosAndTextureSize,
const int contextWidth, const int contextHeight,

View file

@ -262,6 +262,12 @@ public:
bool textureOriginIsBottomLeft);
/** Changes the amount of GPU memory that the internal cache for Images is allowed to use. */
void setImageCacheSize (size_t cacheSizeBytes) noexcept;
/** Returns the amount of GPU memory that the internal cache for Images is allowed to use. */
size_t getImageCacheSize() const noexcept;
//==============================================================================
#ifndef DOXYGEN
class NativeContext;
@ -277,6 +283,7 @@ private:
OpenGLPixelFormat pixelFormat;
void* contextToShareWith;
OpenGLVersion versionRequired;
size_t imageCacheMaxSize;
bool renderComponents, useMultisampling, continuousRepaint;
CachedImage* getCachedImage() const noexcept;

View file

@ -38,8 +38,8 @@ struct TextureInfo
struct CachedImageList : public ReferenceCountedObject,
private ImagePixelData::Listener
{
CachedImageList (OpenGLContext& c, size_t totalCacheSizeInPixels = 8 * 1024 * 1024) noexcept
: context (c), totalSize (0), maxCacheSize (totalCacheSizeInPixels) {}
CachedImageList (OpenGLContext& c) noexcept
: context (c), totalSize (0), maxCacheSize (c.getImageCacheSize()) {}
static CachedImageList* get (OpenGLContext& c)
{