31 f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0);
33 f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
44 f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
45 f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
48 f->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
192 if (!blockMipmapRegeneration &&
193 patchLevelOfDetail > 0 &&
215 int centerWidth = patchSize.width();
216 int centerHeight = patchSize.height();
220 topHeight = patchOffset.y();
227 leftWidth = patchOffset.x();
234 rightWidth = tileSize.width() - patchOffset.x() - centerWidth;
241 bottomHeight = tileSize.height() - patchOffset.y() - centerHeight;
246 if (topHeight > 0 || leftWidth > 0 || rightWidth > 0 || bottomHeight > 0) {
247 int bufWidth = leftWidth + centerWidth + rightWidth;
248 int bufHeight = topHeight + centerHeight + bottomHeight;
250 int centerStride = centerWidth * pixelSize;
251 int leftStride = leftWidth * pixelSize;
252 int rightStride = rightWidth * pixelSize;
253 int bufStride = bufWidth * pixelSize;
255 QByteArray buf(bufStride * bufHeight, 0);
256 quint8 *bufData =
reinterpret_cast<quint8 *
>(buf.data());
257 const quint8 *patchData = updateInfo.
data();
260 const quint8 *topSrcPtr = patchData;
261 quint8 *topDstPtr = bufData + leftStride;
262 for (
int y = 0; y < topHeight; ++y) {
263 memcpy(topDstPtr, topSrcPtr, centerStride);
264 topDstPtr += bufStride;
269 int leftDstSkip = centerStride + rightStride;
270 const quint8 *leftSrcPtr = patchData;
271 quint8 *leftDstPtr = bufData + (topHeight * bufStride);
272 for (
int y = 0; y < centerHeight; ++y) {
273 for (
int x = 0; x < leftWidth; ++x) {
274 memcpy(leftDstPtr, leftSrcPtr, pixelSize);
275 leftDstPtr += pixelSize;
277 leftSrcPtr += centerStride;
278 leftDstPtr += leftDstSkip;
283 const quint8 *centerSrcPtr = patchData;
284 quint8 *centerDstPtr = bufData + (topHeight * bufStride) + leftStride;
285 for (
int y = 0; y < centerHeight; ++y) {
286 memcpy(centerDstPtr, centerSrcPtr, centerStride);
287 centerSrcPtr += centerStride;
288 centerDstPtr += bufStride;
292 if (rightWidth > 0) {
293 int rightDstSkip = leftStride + centerStride;
294 const quint8 *rightSrcPtr = patchData + (centerStride - pixelSize);
295 quint8 *rightDstPtr = bufData + (topHeight * bufStride) + rightDstSkip;
296 for (
int y = 0; y < centerHeight; ++y) {
297 for (
int x = 0; x < rightWidth; ++x) {
298 memcpy(rightDstPtr, rightSrcPtr, pixelSize);
299 rightDstPtr += pixelSize;
301 rightSrcPtr += centerStride;
302 rightDstPtr += rightDstSkip;
306 if (bottomHeight > 0) {
307 const quint8 *bottomSrcPtr = patchData + ((centerHeight - 1) * centerStride);
308 quint8 *bottomDstPtr = bufData + ((topHeight + centerHeight) * bufStride) + leftStride;
309 for (
int y = 0; y < bottomHeight; ++y) {
310 memcpy(bottomDstPtr, bottomSrcPtr, centerStride);
311 bottomDstPtr += bufStride;
315 const GLvoid *fd = bufData;
317 f->glTexSubImage2D(GL_TEXTURE_2D,
319 patchOffset.x() - leftWidth,
320 patchOffset.y() - topHeight,
328 const GLvoid *fd = updateInfo.
data();
332 f->glTexImage2D(GL_TEXTURE_2D, patchLevelOfDetail,
335 patchSize.height(), 0,
341 const GLvoid *fd = updateInfo.
data();
342 const int size = centerWidth * centerHeight * pixelSize;
346 f->glTexSubImage2D(GL_TEXTURE_2D, patchLevelOfDetail,
347 patchOffset.x(), patchOffset.y(),
348 patchSize.width(), patchSize.height(),
365 if (!patchLevelOfDetail) {
const KisGLTexturesInfo * m_texturesInfo
KisOpenGL::FilterMode m_filter
KisTextureTile(const QRect &imageRect, const KisGLTexturesInfo *texturesInfo, const QByteArray &fillData, KisOpenGL::FilterMode mode, KisOpenGLBufferCircularStorage *bufferStorage, int numMipmapLevels, QOpenGLFunctions *f)
void update(const KisTextureTileUpdateInfo &updateInfo, bool blockMipmapRegeneration)
int bindToActiveTexture(bool blockMipmapRegeneration)
KisOpenGLBufferCircularStorage * m_bufferStorage
QRectF imageRectInTexturePixels(const QRect &imageRect) const
QRectF relativeRect(const QRect &br, const QRect &cr, const KisGLTexturesInfo *texturesInfo)