void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirtyRect, bool /*isSnapshot*/) { if (m_isWindowed) return; if (!m_isStarted) { // FIXME: we should paint a missing plugin icon. return; } if (context->paintingDisabled() || !m_drawable) return; XEvent xevent; memset(&xevent, 0, sizeof(XEvent)); XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose; exposeEvent.type = GraphicsExpose; exposeEvent.display = x11HostDisplay(); exposeEvent.drawable = m_drawable; IntRect exposedRect(dirtyRect); exposeEvent.x = exposedRect.x(); exposeEvent.y = exposedRect.y(); // Note: in transparent mode Flash thinks width is the right and height is the bottom. // We should take it into account if we want to support transparency. exposeEvent.width = exposedRect.width(); exposeEvent.height = exposedRect.height(); NPP_HandleEvent(&xevent); if (m_pluginDisplay != x11HostDisplay()) XSync(m_pluginDisplay, false); #if PLATFORM(GTK) || (PLATFORM(EFL) && USE(CAIRO)) RefPtr<cairo_surface_t> drawableSurface = adoptRef(cairo_xlib_surface_create(m_pluginDisplay, m_drawable, static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info)->visual, m_pluginSize.width(), m_pluginSize.height())); cairo_t* cr = context->platformContext()->cr(); cairo_save(cr); cairo_set_source_surface(cr, drawableSurface.get(), 0, 0); cairo_rectangle(cr, exposedRect.x(), exposedRect.y(), exposedRect.width(), exposedRect.height()); cairo_clip(cr); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_paint(cr); cairo_restore(cr); #else notImplemented(); #endif }
void NetscapePluginX11::paint(GraphicsContext& context, const IntRect& dirtyRect) { ASSERT(!m_plugin.isWindowed()); if (context.paintingDisabled() || !m_drawable) return; XEvent xevent; memset(&xevent, 0, sizeof(XEvent)); XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose; exposeEvent.type = GraphicsExpose; exposeEvent.display = x11HostDisplay(); exposeEvent.drawable = m_drawable.get(); IntRect exposedRect(dirtyRect); exposeEvent.x = exposedRect.x(); exposeEvent.y = exposedRect.y(); // Note: in transparent mode Flash thinks width is the right and height is the bottom. // We should take it into account if we want to support transparency. exposeEvent.width = exposedRect.width(); exposeEvent.height = exposedRect.height(); m_plugin.NPP_HandleEvent(&xevent); if (m_pluginDisplay != x11HostDisplay()) XSync(m_pluginDisplay, false); #if PLATFORM(GTK) || (PLATFORM(EFL) && USE(CAIRO)) RefPtr<cairo_surface_t> drawableSurface = adoptRef(cairo_xlib_surface_create(m_pluginDisplay, m_drawable.get(), m_setWindowCallbackStruct.visual, m_plugin.size().width(), m_plugin.size().height())); cairo_t* cr = context.platformContext()->cr(); cairo_save(cr); cairo_set_source_surface(cr, drawableSurface.get(), 0, 0); cairo_rectangle(cr, exposedRect.x(), exposedRect.y(), exposedRect.width(), exposedRect.height()); cairo_clip(cr); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_paint(cr); cairo_restore(cr); #else notImplemented(); #endif }
void PluginView::paint(GraphicsContext* context, const IntRect& rect) { if (!m_isStarted || m_status != PluginStatusLoadedSuccessfully) { paintMissingPluginIcon(context, rect); return; } if (context->paintingDisabled()) return; setNPWindowIfNeeded(); if (m_isWindowed) return; if (!m_drawable) return; Display* display = getPluginDisplay(nullptr); const bool syncX = m_pluginDisplay && m_pluginDisplay != display; IntRect exposedRect(rect); exposedRect.intersect(frameRect()); exposedRect.move(-frameRect().x(), -frameRect().y()); RefPtr<cairo_surface_t> drawableSurface = adoptRef(cairo_xlib_surface_create(display, m_drawable, m_visual, m_windowRect.width(), m_windowRect.height())); if (m_isTransparent) { // If we have a 32 bit drawable and the plugin wants transparency, // we'll clear the exposed area to transparent first. Otherwise, // we'd end up with junk in there from the last paint, or, worse, // uninitialized data. RefPtr<cairo_t> cr = adoptRef(cairo_create(drawableSurface.get())); if (!(cairo_surface_get_content(drawableSurface.get()) & CAIRO_CONTENT_ALPHA)) { // Attempt to fake it when we don't have an alpha channel on our // pixmap. If that's not possible, at least clear the window to // avoid drawing artifacts. // This Would not work without double buffering, but we always use it. cairo_set_source_surface(cr.get(), cairo_get_group_target(context->platformContext()->cr()), -m_windowRect.x(), -m_windowRect.y()); cairo_set_operator(cr.get(), CAIRO_OPERATOR_SOURCE); } else cairo_set_operator(cr.get(), CAIRO_OPERATOR_CLEAR); cairo_rectangle(cr.get(), exposedRect.x(), exposedRect.y(), exposedRect.width(), exposedRect.height()); cairo_fill(cr.get()); } XEvent xevent; memset(&xevent, 0, sizeof(XEvent)); XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose; exposeEvent.type = GraphicsExpose; exposeEvent.display = display; exposeEvent.drawable = m_drawable; exposeEvent.x = exposedRect.x(); exposeEvent.y = exposedRect.y(); exposeEvent.width = exposedRect.x() + exposedRect.width(); // flash bug? it thinks width is the right in transparent mode exposeEvent.height = exposedRect.y() + exposedRect.height(); // flash bug? it thinks height is the bottom in transparent mode dispatchNPEvent(xevent); if (syncX) XSync(m_pluginDisplay, false); // sync changes by plugin cairo_t* cr = context->platformContext()->cr(); cairo_save(cr); cairo_set_source_surface(cr, drawableSurface.get(), frameRect().x(), frameRect().y()); cairo_rectangle(cr, frameRect().x() + exposedRect.x(), frameRect().y() + exposedRect.y(), exposedRect.width(), exposedRect.height()); cairo_clip(cr); if (m_isTransparent) cairo_set_operator(cr, CAIRO_OPERATOR_OVER); else cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_paint(cr); cairo_restore(cr); }