~ubuntu-branches/ubuntu/wily/qtdeclarative-opensource-src/wily-proposed

« back to all changes in this revision

Viewing changes to src/quick/scenegraph/util/qsgatlastexture.cpp

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo, Ricardo Salveti de Araujo, Timo Jyrinki
  • Date: 2014-06-19 02:39:21 UTC
  • mfrom: (0.1.18 experimental)
  • Revision ID: package-import@ubuntu.com-20140619023921-yb2oasnuetz9b0fc
Tags: 5.3.0-3ubuntu4
[ Ricardo Salveti de Araujo ]
* debian/control:
  - Updating dependencies as we now also have libqt5quickwidgets5-gles
* libqt5quickwidgets5.symbols: updating to allow gles variant

[ Timo Jyrinki ]
* Update libqt5quickparticles5.symbols from build logs

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
 
53
53
#include <private/qsgtexture_p.h>
54
54
 
55
 
#include <private/qqmlprofilerservice_p.h>
 
55
#include <private/qquickprofiler_p.h>
56
56
 
57
57
QT_BEGIN_NAMESPACE
58
58
 
140
140
    : m_allocator(size)
141
141
    , m_texture_id(0)
142
142
    , m_size(size)
143
 
    , m_filtering(QSGTexture::Linear)
144
143
    , m_allocated(false)
145
144
{
146
145
 
147
 
#ifdef QT_OPENGL_ES
 
146
    m_internalFormat = GL_RGBA;
 
147
    m_externalFormat = GL_BGRA;
 
148
 
 
149
#ifndef QT_OPENGL_ES
 
150
    if (QOpenGLContext::currentContext()->isOpenGLES()) {
 
151
#endif
 
152
 
148
153
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
149
154
    QString *deviceName =
150
155
            static_cast<QString *>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("AndroidDeviceName"));
151
 
    static bool wrongfullyReportsBgra8888Support = deviceName->compare(QStringLiteral("samsung SM-T211"), Qt::CaseInsensitive) == 0
152
 
                                                || deviceName->compare(QStringLiteral("samsung SM-T210"), Qt::CaseInsensitive) == 0
153
 
                                                || deviceName->compare(QStringLiteral("samsung SM-T215"), Qt::CaseInsensitive) == 0;
 
156
    static bool wrongfullyReportsBgra8888Support = deviceName != 0
 
157
                                                    && (deviceName->compare(QStringLiteral("samsung SM-T211"), Qt::CaseInsensitive) == 0
 
158
                                                        || deviceName->compare(QStringLiteral("samsung SM-T210"), Qt::CaseInsensitive) == 0
 
159
                                                        || deviceName->compare(QStringLiteral("samsung SM-T215"), Qt::CaseInsensitive) == 0);
154
160
#else
155
161
    static bool wrongfullyReportsBgra8888Support = false;
156
 
#endif
 
162
#endif // ANDROID
157
163
 
158
164
    const char *ext = (const char *) glGetString(GL_EXTENSIONS);
159
165
    if (!wrongfullyReportsBgra8888Support
165
171
    } else if (strstr(ext, "GL_APPLE_texture_format_BGRA8888")) {
166
172
        m_internalFormat = GL_RGBA;
167
173
        m_externalFormat = GL_BGRA;
168
 
#endif
 
174
#endif // IOS
169
175
    } else {
170
176
        m_internalFormat = m_externalFormat = GL_RGBA;
171
177
    }
172
 
#else
173
 
    m_internalFormat = GL_RGBA;
174
 
    m_externalFormat = GL_BGRA;
 
178
 
 
179
#ifndef QT_OPENGL_ES
 
180
    }
175
181
#endif
176
182
 
177
183
    m_use_bgra_fallback = qEnvironmentVariableIsSet("QSG_ATLAS_USE_BGRA_FALLBACK");
314
320
 
315
321
}
316
322
 
317
 
bool Atlas::bind(QSGTexture::Filtering filtering)
 
323
void Atlas::bind(QSGTexture::Filtering filtering)
318
324
{
319
 
    bool forceUpdate = false;
320
325
    if (!m_allocated) {
321
326
        m_allocated = true;
322
327
 
329
334
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
330
335
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
331
336
#if !defined(QT_OPENGL_ES_2)
332
 
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
 
337
        if (!QOpenGLContext::currentContext()->isOpenGLES())
 
338
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
333
339
#endif
334
340
        glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_size.width(), m_size.height(), 0, m_externalFormat, GL_UNSIGNED_BYTE, 0);
335
341
 
361
367
            glDeleteTextures(1, &m_texture_id);
362
368
            m_texture_id = 0;
363
369
        }
364
 
        forceUpdate = true;
365
370
    } else {
366
371
        glBindTexture(GL_TEXTURE_2D, m_texture_id);
367
372
    }
368
373
 
369
374
    if (m_texture_id == 0)
370
 
        return false;
 
375
        return;
371
376
 
372
377
    // Upload all pending images..
373
378
    for (int i=0; i<m_pending_uploads.size(); ++i) {
374
379
 
375
380
#ifndef QSG_NO_RENDER_TIMING
376
 
        bool profileFrames = qsg_render_timing || QQmlProfilerService::enabled;
 
381
        bool profileFrames = qsg_render_timing || QQuickProfiler::enabled;
377
382
        if (profileFrames)
378
383
            qsg_renderer_timer.start();
379
384
#endif
393
398
                   (int) (qsg_renderer_timer.elapsed()));
394
399
        }
395
400
 
396
 
        if (QQmlProfilerService::enabled) {
397
 
            QQmlProfilerService::sceneGraphFrame(
398
 
                        QQmlProfilerService::SceneGraphTexturePrepare,
399
 
                        0,  // bind (not relevant)
400
 
                        0,  // convert (not relevant)
401
 
                        0,  // swizzle (not relevant)
402
 
                        qsg_renderer_timer.nsecsElapsed(), // (upload all of the above)
403
 
                        0); // mipmap (not used ever...)
404
 
        }
 
401
        Q_QUICK_SG_PROFILE1(QQuickProfiler::SceneGraphTexturePrepare, (
 
402
                0,  // bind (not relevant)
 
403
                0,  // convert (not relevant)
 
404
                0,  // swizzle (not relevant)
 
405
                qsg_renderer_timer.nsecsElapsed(), // (upload all of the above)
 
406
                0)); // mipmap (not used ever...)
405
407
#endif
406
408
    }
407
409
 
408
 
    if (filtering != m_filtering) {
409
 
        GLenum f = filtering == QSGTexture::Nearest ? GL_NEAREST : GL_LINEAR;
410
 
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, f);
411
 
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, f);
412
 
        m_filtering = filtering;
413
 
    }
 
410
    GLenum f = filtering == QSGTexture::Nearest ? GL_NEAREST : GL_LINEAR;
 
411
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, f);
 
412
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, f);
414
413
 
415
414
    m_pending_uploads.clear();
416
 
 
417
 
    return forceUpdate;
418
415
}
419
416
 
420
417
void Atlas::remove(Texture *t)
461
458
        m_nonatlas_texture = new QSGPlainTexture();
462
459
        m_nonatlas_texture->setImage(m_image);
463
460
        m_nonatlas_texture->setFiltering(filtering());
 
461
        m_nonatlas_texture->setMipmapFiltering(mipmapFiltering());
464
462
    }
465
463
    return m_nonatlas_texture;
466
464
}