Qt 4.8
Classes | Functions | Variables
qglpixmapfilter.cpp File Reference
#include "private/qpixmapfilter_p.h"
#include "private/qpixmapdata_gl_p.h"
#include "private/qpaintengineex_opengl2_p.h"
#include "private/qglengineshadermanager_p.h"
#include "private/qpixmapdata_p.h"
#include "private/qimagepixmapcleanuphooks_p.h"
#include "qglpixmapfilter_p.h"
#include "qgraphicssystem_gl_p.h"
#include "qpaintengine_opengl_p.h"
#include "qcache.h"
#include "qglframebufferobject.h"
#include "qglshaderprogram.h"
#include "qgl_p.h"
#include "private/qapplication_p.h"
#include "private/qdrawhelper_p.h"
#include "private/qmemrotate_p.h"
#include "private/qmath_p.h"
#include "qmath.h"

Go to the source code of this file.

Classes

class  QGLBlurTextureCache
 
class  QGLBlurTextureInfo
 
class  QGLPixmapBlurFilter
 
class  QGLPixmapColorizeFilter
 
class  QGLPixmapConvolutionFilter
 
class  QGLPixmapDropShadowFilter
 

Functions

static GLuint generateBlurTexture (const QSize &size, GLenum format=GL_RGBA)
 
static uint nextMultiple (uint x, uint multiplier)
 
Q_GUI_EXPORT void qt_blurImage (QImage &blurImage, qreal radius, bool quality, int transposed=0)
 
const QGLContextqt_gl_share_context ()
 
Q_GUI_EXPORT QImage qt_halfScaled (const QImage &source)
 
Q_GUI_EXPORT void qt_memrotate90_gl (const quint32 *src, int srcWidth, int srcHeight, int srcStride, quint32 *dest, int dstStride)
 

Variables

static const int qAnimatedBlurLevelIncrement = 16
 
static const int qMaxBlurHalfScaleLevel = 1
 
static const char * qt_gl_colorize_filter
 
static const char * qt_gl_drop_shadow_filter
 

Function Documentation

◆ generateBlurTexture()

static GLuint generateBlurTexture ( const QSize size,
GLenum  format = GL_RGBA 
)
static

Definition at line 410 of file qglpixmapfilter.cpp.

Referenced by QGLPixmapBlurFilter::processGL().

411 {
412  GLuint texture;
413  glGenTextures(1, &texture);
414  glBindTexture(GL_TEXTURE_2D, texture);
415  glTexImage2D(GL_TEXTURE_2D, 0, format, size.width(), size.height(), 0, format,
416  GL_UNSIGNED_BYTE, 0);
417  return texture;
418 }
#define GL_TEXTURE_2D
int width() const
Returns the width.
Definition: qsize.h:126
#define GL_UNSIGNED_BYTE
int height() const
Returns the height.
Definition: qsize.h:129

◆ nextMultiple()

static uint nextMultiple ( uint  x,
uint  multiplier 
)
inlinestatic

Definition at line 420 of file qglpixmapfilter.cpp.

Referenced by QGLPixmapBlurFilter::processGL().

421 {
422  uint mod = x % multiplier;
423  if (mod == 0)
424  return x;
425  return x + multiplier - mod;
426 }
unsigned int uint
Definition: qglobal.h:996

◆ qt_blurImage()

Q_GUI_EXPORT void qt_blurImage ( QImage blurImage,
qreal  radius,
bool  quality,
int  transposed = 0 
)

Definition at line 912 of file qpixmapfilter.cpp.

Referenced by QGLPixmapBlurFilter::processGL(), and QGLPixmapDropShadowFilter::processGL().

913 {
914  if (blurImage.format() == QImage::Format_Indexed8)
915  expblur<12, 10, true>(blurImage, radius, quality, transposed);
916  else
917  expblur<12, 10, false>(blurImage, radius, quality, transposed);
918 }
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305

◆ qt_gl_share_context()

const QGLContext* qt_gl_share_context ( )

Definition at line 284 of file qwindowsurface_gl.cpp.

285 {
287  if (widget)
288  return widget->context();
289  return 0;
290 }
QPointer< QWidget > widget
const QGLContext * context() const
Returns the context of this widget.
Definition: qgl.cpp:5303
The QGLWidget class is a widget for rendering OpenGL graphics.
Definition: qgl.h:474
QGLWidget * qt_gl_share_widget()

◆ qt_halfScaled()

Q_GUI_EXPORT QImage qt_halfScaled ( const QImage source)

Definition at line 797 of file qpixmapfilter.cpp.

Referenced by QGLBlurTextureInfo::paddedImage(), QGLPixmapBlurFilter::processGL(), QGLPixmapDropShadowFilter::processGL(), and qt_blurImage().

798 {
799  if (source.width() < 2 || source.height() < 2)
800  return QImage();
801 
802  QImage srcImage = source;
803 
804  if (source.format() == QImage::Format_Indexed8) {
805  // assumes grayscale
806  QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
807 
808  const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits());
809  int sx = srcImage.bytesPerLine();
810  int sx2 = sx << 1;
811 
812  uchar *dst = reinterpret_cast<uchar*>(dest.bits());
813  int dx = dest.bytesPerLine();
814  int ww = dest.width();
815  int hh = dest.height();
816 
817  for (int y = hh; y; --y, dst += dx, src += sx2) {
818  const uchar *p1 = src;
819  const uchar *p2 = src + sx;
820  uchar *q = dst;
821  for (int x = ww; x; --x, ++q, p1 += 2, p2 += 2)
822  *q = ((int(p1[0]) + int(p1[1]) + int(p2[0]) + int(p2[1])) + 2) >> 2;
823  }
824 
825  return dest;
826  } else if (source.format() == QImage::Format_ARGB8565_Premultiplied) {
827  QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
828 
829  const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits());
830  int sx = srcImage.bytesPerLine();
831  int sx2 = sx << 1;
832 
833  uchar *dst = reinterpret_cast<uchar*>(dest.bits());
834  int dx = dest.bytesPerLine();
835  int ww = dest.width();
836  int hh = dest.height();
837 
838  for (int y = hh; y; --y, dst += dx, src += sx2) {
839  const uchar *p1 = src;
840  const uchar *p2 = src + sx;
841  uchar *q = dst;
842  for (int x = ww; x; --x, q += 3, p1 += 6, p2 += 6) {
843  // alpha
844  q[0] = AVG(AVG(p1[0], p1[3]), AVG(p2[0], p2[3]));
845  // rgb
846  const quint16 p16_1 = (p1[2] << 8) | p1[1];
847  const quint16 p16_2 = (p1[5] << 8) | p1[4];
848  const quint16 p16_3 = (p2[2] << 8) | p2[1];
849  const quint16 p16_4 = (p2[5] << 8) | p2[4];
850  const quint16 result = AVG16(AVG16(p16_1, p16_2), AVG16(p16_3, p16_4));
851  q[1] = result & 0xff;
852  q[2] = result >> 8;
853  }
854  }
855 
856  return dest;
857  } else if (source.format() != QImage::Format_ARGB32_Premultiplied
858  && source.format() != QImage::Format_RGB32)
859  {
861  }
862 
863  QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
864 
865  const quint32 *src = reinterpret_cast<const quint32*>(const_cast<const QImage &>(srcImage).bits());
866  int sx = srcImage.bytesPerLine() >> 2;
867  int sx2 = sx << 1;
868 
869  quint32 *dst = reinterpret_cast<quint32*>(dest.bits());
870  int dx = dest.bytesPerLine() >> 2;
871  int ww = dest.width();
872  int hh = dest.height();
873 
874  for (int y = hh; y; --y, dst += dx, src += sx2) {
875  const quint32 *p1 = src;
876  const quint32 *p2 = src + sx;
877  quint32 *q = dst;
878  for (int x = ww; x; --x, q++, p1 += 2, p2 += 2)
879  *q = AVG(AVG(p1[0], p1[1]), AVG(p2[0], p2[1]));
880  }
881 
882  return dest;
883 }
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
unsigned char uchar
Definition: qglobal.h:994
unsigned short quint16
Definition: qglobal.h:936
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
#define AVG16(a, b)
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966
#define AVG(a, b)
unsigned int quint32
Definition: qglobal.h:938
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572

◆ qt_memrotate90_gl()

Q_GUI_EXPORT void qt_memrotate90_gl ( const quint32 src,
int  srcWidth,
int  srcHeight,
int  srcStride,
quint32 dest,
int  dstStride 
)

Definition at line 591 of file qmemrotate.cpp.

Referenced by nextMultiple(), and QGLPixmapBlurFilter::processGL().

593 {
594  qt_memrotate90_template(src, srcWidth, srcHeight, srcStride, reinterpret_cast<qrgb_gl_rgba *>(dest), dstStride);
595 }
Q_STATIC_TEMPLATE_FUNCTION void qt_memrotate90_template(const SRC *src, int srcWidth, int srcHeight, int srcStride, DST *dest, int dstStride)
Definition: qmemrotate.cpp:389

Variable Documentation

◆ qAnimatedBlurLevelIncrement

const int qAnimatedBlurLevelIncrement = 16
static

Definition at line 407 of file qglpixmapfilter.cpp.

Referenced by QGLPixmapBlurFilter::processGL().

◆ qMaxBlurHalfScaleLevel

const int qMaxBlurHalfScaleLevel = 1
static

Definition at line 408 of file qglpixmapfilter.cpp.

Referenced by QGLPixmapBlurFilter::processGL().

◆ qt_gl_colorize_filter

const char* qt_gl_colorize_filter
static
Initial value:
=
"uniform lowp vec4 colorizeColor;"
"uniform lowp float colorizeStrength;"
"lowp vec4 customShader(lowp sampler2D src, highp vec2 srcCoords)"
"{"
" lowp vec4 srcPixel = texture2D(src, srcCoords);"
" lowp float gray = dot(srcPixel.rgb, vec3(0.212671, 0.715160, 0.072169));"
" lowp vec3 colorized = 1.0-((1.0-gray)*(1.0-colorizeColor.rgb));"
" return vec4(mix(srcPixel.rgb, colorized * srcPixel.a, colorizeStrength), srcPixel.a);"
"}"

Definition at line 161 of file qglpixmapfilter.cpp.

Referenced by QGLPixmapColorizeFilter::QGLPixmapColorizeFilter().

◆ qt_gl_drop_shadow_filter

const char* qt_gl_drop_shadow_filter
static
Initial value:
=
"uniform lowp vec4 shadowColor;"
"lowp vec4 customShader(lowp sampler2D src, highp vec2 srcCoords)"
"{"
" return shadowColor * texture2D(src, srcCoords.yx).a;"
"}"

Definition at line 537 of file qglpixmapfilter.cpp.

Referenced by QGLPixmapDropShadowFilter::QGLPixmapDropShadowFilter().