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); } }
void PluginProxy::paint(GraphicsContext* graphicsContext, const IntRect& dirtyRect) { if (!needsBackingStore() || !m_backingStore) return; float contentsScaleFactor = controller()->contentsScaleFactor(); 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. OwnPtr<WebCore::GraphicsContext> graphicsContext = m_backingStore->createGraphicsContext(); graphicsContext->applyDeviceScaleFactor(contentsScaleFactor); graphicsContext->setCompositeOperation(CompositeCopy); m_pluginBackingStore->paint(*graphicsContext, contentsScaleFactor, IntPoint(), IntRect(0, 0, m_frameRect.width(), m_frameRect.height())); m_pluginBackingStoreContainsValidData = true; } IntRect dirtyRectInPluginCoordinates = dirtyRect; dirtyRectInPluginCoordinates.move(-m_frameRect.x(), -m_frameRect.y()); m_backingStore->paint(*graphicsContext, contentsScaleFactor, dirtyRect.location(), dirtyRectInPluginCoordinates); if (m_waitingForPaintInResponseToUpdate) { m_waitingForPaintInResponseToUpdate = false; m_connection->connection()->send(Messages::PluginControllerProxy::DidUpdate(), m_pluginInstanceID); return; } }
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; }
void PluginProxy::geometryDidChange() { ASSERT(m_isStarted); float contentsScaleFactor = controller()->contentsScaleFactor(); if (m_frameRect.isEmpty() || !needsBackingStore()) { ShareableBitmap::Handle pluginBackingStoreHandle; m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(m_frameRect, m_clipRect, contentsScaleFactor, pluginBackingStoreHandle), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply); return; } bool didUpdateBackingStore = false; IntSize backingStoreSize = m_frameRect.size(); backingStoreSize.scale(contentsScaleFactor); if (!m_backingStore) { m_backingStore = ShareableBitmap::create(backingStoreSize, ShareableBitmap::SupportsAlpha); didUpdateBackingStore = true; } else if (backingStoreSize != m_backingStore->size()) { // The backing store already exists, just resize it. if (!m_backingStore->resize(backingStoreSize)) return; didUpdateBackingStore = true; } ShareableBitmap::Handle pluginBackingStoreHandle; if (didUpdateBackingStore) { // Create a new plug-in backing store. m_pluginBackingStore = ShareableBitmap::createShareable(backingStoreSize, 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_frameRect, m_clipRect, contentsScaleFactor, pluginBackingStoreHandle), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply); }
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; }