本文整理汇总了C++中QPixmap::surface方法的典型用法代码示例。如果您正苦于以下问题:C++ QPixmap::surface方法的具体用法?C++ QPixmap::surface怎么用?C++ QPixmap::surface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPixmap
的用法示例。
在下文中一共展示了QPixmap::surface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: adoptImageBackingStore
int64_t LayerTreeCoordinator::adoptImageBackingStore(Image* image)
{
if (!image)
return InvalidWebLayerID;
int64_t key = 0;
#if PLATFORM(QT)
QPixmap* nativeImage = image->nativeImageForCurrentFrame();
if (!nativeImage)
return InvalidWebLayerID;
key = nativeImage->cacheKey();
#elif USE(CAIRO)
NativeImageCairo* nativeImage = image->nativeImageForCurrentFrame();
if (!nativeImage)
return InvalidWebLayerID;
// This can be safely done since we own the reference.
// A corresponding cairo_surface_destroy() is ensured in releaseImageBackingStore().
cairo_surface_t* cairoSurface = cairo_surface_reference(nativeImage->surface());
key = reinterpret_cast<int64_t>(cairoSurface);
#endif
HashMap<int64_t, int>::iterator it = m_directlyCompositedImageRefCounts.find(key);
if (it != m_directlyCompositedImageRefCounts.end()) {
++(it->value);
return key;
}
// Check if we were going to release this image during the next flush.
size_t releasedIndex = m_releasedDirectlyCompositedImages.find(key);
if (releasedIndex == notFound) {
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));
} else
m_releasedDirectlyCompositedImages.remove(releasedIndex);
m_directlyCompositedImageRefCounts.add(key, 1);
return key;
}