<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">
<div>Forget about add the source code for nsgl gl-surface-source test, sorry</div>
<div><br>
</div>
<div><br>
</div>
<div>From cbe2151f22e587fb680e489a953b50e3550afa06 Mon Sep 17 00:00:00 2001</div>
<div>From: Henry Song <hsong@sisa.samsung.com></div>
<div>Date: Tue, 8 Jan 2013 10:19:16 -0800</div>
<div>Subject: [PATCH] gl: add nsgl-surface-source.m as gl-surface-source test code</div>
<div><br>
</div>
<div>---</div>
<div> test/nsgl-surface-source.m | 108 +++++++++++++++++++++++++++++++++++++++++++++</div>
<div> 1 file changed, 108 insertions(+)</div>
<div> create mode 100644 test/nsgl-surface-source.m</div>
<div><br>
</div>
<div>diff --git a/test/nsgl-surface-source.m b/test/nsgl-surface-source.m</div>
<div>new file mode 100644</div>
<div>index 0000000..b51f517</div>
<div>--- /dev/null</div>
<div>+++ b/test/nsgl-surface-source.m</div>
<div>@@ -0,0 +1,108 @@</div>
<div>+/*</div>
<div>+ * Copyright ¬© 2008 Chris Wilson</div>
<div>+ * Copyright ¬© 2010 Intel Corporation</div>
<div>+ *</div>
<div>+ * Permission to use, copy, modify, distribute, and sell this software</div>
<div>+ * and its documentation for any purpose is hereby granted without</div>
<div>+ * fee, provided that the above copyright notice appear in all copies</div>
<div>+ * and that both that copyright notice and this permission notice</div>
<div>+ * appear in supporting documentation, and that the name of</div>
<div>+ * Chris Wilson not be used in advertising or publicity pertaining to</div>
<div>+ * distribution of the software without specific, written prior</div>
<div>+ * permission. Chris Wilson makes no representations about the</div>
<div>+ * suitability of this software for any purpose.  It is provided "as</div>
<div>+ * is" without express or implied warranty.</div>
<div>+ *</div>
<div>+ * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS</div>
<div>+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND</div>
<div>+ * FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL,</div>
<div>+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER</div>
<div>+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION</div>
<div>+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR</div>
<div>+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</div>
<div>+ *</div>
<div>+ * Author: Henry Song <henry.song@samsung.com></div>
<div>+ */</div>
<div>+</div>
<div>+#import "cairo-test.h"</div>
<div>+#import <cairo-gl.h></div>
<div>+</div>
<div>+#import <AppKit/NSOpenGL.h></div>
<div>+#import <Foundation/NSAutoreleasePool.h></div>
<div>+</div>
<div>+#import "surface-source.c"</div>
<div>+</div>
<div>+struct closure {</div>
<div>+    NSOpenGLContext *ctx;</div>
<div>+    NSAutoreleasePool *pool;</div>
<div>+};</div>
<div>+</div>
<div>+static void</div>
<div>+cleanup (void *data)</div>
<div>+{</div>
<div>+    struct closure *arg = data;</div>
<div>+</div>
<div>+    [NSOpenGLContext clearCurrentContext];</div>
<div>+    if (arg->ctx)</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>[arg->ctx release];</div>
<div>+    </div>
<div>+    [arg->pool release];</div>
<div>+</div>
<div>+    free (arg);</div>
<div>+}</div>
<div>+</div>
<div>+static cairo_surface_t *</div>
<div>+create_source_surface (int size)</div>
<div>+{</div>
<div>+    NSOpenGLPixelFormat *pixelFormat;</div>
<div>+</div>
<div>+    NSOpenGLPixelFormatAttribute attrs[] = {</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>NSOpenGLPFADepthSize, 24,</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>NSOpenGLPFAStencilSize, 8,</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>NSOpenGLPFAAlphaSize, 8,</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>0</div>
<div>+    };</div>
<div>+    struct closure *arg;</div>
<div>+    cairo_device_t *device;</div>
<div>+    cairo_surface_t *surface;</div>
<div>+</div>
<div>+    arg = xmalloc (sizeof (struct closure));</div>
<div>+    arg->ctx = nil;</div>
<div>+    arg->pool = [[NSAutoreleasePool alloc] init];</div>
<div>+    pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes: attrs] autorelease];</div>
<div>+    if (!pixelFormat) {</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>cleanup (arg);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>return NULL;</div>
<div>+    }</div>
<div>+</div>
<div>+    arg->ctx = [[NSOpenGLContext alloc] initWithFormat: pixelFormat</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span> shareContext: nil];</div>
<div>+    if (!arg->ctx) {</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>cleanup (arg);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>return NULL;</div>
<div>+    }</div>
<div>+</div>
<div>+    device = cairo_nsgl_device_create (arg->ctx);</div>
<div>+    if (cairo_device_set_user_data (device,</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>   (cairo_user_data_key_t *) cleanup,</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>   arg,</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>   cleanup))</div>
<div>+    {</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>cleanup (arg);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>return NULL;</div>
<div>+    }</div>
<div>+</div>
<div>+    surface = cairo_gl_surface_create (device,</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>      CAIRO_CONTENT_COLOR_ALPHA,</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>      size, size);</div>
<div>+    cairo_device_destroy (device);</div>
<div>+</div>
<div>+    return surface;</div>
<div>+}</div>
<div>+</div>
<div>+CAIRO_TEST (gl_surface_source,</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>   "Test using a GL surface as the source",</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>   "source", /* keywords */</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>   NULL, /* requirements */</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>   SIZE, SIZE,</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>   preamble, draw)</div>
<div>-- </div>
<div>1.8.0.1</div>
<div><br>
</div>
</div>
</body>
</html>