Browse Source

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

tags/2021-05-28
jules 10 years ago
parent
commit
c240ca4eaf
3 changed files with 13 additions and 2 deletions
  1. +4
    -0
      modules/juce_opengl/opengl/juce_OpenGLContext.cpp
  2. +7
    -0
      modules/juce_opengl/opengl/juce_OpenGLContext.h
  3. +2
    -2
      modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp

+ 4
- 0
modules/juce_opengl/opengl/juce_OpenGLContext.cpp 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,


+ 7
- 0
modules/juce_opengl/opengl/juce_OpenGLContext.h 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;


+ 2
- 2
modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp 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)
{


Loading…
Cancel
Save