void MediaPlayerPrivateFullscreenWindow::setRootChildLayer(PassRefPtr<WKCACFLayer> rootChild) { if (m_rootChild == rootChild) return; if (m_rootChild) m_rootChild->removeFromSuperlayer(); m_rootChild = rootChild; if (!m_rootChild) return; m_layerRenderer->setRootChildLayer(m_rootChild.get()); WKCACFLayer* rootLayer = m_rootChild->rootLayer(); CGRect rootBounds = m_rootChild->rootLayer()->bounds(); m_rootChild->setFrame(rootBounds); m_layerRenderer->setScrollFrame(IntPoint(rootBounds.origin), IntSize(rootBounds.size)); m_rootChild->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack)); #ifndef NDEBUG RetainPtr<CGColorRef> redColor(AdoptCF, CGColorCreateGenericRGB(1, 0, 0, 1)); rootLayer->setBackgroundColor(redColor.get()); #else rootLayer->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack)); #endif }
void WKCACFLayer::removeFromSuperlayer() { WKCACFLayer* superlayer = this->superlayer(); CACFLayerRemoveFromSuperlayer(layer()); if (superlayer) superlayer->setNeedsCommit(); }
void WKCACFLayer::setNeedsCommit() { WKCACFLayer* root = rootLayer(); // Call setNeedsRender on the root layer, which will cause a render to // happen in WKCACFLayerRenderer root->setNeedsRender(); }
void WKCACFLayer::removeFromSuperlayer() { WKCACFLayer* superlayer = this->superlayer(); if (!superlayer) return; superlayer->removeSublayer(this); CACFLayerRemoveFromSuperlayer(layer()); superlayer->setNeedsCommit(); }
void MediaPlayerPrivateQuickTimeVisualContext::retrieveCurrentImage() { if (!m_visualContext) return; #if USE(ACCELERATED_COMPOSITING) if (m_qtVideoLayer) { QTPixelBuffer buffer = m_visualContext->imageForTime(0); if (!buffer.pixelBufferRef()) return; WKCACFLayer* layer = static_cast<WKCACFLayer*>(m_qtVideoLayer->platformLayer()); if (!buffer.lockBaseAddress()) { if (requiredDllsAvailable()) { if (!m_imageQueue) { m_imageQueue = new WKCAImageQueue(buffer.width(), buffer.height(), 30); m_imageQueue->setFlags(WKCAImageQueue::Fill, WKCAImageQueue::Fill); layer->setContents(m_imageQueue->get()); } // Debug QuickTime links against a non-Debug version of CoreFoundation, so the // CFDictionary attached to the CVPixelBuffer cannot be directly passed on into the // CAImageQueue without being converted to a non-Debug CFDictionary. Additionally, // old versions of QuickTime used a non-AAS CoreFoundation, so the types are not // interchangable even in the release case. RetainPtr<CFDictionaryRef> attachments(AdoptCF, QTCFDictionaryCreateCopyWithDataCallback(kCFAllocatorDefault, buffer.attachments(), &QTCFDictionaryCreateWithDataCallback)); CFTimeInterval imageTime = QTMovieVisualContext::currentHostTime(); m_imageQueue->collect(); uint64_t imageId = m_imageQueue->registerPixelBuffer(buffer.baseAddress(), buffer.dataSize(), buffer.bytesPerRow(), buffer.width(), buffer.height(), buffer.pixelFormatType(), attachments.get(), 0); if (m_imageQueue->insertImage(imageTime, WKCAImageQueue::Buffer, imageId, WKCAImageQueue::Opaque | WKCAImageQueue::Flush, &QTPixelBuffer::imageQueueReleaseCallback, buffer.pixelBufferRef())) { // Retain the buffer one extra time so it doesn't dissappear before CAImageQueue decides to release it: QTPixelBuffer::retainCallback(buffer.pixelBufferRef()); } } else { CGImageRef image = CreateCGImageFromPixelBuffer(buffer); layer->setContents(image); CGImageRelease(image); } buffer.unlockBaseAddress(); layer->rootLayer()->setNeedsRender(); } } else #endif m_player->repaint(); m_visualContext->task(); }
void WKCACFLayer::internalCheckLayerConsistency() { ASSERT(layer()); size_t n = sublayerCount(); for (size_t i = 0; i < n; ++i) { // This will ASSERT in internalSublayerAtIndex if this entry doesn't have proper user data WKCACFLayer* sublayer = internalSublayerAtIndex(i); // Make sure we don't have any null entries in the list ASSERT(sublayer); // Make sure the each layer has a corresponding CACFLayer ASSERT(sublayer->layer()); } }
void WKCACFLayer::setNeedsCommit() { WKCACFLayer* root = rootLayer(); CACFContextRef context = CACFLayerGetContext(root->layer()); // The context might now be set yet. This happens if a property gets set // before placing the layer in the tree. In this case we don't need to // worry about remembering the context because we will when the layer is // added to the tree. if (context) WKCACFContextFlusher::shared().addContext(context); // Call setNeedsRender on the root layer, which will cause a render to // happen in WKCACFLayerRenderer root->setNeedsRender(); }
WKCACFLayer* WKCACFLayer::ancestorOrSelfWithSuperlayer(WKCACFLayer* superlayer) const { WKCACFLayer* layer = const_cast<WKCACFLayer*>(this); for (WKCACFLayer* ancestor = this->superlayer(); ancestor; layer = ancestor, ancestor = ancestor->superlayer()) { if (ancestor == superlayer) return layer; } return 0; }
WKCACFLayer* WKCACFLayer::rootLayer() const { WKCACFLayer* layer = const_cast<WKCACFLayer*>(this); for (WKCACFLayer* superlayer = layer->superlayer(); superlayer; layer = superlayer, superlayer = superlayer->superlayer()) { } return layer; }