void PluginProxy::paint(GraphicsContext* graphicsContext, const IntRect& dirtyRect) { if (!needsBackingStore() || !m_backingStore) return; if (!m_pluginBackingStoreContainsValidData) { m_connection->connection()->sendSync(Messages::PluginControllerProxy::PaintEntirePlugin(), Messages::PluginControllerProxy::PaintEntirePlugin::Reply(), m_pluginInstanceID); // Blit the plug-in backing store into our own backing store. auto graphicsContext = m_backingStore->createGraphicsContext(); graphicsContext->applyDeviceScaleFactor(contentsScaleFactor()); graphicsContext->setCompositeOperation(CompositeCopy); m_pluginBackingStore->paint(*graphicsContext, contentsScaleFactor(), IntPoint(), pluginBounds()); m_pluginBackingStoreContainsValidData = true; } m_backingStore->paint(*graphicsContext, contentsScaleFactor(), dirtyRect.location(), dirtyRect); if (m_waitingForPaintInResponseToUpdate) { m_waitingForPaintInResponseToUpdate = false; m_connection->connection()->send(Messages::PluginControllerProxy::DidUpdate(), m_pluginInstanceID); } }
bool PluginProxy::initialize(const Parameters& parameters) { ASSERT(!m_connection); m_connection = WebProcess::singleton().pluginProcessConnectionManager().getPluginProcessConnection(m_pluginProcessToken); if (!m_connection) return false; // Add the plug-in proxy before creating the plug-in; it needs to be in the map because CreatePlugin // can call back out to the plug-in proxy. m_connection->addPluginProxy(this); // Ask the plug-in process to create a plug-in. m_pendingPluginCreationParameters = std::make_unique<PluginCreationParameters>(); m_pendingPluginCreationParameters->pluginInstanceID = m_pluginInstanceID; m_pendingPluginCreationParameters->windowNPObjectID = windowNPObjectID(); m_pendingPluginCreationParameters->parameters = parameters; m_pendingPluginCreationParameters->userAgent = controller()->userAgent(); m_pendingPluginCreationParameters->contentsScaleFactor = contentsScaleFactor(); m_pendingPluginCreationParameters->isPrivateBrowsingEnabled = controller()->isPrivateBrowsingEnabled(); m_pendingPluginCreationParameters->isMuted = controller()->isMuted(); m_pendingPluginCreationParameters->artificialPluginInitializationDelayEnabled = controller()->artificialPluginInitializationDelayEnabled(); m_pendingPluginCreationParameters->isAcceleratedCompositingEnabled = controller()->isAcceleratedCompositingEnabled(); if (!canInitializeAsynchronously()) return initializeSynchronously(); // Remember that we tried to create this plug-in asynchronously in case we need to create it synchronously later. m_waitingOnAsynchronousInitialization = true; PluginCreationParameters creationParameters(*m_pendingPluginCreationParameters.get()); m_connection->connection()->send(Messages::WebProcessConnection::CreatePluginAsynchronously(creationParameters), m_pluginInstanceID); return true; }
void PluginView::paint(GraphicsContext* context, const IntRect& dirtyRect) { if (!m_plugin || !m_isInitialized) return; if (context->paintingDisabled()) { if (context->updatingControlTints()) m_plugin->updateControlTints(context); return; } // FIXME: We should try to intersect the dirty rect with the plug-in's clip rect here. IntRect paintRect = IntRect(IntPoint(), frameRect().size()); if (paintRect.isEmpty()) return; if (m_snapshot) { m_snapshot->paint(*context, contentsScaleFactor(), frameRect().location(), m_snapshot->bounds()); return; } GraphicsContextStateSaver stateSaver(*context); // Translate the coordinate system so that the origin is in the top-left corner of the plug-in. context->translate(frameRect().location().x(), frameRect().location().y()); m_plugin->paint(context, paintRect); }
void PluginProxy::update(const IntRect& paintedRect) { if (paintedRect == pluginBounds()) m_pluginBackingStoreContainsValidData = true; if (m_backingStore) { // Blit the plug-in backing store into our own backing store. auto graphicsContext = m_backingStore->createGraphicsContext(); graphicsContext->applyDeviceScaleFactor(contentsScaleFactor()); graphicsContext->setCompositeOperation(CompositeCopy); m_pluginBackingStore->paint(*graphicsContext, contentsScaleFactor(), paintedRect.location(), paintedRect); } // Ask the controller to invalidate the rect for us. m_waitingForPaintInResponseToUpdate = true; controller()->invalidate(paintedRect); }
PassRefPtr<ShareableBitmap> NetscapePlugin::snapshot() { if (!supportsSnapshotting() || m_pluginSize.isEmpty()) return 0; ASSERT(m_isStarted); IntSize backingStoreSize = m_pluginSize; backingStoreSize.scale(contentsScaleFactor()); RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha); OwnPtr<GraphicsContext> context = bitmap->createGraphicsContext(); // FIXME: We should really call applyDeviceScaleFactor instead of scale, but that ends up calling into WKSI // which we currently don't have initiated in the plug-in process. context->scale(FloatSize(contentsScaleFactor(), contentsScaleFactor())); platformPaint(context.get(), IntRect(IntPoint(), m_pluginSize), true); return bitmap.release(); }
bool PluginProxy::updateBackingStore() { if (m_pluginSize.isEmpty() || !needsBackingStore()) return false; IntSize backingStoreSize = m_pluginSize; backingStoreSize.scale(contentsScaleFactor()); if (m_backingStore) { if (m_backingStore->size() == backingStoreSize) return false; m_backingStore = nullptr; // Give malloc a chance to recycle our backing store. } m_backingStore = ShareableBitmap::create(backingStoreSize, ShareableBitmap::SupportsAlpha); return !!m_backingStore; }
bool PluginProxy::updateBackingStore() { if (m_pluginSize.isEmpty() || !needsBackingStore()) return false; IntSize backingStoreSize = m_pluginSize; backingStoreSize.scale(contentsScaleFactor()); if (!m_backingStore) { m_backingStore = ShareableBitmap::create(backingStoreSize, ShareableBitmap::SupportsAlpha); return true; } if (backingStoreSize != m_backingStore->size()) { // The backing store already exists, just resize it. return m_backingStore->resize(backingStoreSize); } return false; }
bool PluginProxy::initialize(const Parameters& parameters) { ASSERT(!m_connection); m_connection = WebProcess::shared().pluginProcessConnectionManager().getPluginProcessConnection(m_pluginPath); if (!m_connection) return false; // Add the plug-in proxy before creating the plug-in; it needs to be in the map because CreatePlugin // can call back out to the plug-in proxy. m_connection->addPluginProxy(this); // Ask the plug-in process to create a plug-in. PluginCreationParameters creationParameters; creationParameters.pluginInstanceID = m_pluginInstanceID; creationParameters.windowNPObjectID = windowNPObjectID(); creationParameters.parameters = parameters; creationParameters.userAgent = controller()->userAgent(); creationParameters.contentsScaleFactor = contentsScaleFactor(); creationParameters.isPrivateBrowsingEnabled = controller()->isPrivateBrowsingEnabled(); #if USE(ACCELERATED_COMPOSITING) creationParameters.isAcceleratedCompositingEnabled = controller()->isAcceleratedCompositingEnabled(); #endif bool result = false; bool wantsWheelEvents = false; uint32_t remoteLayerClientID = 0; if (!m_connection->connection()->sendSync(Messages::WebProcessConnection::CreatePlugin(creationParameters), Messages::WebProcessConnection::CreatePlugin::Reply(result, wantsWheelEvents, remoteLayerClientID), 0) || !result) { m_connection->removePluginProxy(this); return false; } m_wantsWheelEvents = wantsWheelEvents; m_remoteLayerClientID = remoteLayerClientID; m_isStarted = true; return true; }
void PluginProxy::geometryDidChange() { ASSERT(m_isStarted); ShareableBitmap::Handle pluginBackingStoreHandle; if (updateBackingStore()) { // Create a new plug-in backing store. m_pluginBackingStore = ShareableBitmap::createShareable(m_backingStore->size(), ShareableBitmap::SupportsAlpha); if (!m_pluginBackingStore) return; // Create a handle to the plug-in backing store so we can send it over. if (!m_pluginBackingStore->createHandle(pluginBackingStoreHandle)) { m_pluginBackingStore = nullptr; return; } m_pluginBackingStoreContainsValidData = false; } m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(m_pluginSize, m_clipRect, m_pluginToRootViewTransform, contentsScaleFactor(), pluginBackingStoreHandle), m_pluginInstanceID, IPC::DispatchMessageEvenWhenWaitingForSyncReply); }