本文整理汇总了C++中ImageResource类的典型用法代码示例。如果您正苦于以下问题:C++ ImageResource类的具体用法?C++ ImageResource怎么用?C++ ImageResource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ImageResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(ImageResourceTest, CancelOnDetach) {
KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
ScopedRegisteredURL scopedRegisteredURL(testURL);
ResourceFetcher* fetcher =
ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
// Emulate starting a real load.
ImageResource* cachedImage = ImageResource::create(ResourceRequest(testURL));
cachedImage->setIdentifier(createUniqueIdentifier());
fetcher->startLoad(cachedImage);
memoryCache()->add(cachedImage);
Persistent<MockImageResourceClient> client =
new MockImageResourceClient(cachedImage);
EXPECT_EQ(Resource::Pending, cachedImage->getStatus());
// The load should still be alive, but a timer should be started to cancel the
// load inside removeClient().
client->removeAsClient();
EXPECT_EQ(Resource::Pending, cachedImage->getStatus());
EXPECT_TRUE(memoryCache()->resourceForURL(testURL));
// Trigger the cancel timer, ensure the load was cancelled and the resource
// was evicted from the cache.
blink::testing::runPendingTasks();
EXPECT_EQ(Resource::LoadError, cachedImage->getStatus());
EXPECT_FALSE(memoryCache()->resourceForURL(testURL));
}
示例2: document
void ImageDocumentParser::finish()
{
if (!isStopped() && document()->imageElement() && document()->cachedImage()) {
ImageResource* cachedImage = document()->cachedImage();
cachedImage->finish();
cachedImage->setResponse(document()->frame()->loader().documentLoader()->response());
// Report the natural image size in the page title, regardless of zoom level.
// At a zoom level of 1 the image is guaranteed to have an integer size.
IntSize size = flooredIntSize(cachedImage->imageSizeForLayoutObject(document()->imageElement()->layoutObject(), 1.0f));
if (size.width()) {
// Compute the title, we use the decoded filename of the resource, falling
// back on the (decoded) hostname if there is no path.
String fileName = decodeURLEscapeSequences(document()->url().lastPathComponent());
if (fileName.isEmpty())
fileName = document()->url().host();
document()->setTitle(imageTitle(fileName, size));
}
document()->imageUpdated();
}
if (document())
document()->finishedParsing();
}
示例3: updateImage
void PaintChatWindow::on_pushButtonClear_clicked()
{
//käse tut ned, vermutlich wegen gleichen timestamps
/*
// not the best way to reset the image, because it causes the entire image to be transmitted
// first overwrite with black
ui->paintWidget->fillImage(Qt::black);
updateImage();
// then with white
ui->paintWidget->fillImage(Qt::white);
updateImage();
*/
// andere Lösung:
// sendet viele bytes, weil resource unkomprimiert ist
// tut nicht, vielleicht zu große items?
ui->paintWidget->fillImage(Qt::white);
ImageResource res;
res.fromQImage(ui->paintWidget->getImage());
paintChatService->init(peerId,res);
paintChatService->sendInit(peerId,res);
}
示例4: cachedImage
bool HTMLImageElement::wouldTaintOrigin(SecurityOrigin* destinationSecurityOrigin) const
{
ImageResource* image = cachedImage();
if (!image)
return false;
return !image->isAccessAllowed(destinationSecurityOrigin);
}
示例5: ASSERT
void ImageLoader::setImageWithoutConsideringPendingLoadEvent(ImageResource* newImage)
{
ASSERT(m_failedLoadURL.isEmpty());
ImageResource* oldImage = m_image.get();
if (newImage != oldImage) {
sourceImageChanged();
m_image = newImage;
if (m_hasPendingBeforeLoadEvent) {
beforeLoadEventSender().cancelEvent(this);
m_hasPendingBeforeLoadEvent = false;
}
if (m_hasPendingLoadEvent) {
loadEventSender().cancelEvent(this);
m_hasPendingLoadEvent = false;
}
if (m_hasPendingErrorEvent) {
errorEventSender().cancelEvent(this);
m_hasPendingErrorEvent = false;
}
m_imageComplete = true;
if (newImage)
newImage->addClient(this);
if (oldImage)
oldImage->removeClient(this);
}
if (RenderImageResource* imageResource = renderImageResource())
imageResource->resetAnimation();
}
示例6: DCHECK
void ImageLoader::setImageWithoutConsideringPendingLoadEvent(
ImageResource* newImage) {
DCHECK(m_failedLoadURL.isEmpty());
ImageResource* oldImage = m_image.get();
if (newImage != oldImage) {
m_image = newImage;
if (m_hasPendingLoadEvent) {
loadEventSender().cancelEvent(this);
m_hasPendingLoadEvent = false;
}
if (m_hasPendingErrorEvent) {
errorEventSender().cancelEvent(this);
m_hasPendingErrorEvent = false;
}
m_imageComplete = true;
if (newImage) {
newImage->addObserver(this);
}
if (oldImage) {
oldImage->removeObserver(this);
}
}
if (LayoutImageResource* imageResource = layoutImageResource())
imageResource->resetAnimation();
}
示例7: defaultInterpolateTo
PassRefPtr<AnimatableValue> AnimatableImage::interpolateTo(const AnimatableValue* value, double fraction) const
{
if (fraction <= 0 || fraction >= 1)
return defaultInterpolateTo(this, value, fraction);
RefPtr<CSSValue> fromValue = toCSSValue();
// FIXME: Once cross-fade works on generated image types, remove this check.
if (fromValue->isImageGeneratorValue())
return defaultInterpolateTo(this, value, fraction);
if (!fromValue->isImageValue() && !fromValue->isImageGeneratorValue()) {
if (!m_image->isImageResource())
return defaultInterpolateTo(this, value, fraction);
ImageResource* resource = static_cast<ImageResource*>(m_image->data());
fromValue = CSSImageValue::create(resource->url(), m_image.get());
}
const AnimatableImage* image = toAnimatableImage(value);
RefPtr<CSSValue> toValue = image->toCSSValue();
// FIXME: Once cross-fade works on generated image types, remove this check.
if (toValue->isImageGeneratorValue())
return defaultInterpolateTo(this, value, fraction);
if (!toValue->isImageValue() && !toValue->isImageGeneratorValue()) {
if (!image->m_image->isImageResource())
return defaultInterpolateTo(this, value, fraction);
ImageResource* resource = static_cast<ImageResource*>(image->m_image->data());
toValue = CSSImageValue::create(resource->url(), image->m_image.get());
}
RefPtr<CSSCrossfadeValue> crossfadeValue = CSSCrossfadeValue::create(fromValue, toValue);
crossfadeValue->setPercentage(CSSPrimitiveValue::create(fraction, CSSPrimitiveValue::CSS_NUMBER));
return create(StyleGeneratedImage::create(crossfadeValue.get()).get());
}
示例8: document
void ImageDocumentParser::finish()
{
if (!isStopped() && document()->imageElement() && document()->cachedImage()) {
ImageResource* cachedImage = document()->cachedImage();
DocumentLoader* loader = document()->loader();
cachedImage->setResponse(loader->response());
cachedImage->setLoadFinishTime(loader->timing().responseEnd());
cachedImage->finish();
// Report the natural image size in the page title, regardless of zoom level.
// At a zoom level of 1 the image is guaranteed to have an integer size.
IntSize size = flooredIntSize(cachedImage->imageSizeForLayoutObject(document()->imageElement()->layoutObject(), 1.0f));
if (size.width()) {
// Compute the title, we use the decoded filename of the resource, falling
// back on the (decoded) hostname if there is no path.
String fileName = decodeURLEscapeSequences(document()->url().lastPathComponent());
if (fileName.isEmpty())
fileName = document()->url().host();
document()->setTitle(imageTitle(fileName, size));
}
document()->imageUpdated();
}
// TODO(esprehn): These null checks on Document don't make sense, document()
// will ASSERT if it was null. Do these want to check isDetached() ?
if (document())
document()->finishedParsing();
}
示例9: TEST
TEST(ImageResourceTest, CancelOnDetach)
{
KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
URLTestHelpers::registerMockedURLLoad(testURL, "cancelTest.html", "text/html");
ResourceFetcher* fetcher = ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
// Emulate starting a real load.
ImageResource* cachedImage = ImageResource::create(ResourceRequest(testURL));
cachedImage->setIdentifier(createUniqueIdentifier());
fetcher->startLoad(cachedImage);
memoryCache()->add(cachedImage);
Persistent<MockImageResourceClient> client = new MockImageResourceClient(cachedImage);
EXPECT_EQ(Resource::Pending, cachedImage->getStatus());
// The load should still be alive, but a timer should be started to cancel the load inside removeClient().
client->removeAsClient();
EXPECT_EQ(Resource::Pending, cachedImage->getStatus());
EXPECT_NE(reinterpret_cast<Resource*>(0), memoryCache()->resourceForURL(testURL));
// Trigger the cancel timer, ensure the load was cancelled and the resource was evicted from the cache.
blink::testing::runPendingTasks();
EXPECT_EQ(Resource::LoadError, cachedImage->getStatus());
EXPECT_EQ(reinterpret_cast<Resource*>(0), memoryCache()->resourceForURL(testURL));
Platform::current()->getURLLoaderMockFactory()->unregisterURL(testURL);
}
示例10: containerSizeIsSetForLayoutObject
static bool containerSizeIsSetForLayoutObject(ImageResource& cachedImage, const LayoutObject* layoutObject)
{
const Image* image = cachedImage.image();
// If a container size has been specified for this layoutObject, then
// imageForLayoutObject() will return the SVGImageForContainer while image()
// will return the underlying SVGImage.
return !image->isSVGImage() || image != cachedImage.imageForLayoutObject(layoutObject);
}
示例11: cachedImage
FloatSize HTMLImageElement::sourceSize() const
{
ImageResource* image = cachedImage();
if (!image)
return FloatSize();
LayoutSize size;
size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure about this.
return size;
}
示例12: embeddedContentBox
RenderBox* RenderImage::embeddedContentBox() const
{
if (!m_imageResource)
return 0;
ImageResource* cachedImage = m_imageResource->cachedImage();
if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage())
return static_cast<SVGImage*>(cachedImage->image())->embeddedContentBox();
return 0;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:11,代码来源:RenderImage.cpp
示例13: insertResource
/**
* Returns an image resource.
*
* @param fileName The filename of the image.
*
* @return The image.
*
* @throw ResourceNotLoadedExcpetion
*/
ImageResource* ResourceManager::image(std::string fileName) {
std::string id = ImageResource::createID(fileName);
if (!hasResource(id)) {
ImageResource* res = ImageResource::open(fileName);
insertResource(res->getName(), res);
return res;
} else {
return static_cast<ImageResource*>(getResource(id));
}
}
示例14: updateImageContainerSize
void LayoutSVGImage::updateImageContainerSize()
{
ImageResource* cachedImage = m_imageResource->cachedImage();
if (!cachedImage || !cachedImage->usesImageContainerSize())
return;
FloatSize imageViewportSize = computeImageViewportSize(*cachedImage);
if (LayoutSize(imageViewportSize) != m_imageResource->imageSize(styleRef().effectiveZoom())
|| !containerSizeIsSetForLayoutObject(*cachedImage, this)) {
m_imageResource->setContainerSizeForLayoutObject(roundedIntSize(imageViewportSize));
}
}
示例15: embeddedContentBox
LayoutBox* LayoutImage::embeddedContentBox() const
{
if (!m_imageResource)
return nullptr;
ImageResource* cachedImage = m_imageResource->cachedImage();
if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage())
return toSVGImage(cachedImage->image())->embeddedContentBox();
return nullptr;
}