Ejemplo n.º 1
0
void
gfxASurface::MarkDirty(const gfxRect& r)
{
    cairo_surface_mark_dirty_rectangle(mSurface,
                                       (int) r.pos.x, (int) r.pos.y,
                                       (int) r.size.width, (int) r.size.height);
}
Ejemplo n.º 2
0
static SeedValue
seed_cairo_surface_mark_dirty_rectangle(SeedContext ctx,
					SeedObject function,
					SeedObject this_object,
					gsize argument_count,
					const SeedValue arguments[],
					SeedException *exception)
{
  cairo_surface_t *surf;
  guint x, y, width, height;
  CHECK_THIS();
  if (argument_count != 4)
    {
      EXPECTED_EXCEPTION("mark_dirty_rectangle", "4 arguments");
    }
  surf = seed_object_to_cairo_surface (ctx, this_object, exception);
  x = seed_value_to_int (ctx, arguments[0], exception);
  y = seed_value_to_int (ctx, arguments[1], exception);
  width = seed_value_to_int (ctx, arguments[2], exception);
  height = seed_value_to_int (ctx, arguments[3], exception);

  cairo_surface_mark_dirty_rectangle (surf, x, y, width, height);

  return seed_make_undefined (ctx);
}
Ejemplo n.º 3
0
void
swfdec_bitmap_data_setPixel32 (SwfdecAsContext *cx, SwfdecAsObject *object,
    guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
  SwfdecBitmapData *bitmap;
  guint x, y, color;
  guint8 *addr;

  SWFDEC_AS_CHECK (SWFDEC_TYPE_BITMAP_DATA, &bitmap, "iii", &x, &y, &color);

  if (bitmap->surface == NULL ||
      x >= (guint) cairo_image_surface_get_width (bitmap->surface) ||
      y >= (guint) cairo_image_surface_get_height (bitmap->surface))
    return;

  addr = cairo_image_surface_get_data (bitmap->surface);
  addr += cairo_image_surface_get_stride (bitmap->surface) * y;
  addr += 4 * x;
  if (swfdec_surface_has_alpha (bitmap->surface)) {
    *(SwfdecColor *) (gpointer) addr = SWFDEC_COLOR_MULTIPLY ((SwfdecColor) color);
  } else {
    *(SwfdecColor *) (gpointer) addr = SWFDEC_COLOR_OPAQUE ((SwfdecColor) color);
  }
  cairo_surface_mark_dirty_rectangle (bitmap->surface, x, y, 1, 1);
  swfdec_bitmap_data_invalidate (bitmap, x, y, 1, 1);
}
Ejemplo n.º 4
0
na_tray_child_expose_event (GtkWidget      *widget,
                            GdkEventExpose *event)
#endif
{
  NaTrayChild *child = NA_TRAY_CHILD (widget);
  GdkWindow *window = gtk_widget_get_window (widget);

  if (na_tray_child_has_alpha (child))
    {
      /* Clear to transparent */
#if !GTK_CHECK_VERSION (3, 0, 0)
      cairo_t *cr = gdk_cairo_create (window);
#endif
      cairo_set_source_rgba (cr, 0, 0, 0, 0);
      cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
#if GTK_CHECK_VERSION (3, 0, 0)
      cairo_paint (cr);
#else
      gdk_cairo_region (cr, event->region);
      cairo_fill (cr);
      cairo_destroy (cr);
#endif
    }
  else if (child->parent_relative_bg)
    {
      /* Clear to parent-relative pixmap */
#if GTK_CHECK_VERSION (3, 0, 0)
      GdkWindow *window;
      cairo_surface_t *target;
      GdkRectangle clip_rect;

      window = gtk_widget_get_window (widget);
      target = cairo_get_group_target (cr);

      gdk_cairo_get_clip_rectangle (cr, &clip_rect);

      /* Clear to parent-relative pixmap
       * We need to use direct X access here because GDK doesn't know about
       * the parent relative pixmap. */
      cairo_surface_flush (target);

      XClearArea (GDK_WINDOW_XDISPLAY (window),
                  GDK_WINDOW_XID (window),
                  clip_rect.x, clip_rect.y,
                  clip_rect.width, clip_rect.height,
                  False);
      cairo_surface_mark_dirty_rectangle (target,
                                          clip_rect.x, clip_rect.y,
                                          clip_rect.width, clip_rect.height);
#else
      gdk_window_clear_area (window,
                             event->area.x, event->area.y,
                             event->area.width, event->area.height);
#endif
    }

  return FALSE;
}
Ejemplo n.º 5
0
void ImageBuffer::putByteArray(Multiply multiplied, ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem)
{
    ASSERT(cairo_surface_get_type(m_data.m_surface) == CAIRO_SURFACE_TYPE_IMAGE);

    unsigned char* dataDst = cairo_image_surface_get_data(m_data.m_surface);

    ASSERT(sourceRect.width() > 0);
    ASSERT(sourceRect.height() > 0);

    int originx = sourceRect.x();
    int destx = destPoint.x() + sourceRect.x();
    ASSERT(destx >= 0);
    ASSERT(destx < m_size.width());
    ASSERT(originx >= 0);
    ASSERT(originx <= sourceRect.maxX());

    int endx = destPoint.x() + sourceRect.maxX();
    ASSERT(endx <= m_size.width());

    int numColumns = endx - destx;

    int originy = sourceRect.y();
    int desty = destPoint.y() + sourceRect.y();
    ASSERT(desty >= 0);
    ASSERT(desty < m_size.height());
    ASSERT(originy >= 0);
    ASSERT(originy <= sourceRect.maxY());

    int endy = destPoint.y() + sourceRect.maxY();
    ASSERT(endy <= m_size.height());
    int numRows = endy - desty;

    unsigned srcBytesPerRow = 4 * sourceSize.width();
    int stride = cairo_image_surface_get_stride(m_data.m_surface);

    unsigned char* srcRows = source->data() + originy * srcBytesPerRow + originx * 4;
    for (int y = 0; y < numRows; ++y) {
        unsigned* row = reinterpret_cast<unsigned*>(dataDst + stride * (y + desty));
        for (int x = 0; x < numColumns; x++) {
            int basex = x * 4;
            unsigned* pixel = row + x + destx;
            Color pixelColor(srcRows[basex],
                    srcRows[basex + 1],
                    srcRows[basex + 2],
                    srcRows[basex + 3]);
            if (multiplied == Unmultiplied)
                *pixel = premultipliedARGBFromColor(pixelColor);
            else
                *pixel = pixelColor.rgb();
        }
        srcRows += srcBytesPerRow;
    }
    cairo_surface_mark_dirty_rectangle(m_data.m_surface,
                                        destx, desty,
                                        numColumns, numRows);
}
Ejemplo n.º 6
0
IoObject *IoCairoSurface_markDirtyRectangle(IoCairoSurface *self, IoObject *locals, IoMessage *m)
{
	double x = IoMessage_locals_doubleArgAt_(m, locals, 0);
	double y = IoMessage_locals_doubleArgAt_(m, locals, 1);
	double w = IoMessage_locals_doubleArgAt_(m, locals, 2);
	double h = IoMessage_locals_doubleArgAt_(m, locals, 3);

	cairo_surface_mark_dirty_rectangle(SURFACE(self), x, y, w, h);
	CHECK_STATUS(self);
	return self;
}
Ejemplo n.º 7
0
static PyObject *
surface_mark_dirty_rectangle (PycairoSurface *o, PyObject *args)
{
    int x, y, width, height;

    if (!PyArg_ParseTuple(args, "iiii:Surface.mark_dirty_rectangle",
			  &x, &y, &width, &height))
	return NULL;

    cairo_surface_mark_dirty_rectangle (o->surface, x, y, width, height);
    RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface);
    Py_RETURN_NONE;
}
Ejemplo n.º 8
0
static PyObject *
surface_mark_dirty (PycairoSurface *o, PyObject *args, PyObject *kwds)
{
    static char *kwlist[] = {"x", "y", "width", "height", NULL};
    int x = 0, y = 0, width = -1, height = -1;

    if (!PyArg_ParseTupleAndKeywords(args, kwds,
				     "|iiii:Surface.mark_dirty", kwlist,
				     &x, &y, &width, &height))
	return NULL;

    cairo_surface_mark_dirty_rectangle (o->surface, x, y, width, height);
    RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface);
    Py_RETURN_NONE;
}
void WidgetBackingStoreGtkX11::scroll(const IntRect& scrollRect, const IntSize& scrollOffset)
{
    IntRect targetRect(scrollRect);
    targetRect.move(scrollOffset);
    targetRect.intersect(scrollRect);
    if (targetRect.isEmpty())
        return;

    cairo_surface_flush(m_surface.get());
    XCopyArea(m_display, m_pixmap, m_pixmap, m_gc, 
        targetRect.x() - scrollOffset.width(), targetRect.y() - scrollOffset.height(),
        targetRect.width(), targetRect.height(),
        targetRect.x(), targetRect.y());
    cairo_surface_mark_dirty_rectangle(m_surface.get(),
        targetRect.x(), targetRect.y(),
        targetRect.width(), targetRect.height());
}
Ejemplo n.º 10
0
void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
{
    ASSERT(cairo_surface_get_type(m_data.m_surface) == CAIRO_SURFACE_TYPE_IMAGE);

    unsigned char* dataSrc = cairo_image_surface_get_data(m_data.m_surface);
    int stride = cairo_image_surface_get_stride(m_data.m_surface);
    for (int y = 0; y < m_size.height(); ++y) {
        unsigned* row = reinterpret_cast<unsigned*>(dataSrc + stride * y);
        for (int x = 0; x < m_size.width(); x++) {
            unsigned* pixel = row + x;
            Color pixelColor = colorFromPremultipliedARGB(*pixel);
            pixelColor = Color(lookUpTable[pixelColor.red()],
                               lookUpTable[pixelColor.green()],
                               lookUpTable[pixelColor.blue()],
                               pixelColor.alpha());
            *pixel = premultipliedARGBFromColor(pixelColor);
        }
    }
    cairo_surface_mark_dirty_rectangle (m_data.m_surface, 0, 0, m_size.width(), m_size.height());
}
Ejemplo n.º 11
0
/* The plug window should completely occupy the area of the child, so we won't
 * get a draw event. But in case we do (the plug unmaps itself, say), this
 * draw handler draws with real or fake transparency.
 */
static gboolean
na_tray_child_draw (GtkWidget *widget,
                    cairo_t   *cr)
{
  NaTrayChild *child = NA_TRAY_CHILD (widget);

  if (na_tray_child_has_alpha (child))
    {
      /* Clear to transparent */
      cairo_set_source_rgba (cr, 0, 0, 0, 0);
      cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
      cairo_paint (cr);
    }
  else if (child->parent_relative_bg)
    {
      GdkWindow *window;
      cairo_surface_t *target;
      GdkRectangle clip_rect;

      window = gtk_widget_get_window (widget);
      target = cairo_get_group_target (cr);

      gdk_cairo_get_clip_rectangle (cr, &clip_rect);

      /* Clear to parent-relative pixmap
       * We need to use direct X access here because GDK doesn't know about
       * the parent relative pixmap. */
      cairo_surface_flush (target);

      XClearArea (GDK_WINDOW_XDISPLAY (window),
                  GDK_WINDOW_XID (window),
                  clip_rect.x, clip_rect.y,
                  clip_rect.width, clip_rect.height,
                  False);
      cairo_surface_mark_dirty_rectangle (target,
                                          clip_rect.x, clip_rect.y,
                                          clip_rect.width, clip_rect.height);
    }

  return FALSE;
}
void BackingStoreBackendCairoX11::scroll(const IntRect& scrollRect, const IntSize& scrollOffset)
{
    IntRect targetRect = scrollRect;
    targetRect.move(scrollOffset);
    targetRect.intersect(scrollRect);
    if (targetRect.isEmpty())
        return;

    double xScale, yScale;
    cairoSurfaceGetDeviceScale(m_surface.get(), xScale, yScale);
    ASSERT(xScale == yScale);

    IntSize scaledScrollOffset = scrollOffset;
    targetRect.scale(xScale);
    scaledScrollOffset.scale(xScale, yScale);

    cairo_surface_flush(m_surface.get());
    XCopyArea(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(), m_pixmap.get(), m_pixmap.get(), m_gc.get(),
        targetRect.x() - scaledScrollOffset.width(), targetRect.y() - scaledScrollOffset.height(),
        targetRect.width(), targetRect.height(), targetRect.x(), targetRect.y());
    cairo_surface_mark_dirty_rectangle(m_surface.get(), targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height());
}
Ejemplo n.º 13
0
static VALUE
cr_surface_mark_dirty (int argc, VALUE *argv, VALUE self)
{
  VALUE x, y, width, height;
  int n;
  
  n = rb_scan_args (argc, argv, "04", &x, &y, &width, &height);

  if (n == 0)
    {
      cairo_surface_mark_dirty (_SELF);
    }
  else if (n == 4)
    {
      cairo_surface_mark_dirty_rectangle (_SELF,
                                          NUM2INT (x), NUM2INT (y),
                                          NUM2INT (width), NUM2INT (height));
    }
  else
    {
      int i;
      VALUE args;

      args = rb_ary_new2 (n);
      for (i = 0; i < n; i++)
        {
          rb_ary_push (args, argv[i]);
        }

      rb_raise (rb_eArgError,
                "invalid argument (expect () or (x, y, width, height)): %s",
                inspect (args));
    }

  cr_surface_check_status (_SELF);
  return self;
}
Ejemplo n.º 14
0
void CairoDevice::InvalidateRect( float left, float top, float right, float bottom ) 
{
	cairo_surface_t* surface = cairo_get_target (fNativeDevice);
	cairo_surface_mark_dirty_rectangle (surface, left, top, right-left, bottom-top);
}
Ejemplo n.º 15
0
void
swfdec_bitmap_data_copyPixels (SwfdecAsContext *cx, SwfdecAsObject *object,
    guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
  SwfdecBitmapData *bitmap, *source, *alpha = NULL;
  SwfdecAsObject *recto = NULL, *pt, *apt = NULL, *so, *ao = NULL;
  SwfdecRectangle rect;
  gboolean copy_alpha = FALSE;
  cairo_t *cr;
  int x, y;

  SWFDEC_AS_CHECK (SWFDEC_TYPE_BITMAP_DATA, &bitmap, "ooo|oob", &so, &recto, &pt,
      &ao, &apt, &copy_alpha);

  if (bitmap->surface == NULL ||
      !SWFDEC_IS_BITMAP_DATA (so) ||
      (source = SWFDEC_BITMAP_DATA (so))->surface == NULL ||
      (ao != NULL && (!SWFDEC_IS_BITMAP_DATA (ao) || 
		    (alpha = SWFDEC_BITMAP_DATA (ao))->surface == NULL)) ||
      !swfdec_rectangle_from_as_object (&rect, recto))
    return;

  x = rect.x;
  y = rect.y;
  swfdec_point_from_as_object (&rect.x, &rect.y, pt);
  cr = cairo_create (bitmap->surface);
  if (bitmap == source) {
    cairo_surface_t *copy = cairo_surface_create_similar (source->surface,
	cairo_surface_get_content (source->surface),
	rect.width, rect.height);
    cairo_t *cr2 = cairo_create (copy);
    cairo_set_source_surface (cr2, source->surface, x, y);
    cairo_paint (cr2);
    cairo_destroy (cr2);
    cairo_set_source_surface (cr, copy, rect.x, rect.y);
    cairo_surface_destroy (copy);
  } else {
    cairo_set_source_surface (cr, source->surface, rect.x - x, rect.y - y);
  }

  if (swfdec_surface_has_alpha (bitmap->surface) && !copy_alpha) {
    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
  }

  cairo_rectangle (cr, rect.x, rect.y, rect.width, rect.height);
  if (alpha) {
    cairo_surface_t *mask = cairo_surface_create_similar (alpha->surface,
	CAIRO_CONTENT_COLOR_ALPHA, rect.width, rect.height);
    cairo_t *cr2 = cairo_create (mask);

    cairo_surface_set_device_offset (mask, -rect.x, -rect.y);
    cairo_set_source (cr2, cairo_get_source (cr));
    if (apt) {
      swfdec_point_from_as_object (&x, &y, apt);
    } else {
      x = y = 0;
    }
    cairo_mask_surface (cr2, alpha->surface, rect.x - x, rect.y - y);
    cairo_destroy (cr2);
    cairo_set_source_surface (cr, mask, 0, 0);
    cairo_surface_destroy (mask);
  }
  cairo_fill (cr);
  cairo_destroy (cr);
  cairo_surface_mark_dirty_rectangle (bitmap->surface, rect.x, rect.y, 
      rect.width, rect.height);
}
Ejemplo n.º 16
0
static cairo_test_status_t
test_cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface)
{
    cairo_surface_mark_dirty_rectangle (surface, 1, 1, 8, 8);
    return CAIRO_TEST_SUCCESS;
}
Ejemplo n.º 17
0
 void dirty(const rect& r) {
   cairo_surface_mark_dirty_rectangle(m_s, r.x, r.y, r.w, r.h);
 }