void GraphicsLayerChromium::setContentsToMedia(PlatformLayer* layer)
{
    bool childrenChanged = false;
    if (layer) {
        if (!m_contentsLayer.get() || m_contentsLayerPurpose != ContentsLayerForVideo) {
            setupContentsLayer(layer);
            m_contentsLayer = layer;
            m_contentsLayerPurpose = ContentsLayerForVideo;
            childrenChanged = true;
        }
        layer->setOwner(this);
        layer->setNeedsDisplay();
        updateContentsRect();
    } else {
        if (m_contentsLayer) {
            childrenChanged = true;
  
            // The old contents layer will be removed via updateSublayerList.
            m_contentsLayer = 0;
        }
    }
  
    if (childrenChanged)
        updateSublayerList();
}
Example #2
0
void GraphicsLayerChromium::setContentsToImage(Image* image)
{
    bool childrenChanged = false;
    if (image) {
        if (!m_contentsLayer.get() || m_contentsLayerPurpose != ContentsLayerForImage) {
            RefPtr<ImageLayerChromium> imageLayer = ImageLayerChromium::create();
            setupContentsLayer(imageLayer.get());
            m_contentsLayerPurpose = ContentsLayerForImage;
            childrenChanged = true;
        }
        ImageLayerChromium* imageLayer = static_cast<ImageLayerChromium*>(m_contentsLayer.get());
        imageLayer->setContents(image);
        imageLayer->setOpaque(image->isBitmapImage() && !image->currentFrameHasAlpha());
        updateContentsRect();
    } else {
        if (m_contentsLayer) {
            childrenChanged = true;

            // The old contents layer will be removed via updateChildList.
            m_contentsLayer = 0;
        }
    }

    if (childrenChanged)
        updateChildList();
}
void GraphicsLayerChromium::setContentsToImage(Image* image)
{
    bool childrenChanged = false;
    if (image) {
        if (!m_contentsLayer.get() || m_contentsLayerPurpose != ContentsLayerForImage) {
            RefPtr<ImageLayerChromium> imageLayer = ImageLayerChromium::create(this);
            setupContentsLayer(imageLayer.get());
            m_contentsLayer = imageLayer;
            m_contentsLayerPurpose = ContentsLayerForImage;
            childrenChanged = true;
        }
        ImageLayerChromium* imageLayer = static_cast<ImageLayerChromium*>(m_contentsLayer.get());
        imageLayer->setContents(image);
        updateContentsRect();
    } else {
        if (m_contentsLayer) {
            childrenChanged = true;

            // The old contents layer will be removed via updateSublayerList.
            m_contentsLayer = 0;
        }
    }

    if (childrenChanged)
        updateSublayerList();
}
void GraphicsLayerChromium::setContentsToCanvas(PlatformLayer* platformLayer)
{
    bool childrenChanged = false;
    if (platformLayer) {
        platformLayer->setOwner(this);
        if (m_contentsLayer.get() != platformLayer) {
            setupContentsLayer(platformLayer);
            m_contentsLayer = platformLayer;
            m_contentsLayerPurpose = ContentsLayerForCanvas;
            childrenChanged = true;
        }
        m_contentsLayer->setNeedsDisplay();
        updateContentsRect();
    } else {
        if (m_contentsLayer) {
            childrenChanged = true;

            // The old contents layer will be removed via updateSublayerList.
            m_contentsLayer = 0;
        }
    }

    if (childrenChanged)
        updateSublayerList();
}
Example #5
0
void GraphicsLayer::setContentsTo(WebLayer* layer)
{
    bool childrenChanged = false;
    if (layer) {
        ASSERT(s_registeredLayerSet);
        if (!s_registeredLayerSet->contains(layer->id()))
            CRASH();
        if (m_contentsLayerId != layer->id()) {
            setupContentsLayer(layer);
            childrenChanged = true;
        }
        updateContentsRect();
    } else {
        if (m_contentsLayer) {
            childrenChanged = true;

            // The old contents layer will be removed via updateChildList.
            m_contentsLayer = 0;
            m_contentsLayerId = 0;
        }
    }

    if (childrenChanged)
        updateChildList();
}
Example #6
0
void GraphicsLayerChromium::setContentsToImage(Image* image)
{
    bool childrenChanged = false;
    NativeImageSkia* nativeImage = image ? image->nativeImageForCurrentFrame() : 0;
    if (nativeImage) {
        if (m_contentsLayerPurpose != ContentsLayerForImage) {
            m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->createImageLayer());
            registerContentsLayer(m_imageLayer->layer());

            setupContentsLayer(m_imageLayer->layer());
            m_contentsLayerPurpose = ContentsLayerForImage;
            childrenChanged = true;
        }
        m_imageLayer->setBitmap(nativeImage->bitmap());
        m_imageLayer->layer()->setOpaque(image->isBitmapImage() && !image->currentFrameHasAlpha());
        updateContentsRect();
    } else {
        if (m_imageLayer) {
            childrenChanged = true;

            unregisterContentsLayer(m_imageLayer->layer());
            m_imageLayer.clear();
        }
        // The old contents layer will be removed via updateChildList.
        m_contentsLayer = 0;
    }

    if (childrenChanged)
        updateChildList();
}
void GraphicsLayerCACF::updateContentsImage()
{
    if (m_pendingContentsImage) {
        if (!m_contentsLayer.get()) {
            RefPtr<WKCACFLayer> imageLayer = WebLayer::create(WKCACFLayer::Layer, this);
#ifndef NDEBUG
            imageLayer->setName("Image Layer");
#endif
            setupContentsLayer(imageLayer.get());
            m_contentsLayer = imageLayer;
            // m_contentsLayer will be parented by updateSublayerList
        }

        // FIXME: maybe only do trilinear if the image is being scaled down,
        // but then what if the layer size changes?
        m_contentsLayer->setMinificationFilter(WKCACFLayer::Trilinear);
        m_contentsLayer->setContents(m_pendingContentsImage.get());
        m_pendingContentsImage = 0;
        
        updateContentsRect();
    } else {
        // No image.
        // m_contentsLayer will be removed via updateSublayerList.
        m_contentsLayer = 0;
    }
}
Example #8
0
void GraphicsLayerChromium::setContentsToImage(Image* image)
{
    bool childrenChanged = false;
    if (image) {
        if (m_contentsLayer.isNull() || m_contentsLayerPurpose != ContentsLayerForImage) {
            WebKit::WebImageLayer imageLayer = WebKit::WebImageLayer::create();
            setupContentsLayer(imageLayer);
            m_contentsLayerPurpose = ContentsLayerForImage;
            childrenChanged = true;
        }
        WebKit::WebImageLayer imageLayer = m_contentsLayer.to<WebKit::WebImageLayer>();
        NativeImageSkia* nativeImage = image->nativeImageForCurrentFrame();
        imageLayer.setBitmap(nativeImage->bitmap());
        imageLayer.setOpaque(image->isBitmapImage() && !image->currentFrameHasAlpha());
        updateContentsRect();
    } else {
        if (!m_contentsLayer.isNull()) {
            childrenChanged = true;

            // The old contents layer will be removed via updateChildList.
            m_contentsLayer.reset();
        }
    }

    if (childrenChanged)
        updateChildList();
}
void GraphicsLayerCACF::updateContentsMedia()
{
    // Media layer was set as m_contentsLayer, and will get parented in updateSublayerList().
    if (m_contentsLayer) {
        setupContentsLayer(m_contentsLayer.get());
        updateContentsRect();
    }
}
Example #10
0
void GraphicsLayerBlackBerry::updateContentsImage(Image* image)
{
    if (image) {
        if (!m_contentsLayer.get()) {
            RefPtr<LayerWebKitThread> imageLayer = LayerWebKitThread::create(LayerData::Layer, this);

            setupContentsLayer(imageLayer.get());
            m_contentsLayer = imageLayer;
            // m_contentsLayer will be parented by updateSublayerList.
        }
        m_contentsLayer->setContents(image);

        updateContentsRect();
    } else {
        // No image. m_contentsLayer will be removed via updateSublayerList.
        m_contentsLayer = 0;
    }
}
Example #11
0
void GraphicsLayerChromium::setContentsToMedia(PlatformLayer* layer)
{
    bool childrenChanged = false;
    if (layer) {
        if (m_contentsLayer.isNull() || m_contentsLayerPurpose != ContentsLayerForVideo) {
            setupContentsLayer(WebLayer(layer));
            m_contentsLayerPurpose = ContentsLayerForVideo;
            childrenChanged = true;
        }
        updateContentsRect();
    } else {
        if (!m_contentsLayer.isNull()) {
            childrenChanged = true;

            // The old contents layer will be removed via updateChildList.
            m_contentsLayer.reset();
        }
    }

    if (childrenChanged)
        updateChildList();
}