当前位置: 首页>>代码示例>>C++>>正文


C++ MoonSurface类代码示例

本文整理汇总了C++中MoonSurface的典型用法代码示例。如果您正苦于以下问题:C++ MoonSurface类的具体用法?C++ MoonSurface怎么用?C++ MoonSurface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MoonSurface类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Top

void
MoonEGLContext::SetupVertexData (const double *matrix,
				 double       x,
				 double       y,
				 double       width,
				 double       height)
{
	Target         *target = Top ()->GetTarget ();
	MoonSurface    *ms;
	Rect           r = target->GetData (&ms);
	MoonEGLSurface *dst = (MoonEGLSurface *) ms;
	double         m[16];

	if (matrix)
		Matrix3D::Init (m, matrix);
	else
		Matrix3D::Identity (m);

	GLContext::SetupVertexData (m, x, y, width, height);

	if (dst->GetEGLDisplay ()) {
		int i;

		for (i = 0; i < 4; i++) {
			GLfloat v = vertices[i][1] + vertices[i][3];

			vertices[i][1] = vertices[i][3] - v;
		}
	}

	ms->unref ();
}
开发者ID:499940913,项目名称:moon,代码行数:32,代码来源:context-egl.cpp

示例2: Top

void
CGLContext::BlitVUY2 (unsigned char *data)
{
	Target      *target = Top ()->GetTarget ();
	MoonSurface *ms;
	Rect        r = target->GetData (&ms);
	OpengGLSurface *dst = (OpenGLSurface *) ms;
	int         size[] = { dst->Width (), dst->Height () };
	GLuint texture = dst->Texture ();

	// no support for clipping
	g_assert (GetClip () == r);

	// no support for blit to drawable at the moment
	g_assert (!dst->HasDrawable ());

	// mark target as initialized
	target->SetInit (ms);

	glBindTexture (GL_TEXTURE_2D, texture);
	glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, size [0], size [1], 0, GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, data);
	glBindTexture (GL_TEXTURE_2D, 0);

	ms->unref ();
}
开发者ID:zephyrpellerin,项目名称:moon,代码行数:25,代码来源:context-cgl.cpp

示例3: Top

void
CairoContext::Push (Group extents)
{
    cairo_surface_t *parent = Top ()->GetTarget ()->Cairo ();
    Rect            r = extents.r.RoundOut ();
    cairo_surface_t *data =
        cairo_surface_create_similar (parent,
                                      CAIRO_CONTENT_COLOR_ALPHA,
                                      r.width,
                                      r.height);
    MoonSurface     *surface = new CairoSurface (data, r.width, r.height);
    Target          *target = new Target (surface, extents.r);
    cairo_matrix_t  matrix;

    Top ()->GetMatrix (&matrix);

    Stack::Push (new Context::Node (target, &matrix, &extents.r));

    target->unref ();
    surface->unref ();

    cairo_surface_destroy (data);
}
开发者ID:snorp,项目名称:moon,代码行数:23,代码来源:context-cairo.cpp

示例4: bounds

void
WriteableBitmap::Render (UIElement *element, Transform *transform)
{
	MoonSurface *src;
	Context     *ctx;

	if (!element)
		return;

	cairo_surface_t *surface = GetImageSurface ();
	if (!surface)
		return;

	Rect bounds (0, 0, GetPixelWidth (), GetPixelHeight ());

#ifdef USE_GALLIUM
	struct pipe_resource pt, *texture;
	GalliumSurface       *target;
	struct pipe_screen   *screen =
		swrast_screen_create (null_sw_create ());

	memset (&pt, 0, sizeof (pt));
	pt.target = PIPE_TEXTURE_2D;
	pt.format = PIPE_FORMAT_B8G8R8A8_UNORM;
	pt.width0 = 1;
	pt.height0 = 1;
	pt.depth0 = 1;
	pt.last_level = 0;
	pt.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_TRANSFER_WRITE |
		PIPE_BIND_TRANSFER_READ;

	texture = (*screen->resource_create) (screen, &pt);

	target = new GalliumSurface (texture);
	pipe_resource_reference (&texture, NULL);
	ctx = new GalliumContext (target);
	target->unref ();
#else
	CairoSurface *target;

	target = new CairoSurface (1, 1);
	ctx = new CairoContext (target);
	target->unref ();
#endif

	ctx->Push (Context::Group (bounds));

	cairo_matrix_t xform;
	cairo_matrix_init_identity (&xform);

	if (transform)
		transform->GetTransform (&xform);

	FrameworkElement *fe = (FrameworkElement *)element;
	if (fe->GetFlowDirection () == FlowDirectionRightToLeft) {
		cairo_matrix_translate (&xform, fe->GetActualWidth (), 0.0);
		cairo_matrix_scale (&xform, -1, 1);
	}

	element->Paint (ctx, bounds, &xform);

	bounds = ctx->Pop (&src);
	if (!bounds.IsEmpty ()) {
		cairo_surface_t *image = src->Cairo ();
		cairo_t         *cr = cairo_create (surface);

		cairo_set_source_surface (cr, image, 0, 0);
		cairo_paint (cr);
		cairo_destroy (cr);
		cairo_surface_destroy (image);
		src->unref ();
	}

	delete ctx;

#ifdef USE_GALLIUM
	screen->destroy (screen);
#endif

}
开发者ID:499940913,项目名称:moon,代码行数:80,代码来源:writeablebitmap.cpp

示例5: main

int
main (int argc, char **argv)
{
	Context *ctx;
	CairoSurface *target;
	MoonSurface *surface;
	cairo_surface_t *dst, *src;
	TransformEffect *effect;
	Matrix3D *matrix;
	DoubleCollection *values;
	int stride = width * 4;
	Rect bounds = Rect (0, 0, width, height);
	gpointer data;
	bool status = true;
	int count = 1;

	if (argc < 2) {
		printf ("usage: %s MATRIX [COUNT]\n", argv[0]);
		return 1;
	}

	gtk_init (&argc, &argv);

	runtime_init_desktop ();

	values = DoubleCollection::FromStr (argv[1]);
	if (!values) {
		printf ("usage: %s MATRIX [COUNT]\n", argv[0]);
		return 1;
	}

	if (values->GetCount () != 16) {
		printf ("usage: %s MATRIX [COUNT]\n", argv[0]);
		values->unref ();
		return 1;
	}

	data = g_malloc0 (height * stride);
	dst = cairo_image_surface_create_for_data ((unsigned char *) data,
						   CAIRO_FORMAT_ARGB32,
						   width, height, stride);
	target = new CairoSurface (dst);
	cairo_surface_destroy (dst);
	ctx = new CairoContext (target);
	target->unref ();

	src = cairo_surface_create_similar (dst,
					    CAIRO_CONTENT_COLOR_ALPHA,
					    width, height);
	surface = new CairoSurface (src);
	cairo_surface_destroy (src);

	effect = new TransformEffect ();

	matrix = new Matrix3D ();
	matrix->SetM11 (values->GetValueAt (0)->AsDouble ());
	matrix->SetM12 (values->GetValueAt (1)->AsDouble ());
	matrix->SetM13 (values->GetValueAt (2)->AsDouble ());
	matrix->SetM14 (values->GetValueAt (3)->AsDouble ());
	matrix->SetM21 (values->GetValueAt (4)->AsDouble ());
	matrix->SetM22 (values->GetValueAt (5)->AsDouble ());
	matrix->SetM23 (values->GetValueAt (6)->AsDouble ());
	matrix->SetM24 (values->GetValueAt (7)->AsDouble ());
	matrix->SetM31 (values->GetValueAt (8)->AsDouble ());
	matrix->SetM32 (values->GetValueAt (9)->AsDouble ());
	matrix->SetM33 (values->GetValueAt (10)->AsDouble ());
	matrix->SetM34 (values->GetValueAt (11)->AsDouble ());
	matrix->SetOffsetX (values->GetValueAt (12)->AsDouble ());
	matrix->SetOffsetY (values->GetValueAt (13)->AsDouble ());
	matrix->SetOffsetZ (values->GetValueAt (14)->AsDouble ());
	matrix->SetM44 (values->GetValueAt (15)->AsDouble ());

	values->unref ();

	if (argc > 2) {
		count = atoi (argv[2]);
		if (count > 1) {
			signal (SIGALRM, projection_alarm_handler);
			alarm (5);
		}
	}

	while (status && count-- > 0) {
		status = effect->Render (ctx,
					 surface,
					 (double *) matrix->GetMatrixValues (),
					 0, 0, width, height);

		frames++;
	}

	matrix->unref ();

	surface->unref ();
	delete ctx;
	g_free (data);

	runtime_shutdown ();

	return status != true;
//.........这里部分代码省略.........
开发者ID:kangaroo,项目名称:moon,代码行数:101,代码来源:projection-test.cpp

示例6: SetCurrentDeployment

void
MoonWindowGtk::PaintToDrawable (GdkDrawable *drawable, GdkVisual *visual, GdkEventExpose *event, int off_x, int off_y, bool transparent, bool clear_transparent)
{
// 	LOG_UI ("Surface::PaintToDrawable (%p, %p, (%d,%d %d,%d), %d, %d, %d, %d)\n",
// 		drawable, visual, event->area.x, event->area.y, event->area.width, event->area.height,
// 		off_x, off_y, transparent, clear_transparent);
	
	SetCurrentDeployment ();

#if 0
#if TIME_REDRAW
	STARTTIMER (expose, "redraw");
#endif
	if (cache_size_multiplier == -1)
		cache_size_multiplier = gdk_drawable_get_depth (drawable) / 8 + 1;
#endif
	int width, height;
	gdk_drawable_get_size (drawable, &width, &height);
	Context *ctx;
	GdkRectangle area = event->area;
	MoonSurface *src;
	Rect r = Rect (area.x, area.y, area.width, area.height);

	if (!native)
		native = CreateCairoSurface (drawable, visual, true, width, height);
	cairo_xlib_surface_set_drawable (native,
					 gdk_x11_drawable_get_xid (drawable),
					 width, height);
	cairo_surface_set_device_offset (native, off_x, off_y);

	Region *region = new Region ();
	int count = 0;
	GdkRectangle *rects;
	gdk_region_get_rectangles (event->region, &rects, &count);
	while (count--) {
		GdkRectangle c = rects[count];
		region->Union (Rect (c.x, c.y, c.width, c.height));
	}

#ifdef USE_GALLIUM
	if (gctx) {
		ctx = gctx;
	}
	else {
		struct pipe_resource pt, *texture;
		GalliumSurface       *target;

		memset (&pt, 0, sizeof (pt));
		pt.target = PIPE_TEXTURE_2D;
		pt.format = PIPE_FORMAT_B8G8R8A8_UNORM;
		pt.width0 = width;
		pt.height0 = height;
		pt.depth0 = 1;
		pt.last_level = 0;
		pt.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_TRANSFER_WRITE |
			PIPE_BIND_TRANSFER_READ;

		g_assert (screen);

		texture = (*screen->resource_create) (screen, &pt);

		target = new GalliumSurface (texture);
		pipe_resource_reference (&texture, NULL);
		ctx = new GalliumContext (target);
		target->unref ();

		if (gctxn < CONTEXT_CACHE_SIZE) {
			gctxn++;
			gctx = ctx;
		}
	}
#else
	CairoSurface *target = new CairoSurface (1, 1);
	ctx = new CairoContext (target);
	target->unref ();
#endif

	ctx->Push (Context::Group (r));
	/* if we are redirecting to an image surface clear that first */
	surface->Paint (ctx, region, transparent, true);

	r = ctx->Pop (&src);
	if (!r.IsEmpty ()) {
		cairo_surface_t *image = src->Cairo ();
		cairo_t         *cr = cairo_create (native);

		cairo_surface_flush (image);

		cairo_set_source_surface (cr, image, r.x, r.y);
		cairo_set_operator (cr, clear_transparent ? CAIRO_OPERATOR_SOURCE : CAIRO_OPERATOR_OVER);

		region->Draw (cr);
		cairo_fill (cr);

		cairo_destroy (cr);
		cairo_surface_destroy (image);
		src->unref ();
	}

#ifdef USE_GALLIUM
//.........这里部分代码省略.........
开发者ID:499940913,项目名称:moon,代码行数:101,代码来源:window-gtk.cpp


注:本文中的MoonSurface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。