Ejemplo n.º 1
0
int64_t LayerTreeCoordinator::adoptImageBackingStore(Image* image)
{
    if (!image)
        return InvalidWebLayerID;

    int64_t key = 0;

#if PLATFORM(QT)
    QImage* nativeImage = image->nativeImageForCurrentFrame();

    if (!nativeImage)
        return InvalidWebLayerID;

    key = nativeImage->cacheKey();
#endif

    HashMap<int64_t, int>::iterator it = m_directlyCompositedImageRefCounts.find(key);

    if (it != m_directlyCompositedImageRefCounts.end()) {
        ++(it->second);
        return key;
    }

    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), (image->currentFrameHasAlpha() ? ShareableBitmap::SupportsAlpha : 0));
    {
        OwnPtr<WebCore::GraphicsContext> graphicsContext = bitmap->createGraphicsContext();
        graphicsContext->drawImage(image, ColorSpaceDeviceRGB, IntPoint::zero());
    }

    ShareableBitmap::Handle handle;
    bitmap->createHandle(handle);
    m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateDirectlyCompositedImage(key, handle));
    m_directlyCompositedImageRefCounts.add(key, 1);
    return key;
}
Ejemplo n.º 2
0
GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, const QImage &image, BindOptions options)
{
    if (image.isNull())
        return 0;
    QMutexLocker locker(&m_mutex);
    qint64 key = image.cacheKey();

    // A QPainter is active on the image - take the safe route and replace the texture.
    if (!image.paintingActive()) {
        QOpenGLCachedTexture *entry = m_cache.object(key);
        if (entry && entry->options() == options) {
            context->functions()->glBindTexture(GL_TEXTURE_2D, entry->id());
            return entry->id();
        }
    }

    QImage img = image;
    if (!context->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures)) {
        // Scale the pixmap if needed. GL textures needs to have the
        // dimensions 2^n+2(border) x 2^m+2(border), unless we're using GL
        // 2.0 or use the GL_TEXTURE_RECTANGLE texture target
        int tx_w = qNextPowerOfTwo(image.width() - 1);
        int tx_h = qNextPowerOfTwo(image.height() - 1);
        if (tx_w != image.width() || tx_h != image.height()) {
            img = img.scaled(tx_w, tx_h);
        }
    }

    GLuint id = bindTexture(context, key, img, options);
    if (id > 0)
        QImagePixmapCleanupHooks::enableCleanupHooks(image);

    return id;
}
Ejemplo n.º 3
0
QContactDetail *CntTransformThumbnail::transformItemField(const CContactItemField& field, const QContact &contact)
{
    Q_UNUSED(contact);

    QContactThumbnail *thumbnail = NULL;

    if (field.ContentType().ContainsFieldType(KUidContactFieldPicture)
            || field.ContentType().ContainsFieldType(KUidContactFieldVCardMapJPEG)) {
        // check storage type
        if (field.StorageType() != KStorageTypeStore) {
            return NULL;
        }

        // Create new field
        CContactStoreField* storage = field.StoreStorage();
        QImage image;
        HBufC8 *theThing = storage->Thing();
        if (theThing != NULL) {
            QByteArray bytes((char*)theThing->Ptr(), theThing->Length());
            bool loaded = image.loadFromData(bytes, "JPG");
            if (loaded) {
                // Create thumbnail detail
                thumbnail = new QContactThumbnail();
                thumbnail->setThumbnail(image);
                // Keep jpg image, so no need for conversion when saving thumbnail detail.
                thumbnail->setValue(KThumbnailChecksum, image.cacheKey());
                thumbnail->setValue(KThumbnailJpgImage, bytes);
            }
        }
    }

    return thumbnail;
}
Ejemplo n.º 4
0
QString QtImageProvider::encode(const QImage& image)
{
	auto key = image.cacheKey();
	auto it = imageCache_.find(key);
	if (it == imageCache_.end())
	{
		imageCache_[key] = image;
	}
	return "image://" + QString(providerId()) + "/" + QString(std::to_string(key).c_str());
}
Ejemplo n.º 5
0
void
CurrentEngine::metadataChanged( Meta::AlbumPtr album )
{
    QImage cover = album->image( m_coverWidth );
    qint64 coverCacheKey = cover.cacheKey();
    if( m_coverCacheKey != coverCacheKey )
    {
        m_coverCacheKey = coverCacheKey;
        setData( "current", "albumart", cover );
    }
}
Ejemplo n.º 6
0
void QPdfEngine::drawImage(const QRectF &rectangle, const QImage &image, const QRectF &sr, Qt::ImageConversionFlags)
{
    if (sr.isEmpty() || rectangle.isEmpty() || image.isNull())
        return;
    Q_D(QPdfEngine);

    QRect sourceRect = sr.toRect();
    QImage im = sourceRect != image.rect() ? image.copy(sourceRect) : image;
    bool bitmap = true;
    const int object = d->addImage(im, &bitmap, im.cacheKey());
    if (object < 0)
        return;

    *d->currentPage << "q\n/GSa gs\n";
    *d->currentPage
        << QPdf::generateMatrix(QTransform(rectangle.width() / sr.width(), 0, 0, rectangle.height() / sr.height(),
                                           rectangle.x(), rectangle.y()) * (d->simplePen ? QTransform() : d->stroker.matrix));
    setBrush();
    d->currentPage->streamImage(im.width(), im.height(), object);
    *d->currentPage << "Q\n";
}