Qt 4.8
Classes | Public Types | Public Functions | Private Functions | Properties | List of all members
QGLMaskTextureCache Class Reference

Classes

struct  CacheInfo
 
struct  CacheLocation
 
struct  QuadTreeNode
 

Public Types

enum  { block_size = 64 }
 
typedef QMultiHash< quint64, CacheInfoQGLTextureCacheHash
 

Public Functions

void clearCache ()
 
CacheLocation getMask (QGLMaskGenerator &maskGenerator, QOpenGLPaintEnginePrivate *engine)
 
void maintainCache ()
 
void setDrawableSize (const QSize &drawableSize)
 
void setOffscreenSize (const QSize &offscreenSize)
 

Private Functions

void createMask (quint64 key, CacheInfo &info, QGLMaskGenerator &maskGenerator)
 
quint64 hash (const QPainterPath &p, const QTransform &m, qreal w)
 
void quadtreeAllocate (quint64 key, const QSize &size, QRect *rect, int *channel)
 
int quadtreeBlocksize (int node)
 
void quadtreeClear (int channel, const QRect &rect, int node=0)
 
bool quadtreeFindAvailableLocation (const QSize &size, QRect *rect, int *channel)
 
void quadtreeFindExistingLocation (const QSize &size, QRect *rect, int *channel)
 
void quadtreeInsert (int channel, quint64 key, const QRect &rect, int node=0)
 
QPoint quadtreeLocation (int node)
 
void quadtreeUpdate (int channel, int node, int current_block_size)
 

Properties

QGLTextureCacheHash cache
 
QSize drawableSize
 
QOpenGLPaintEnginePrivateengine
 
QVector< QuadTreeNodeoccupied_quadtree [4]
 
QSize offscreenSize
 

Detailed Description

Definition at line 163 of file qpaintengine_opengl.cpp.

Typedefs

◆ QGLTextureCacheHash

Definition at line 198 of file qpaintengine_opengl.cpp.

Enumerations

◆ anonymous enum

anonymous enum
Enumerator
block_size 

Definition at line 200 of file qpaintengine_opengl.cpp.

Functions

◆ clearCache()

void QGLMaskTextureCache::clearCache ( )

Definition at line 2643 of file qpaintengine_opengl.cpp.

2644 {
2645  cache.clear();
2646 
2647  int quad_tree_size = 1;
2648 
2649  for (int i = block_size; i < offscreenSize.width(); i *= 2)
2650  quad_tree_size += quad_tree_size * 4;
2651 
2652  for (int i = 0; i < 4; ++i) {
2653  occupied_quadtree[i].resize(quad_tree_size);
2654 
2655  occupied_quadtree[i][0].key = 0;
2656  occupied_quadtree[i][0].largest_available_block = offscreenSize.width();
2657  occupied_quadtree[i][0].largest_used_block = 0;
2658 
2659  DEBUG_ONCE qDebug() << "QGLMaskTextureCache:: created quad tree of size" << quad_tree_size;
2660  }
2661 }
void clear()
Removes all items from the hash.
Definition: qhash.h:574
QGLTextureCacheHash cache
Q_CORE_EXPORT void qDebug(const char *,...)
int width() const
Returns the width.
Definition: qsize.h:126
QVector< QuadTreeNode > occupied_quadtree[4]
#define DEBUG_ONCE

◆ createMask()

void QGLMaskTextureCache::createMask ( quint64  key,
CacheInfo info,
QGLMaskGenerator maskGenerator 
)
private

Definition at line 2763 of file qpaintengine_opengl.cpp.

2764 {
2765  info.loc.screen_rect = maskGenerator.screenRect();
2766 
2767  if (info.loc.screen_rect.isEmpty()) {
2768  info.loc.channel = 0;
2769  info.loc.rect = QRect();
2770  return;
2771  }
2772 
2773  quadtreeAllocate(key, info.loc.screen_rect.size(), &info.loc.rect, &info.loc.channel);
2774 
2775  int ch = info.loc.channel;
2776  glColorMask(ch == 0, ch == 1, ch == 2, ch == 3);
2777 
2778  maskGenerator.drawMask(info.loc.rect);
2779 
2780  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
2781 }
static mach_timebase_info_data_t info
#define GL_TRUE
virtual void drawMask(const QRect &rect)=0
virtual QRect screenRect()=0
int key
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void quadtreeAllocate(quint64 key, const QSize &size, QRect *rect, int *channel)

◆ getMask()

QGLMaskTextureCache::CacheLocation QGLMaskTextureCache::getMask ( QGLMaskGenerator maskGenerator,
QOpenGLPaintEnginePrivate engine 
)

Definition at line 2688 of file qpaintengine_opengl.cpp.

2689 {
2690 #ifndef DISABLE_MASK_CACHE
2691  engine = e;
2692 
2693  quint64 key = hash(maskGenerator.path(), maskGenerator.matrix(), maskGenerator.strokeWidth());
2694 
2695  if (key == 0)
2696  key = 1;
2697 
2698  CacheInfo info(maskGenerator.path(), maskGenerator.matrix(), maskGenerator.strokeWidth());
2699 
2701 
2702  while (it != cache.end() && it.key() == key) {
2703  CacheInfo &cache_info = it.value();
2704  if (info.stroke_width == cache_info.stroke_width && info.matrix == cache_info.matrix && info.path == cache_info.path) {
2705  DEBUG_ONCE_STR("QGLMaskTextureCache::getMask(): Using cached mask");
2706 
2707  cache_info.age = 0;
2708  return cache_info.loc;
2709  }
2710  ++it;
2711  }
2712 
2713  // mask was not found, create new mask
2714 
2715  DEBUG_ONCE_STR("QGLMaskTextureCache::getMask(): Creating new mask...");
2716 
2717  createMask(key, info, maskGenerator);
2718 
2719  cache.insert(key, info);
2720 
2721  return info.loc;
2722 #else
2723  CacheInfo info(maskGenerator.path(), maskGenerator.matrix());
2724  createMask(0, info, maskGenerator);
2725  return info.loc;
2726 #endif
2727 }
#define DEBUG_ONCE_STR(str)
static mach_timebase_info_data_t info
#define it(className, varName)
QHash< Key, T >::iterator find(const Key &key, const T &value)
Returns an iterator pointing to the item with the key and value.
Definition: qhash.h:972
QGLTextureCacheHash cache
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
unsigned __int64 quint64
Definition: qglobal.h:943
QHash< Key, T >::iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:934
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
int key
QTransform matrix() const
void createMask(quint64 key, CacheInfo &info, QGLMaskGenerator &maskGenerator)
quint64 hash(const QPainterPath &p, const QTransform &m, qreal w)
friend class iterator
Definition: qhash.h:393
QPainterPath path() const

◆ hash()

quint64 QGLMaskTextureCache::hash ( const QPainterPath p,
const QTransform m,
qreal  w 
)
private

Definition at line 2733 of file qpaintengine_opengl.cpp.

2734 {
2735  Q_ASSERT(sizeof(quint64) == 8);
2736 
2737  quint64 h = 0;
2738 
2739  for (int i = 0; i < p.elementCount(); ++i) {
2740  h += FloatToQuint64(p.elementAt(i).x) << 32;
2741  h += FloatToQuint64(p.elementAt(i).y);
2742  h += p.elementAt(i).type;
2743  }
2744 
2745  h += FloatToQuint64(m.m11());
2746 #ifndef Q_OS_WINCE // ###
2747  //Compiler crashes for arm on WinCE
2748  h += FloatToQuint64(m.m12()) << 4;
2749  h += FloatToQuint64(m.m13()) << 8;
2750  h += FloatToQuint64(m.m21()) << 12;
2751  h += FloatToQuint64(m.m22()) << 16;
2752  h += FloatToQuint64(m.m23()) << 20;
2753  h += FloatToQuint64(m.m31()) << 24;
2754  h += FloatToQuint64(m.m32()) << 28;
2755 #endif
2756  h += FloatToQuint64(m.m33()) << 32;
2757 
2758  h += FloatToQuint64(w);
2759 
2760  return h;
2761 }
ElementType type
the type of element
Definition: qpainterpath.h:81
qreal m32() const
Returns the vertical translation factor.
Definition: qtransform.h:265
qreal m21() const
Returns the horizontal shearing factor.
Definition: qtransform.h:249
qreal m22() const
Returns the vertical scaling factor.
Definition: qtransform.h:253
qreal y
the y coordinate of the element&#39;s position.
Definition: qpainterpath.h:80
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const QPainterPath::Element & elementAt(int i) const
Returns the element at the given index in the painter path.
Definition: qpainterpath.h:402
qreal m12() const
Returns the vertical shearing factor.
Definition: qtransform.h:241
unsigned __int64 quint64
Definition: qglobal.h:943
#define FloatToQuint64(i)
qreal m31() const
Returns the horizontal translation factor.
Definition: qtransform.h:261
qreal m23() const
Returns the vertical projection factor.
Definition: qtransform.h:257
qreal x
the x coordinate of the element&#39;s position.
Definition: qpainterpath.h:79
int elementCount() const
Returns the number of path elements in the painter path.
Definition: qpainterpath.h:397
qreal m13() const
Returns the horizontal projection factor.
Definition: qtransform.h:245
qreal m11() const
Returns the horizontal scaling factor.
Definition: qtransform.h:237
qreal m33() const
Returns the division factor.
Definition: qtransform.h:269

◆ maintainCache()

void QGLMaskTextureCache::maintainCache ( )

Definition at line 2668 of file qpaintengine_opengl.cpp.

2669 {
2672 
2673  while (it != end) {
2674  CacheInfo &cache_info = it.value();
2675  ++cache_info.age;
2676 
2677  if (cache_info.age > 1) {
2678  quadtreeInsert(cache_info.loc.channel, 0, cache_info.loc.rect);
2679  it = cache.erase(it);
2680  } else {
2681  ++it;
2682  }
2683  }
2684 }
#define it(className, varName)
void quadtreeInsert(int channel, quint64 key, const QRect &rect, int node=0)
QGLTextureCacheHash cache
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
static const KeyPair *const end
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
Definition: qhash.h:827
friend class iterator
Definition: qhash.h:393

◆ quadtreeAllocate()

void QGLMaskTextureCache::quadtreeAllocate ( quint64  key,
const QSize size,
QRect rect,
int *  channel 
)
private

Definition at line 3017 of file qpaintengine_opengl.cpp.

3018 {
3019 #ifndef DISABLE_MASK_CACHE
3020  if (!quadtreeFindAvailableLocation(size, rect, channel)) {
3021  quadtreeFindExistingLocation(size, rect, channel);
3022  quadtreeClear(*channel, *rect);
3023  }
3024 
3025  quadtreeInsert(*channel, key, *rect);
3026 #else
3027  *channel = 0;
3028  *rect = QRect(QPoint(), size);
3029 #endif
3030 }
void quadtreeInsert(int channel, quint64 key, const QRect &rect, int node=0)
bool quadtreeFindAvailableLocation(const QSize &size, QRect *rect, int *channel)
void quadtreeFindExistingLocation(const QSize &size, QRect *rect, int *channel)
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void quadtreeClear(int channel, const QRect &rect, int node=0)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ quadtreeBlocksize()

int QGLMaskTextureCache::quadtreeBlocksize ( int  node)
private

Definition at line 2783 of file qpaintengine_opengl.cpp.

2784 {
2785  DEBUG_ONCE qDebug() << "Offscreen size:" << offscreenSize.width();
2786 
2787  int blocksize = offscreenSize.width();
2788 
2789  while (node) {
2790  node = (node - 1) / 4;
2791  blocksize /= 2;
2792  }
2793 
2794  return blocksize;
2795 }
Q_CORE_EXPORT void qDebug(const char *,...)
int width() const
Returns the width.
Definition: qsize.h:126
#define DEBUG_ONCE

◆ quadtreeClear()

void QGLMaskTextureCache::quadtreeClear ( int  channel,
const QRect rect,
int  node = 0 
)
private

Definition at line 2895 of file qpaintengine_opengl.cpp.

2896 {
2897  const quint64 &key = occupied_quadtree[channel][node].key;
2898 
2899  int current_block_size = quadtreeBlocksize(node);
2901 
2902  QRect relative = rect.translated(-location);
2903 
2904  if (relative.left() >= current_block_size || relative.top() >= current_block_size
2905  || relative.right() < 0 || relative.bottom() < 0)
2906  return;
2907 
2908  if (key != 0) {
2910 
2911  Q_ASSERT(it != cache.end());
2912 
2913  while (it != cache.end() && it.key() == key) {
2914  const CacheInfo &cache_info = it.value();
2915 
2916  if (cache_info.loc.channel == channel
2917  && cache_info.loc.rect.left() <= location.x()
2918  && cache_info.loc.rect.top() <= location.y()
2919  && cache_info.loc.rect.right() >= location.x()
2920  && cache_info.loc.rect.bottom() >= location.y())
2921  {
2922  quadtreeInsert(channel, 0, cache_info.loc.rect);
2923  engine->cacheItemErased(channel, cache_info.loc.rect);
2924  cache.erase(it);
2925  goto found;
2926  } else {
2927  ++it;
2928  }
2929  }
2930 
2931  // if we don't find the key there's an error in the quadtree
2932  Q_ASSERT(false);
2933 found:
2934  Q_ASSERT(occupied_quadtree[channel][node].key == 0);
2935  } else if (occupied_quadtree[channel][node].largest_available_block < current_block_size) {
2936  Q_ASSERT(current_block_size >= block_size);
2937 
2938  node = node * 4 + 1;
2939 
2940  for (int sibling = 0; sibling < 4; ++sibling)
2941  quadtreeClear(channel, rect, node + sibling);
2942  }
2943 }
QOpenGLPaintEnginePrivate * engine
#define it(className, varName)
void quadtreeInsert(int channel, quint64 key, const QRect &rect, int node=0)
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QHash< Key, T >::iterator find(const Key &key, const T &value)
Returns an iterator pointing to the item with the key and value.
Definition: qhash.h:972
QGLTextureCacheHash cache
unsigned __int64 quint64
Definition: qglobal.h:943
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
void cacheItemErased(int channel, const QRect &rect)
QVector< QuadTreeNode > occupied_quadtree[4]
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void quadtreeClear(int channel, const QRect &rect, int node=0)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QPoint quadtreeLocation(int node)
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
Definition: qhash.h:827
friend class iterator
Definition: qhash.h:393

◆ quadtreeFindAvailableLocation()

bool QGLMaskTextureCache::quadtreeFindAvailableLocation ( const QSize size,
QRect rect,
int *  channel 
)
private

Definition at line 2945 of file qpaintengine_opengl.cpp.

2946 {
2947  int needed_block_size = qMax(1, qMax(size.width(), size.height()));
2948 
2949  for (int i = 0; i < 4; ++i) {
2950  int current_block_size = offscreenSize.width();
2951 
2952  if (occupied_quadtree[i][0].largest_available_block >= needed_block_size) {
2953  int node = 0;
2954 
2955  while (current_block_size != occupied_quadtree[i][node].largest_available_block) {
2956  Q_ASSERT(current_block_size > block_size);
2957  Q_ASSERT(current_block_size > occupied_quadtree[i][node].largest_available_block);
2958 
2959  node = node * 4 + 1;
2960  current_block_size /= 2;
2961 
2962  int sibling = 0;
2963 
2964  while (occupied_quadtree[i][node + sibling].largest_available_block < needed_block_size)
2965  ++sibling;
2966 
2967  Q_ASSERT(sibling < 4);
2968  node += sibling;
2969  }
2970 
2971  *channel = i;
2972  *rect = QRect(quadtreeLocation(node), size);
2973 
2974  return true;
2975  }
2976  }
2977 
2978  return false;
2979 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int width() const
Returns the width.
Definition: qsize.h:126
QVector< QuadTreeNode > occupied_quadtree[4]
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QPoint quadtreeLocation(int node)

◆ quadtreeFindExistingLocation()

void QGLMaskTextureCache::quadtreeFindExistingLocation ( const QSize size,
QRect rect,
int *  channel 
)
private

Definition at line 2981 of file qpaintengine_opengl.cpp.

2982 {
2983  // try to pick small masks to throw out, as large masks are more expensive to recompute
2984  *channel = qrand() % 4;
2985  for (int i = 0; i < 4; ++i)
2986  if (occupied_quadtree[i][0].largest_used_block < occupied_quadtree[*channel][0].largest_used_block)
2987  *channel = i;
2988 
2989  int needed_block_size = qt_next_power_of_two(qMax(1, qMax(size.width(), size.height())));
2990 
2991  int node = 0;
2992  int current_block_size = offscreenSize.width();
2993 
2994  while (current_block_size > block_size
2995  && current_block_size >= needed_block_size * 2
2996  && occupied_quadtree[*channel][node].key == 0)
2997  {
2998  node = node * 4 + 1;
2999 
3000  int sibling = 0;
3001 
3002  for (int i = 1; i < 4; ++i) {
3003  if (occupied_quadtree[*channel][node + i].largest_used_block
3004  <= occupied_quadtree[*channel][node + sibling].largest_used_block)
3005  {
3006  sibling = i;
3007  }
3008  }
3009 
3010  node += sibling;
3011  current_block_size /= 2;
3012  }
3013 
3014  *rect = QRect(quadtreeLocation(node), size);
3015 }
Q_CORE_EXPORT int qrand()
int qt_next_power_of_two(int v)
Definition: qgl.cpp:1886
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int width() const
Returns the width.
Definition: qsize.h:126
QVector< QuadTreeNode > occupied_quadtree[4]
int key
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QPoint quadtreeLocation(int node)

◆ quadtreeInsert()

void QGLMaskTextureCache::quadtreeInsert ( int  channel,
quint64  key,
const QRect rect,
int  node = 0 
)
private

Definition at line 2850 of file qpaintengine_opengl.cpp.

2851 {
2852  int current_block_size = quadtreeBlocksize(node);
2854  QRect relative = rect.translated(-location);
2855 
2856  if (relative.left() >= current_block_size || relative.top() >= current_block_size
2857  || relative.right() < 0 || relative.bottom() < 0)
2858  return;
2859 
2860  if (current_block_size == block_size // no more refining possible
2861  || (relative.top() < block_size && relative.bottom() >= (current_block_size - block_size)
2862  && relative.left() < block_size && relative.right() >= (current_block_size - block_size)))
2863  {
2864  if (key != 0) {
2865  occupied_quadtree[channel][node].largest_available_block = 0;
2866  occupied_quadtree[channel][node].largest_used_block = rect.width() * rect.height();
2867  } else {
2868  occupied_quadtree[channel][node].largest_available_block = current_block_size;
2869  occupied_quadtree[channel][node].largest_used_block = 0;
2870  }
2871 
2872  occupied_quadtree[channel][node].key = key;
2873 
2874  quadtreeUpdate(channel, node, current_block_size);
2875  } else {
2876  if (key && occupied_quadtree[channel][node].largest_available_block == current_block_size) {
2877  // refining the quad tree, initialize child nodes
2878  int half_block_size = current_block_size / 2;
2879 
2880  int temp = node * 4 + 1;
2881  for (int sibling = 0; sibling < 4; ++sibling) {
2882  occupied_quadtree[channel][temp + sibling].largest_available_block = half_block_size;
2883  occupied_quadtree[channel][temp + sibling].largest_used_block = 0;
2884  occupied_quadtree[channel][temp + sibling].key = 0;
2885  }
2886  }
2887 
2888  node = node * 4 + 1;
2889 
2890  for (int sibling = 0; sibling < 4; ++sibling)
2891  quadtreeInsert(channel, key, rect, node + sibling);
2892  }
2893 }
void quadtreeInsert(int channel, quint64 key, const QRect &rect, int node=0)
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
void quadtreeUpdate(int channel, int node, int current_block_size)
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QVector< QuadTreeNode > occupied_quadtree[4]
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QPoint quadtreeLocation(int node)

◆ quadtreeLocation()

QPoint QGLMaskTextureCache::quadtreeLocation ( int  node)
private

Definition at line 2797 of file qpaintengine_opengl.cpp.

2798 {
2799  QPoint location;
2800  int blocksize = quadtreeBlocksize(node);
2801 
2802  while (node) {
2803  --node;
2804 
2805  if (node & 1)
2806  location.setX(location.x() + blocksize);
2807 
2808  if (node & 2)
2809  location.setY(location.y() + blocksize);
2810 
2811  node /= 4;
2812  blocksize *= 2;
2813  }
2814 
2815  return location;
2816 }
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
Definition: qpoint.h:137
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
Definition: qpoint.h:134

◆ quadtreeUpdate()

void QGLMaskTextureCache::quadtreeUpdate ( int  channel,
int  node,
int  current_block_size 
)
private

Definition at line 2818 of file qpaintengine_opengl.cpp.

2819 {
2820  while (node) {
2821  node = (node - 1) / 4;
2822 
2823  int first_child = node * 4 + 1;
2824 
2825  int largest_available = 0;
2826  int largest_used = 0;
2827 
2828  bool all_empty = true;
2829 
2830  for (int i = 0; i < 4; ++i) {
2831  largest_available = qMax(largest_available, occupied_quadtree[channel][first_child + i].largest_available_block);
2832  largest_used = qMax(largest_used, occupied_quadtree[channel][first_child + i].largest_used_block);
2833 
2834  if (occupied_quadtree[channel][first_child + i].largest_available_block < current_block_size)
2835  all_empty = false;
2836  }
2837 
2838  current_block_size *= 2;
2839 
2840  if (all_empty) {
2841  occupied_quadtree[channel][node].largest_available_block = current_block_size;
2842  occupied_quadtree[channel][node].largest_used_block = 0;
2843  } else {
2844  occupied_quadtree[channel][node].largest_available_block = largest_available;
2845  occupied_quadtree[channel][node].largest_used_block = largest_used;
2846  }
2847  }
2848 }
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QVector< QuadTreeNode > occupied_quadtree[4]

◆ setDrawableSize()

void QGLMaskTextureCache::setDrawableSize ( const QSize drawableSize)

Definition at line 2663 of file qpaintengine_opengl.cpp.

2664 {
2665  drawableSize = sz;
2666 }

◆ setOffscreenSize()

void QGLMaskTextureCache::setOffscreenSize ( const QSize offscreenSize)

Definition at line 2633 of file qpaintengine_opengl.cpp.

2634 {
2635  Q_ASSERT(sz.width() == sz.height());
2636 
2637  if (offscreenSize != sz) {
2638  offscreenSize = sz;
2639  clearCache();
2640  }
2641 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

Properties

◆ cache

QGLTextureCacheHash QGLMaskTextureCache::cache
private

Definition at line 214 of file qpaintengine_opengl.cpp.

◆ drawableSize

QSize QGLMaskTextureCache::drawableSize
private

Definition at line 212 of file qpaintengine_opengl.cpp.

◆ engine

QOpenGLPaintEnginePrivate* QGLMaskTextureCache::engine
private

Definition at line 230 of file qpaintengine_opengl.cpp.

◆ occupied_quadtree

QVector<QuadTreeNode> QGLMaskTextureCache::occupied_quadtree[4]
private

Definition at line 216 of file qpaintengine_opengl.cpp.

◆ offscreenSize

QSize QGLMaskTextureCache::offscreenSize
private

Definition at line 211 of file qpaintengine_opengl.cpp.


The documentation for this class was generated from the following file: