当前位置: 首页>>代码示例>>C++>>正文


C++ ImageResource类代码示例

本文整理汇总了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));
}
开发者ID:ollie314,项目名称:chromium,代码行数:30,代码来源:ImageResourceTest.cpp

示例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();
}
开发者ID:alexanderbill,项目名称:blink-crosswalk,代码行数:25,代码来源:ImageDocument.cpp

示例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);


}
开发者ID:DaPhexion,项目名称:Retroshare-Paintchat-Plugin,代码行数:25,代码来源:paintchatwindow.cpp

示例4: cachedImage

bool HTMLImageElement::wouldTaintOrigin(SecurityOrigin* destinationSecurityOrigin) const
{
    ImageResource* image = cachedImage();
    if (!image)
        return false;
    return !image->isAccessAllowed(destinationSecurityOrigin);
}
开发者ID:dstockwell,项目名称:blink,代码行数:7,代码来源:HTMLImageElement.cpp

示例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();
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例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();
}
开发者ID:ollie314,项目名称:chromium,代码行数:26,代码来源:ImageLoader.cpp

示例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());
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例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();
}
开发者ID:JulienIsorce,项目名称:ChromiumGStreamerBackend,代码行数:29,代码来源:ImageDocument.cpp

示例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);
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:29,代码来源:ImageResourceTest.cpp

示例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);
}
开发者ID:smishenk,项目名称:chromium-crosswalk,代码行数:8,代码来源:LayoutSVGImage.cpp

示例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;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:10,代码来源:HTMLImageElement.cpp

示例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));
		}
	}
开发者ID:idaohang,项目名称:gpsi,代码行数:20,代码来源:resourcemanager.cpp

示例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));
    }
}
开发者ID:smishenk,项目名称:chromium-crosswalk,代码行数:11,代码来源:LayoutSVGImage.cpp

示例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;
}
开发者ID:dstockwell,项目名称:blink,代码行数:11,代码来源:LayoutImage.cpp


注:本文中的ImageResource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。